:root {
  /* Warm, Claude-like palette: beige page, cream panels, terracotta accent. */
  --bg: #f5f4ed; --fg: #141413; --muted: #6f6d66; --line: #e3dfd3;
  --panel: #fbfaf6; --accent: #ad5130; --err-bg: #fbe9e6; --err: #b42318; --warn: #8a5a00;
  --ai: #6d28d9; --ai-from: #8b5cf6; --ai-to: #1d4ed8;
  --ai-fill: linear-gradient(135deg, #7c3aed, #1e40af);   /* behind white text, both themes */
  --chip-bg: #eeebe1; --tbar-bg: #e6e2d6; --tbar: #c96442;
  --f-who: #2563eb; --f-client: #64748b; --f-repo: #0f766e; --f-when: #b45309; --f-work: #be185d; --f-cost: #15803d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --fg: #f5f4ed; --muted: #a6a39a; --line: #3e3d38;
    --panel: #30302e; --accent: #e08868; --err-bg: #3d1a17; --err: #f2a097; --warn: #e0b05a;
    --ai: #c4b5fd; --ai-from: #a78bfa; --ai-to: #3b82f6;
    --chip-bg: #3a3936; --tbar-bg: #45443f; --tbar: #d97757;
    --f-who: #60a5fa; --f-client: #94a3b8; --f-repo: #2dd4bf; --f-when: #fbbf24; --f-work: #f472b6; --f-cost: #4ade80;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
       font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; gap: 12px; align-items: baseline; padding: 12px 20px;
         border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--accent); text-decoration: none; }
main { padding: 16px 20px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
code, textarea, pre, td { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: 13px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
textarea { width: 100%; padding: 10px; background: var(--panel); color: var(--fg);
           border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
select, button { font: inherit; padding: 5px 10px; border-radius: 6px;
                 border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
button { background: var(--accent); color: var(--bg); border-color: var(--accent); cursor: pointer; }
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.error { background: var(--err-bg); color: var(--err); padding: 10px 14px; border-radius: 6px; }
.error pre { white-space: pre-wrap; margin: 6px 0 0; }
/* Tables flow in the page: no inner scroll frame. The header sticks to the top of the window. */
.table-wrap { margin-top: 12px; }
table { border-collapse: collapse; width: max-content; min-width: 100%; background: var(--panel);
        border: 1px solid var(--line); }
th, td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--panel); white-space: nowrap; }
th small { display: block; font-weight: 400; color: var(--muted); }
.cell { max-width: 60ch; max-height: 8em; overflow: auto; white-space: pre-wrap; word-break: break-word; }
nav { margin-left: auto; display: flex; gap: 16px; }
nav a, main a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.ok { color: var(--accent); }
.notice { color: var(--accent); }
button.secondary { background: var(--panel); color: var(--fg); border-color: var(--line); }
button.danger { background: var(--panel); color: var(--err); border-color: var(--line); }
.actions { white-space: nowrap; }
.actions > div { white-space: normal; max-width: 50ch; margin-top: 4px; }
.provider-form { margin-top: 20px; max-width: 640px; display: grid; gap: 8px; }
.provider-form label { display: grid; gap: 2px; }
.provider-form input { font: inherit; padding: 6px 8px; border-radius: 6px;
                       border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
.ask { margin: 12px 0 4px; max-width: 900px; }
.ask textarea, .insight textarea { font-family: inherit; font-size: 14px; }
.insight { margin-top: 12px; max-width: 900px; }
.turn { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; margin: 14px 0; }
.question { font-weight: 600; white-space: pre-wrap; margin: 0 0 6px; }
.answer table { border: 1px solid var(--line); width: auto; min-width: 0; }
.answer pre { background: var(--panel); border: 1px solid var(--line); padding: 8px; overflow: auto; }
.answer code { font-size: 12.5px; }
.small { font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.card { display: grid; align-content: start; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 8px;
        background: var(--panel); color: var(--fg); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card strong { color: var(--accent); }
.report-form { max-width: 900px; }
.field { display: grid; gap: 3px; margin: 10px 0; }
.field input, .field select, .field textarea { font: inherit; padding: 6px 8px; border-radius: 6px;
      border: 1px solid var(--line); background: var(--panel); color: var(--fg); max-width: 100%; }
.field textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
/* Data tables use the page width; forms, text and summaries stay readable. */
.run { margin-top: 16px; }
.run > :not(.table-wrap), #query-form, .prose { max-width: 1100px; }
table.summary { width: auto; min-width: 0; }
.run .answer h1, .run .answer h2 { margin-top: 18px; }
.runs { padding-left: 18px; }
/* Long option labels and wide report tables must not widen the page. */
.field { min-width: 0; }
.field select, .field input, .field textarea { width: 100%; }
.run .table-wrap { overflow-x: auto; }
.provider-form .prices { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
/* AI features: purple to deep-blue gradient. Anything that sends data to an LLM wears it. */
.ai { border: 1.5px solid transparent;
      background: linear-gradient(var(--panel), var(--panel)) padding-box,
                  linear-gradient(135deg, var(--ai-from), var(--ai-to)) border-box; }
.card.ai strong { color: var(--ai); }
.card.ai:hover { box-shadow: 0 0 0 1px var(--ai-from); }
.ai-badge { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
            line-height: 18px; color: #fff; vertical-align: middle;
            background: var(--ai-fill); }
.card strong .ai-badge { margin-left: 6px; }
h1 .ai-badge { margin-left: 8px; font-size: 12px; }
.report-form.ai { padding: 4px 16px 12px; border-radius: 10px; }
button.ai-button { border-color: transparent; color: #fff;
                   background: var(--ai-fill); }
button.ai-button:disabled { opacity: .5; cursor: not-allowed; }
/* (i) next to a report step title, and the description it reveals. */
button.info { width: 18px; height: 18px; padding: 0; margin-left: 6px; border-radius: 50%;
              font: italic 600 12px/16px Georgia, serif; vertical-align: 2px;
              background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
button.info:hover, button.info[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.step-about { margin: -4px 0 8px; max-width: 80ch; }
/* Help page */
.help { max-width: 860px; }
.help h2 { margin-top: 24px; }
.help table { width: auto; min-width: 0; }
.help td, .help th { font-family: inherit; font-size: 14px; }
/* Session tree (feature 009): guide lines, one summary line per node, chips, duration bars. */
.session-tree { max-width: 1400px; }
/* Header facts: one line, each part in its own color with a small label. */
.tree-head { margin: 8px 0 12px; display: grid; gap: 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fact { --c: var(--muted); display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px 3px 8px;
        border-radius: 6px; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 9%, var(--panel)); }
.fact > b { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--c); }
.fact a { color: inherit; }
.fact.who { --c: var(--f-who); } .fact.client { --c: var(--f-client); } .fact.repo { --c: var(--f-repo); }
.fact.when { --c: var(--f-when); } .fact.work { --c: var(--f-work); } .fact.cost { --c: var(--f-cost); }
.tree-tools { display: flex; gap: 10px; align-items: center; }
.session-id { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 4px; }
a.ai-link { color: var(--ai); }
.tree, .tree .children { list-style: none; margin: 0; padding: 0 0 0 18px; }
.tree { padding-left: 4px; }
.tree .children { border-left: 1px solid var(--line); margin-left: 6px; }
.tree li { position: relative; }
.tree .children > li::before { content: ""; position: absolute; left: -18px; top: 0.95em; width: 12px;
                                border-top: 1px solid var(--line); }
.node > summary, .node.flat { display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
                              padding: 3px 4px; border-radius: 4px; }
.node > summary { cursor: pointer; list-style: none; flex-wrap: nowrap; }
.node > summary > * { flex: none; }
.node > summary > .tbar { flex: 0 0 120px; width: 120px; }
.node > summary::-webkit-details-marker { display: none; }
.node > summary::before { content: "▸"; color: var(--muted); width: 10px; flex: none; transition: transform .1s; }
.node[open] > summary::before { transform: rotate(90deg); }
.node > summary:hover { background: var(--chip-bg); }
.node .label { font-weight: 600; white-space: nowrap; }
.node > summary > .prompt-line, .node .prompt-line { flex: 1 1 0; min-width: 0; overflow: hidden;
                                                     text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .node > summary { flex-wrap: wrap; }
  .tbar { flex-basis: 100%; }
}
.chip { font-size: 12px; line-height: 18px; padding: 0 7px; border-radius: 999px; white-space: nowrap;
        background: var(--chip-bg); color: var(--muted); }
.chip.ok { color: var(--accent); }
.chip.warn { color: var(--warn); }
.chip.fail { color: var(--err); background: var(--err-bg); }
.chip.dim { opacity: .75; font-style: italic; }
.tbar { position: relative; flex: 0 0 120px; height: 5px; margin-left: auto; border-radius: 3px;
        background: var(--tbar-bg); overflow: hidden; }
.tbar > i { position: absolute; top: 0; bottom: 0; background: var(--tbar); border-radius: 3px; min-width: 2px; }
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 4px 0 10px 22px;
        font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; }
.tree-text { white-space: pre-wrap; word-break: break-word; max-height: 32em; overflow: auto; margin: 0 0 4px;
             padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.prompt-node .text-preview, .span-detail { margin: 4px 0 8px 22px; }
.small-button { font-size: 12px; padding: 2px 8px; }
.tree .more { padding: 4px 0 4px 4px; }
/* "Can't fetch data." banner and in-place errors for failed htmx requests (telens.js). */
.status-banner { margin: 0; padding: 10px 20px; background: var(--err-bg); color: var(--err);
                 border-bottom: 1px solid var(--line); }
.ajax-error { display: flex; gap: 10px; align-items: center; padding: 6px 10px; margin: 4px 0;
              background: var(--err-bg); color: var(--err); border-radius: 6px; list-style: none; }
.field-problem:empty { display: none; }
/* Sign-in page and accounts (feature 010) */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(380px, calc(100vw - 32px)); display: grid; gap: 10px; padding: 24px;
         background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.login .brand { font-size: 22px; }
.login p { margin: 0 0 6px; }
.login-form { display: grid; gap: 10px; }
.login-form label { display: grid; gap: 3px; }
.login-form input, .inline-form input { font: inherit; padding: 6px 8px; border-radius: 6px;
                                        border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.notice-box { padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.notice-box pre { margin: 6px 0 0; }
nav .signed-in { display: flex; gap: 8px; align-items: center; margin: 0; }
/* Settings: a list grouped by purpose; each row is the whole link */
.settings-group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 6px; }
.settings-list { list-style: none; margin: 0; padding: 0; max-width: 760px; border-top: 1px solid var(--line); }
.settings-list li { border-bottom: 1px solid var(--line); }
.settings-list a { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 12px; padding: 10px 6px;
                   color: var(--fg); text-decoration: none; }
.settings-list a:hover { background: var(--panel); }
.settings-list a:hover strong { color: var(--accent); }
@media (max-width: 560px) { .settings-list a { grid-template-columns: 1fr; gap: 2px; } }
/* Users: one row per account, actions on the right */
.user-list { list-style: none; margin: 12px 0; padding: 0; max-width: 760px; border-top: 1px solid var(--line); }
.user-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
                padding: 10px 6px; border-bottom: 1px solid var(--line); }
.row-actions { display: flex; gap: 8px; }
.add-user { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; max-width: 760px; }
.add-user label { display: grid; gap: 3px; flex: 1 1 260px; }
.add-user input, .one-time-value { font: inherit; padding: 6px 8px; border-radius: 6px;
      border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
.one-time { max-width: 760px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 8px; margin: 12px 0; }
.one-time p { margin: 0 0 6px; }
.one-time-value { font-family: ui-monospace, Menlo, monospace; font-size: 16px; width: min(320px, 100%); }
.users-table { overflow-x: auto; }
.users-table td.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.inline-form > summary { cursor: pointer; color: var(--accent); list-style: none; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] > summary { font-weight: 600; }
.inline-form form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 760px) {
  header { flex-wrap: wrap; row-gap: 6px; }
  header > .muted { display: none; }
  nav { flex-wrap: wrap; gap: 12px; }
  nav .signed-in > .muted { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* A new API key, shown once (feature 011) */
.new-key { display: grid; gap: 6px; padding: 12px 14px; margin: 8px 0 14px; border-radius: 8px;
           border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.new-key-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.new-key code#new-key { font-size: 14px; word-break: break-all; user-select: all; }
/* AI usage (feature 013) */
.budget { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); margin: 8px 0 16px; }
.budget.over, #ai-budget-banner { border-color: var(--warn); color: var(--warn); }
.over-row td { background: color-mix(in srgb, var(--err) 6%, transparent); }
label.check { display: flex; gap: 8px; align-items: center; }
#ai-budget-banner { margin: 0; padding: 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
