/* The TUI's look (cmd/kubical/tui_theme.go's tokens, light and dark): its
   neutrals, green, yellow and red for state, and the accent pair of the
   wordmark and focus marks; monospace type; a header with the wordmark and
   its rule of ╱, a sidebar of numbered sections, banded tables with state
   dots, and a status line over the key hints. */
:root {
  color-scheme: light dark;
  --fg: #3A3943; --dim: #605F6B; --subtle: #BFBCC8; --sel: #DCE7F5; --band: #F4F3F7; --bg: #FFFFFF;
  --ok: #0CB37F; --warn: #B8860B; --bad: #EB4268; --acc: #0087D7; --acc2: #00A67E;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #DFDBDD; --dim: #858392; --subtle: #4D4C57; --sel: #2E3445; --band: #1F1E25; --bg: #17161C;
    --ok: #12C78F; --warn: #F5C542; --bad: #FF577D; --acc: #00A4FF; --acc2: #00FFB2;
  }
}
body { font: 14px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; margin: 0; color: var(--fg); background: var(--bg);
  min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--acc); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 0.5rem; background: var(--bg); padding: 0.3rem 0.6rem; z-index: 10; }

/* The header: the wordmark in the accent's gradient, then the ╱ rule. */
header { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 0 1ch; padding: 0.75rem 1ch 0.25rem; }
header p, header form { margin: 0; }
.brand { text-decoration: none; grid-row: 1; }
.wordmark, .word, .slashes { background: linear-gradient(90deg, var(--acc), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wordmark { margin: 0; font: inherit; line-height: 1.1; white-space: pre; border: 0; border-radius: 0; padding: 0; max-height: none; overflow: visible; }
.word { display: none; font-weight: bold; }
.slashes { grid-row: 1; overflow: hidden; white-space: nowrap; line-height: 1.1;
  background: linear-gradient(90deg, var(--acc), var(--acc2), var(--subtle) 60%); -webkit-background-clip: text; background-clip: text; }
.tagline { color: var(--dim); grid-column: 1; }
.who { grid-column: 2; grid-row: 2; justify-self: end; }
header form { grid-column: 2; justify-self: end; margin-top: 0.25rem; }
.sep { color: var(--subtle); }
.acc { color: var(--acc); }

/* The sidebar of sections and the section beside it. */
.frame { display: flex; flex: 1; gap: 3ch; padding: 1rem 1ch; }
nav { flex: 0 0 27ch; }
nav ul { list-style: none; margin: 0 0 1rem; padding: 0; }
nav a { display: block; color: var(--dim); text-decoration: none; padding: 0 0 0 1ch; border-left: 1ch solid transparent; margin-left: -1ch; }
nav a .key { color: var(--subtle); }
nav a:hover { color: var(--fg); }
nav a[aria-current="page"] { color: var(--fg); font-weight: bold; border-left: 0.5ch solid var(--acc); padding-left: 1.5ch; }
nav a[aria-current="page"] .key { color: var(--acc); }
nav .group { color: var(--dim); font-weight: bold; text-transform: uppercase; margin: 0 0 0.25rem 1ch; }
main { flex: 1; min-width: 0; max-width: 120ch; }
h1, h2 { display: flex; align-items: center; gap: 1ch; font-size: 1rem; margin: 0 0 0.75rem; }
h1::after, h2::after { content: ""; flex: 1; border-top: 1px solid var(--subtle); }
h2 { margin-top: 1.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.3rem; }

/* Tables: dim bold capitals over banded rows, no rules. */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
caption { text-align: left; color: var(--dim); padding-bottom: 0.3rem; }
th { text-align: left; color: var(--dim); font-weight: bold; text-transform: uppercase; padding: 0.15rem 1ch; vertical-align: bottom; }
td { text-align: left; padding: 0.15rem 1ch; vertical-align: top; }
tbody tr:nth-child(even) { background: var(--band); }
tbody tr:hover { background: var(--sel); box-shadow: inset 0.5ch 0 var(--acc); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
code, .id { font-family: inherit; word-break: break-all; }
pre { font: inherit; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--subtle); border-radius: 6px; padding: 0.5rem 1ch; max-height: 70vh; overflow: auto; }

/* Controls. */
button, .button { font: inherit; padding: 0 1ch; border: 0; border-radius: 0; background: var(--sel); color: var(--dim); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .button:hover, button:focus-visible, .button:focus-visible { background: var(--acc); color: #FFFFFF; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
form.inline { display: inline-flex; gap: 0.5ch; align-items: center; margin: 0 1ch 0.2rem 0; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--subtle); border-radius: 0; padding: 0 0.5ch; }
input[type="number"] { width: 8ch; }

.note, .muted { color: var(--dim); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
td.state { white-space: nowrap; }
.dot.ok { color: var(--ok); } .dot.warn { color: var(--warn); } .dot.bad { color: var(--bad); } .dot.muted { color: var(--dim); } .dot.acc { color: var(--acc); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(22ch, 1fr)); gap: 1ch; margin-bottom: 1rem; }
.card { border: 1px solid var(--subtle); border-radius: 6px; padding: 0.25rem 1ch; }
.card p { margin: 0.25rem 0; color: var(--dim); }
.card .big { font-size: 1.4rem; font-weight: bold; color: var(--fg); }
.card .big.warn { color: var(--warn); }
.transcript .turn { border-left: 0.5ch solid var(--subtle); padding: 0 0 0 1.5ch; margin: 0 0 1rem; }
.transcript .turn.assistant { border-color: var(--acc); }
.transcript .who { color: var(--dim); margin: 0; }
.transcript .tool { color: var(--dim); }
.report { border: 1px solid var(--subtle); border-radius: 6px; padding: 0 1ch; margin-bottom: 1rem; }
.md img { max-width: 100%; }
#terminal-panel .bar { display: flex; justify-content: space-between; margin-bottom: 0.3rem; }
#terminal { height: 70vh; background: #000; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The status line, then the keys, at the foot of the screen. */
footer { position: sticky; bottom: 0; background: var(--bg); padding: 0.25rem 1ch; border-top: 1px solid var(--subtle); }
footer p { margin: 0; }
.status:empty::before { content: "\00a0"; }
.hints { color: var(--dim); }
kbd { font: inherit; font-weight: bold; color: var(--fg); }

/* Narrow: the one-line wordmark, the sections in a row above the section. */
@media (max-width: 70ch) {
  .wordmark, .tagline { display: none; }
  .word { display: inline; }
  header { align-items: center; }
  .frame { flex-direction: column; gap: 0.5rem; }
  nav { flex: none; }
  nav ul { display: flex; flex-wrap: wrap; gap: 0 2ch; margin: 0 0 0.5rem; }
}
