:root {
  color-scheme: dark;
  font-family: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --canvas: oklch(12% 0.018 260);
  --stage: oklch(16% 0.025 265);
  --surface: oklch(20% 0.025 265);
  --active: oklch(25% 0.035 265);
  --line: oklch(34% 0.035 264);
  --soft-line: oklch(27% 0.025 265);
  --text: oklch(91% 0.025 82);
  --secondary: oklch(72% 0.025 80);
  --muted: oklch(57% 0.025 75);
  --gold: oklch(78% 0.13 78);
  --cyan: oklch(78% 0.12 205);
  --amber: oklch(76% 0.13 70);
  --error: oklch(64% 0.18 28);
  --success: oklch(72% 0.13 150);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.no-js .js-only { display: none !important; }
html { height: 100%; overflow: hidden; }
body { margin: 0; min-width: 320px; height: 100%; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable; background: var(--canvas); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.skip-link { position: fixed; inset: 8px auto auto 8px; z-index: 20; padding: 10px 14px; background: var(--text); color: var(--canvas); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.topbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px clamp(20px, 4vw, 54px); border-bottom: 1px solid var(--line); background: var(--stage); }
.identity { display: flex; align-items: center; gap: 13px; text-decoration: none; }
.identity svg { width: 40px; height: 40px; fill: none; stroke: var(--gold); stroke-width: 1.6; }
.identity span { display: grid; gap: 1px; }
.identity small { color: var(--muted); font: .66rem/1.2 ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.identity strong { font-size: 1.18rem; }
.runtime { display: flex; align-items: center; gap: 9px; }
.connection { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 10px; border: 1px solid var(--line); color: var(--secondary); font: .72rem ui-monospace, monospace; }
.connection::before { content: ""; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: currentColor; }
.connection.ready { color: var(--success); }
.connection.attention { color: var(--amber); }

.environment { padding: 9px clamp(20px, 4vw, 54px); border-bottom: 1px solid oklch(42% 0.08 70); background: oklch(20% 0.045 70); color: oklch(86% 0.07 78); font-size: .8rem; }
.environment.live { border-color: oklch(40% .09 150); background: oklch(19% .045 150); color: oklch(85% .07 150); }

button, .draft-actions a { min-height: 38px; padding: 8px 13px; border: 1px solid var(--line); background: transparent; cursor: pointer; text-decoration: none; transition: background 180ms cubic-bezier(.25,1,.5,1), border-color 180ms cubic-bezier(.25,1,.5,1), color 180ms cubic-bezier(.25,1,.5,1); }
button:hover:not(:disabled), .draft-actions a:hover { border-color: var(--secondary); background: var(--active); }
button:disabled { opacity: .45; cursor: not-allowed; }
.quiet { min-height: 34px; padding: 6px 10px; color: var(--secondary); }
.primary { min-height: 45px; border-color: var(--gold); background: var(--gold); color: oklch(18% .025 78); font-weight: 700; }
.primary:hover:not(:disabled) { border-color: oklch(84% .12 78); background: oklch(84% .12 78); }
.primary.compact { min-height: 38px; }

.tabs { display: flex; min-height: 50px; padding: 0 clamp(20px, 4vw, 54px); border-bottom: 1px solid var(--line); background: var(--stage); overflow-x: auto; }
.tab { border: 0; border-bottom: 2px solid transparent; padding-inline: 15px; color: var(--muted); white-space: nowrap; }
.tab:hover:not(:disabled) { background: transparent; color: var(--secondary); }
.tab.active { border-bottom-color: var(--gold); color: var(--text); }
.tab span { margin-left: 5px; color: var(--secondary); font: .7rem ui-monospace, monospace; }
.commerce-link { display: grid; place-items: center; margin-left: auto; padding: 0 10px; color: var(--muted); font-size: .76rem; text-decoration: none; }

main { width: min(1450px, 100%); margin: 0 auto; padding: clamp(20px, 3vw, 42px); }
.view { display: none; }
.view.active { display: block; }
.overview-grid, .content-grid, .activity-grid { display: grid; gap: 22px; align-items: start; }
.overview-grid { grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); }
.content-grid { grid-template-columns: minmax(320px, .82fr) minmax(0, 1.35fr); }
.activity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.account, .attention, .surfaces, .composer, .queue, .view[data-panel="insights"], .activity-grid > section { border: 1px solid var(--line); background: var(--stage); }
.surfaces { margin-top: 22px; }
.section-heading { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 19px; border-bottom: 1px solid var(--line); }
.section-heading.wide { min-height: 76px; }
h2, p { margin: 0; }
h2 { font-size: 1rem; line-height: 1.2; }
.section-heading p { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.eyebrow { margin-bottom: 4px; color: var(--muted); font: .65rem ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }

.account-state { min-height: 185px; display: grid; grid-template-columns: auto minmax(160px, 1fr) auto; gap: 18px; align-items: center; padding: 25px; }
.account-mark { width: 64px; height: 64px; display: grid; place-items: center; border: 1px solid var(--gold); clip-path: polygon(12px 0,100% 0,100% calc(100% - 12px),calc(100% - 12px) 100%,0 100%,0 12px); background: var(--surface); color: var(--gold); font-size: 1.4rem; font-weight: 700; }
.account-state strong { display: block; font-size: 1.08rem; }
.account-state span { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; }
.account-state dl { display: grid; gap: 12px; margin: 0; }
.account-state dl div { text-align: right; }
.account-state dt { color: var(--muted); font-size: .66rem; }
.account-state dd { margin: 3px 0 0; color: var(--secondary); font: .7rem ui-monospace, monospace; }
.empty-account { display: grid; grid-template-columns: 1fr; place-content: center; text-align: center; }
.empty-account p { margin-top: 7px; color: var(--muted); font-size: .8rem; }
.inline-error { grid-column: 1 / -1; padding: 10px 12px; border: 1px solid oklch(48% .11 28); background: oklch(20% .04 28); color: oklch(82% .08 28); font-size: .76rem; }

.attention-list { min-height: 185px; }
.attention-list > button { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; border: 0; border-bottom: 1px solid var(--soft-line); padding: 12px 18px; color: var(--secondary); text-align: left; }
.attention-list > button b { color: var(--gold); }
.clear-state { min-height: 185px; display: grid; place-content: center; justify-items: center; gap: 11px; color: var(--muted); font-size: .8rem; }
.clear-state span { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--success); border-radius: 50%; color: var(--success); }

.capability-list { display: grid; }
.capability { min-height: 64px; display: grid; grid-template-columns: 12px 150px 1fr 110px; gap: 14px; align-items: center; padding: 12px 19px; border-bottom: 1px solid var(--soft-line); }
.capability:last-child { border-bottom: 0; }
.capability strong { font-size: .8rem; }
.capability p { color: var(--muted); font-size: .76rem; }
.capability-state { color: var(--muted); font: .66rem ui-monospace, monospace; text-align: right; }
.signal { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.signal.ready, .signal.completed, .signal.processed { background: var(--success); }
.signal.configured, .signal.accepted, .signal.observed, .signal.received { background: var(--cyan); }
.signal.needs_setup, .signal.failed { background: var(--error); }

.composer form { display: grid; gap: 18px; padding: 20px; }
label { display: grid; gap: 7px; color: var(--secondary); font-size: .75rem; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 0; background: var(--canvas); color: var(--text); padding: 10px 12px; }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
label small { justify-self: end; color: var(--muted); font: .66rem ui-monospace, monospace; }
.media-input { display: grid; gap: 12px; }
.upload-zone { min-height: 110px; place-content: center; justify-items: center; border: 1px dashed var(--line); background: var(--surface); cursor: pointer; text-align: center; }
.upload-zone:hover { border-color: var(--cyan); }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone span { color: var(--text); font-weight: 650; }
.upload-zone small { justify-self: center; }
.or { color: var(--muted); font: .64rem ui-monospace, monospace; text-align: center; }

.draft-list { display: grid; }
.draft { padding: 17px 19px; border-bottom: 1px solid var(--line); }
.draft-head, .draft-foot, .draft-actions, .confirmation { display: flex; align-items: center; }
.draft-head, .draft-foot { justify-content: space-between; gap: 14px; }
.draft-head time { color: var(--muted); font-size: .68rem; }
.state { display: inline-flex; align-items: center; gap: 7px; color: var(--secondary); font: .66rem ui-monospace, monospace; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.approved, .state.published { color: var(--success); }
.state.awaiting_approval, .state.publishing { color: var(--cyan); }
.state.failed { color: var(--error); }
.state.cancelled { color: var(--muted); }
.draft-body { display: grid; grid-template-columns: minmax(180px, .78fr) minmax(0, 1fr); gap: 18px; align-items: start; margin: 15px 0 18px; }
.draft-media { min-height: 180px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--soft-line); background: var(--canvas); }
.draft-media img, .draft-media video { display: block; width: 100%; max-height: 470px; object-fit: contain; }
.draft-media:hover { border-color: var(--secondary); }
.draft-copy { min-width: 0; }
.draft-copy > p { max-width: 70ch; color: var(--secondary); font-size: .8rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-copy .inline-error { margin-top: 12px; }
.draft-foot code { color: var(--muted); font: .65rem ui-monospace, monospace; }
.draft-actions { gap: 8px; }
.draft-actions button, .draft-actions a { min-height: 34px; padding: 6px 10px; font-size: .7rem; }
.confirmation { gap: 7px; }
.confirmation input { width: 122px; min-height: 34px; padding: 6px 8px; font: .68rem ui-monospace, monospace; }
.confirmation .release { border-color: var(--gold); color: var(--gold); }
.empty { padding: 45px 20px; color: var(--muted); font-size: .8rem; text-align: center; }

.insight-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.insight { min-height: 122px; display: grid; align-content: center; gap: 7px; padding: 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.insight:nth-child(4n) { border-right: 0; }
.insight strong { color: var(--secondary); font-size: .72rem; text-transform: capitalize; }
.insight span { overflow-wrap: anywhere; color: var(--text); font: 1.1rem ui-monospace, monospace; }
.insight small { color: var(--muted); font: .62rem ui-monospace, monospace; }

.activity-list { min-height: 80px; }
.activity-row { min-height: 59px; display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--soft-line); }
.activity-row strong { display: block; color: var(--secondary); font-size: .76rem; text-transform: capitalize; }
.activity-row small { display: block; margin-top: 3px; color: var(--muted); font: .62rem ui-monospace, monospace; }
.activity-row time { color: var(--muted); font-size: .65rem; }

.access-gate { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: 20px; background: var(--canvas); }
.access-gate form { width: min(390px, 100%); display: grid; gap: 18px; padding: 28px; border: 1px solid var(--line); background: var(--stage); }
.access-gate svg { width: 46px; fill: none; stroke: var(--gold); stroke-width: 1.6; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: 400px; padding: 12px 15px; border: 1px solid var(--line); background: var(--active); box-shadow: 0 14px 40px oklch(4% .02 260 / .5); }
.toast.error { border-color: var(--error); }
.nojs { width: min(650px, calc(100% - 32px)); margin: 60px auto; }

@media (max-width: 940px) {
  .overview-grid, .content-grid, .activity-grid { grid-template-columns: 1fr; }
  .queue.has-drafts { order: -1; }
  .insight-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight:nth-child(4n) { border-right: 1px solid var(--line); }
  .insight:nth-child(2n) { border-right: 0; }
}

@media (max-width: 650px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .runtime { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .runtime .connection { grid-column: 1 / -1; justify-self: start; }
  .runtime button { width: 100%; }
  main { padding: 15px; }
  .capability { grid-template-columns: 12px 1fr auto; }
  .capability p { grid-column: 2 / -1; grid-row: 2; }
  .capability-state { grid-column: 3; grid-row: 1; }
  .account-state { grid-template-columns: auto 1fr; }
  .account-state dl { grid-column: 1 / -1; grid-template-columns: repeat(2, 1fr); }
  .account-state dl div { text-align: left; }
  .insight-list { grid-template-columns: 1fr; }
  .insight { border-right: 0; }
  .draft-body { grid-template-columns: 1fr; }
  .draft-media { min-height: 0; }
  .draft-foot { align-items: flex-start; flex-direction: column; }
  .draft-actions { width: 100%; }
  .confirmation { width: 100%; }
  .confirmation input { flex: 1; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
