:root {
  --bg: #ffffff;
  --fg: #18181b;
  --muted: #71717a;
  --subtle: #f4f4f5;
  --border: #e4e4e7;
  --green: #16a34a;
  --amber: #b45309;
  --red: #dc2626;
  --blue: #2563eb;
  --brand: #2b44ff;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --fg: #fafafa;
    --muted: #a1a1aa;
    --subtle: #18181b;
    --border: #27272a;
    --amber: #f59e0b;
    --brand: #7c8cff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b;
  --fg: #fafafa;
  --muted: #a1a1aa;
  --subtle: #18181b;
  --border: #27272a;
  --amber: #f59e0b;
  --brand: #7c8cff;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select { font: inherit; color: inherit; }

/* header / footer */
header, footer, main { max-width: 680px; margin: 0 auto; padding: 0 16px; }
header { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
/* logo: the buyer's L (text colour) and the supplier's L (brand colour) form one speech bubble */
.brand {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  font-size: 19px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; text-decoration: none;
}
.brand-mark { width: 22px; height: 22px; flex: none; }
.brand-mark .a { fill: currentColor; }
.brand-mark .b { fill: var(--brand); }
.brand { min-height: 44px; }
/* demo header: on phones the scenario picker needs the room, so show the mark only */
@media (max-width: 480px) {
  .brand.compact { min-width: 44px; }
  .brand.compact .brand-word {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}
.new-run { display: flex; gap: 8px; flex: 1; min-width: 0; justify-content: flex-end; }
.new-run select { flex: 0 1 auto; min-width: 0; text-overflow: ellipsis; }
.new-run button { flex: none; }
.header-actions { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; justify-content: flex-end; }
.icon { flex: none; }
.icon { width: 34px; padding: 0; display: grid; place-items: center; color: var(--muted); }
.icon:hover { color: var(--fg); }
.icon svg { width: 16px; height: 16px; }
.icon .moon { display: none; }
:root[data-theme="dark"] .icon .sun { display: none; }
:root[data-theme="dark"] .icon .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon .sun { display: none; }
  :root:not([data-theme="light"]) .icon .moon { display: block; }
}
footer { display: flex; justify-content: space-between; gap: 16px; padding-top: 48px; padding-bottom: 32px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
footer a { text-decoration: none; margin-left: 4px; padding: 6px; display: inline-block; }
footer a:hover { color: var(--fg); }

/* controls */
select, button {
  height: 34px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
button:hover { background: var(--subtle); }
button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 500; }
button.primary:hover { opacity: 0.88; }
button:disabled { opacity: 0.4; cursor: default; }

/* run view */
.logo { width: 20px; height: 20px; flex: none; vertical-align: -5px; margin-right: 7px; }
.parties { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 24px; font-size: 13px; font-weight: 500; }
.parties .party { display: inline-flex; align-items: center; }
.parties .logo { width: 24px; height: 24px; margin-right: 8px; }
.parties .role { color: var(--muted); font-weight: 400; margin-left: 4px; }
.parties .sep { color: var(--muted); }
.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 10px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.running { background: var(--blue); animation: pulse 1.2s infinite; }
.dot.awaiting_human { background: var(--amber); }
.dot.completed { background: var(--green); }
.dot.rejected, .dot.failed { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.3; } }

h1 { font-size: 22px; line-height: 1.35; font-weight: 600; letter-spacing: -0.02em; margin: 8px 0 6px; }
.facts { color: var(--muted); margin: 0; padding: 0; list-style: none; }
.alert { margin: 4px 0 6px; padding: 8px 12px; border-left: 3px solid var(--amber); background: var(--subtle); border-radius: 0 6px 6px 0; font-weight: 500; }
.alert[hidden] { display: none; }
h1:focus { outline: none; }

.decide { border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 24px; }
.decide p { margin: 0 0 14px; }
.consequences { margin: 0 0 10px; padding: 0; list-style: none; }
.consequences li { padding: 2px 0 2px 14px; position: relative; }
.consequences li::before { content: ""; position: absolute; left: 0; top: 0.75em; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.consequences li.warn { color: var(--amber); font-weight: 500; }
.consequences li.warn::before { background: var(--amber); }
.decide .rule { color: var(--muted); font-size: 13px; }
.decide.confirm { border-color: var(--fg); }
.decide .row { display: flex; gap: 8px; }

/* timeline */
section { margin-top: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 4px; }
.section-head h2 { font-size: 13px; font-weight: 600; margin: 0; }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; cursor: pointer; user-select: none; padding: 6px 0; }
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--fg); }

.meta .dot { vertical-align: 1px; margin-right: 2px; }
.step { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.step .time { color: var(--muted); font-size: 12px; font-family: var(--mono); padding-top: 2px; }
.step .line { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.step .who { font-weight: 500; }
.step .type { font-size: 12px; color: var(--muted); }
.step .terms { font-family: var(--mono); font-size: 12px; }
.step .note { color: var(--muted); }
.step.inner { border-bottom: none; padding: 2px 0 8px; font-size: 12.5px; color: var(--muted); }
.step.inner .note { font-style: italic; }
.step.warn .note, .step.warn .who { color: var(--amber); font-style: normal; }
.hide-inner .step.inner { display: none; }

/* "Northbridge is reviewing your order…" row under the timeline while agents work */
.step.working { color: var(--muted); border-bottom: none; }
.step.working[hidden] { display: none; }
.step.working .line { align-items: center; gap: 0; }
.dots { display: inline-flex; gap: 3px; margin-left: 6px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: 0.6; } }

/* hosted order desk: in the demo, the visitor answers for the supplier on its page */
.answer-link {
  display: inline-flex; align-items: center; height: 34px; margin-top: 10px; padding: 0 12px; border-radius: 6px;
  background: var(--fg); color: var(--bg); font-weight: 500; text-decoration: none;
}
.answer-link:hover { opacity: 0.88; }
@media (pointer: coarse), (max-width: 600px) { .answer-link { height: 44px; } }

/* details */
details { border-bottom: 1px solid var(--border); }
summary { cursor: pointer; padding: 12px 0; font-size: 13px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--muted); font-weight: 400; }
details[open] summary::after { content: "−"; }
summary .sub { color: var(--muted); font-weight: 400; margin-left: auto; margin-right: 12px; }
.log { margin: 0 0 12px; padding: 0; list-style: none; font-size: 12.5px; }
.log .entry { all: unset; box-sizing: border-box; width: 100%; padding: 6px 0; cursor: pointer; display: grid; grid-template-columns: 32px 1fr auto; gap: 8px; border-radius: 4px; }
.log .entry:hover .t { text-decoration: underline; }
.log .entry:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.log .n, .log .h { color: var(--muted); font-family: var(--mono); font-size: 12px; }
pre { font-family: var(--mono); font-size: 12px; background: var(--subtle); border-radius: 6px; padding: 12px; margin: 4px 0 8px; overflow: auto; white-space: pre-wrap; word-break: break-word; grid-column: 1 / -1; }

.empty { margin-top: 18vh; }
.empty h1 { font-size: 26px; }
.empty p { color: var(--muted); max-width: 460px; }

/* accessibility */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* touch: 44px targets */
@media (pointer: coarse), (max-width: 600px) {
  select, button { height: 44px; }
  .icon { width: 44px; }
  .log .entry { padding: 12px 0; }
  .toggle { padding: 12px 0; }
  footer a { padding: 12px 8px; }
  header { height: 72px; }
  .step { grid-template-columns: 58px 1fr; gap: 10px; }
}

/* Studio sandbox runs opened in the demo view */
.sandbox-note { margin: 16px 0 0; padding: 8px 12px; background: var(--subtle); border-radius: 6px; font-size: 13px; color: var(--muted); }
.sandbox-note[hidden] { display: none; }
.sandbox-note a { color: var(--fg); margin-left: 4px; }
footer a.studio-link { margin-left: 0; }
