:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-muted: #f0f2f7;
  --surface-strong: #e7eaf2;
  --text: #182033;
  --text-muted: #5c6477;
  --border: #d9deea;
  --primary: #1e293b;
  --primary-strong: #091426;
  --primary-soft: #e5eeff;
  --success: #166534;
  --success-soft: #ecfdf3;
  --attention: #8a4b08;
  --attention-soft: #fff7e6;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --info: #075985;
  --info-soft: #ecfeff;
  --focus: #2563eb;
  --shadow: 0 10px 28px rgba(26, 32, 55, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --sidebar: 292px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, select, input { font: inherit; }
button, select, a { touch-action: manipulation; }
a { color: inherit; }

.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; transform: translateY(-160%); background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 8px; }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); width: 100%; max-width: 100vw; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; min-width: 0; max-width: 100%; height: 100dvh; display: flex; flex-direction: column; gap: 24px; padding: 24px 18px; overflow: hidden; background: #091426; color: #f8f9ff; }
.brand, .sidebar-foot, .account { display: flex; align-items: center; gap: 12px; }
.brand-mark, .avatar { display: grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 8px; background: #ffffff; color: var(--primary-strong); font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.brand span:last-child, .account span:last-child, .sidebar-foot span:last-child { min-width: 0; }
.brand small, .account small, .sidebar-foot small { display: block; color: #abb2cc; font-size: 12px; }
.tree-nav { min-height: 0; display: grid; gap: 8px; overflow: auto; padding: 2px 4px 12px 0; scrollbar-color: #52627a transparent; }
.nav-caption { margin: 0 12px; color: #93a3bd; font-size: 11px; font-weight: 800; letter-spacing: .11em; }
.tree-list, .tree-children { display: grid; gap: 3px; padding: 0; margin: 0; list-style: none; }
.tree-children { position: relative; margin: 2px 0 4px 16px; padding-left: 12px; border-left: 1px solid rgba(184, 200, 223, .28); }
.tree-toggle[aria-expanded="false"] + .tree-children { display: none; }
.tree-link, .tree-toggle { position: relative; display: flex; align-items: center; gap: 9px; width: 100%; min-height: 44px; padding: 9px 12px; border: 0; border-radius: 6px; background: transparent; color: #ced8e9; font: inherit; font-size: 14px; font-weight: 650; line-height: 1.2; text-align: left; text-decoration: none; }
.tree-toggle { cursor: pointer; }
.tree-link:hover, .tree-toggle:hover { background: rgba(255,255,255,.08); color: #ffffff; }
.tree-link:active, .tree-toggle:active { background: rgba(255,255,255,.14); }
.tree-toggle::before { content: ""; flex: 0 0 auto; width: 7px; height: 7px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 180ms ease; }
.tree-toggle[aria-expanded="true"]::before { margin-top: -4px; transform: rotate(45deg); }
.tree-link::before { content: ""; flex: 0 0 5px; width: 5px; height: 5px; margin-left: 4px; border-radius: 50%; background: currentColor; opacity: .62; }
.tree-section { color: #ffffff; font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.tree-overview { justify-content: space-between; color: #ffffff; background: rgba(255,255,255,.06); }
.tree-link small, .tree-toggle small { margin-left: auto; color: #93a3bd; font-size: 11px; font-weight: 650; white-space: nowrap; }
.tree-link-soon { color: #aab8cc; }
.tree-link-attention { color: #ffffff; }
.tree-link[aria-current="page"] { color: #091426; background: #ffffff; box-shadow: inset 3px 0 0 #65d4b0; }
.tree-link[aria-current="page"]::before { opacity: 1; }
.nav-count { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: #383d5f; color: #ffffff; font-size: 12px; text-align: center; }
.nav-count-danger { background: #7f1d1d; }
.sidebar-foot { margin-top: auto; padding: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); }
.provenance-dot { width: 10px; height: 10px; border-radius: 999px; background: #fbbf24; box-shadow: 0 0 0 4px rgba(251,191,36,.15); }

.workspace { min-width: 0; max-width: 100%; }
.topbar { min-height: 76px; display: grid; grid-template-columns: minmax(140px, .55fr) minmax(430px, 1.45fr) auto; align-items: center; gap: 24px; padding: 12px clamp(20px, 4vw, 56px); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar p, .topbar strong { margin: 0; }
.topbar-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.data-controls { display: grid; grid-template-columns: minmax(170px, .75fr) minmax(240px, 1.25fr); gap: 12px; }
.scenario-control { display: grid; gap: 5px; color: var(--text-muted); font-size: 13px; font-weight: 700; }
.scenario-control select { min-height: 44px; width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 0 36px 0 12px; background: var(--surface); color: var(--text); }
.scenario-control select:disabled { cursor: not-allowed; background: var(--surface-muted); color: var(--text-muted); }
.account { justify-self: end; }
.fixture-banner { margin: 18px clamp(20px, 4vw, 56px) 0; padding: 12px 16px; border: 1px solid #c7d2fe; border-radius: var(--radius-sm); background: var(--primary-soft); color: #312e81; }
.journey-wrap { overflow-x: auto; padding: 18px clamp(20px, 4vw, 56px) 0; scrollbar-width: thin; }
.journey-nav { display: flex; min-width: max-content; gap: 6px; padding: 0; margin: 0; list-style: none; }
.journey-nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 7px 11px; border-radius: 999px; color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 700; }
.journey-nav a:hover { background: var(--surface-strong); color: var(--text); }
.journey-nav a[aria-current="step"] { background: var(--text); color: var(--surface); }
.step-number { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid currentColor; border-radius: 999px; font-variant-numeric: tabular-nums; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 64px; }
.loading-state { min-height: 260px; display: grid; place-items: center; color: var(--text-muted); }
.screen-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--primary-strong); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1 { max-width: 760px; margin: 0; font-size: clamp(30px, 4vw, 46px); line-height: 1.12; letter-spacing: -.035em; }
.screen-summary { max-width: 720px; margin: 12px 0 0; color: var(--text-muted); font-size: 17px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted); font-size: 13px; font-weight: 800; white-space: nowrap; }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.tone-success { border-color: #bbefcd; background: var(--success-soft); color: var(--success); }
.tone-attention { border-color: #f2d29d; background: var(--attention-soft); color: var(--attention); }
.tone-danger { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 20px; align-items: start; }
.block-stack { display: grid; gap: 16px; }
.card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 1px 2px rgba(26,32,55,.03); }
.card-body { padding: 20px; }
.card h2 { margin: 0 0 12px; font-size: 18px; line-height: 1.3; }
.card p { margin: 0; }
.card p + p { margin-top: 10px; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.stats-grid, .evidence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat, .evidence-item { min-height: 112px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-muted); }
.stat span, .evidence-item span { display: block; color: var(--text-muted); font-size: 13px; }
.stat strong, .evidence-item strong { display: block; margin: 6px 0 3px; font-size: 24px; font-variant-numeric: tabular-nums; }
.evidence-item strong { font-size: 18px; }
.stat small, .evidence-item small { color: var(--text-muted); }
.discovery-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.flow-step { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; min-height: 112px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-muted); }
.flow-step:not(:last-child)::after { content: ""; position: absolute; top: 50%; right: -13px; z-index: 1; width: 12px; height: 2px; background: var(--border); }
.flow-number { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; background: var(--primary); color: #ffffff; font-weight: 800; }
.flow-step span:not(.flow-number), .flow-step small { display: block; color: var(--text-muted); font-size: 12px; }
.flow-step strong { display: block; margin: 5px 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin-bottom: 5px; }
.section-heading p { max-width: 760px; }
.list-count { flex: 0 0 auto; padding: 5px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-strong); font-size: 13px; font-weight: 800; }
.channel-list, .post-list { display: grid; gap: 8px; }
.channel-row, .post-row { display: grid; align-items: center; gap: 14px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.channel-row { grid-template-columns: minmax(230px, 1.4fr) repeat(3, minmax(110px, .65fr)); }
.post-row { grid-template-columns: minmax(240px, 1.4fr) repeat(2, minmax(80px, .45fr)) auto auto; }
.channel-identity, .post-identity { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 10px; min-width: 0; }
.channel-identity strong, .channel-identity span, .post-identity strong, .post-identity span, .post-identity small { display: block; }
.channel-identity span:not(.channel-id), .post-identity span, .post-identity small { color: var(--text-muted); overflow-wrap: anywhere; }
.channel-id, .post-id { display: grid; place-items: center; min-width: 52px; min-height: 32px; padding: 4px 8px; border-radius: 8px; background: var(--surface-muted); color: var(--text-muted); font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.list-field span { display: block; color: var(--text-muted); font-size: 12px; }
.list-field strong { display: block; margin-top: 3px; font-variant-numeric: tabular-nums; }
.post-row .status-pill { justify-self: start; }
.post-review-link { min-width: 112px; }
.notice { border-left: 4px solid currentColor; box-shadow: none; }
.notice-info { background: var(--info-soft); color: var(--info); }
.notice-warning { background: var(--attention-soft); color: var(--attention); }
.notice p { color: var(--text); }
.plain-list, .checklist, .claim-list { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.plain-list li { position: relative; padding-left: 22px; }
.plain-list li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 7px; height: 7px; border-radius: 999px; background: var(--primary); }
.checklist li { display: flex; align-items: flex-start; gap: 10px; }
.check-state { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 7px; color: var(--surface); font-size: 13px; font-weight: 900; }
.check-state.done { border-color: var(--success); background: var(--success); }
.signal-card { display: grid; grid-template-columns: 1.1fr repeat(3, minmax(90px, .5fr)); gap: 18px; align-items: center; }
.signal-account strong, .signal-account span { display: block; }
.signal-account span { color: var(--text-muted); }
.metric { font-variant-numeric: tabular-nums; }
.metric span { display: block; color: var(--text-muted); font-size: 12px; }
.metric strong { display: block; margin-top: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip { padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-muted); font-size: 13px; font-weight: 700; }
.source-grid, .schedule-grid, .setting-list { display: grid; gap: 12px; }
.source-row, .schedule-row, .setting-row { display: grid; grid-template-columns: minmax(130px, .35fr) minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.source-row:last-child, .schedule-row:last-child, .setting-row:last-child { border-bottom: 0; }
.source-row dt, .schedule-row dt, .setting-row dt { color: var(--text-muted); }
.source-row dd, .schedule-row dd, .setting-row dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.claim-groups { display: grid; gap: 12px; }
.claim-group { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.claim-label { display: inline-flex; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.copy-box { padding: 20px; border-left: 4px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-muted); font-size: 18px; line-height: 1.7; }
.copy-provenance { margin-top: 12px !important; color: var(--text-muted); font-size: 12px; }
.asset-preview { display: grid; place-items: center; min-height: 300px; padding: 36px; border-radius: var(--radius-sm); background: linear-gradient(145deg, #312e81, #6366f1); color: #ffffff; text-align: center; }
.asset-preview strong { max-width: 480px; font-size: clamp(24px, 4vw, 38px); line-height: 1.2; }
.error-card { border-color: #fecaca; background: var(--danger-soft); }
.error-code { display: inline-flex; margin-bottom: 10px; color: var(--danger); font: 700 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.error-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.error-grid div { padding: 14px; border-radius: var(--radius-sm); background: var(--surface); }
.error-grid strong { display: block; margin-bottom: 5px; font-size: 13px; }
.action-panel { position: sticky; top: 96px; display: grid; gap: 12px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); }
.action-panel h2 { margin: 0; font-size: 17px; }
.action-panel p { margin: 0; color: var(--text-muted); font-size: 14px; }
.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 11px 16px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; text-decoration: none; font-weight: 800; transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease; }
.button-primary { background: var(--primary); color: #ffffff; }
.button-primary:hover { background: var(--primary-strong); }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { background: var(--surface-muted); }
.button:disabled { cursor: wait; opacity: .65; }
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.scenario-note { padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.ai-provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ai-provider-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-muted); }
.ai-provider-card h3 { margin: 0; }
.ai-provider-card .definition-list { display: grid; gap: 9px; margin: 0; }
.ai-provider-card .definition-list div { display: grid; grid-template-columns: minmax(105px, .55fr) minmax(0, 1fr); gap: 10px; }
.ai-provider-card dt { color: var(--text-muted); }
.ai-provider-card dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: min(58dvh, 560px); padding: 14px 18px; gap: 14px; }
  .brand { display: flex; }
  .sidebar-foot { display: none; }
  .tree-nav { max-width: 100%; padding-right: 6px; }
  .topbar { grid-template-columns: minmax(140px, .45fr) minmax(400px, 1.55fr); }
  .account { display: none; }
  .channel-row { grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(110px, .65fr)); }
  .channel-row .list-field:last-child { grid-column: 2; }
  .post-row { grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(80px, .45fr)); }
  .post-row .status-pill { grid-column: 2; }
  .post-review-link { grid-column: 3; }
}

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr; gap: 12px; padding: 14px 18px; }
  .data-controls { grid-template-columns: 1fr; }
  .scenario-control { grid-template-columns: 1fr; gap: 5px; }
  .fixture-banner { margin: 14px 18px 0; }
  .journey-wrap { padding: 14px 18px 0; }
  main { width: calc(100% - 36px); padding-top: 22px; }
  .screen-header, .content-grid { grid-template-columns: 1fr; }
  .screen-header { align-items: start; }
  .status-pill { justify-self: start; }
  .stats-grid, .evidence-grid, .error-grid, .discovery-flow { grid-template-columns: 1fr; }
  .flow-step:not(:last-child)::after { top: auto; right: auto; bottom: -13px; left: 31px; width: 2px; height: 12px; }
  .section-heading { display: grid; gap: 10px; }
  .list-count { justify-self: start; }
  .channel-row, .post-row { grid-template-columns: 1fr 1fr; }
  .channel-identity, .post-identity { grid-column: 1 / -1; }
  .channel-row .list-field:last-child, .post-row .status-pill, .post-review-link { grid-column: auto; }
  .post-review-link { grid-column: 1 / -1; width: 100%; }
  .signal-card { grid-template-columns: 1fr 1fr; }
  .signal-account { grid-column: 1 / -1; }
  .action-panel { position: static; }
  .ai-provider-grid { grid-template-columns: 1fr; }
}

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