:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --ink: #1b1a17;
  --ink-2: #4a4740;
  --muted: #6b675e;
  --line: #e2ddd2;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fde9dc;
  --good: #15803d;
  --good-soft: #dcf3e3;
  --warn: #b45309;
  --warn-soft: #fdf0d5;
  --bad: #b91c1c;
  --bad-soft: #fde2e2;
  --info: #1d4ed8;
  --info-soft: #e0e8fd;
  --base: #57534e;
  --base-soft: #ecebe8;
  --focus: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 26, 23, .06), 0 6px 24px rgba(27, 26, 23, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110f;
    --surface: #1c1b18;
    --surface-2: #262420;
    --ink: #f3f1ec;
    --ink-2: #d2cec5;
    --muted: #a19c91;
    --line: #34312b;
    --accent: #fb7a3c;
    --accent-ink: #1b1a17;
    --accent-soft: #3a2216;
    --good: #4ade80;
    --good-soft: #15291c;
    --warn: #fbbf24;
    --warn-soft: #2f2410;
    --bad: #f87171;
    --bad-soft: #351818;
    --info: #93b4ff;
    --info-soft: #1a2340;
    --base: #b9b4aa;
    --base-soft: #2a2824;
    --focus: #93b4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12110f;
  --surface: #1c1b18;
  --surface-2: #262420;
  --ink: #f3f1ec;
  --ink-2: #d2cec5;
  --muted: #a19c91;
  --line: #34312b;
  --accent: #fb7a3c;
  --accent-ink: #1b1a17;
  --accent-soft: #3a2216;
  --good: #4ade80;
  --good-soft: #15291c;
  --warn: #fbbf24;
  --warn-soft: #2f2410;
  --bad: #f87171;
  --bad-soft: #351818;
  --info: #93b4ff;
  --info-soft: #1a2340;
  --base: #b9b4aa;
  --base-soft: #2a2824;
  --focus: #93b4ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-row { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 28px; height: 28px; fill: var(--accent); }
.brand-name { font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.tagline { margin: 0; color: var(--muted); font-size: .9375rem; flex: 1 1 220px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.powered { font-size: .75rem; font-weight: 600; letter-spacing: .02em; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; fill: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }

.demo-banner { background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--line); font-size: .9rem; padding: 8px 0; }
.demo-banner strong { color: var(--warn); }

/* layout */
.layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 24px; padding-top: 24px; padding-bottom: 32px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.form-panel { position: sticky; top: 16px; }
@media (max-width: 900px) { .form-panel { position: static; } }
.panel-title { font-size: 1.25rem; margin: 0 0 4px; letter-spacing: -.01em; }

/* form */
.field { margin: 16px 0 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; padding: 0; }
.req { color: var(--accent); }
.opt { font-weight: 400; color: var(--muted); font-size: .8rem; margin-left: 4px; }
.hint { margin: 6px 0 0; font-size: .8rem; color: var(--muted); }
input[type="text"], input[type="number"], select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
input::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover { border-color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--bad); }
.acts { display: grid; gap: 8px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; text-align: center; padding: 10px 4px; font-weight: 600; font-size: .85rem; cursor: pointer; border-right: 1px solid var(--line); }
.segmented label:last-of-type { border-right: 0; }
.segmented input:checked + label { background: var(--ink); color: var(--bg); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -3px; }
.field-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-inline label { margin: 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.stepper input { width: 56px; text-align: center; border: 0; border-radius: 0; background: transparent; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn { width: 44px; min-height: 44px; border: 0; background: transparent; cursor: pointer; font-size: 1.2rem; }
.step-btn:hover { background: var(--surface-2); }
.form-errors { margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: .9rem; }
.form-errors ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); flex: 1 1 auto; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn-primary[disabled] { opacity: .65; cursor: progress; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: .875rem; }

/* empty state */
.empty-state { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; }
.empty-title { margin: 0 0 16px; font-size: 1.5rem; letter-spacing: -.02em; line-height: 1.2; }
.how { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 14px; }
.how li { display: flex; gap: 12px; align-items: flex-start; }
.how-n { flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .9rem; }

/* trace */
.trace { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.trace summary { cursor: pointer; padding: 14px 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; list-style: none; }
.trace summary::-webkit-details-marker { display: none; }
.trace summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.trace[open] summary::before { transform: rotate(45deg); }
.trace-meta { font-weight: 500; color: var(--muted); font-size: .85rem; }
.trace-meta .live { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.trace-meta .live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .3; } }
.trace-list { list-style: none; margin: 0; padding: 0 18px 14px; display: grid; gap: 8px; max-height: 460px; overflow: auto; }
.step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); animation: in .2s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .step, .trace-meta .live::before { animation: none; } }
.step > :not(.lane) { grid-column: 2; min-width: 0; }
.lane { grid-column: 1; grid-row: 1 / span 4; align-self: start; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; white-space: nowrap; }
@media (max-width: 640px) {
  .step { grid-template-columns: minmax(0, 1fr); }
  .step > :not(.lane) { grid-column: 1; }
  .lane { grid-row: auto; justify-self: start; }
}
.lane-qloo { background: var(--accent-soft); color: var(--accent); }
.lane-llm { background: var(--info-soft); color: var(--info); }
.lane-agent { background: var(--surface-2); color: var(--ink-2); }
.lane-baseline { background: var(--base-soft); color: var(--base); }
.step-title { font-weight: 650; font-size: .9rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.step-ms { color: var(--muted); font-weight: 400; font-size: .75rem; }
.step-badge { font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.badge-empty { background: var(--warn-soft); color: var(--warn); }
.badge-fallback { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--bad-soft); color: var(--bad); }
.badge-cached { background: var(--surface-2); color: var(--muted); }
.step-detail { font-size: .85rem; color: var(--ink-2); }
.step-req { font: .75rem/1.45 var(--mono); color: var(--muted); word-break: break-all; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.step-req b { color: var(--accent); font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat { font-size: .72rem; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.stat b { font-weight: 700; }

.status { font-size: .9rem; color: var(--muted); min-height: 0; }
.status:not(:empty) { margin-bottom: 12px; }
.error-box { background: var(--bad-soft); color: var(--ink); border: 1px solid var(--bad); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.error-box strong { color: var(--bad); }
.error-box p { margin: 6px 0 12px; }

.skeleton { display: grid; gap: 12px; }
.sk-card { height: 180px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-card { animation: none; } }

/* output */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.tabs [role="tab"] { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--ink-2); min-height: 40px; }
.tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.exports { display: flex; gap: 8px; }
.summary { font-size: .9rem; color: var(--muted); margin: 4px 0 8px; }
.section-title { font-size: 1.05rem; margin: 20px 0 10px; letter-spacing: -.01em; }
.sub-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0; }
[role="tabpanel"]:focus-visible { outline-offset: 6px; }

.lineup { display: grid; gap: 14px; }
.date-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.date-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.date-label { font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.date-theme { font-weight: 600; color: var(--ink-2); font-size: .9rem; }
.acts-grid { display: grid; grid-template-columns: 1.25fr 1fr; }
@media (max-width: 640px) { .acts-grid { grid-template-columns: 1fr; } }
.act { padding: 14px 16px; min-width: 0; }
.act + .act { border-left: 1px solid var(--line); }
@media (max-width: 640px) { .act + .act { border-left: 0; border-top: 1px solid var(--line); } }
.role { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.act-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 8px; line-height: 1.2; overflow-wrap: anywhere; }
.act.support .act-name { font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: .75rem; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip b { font-weight: 700; color: var(--ink); }
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-good b { color: var(--good); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-bad b { color: var(--bad); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-accent b { color: var(--accent); }
.meter { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-bottom: 8px; }
.meter-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; position: relative; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; width: calc(var(--v, 0) * 100%); }
.meter-val { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.why { font-size: .9rem; margin: 0 0 6px; color: var(--ink); }
.evidence { font-size: .78rem; color: var(--muted); margin: 0; }
.tags { font-size: .78rem; color: var(--muted); margin: 0 0 6px; }
.blurb { border-top: 1px solid var(--line); padding: 12px 16px 14px; display: grid; gap: 8px; }
.blurb-label { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.blurb p { margin: 0; font-size: .92rem; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: .8rem; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--accent-soft); }

.partners { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .partners { grid-template-columns: 1fr; } }
.partner-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.partner { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.partner-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.partner-name { font-weight: 700; overflow-wrap: anywhere; }
.partner-cat { font-size: .78rem; color: var(--muted); }
.partner-idea { font-size: .88rem; margin: 6px 0 0; }
.partner .meter { margin: 6px 0 0; }
.none { color: var(--muted); font-size: .9rem; }

/* baseline view */
.date-card.base .date-label { color: var(--base); }
.date-card.base .act-name { color: var(--ink-2); }
.base-note { font-size: .9rem; }

.side { display: grid; gap: 12px; }
.side-head, .side-row { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 12px; align-items: start; }
.side-head { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 4px; }
.side-row { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.side-date { font-weight: 800; color: var(--accent); font-size: .85rem; }
.side-cell { min-width: 0; }
.side-cell .nm { font-weight: 700; overflow-wrap: anywhere; }
.side-cell .sm { font-size: .78rem; color: var(--muted); }
.side-cell + .side-cell { border-left: 1px solid var(--line); padding-left: 12px; }
.side-verdict { font-size: .9rem; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
@media (max-width: 640px) {
  .side-head { display: none; }
  .side-row { grid-template-columns: 1fr; }
  .side-cell + .side-cell { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 8px; }
  .side-cell::before { content: attr(data-label); display: block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
}

.site-footer { padding-bottom: 32px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 20; box-shadow: var(--shadow); }

/* print: only the one-page brief */
.brief { display: none; }
@media print {
  @page { size: auto; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  body > *:not(.brief) { display: none !important; }
  .brief { display: block; }
  .brief h1 { font-size: 17pt; margin: 0 0 2pt; }
  .brief .b-sub { color: #444; margin: 0 0 8pt; font-size: 9.5pt; }
  .brief h2 { font-size: 11pt; margin: 9pt 0 4pt; border-bottom: 1px solid #999; padding-bottom: 2pt; }
  .brief table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .brief th, .brief td { text-align: left; vertical-align: top; padding: 3pt 4pt; border-bottom: 1px solid #ddd; }
  .brief th { font-size: 8pt; text-transform: uppercase; letter-spacing: .04em; color: #555; }
  .brief .b-blurb { font-size: 9pt; margin: 2pt 0 5pt; }
  .brief .b-foot { font-size: 8pt; color: #555; margin-top: 8pt; }
  .brief .b-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10pt; }
  .brief ul { margin: 0; padding-left: 12pt; font-size: 9pt; }
}
