:root {
    --background: #f7f7f5;
    --surface: #ffffff;
    --text: #1d1d1b;
    --muted: #6b6b66;
    --line: #dcdcd6;
    --accent: #2f5fd0;
    --accent-text: #ffffff;
    --warning: #b3261e;
    --warning-surface: #fdecea;
    --done: #1e7a3c;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #161615;
        --surface: #20201f;
        --text: #ececea;
        --muted: #a3a39d;
        --line: #3a3a37;
        --accent: #7ea2ff;
        --accent-text: #0d1a3a;
        --warning: #ff8a80;
        --warning-surface: #3b1a17;
        --done: #7fd39a;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    line-height: 1.45;
}

main {
    max-width: 44rem;
    margin: 0 auto;
    padding: 16px;
}

header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 16px;
}

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 8px 0; }

.muted { color: var(--muted); }
.refusal { color: var(--warning); }
.done { color: var(--done); }
.user { display: flex; gap: 12px; align-items: baseline; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); font-weight: 600; }

/* Колонка — не шире окна: у `auto` её распирает самое широкое содержимое (`select` веток — по длине ветки). */
.panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.panel[hidden] { display: none; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

.block {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 16px;
    overflow-wrap: anywhere;
}

.block.stale { border-color: var(--warning); background: var(--warning-surface); }
.warning { color: var(--warning); font-weight: 600; }
.position { font-size: 1.1rem; font-weight: 600; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

ul { margin: 8px 0 0; padding-left: 20px; }
.errors { color: var(--warning); }

.controls { display: grid; gap: 8px; }
.controls-on, .controls-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

button, input, select {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 12px;
}

button { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .controls-on button { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.quiet { background: none; justify-self: start; }
input[type="number"] { width: 5rem; }
select { max-width: 100%; }

/* Прогоны: хеш и run_id — моноширинным; журнал прокручивается в своём окне, а не растягивает страницу. */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
pre.log, .log.tail {
    font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--background);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    margin: 8px 0 0;
    max-height: 24rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
/* Хвост — колонкой снизу вверх: окно открывается прижатым к последней строке. */
.log.tail { display: flex; flex-direction: column-reverse; }
.log.tail pre { margin: 0; font: inherit; white-space: inherit; }
.runs { list-style: none; padding: 0; display: grid; gap: 4px; }
.steps { padding-left: 20px; display: grid; gap: 8px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.link[aria-current="true"] { font-weight: 600; text-decoration: none; }
[data-outcome="green"] { color: var(--done); }
[data-outcome="red"], [data-outcome="broken"], [data-outcome="timeout"], [data-outcome="lost"] { color: var(--warning); }
[data-outcome="stopped"], [data-outcome="no_steps"] { color: var(--muted); }
