/* Ayonix Insight — design system. Semantic tokens (CLAUDE.md §5) with complete light/dark themes. */
:root {
  --canvas: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #F0F0F3;
  --surface-3: #E8E8ED;
  --text: #1D1D1F;
  --text-2: #626269;
  --text-3: #6E6E76;
  --primary: #005FCC;
  --primary-hover: #004FA8;
  --primary-fill: #005FCC;
  --primary-fill-hover: #004FA8;
  --nav-active: #005FCC;
  --primary-soft: #E5F0FF;
  --on-primary: #FFFFFF;
  --border: #D8D8DE;
  --border-soft: #E6E6EB;
  --focus: #0A84FF;
  --ok: #146B37;
  --ok-soft: #E3F5EA;
  --warn: #8A4B00;
  --warn-soft: #FFF3DF;
  --danger: #B42824;
  --danger-soft: #FDECEB;
  --indigo: #4B44C8;
  --indigo-soft: #ECEBFD;
  --stage: #0B0C0F;
  --stage-text: #F5F5F7;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .16);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #111113; --surface: #1C1C1E; --surface-2: #232326; --surface-3: #2C2C30; --text: #F5F5F7; --text-2: #B5B5BD; --text-3: #A0A0A8;
    --primary: #4DA3FF; --primary-hover: #7AB9FF; --primary-fill: #0A68D0; --primary-fill-hover: #0A5CB8; --nav-active: #6CB4FF; --primary-soft: #0F2A4A; --on-primary: #FFFFFF; --border: #414147; --border-soft: #2E2E33;
    --ok: #32D74B; --ok-soft: #133A1D; --warn: #FFB340; --warn-soft: #3A2A10; --danger: #FF6961; --danger-soft: #3D1716; --indigo: #A7A3FF; --indigo-soft: #26244A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #111113; --surface: #1C1C1E; --surface-2: #232326; --surface-3: #2C2C30; --text: #F5F5F7; --text-2: #B5B5BD; --text-3: #A0A0A8;
  --primary: #4DA3FF; --primary-hover: #7AB9FF; --primary-fill: #0A68D0; --primary-fill-hover: #0A5CB8; --nav-active: #6CB4FF; --primary-soft: #0F2A4A; --on-primary: #FFFFFF; --border: #414147; --border-soft: #2E2E33;
  --ok: #32D74B; --ok-soft: #133A1D; --warn: #FFB340; --warn-soft: #3A2A10; --danger: #FF6961; --danger-soft: #3D1716; --indigo: #A7A3FF; --indigo-soft: #26244A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.6; color: var(--text); background: var(--canvas); font-synthesis: none; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3, h4 { line-height: 1.35; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--primary-fill); color: var(--on-primary); padding: 10px 16px; border-radius: 10px; }
.skip-link:focus { top: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; }

/* Boot */
.boot { position: fixed; inset: 0; display: grid; place-content: center; gap: 16px; justify-items: center; color: var(--text-2); }
.boot-mark { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #0A84FF, #005FCC); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .7; } }

/* Shell */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; padding: 20px 12px; position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brandmark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; background: linear-gradient(135deg, #0A84FF, #005FCC); }
.brand strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.brand small { display: block; font-size: .75rem; color: var(--text-2); }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-list a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: .9375rem; }
.nav-list a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-list a:hover { background: var(--surface-2); color: var(--text); }
.nav-list a[aria-current="page"] { background: var(--primary-soft); color: var(--nav-active); }
.nav-list .badge { margin-left: auto; }
.side-foot { margin-top: auto; border-top: 1px solid var(--border-soft); padding: 14px 10px 0; display: grid; gap: 8px; font-size: .8125rem; color: var(--text-2); }
.workspace { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode { display: flex; align-items: center; gap: 8px; }
.mode .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.mode.ok .dot, .dot.ok { background: var(--ok); }
.mode.warn .dot, .dot.warn { background: var(--warn); }
.mode.bad .dot, .dot.bad { background: var(--danger); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 25; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--canvas) 86%, transparent); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--border-soft); }
.route-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn { display: none; }
.avatar-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.avatar-btn span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .875rem; }
.user-menu { position: relative; }
.menu { position: absolute; right: 0; top: 52px; min-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; z-index: 40; }
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.menu .menu-head strong { display: block; }
.menu .menu-head small { color: var(--text-2); font-size: .8125rem; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; min-height: 44px; padding: 0 10px; border: 0; background: transparent; border-radius: 8px; text-align: left; cursor: pointer; color: var(--text); text-decoration: none; font-size: .9375rem; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.live-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: .8125rem; cursor: pointer; }
.rec { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: blinkdot 1.6s ease-in-out infinite; }
@keyframes blinkdot { 50% { opacity: .35; } }
main { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 28px 28px 48px; outline: none; }
.app-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 28px 24px; font-size: .75rem; color: var(--text-3); }

/* Page scaffolding */
.page { display: none; }
.page.active { display: block; animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h2 { font-size: clamp(1.625rem, 2.6vw, 2rem); letter-spacing: -.02em; font-weight: 700; }
.page-head p { color: var(--text-2); margin-top: 4px; max-width: 62ch; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; color: var(--text-2); text-transform: uppercase; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 1.125rem; font-weight: 700; }
.card-head .sub { font-size: .8125rem; color: var(--text-2); }
.section-title { font-size: 1.25rem; font-weight: 700; margin: 28px 0 12px; }
.muted { color: var(--text-2); }
.small { font-size: .875rem; }
.xsmall { font-size: .75rem; }
.mono { font-family: var(--mono); font-size: .8125rem; }
.num { font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; border: 0; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: .9375rem; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary-fill); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-fill-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.field { display: grid; gap: 6px; }
.field > span, .field > label, .label { font-size: .875rem; font-weight: 600; color: var(--text); }
.field small, .hint { font-size: .8125rem; color: var(--text-2); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent); outline-offset: 0; border-color: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .8125rem; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 6px 0; cursor: pointer; }
.switch + .switch { border-top: 1px solid var(--border-soft); }
.switch .text strong { display: block; font-weight: 600; font-size: .9375rem; }
.switch .text small { display: block; color: var(--text-2); font-size: .8125rem; }
.switch input { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; cursor: pointer; transition: background .2s; border: 1px solid var(--border); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked { background: var(--ok); border-color: var(--ok); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:disabled { opacity: .45; cursor: not-allowed; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { min-height: 38px; border: 0; background: transparent; padding: 0 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .875rem; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Pills, badges, tiers */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--primary-soft); color: var(--primary); }
.pill.indigo { background: var(--indigo-soft); color: var(--indigo); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; display: inline-grid; place-items: center; }
.tier { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.tier-observed { background: var(--primary-soft); color: var(--primary); }
.tier-utterance { background: var(--indigo-soft); color: var(--indigo); }
.tier-self_reported { background: var(--ok-soft); color: var(--ok); }
.tier-observer { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.tier-estimated { background: var(--warn-soft); color: var(--warn); }
.tier-unavailable { background: transparent; color: var(--text-2); border-color: var(--border); }
.tier-pending { background: transparent; color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }

/* Metrics */
.metric { display: grid; gap: 4px; }
.metric .label { font-size: .8125rem; color: var(--text-2); font-weight: 600; }
.metric .value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.metric .value.word { font-size: 1.25rem; }
.metric .foot { font-size: .8125rem; color: var(--text-2); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; font-size: .875rem; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* States: empty / error / loading */
.state { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 32px 16px; color: var(--text-2); }
.state strong { color: var(--text); font-size: 1rem; }
.state.error strong { color: var(--danger); }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.notice { border-radius: 12px; padding: 12px 14px; font-size: .875rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--border-soft); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-weight: 700; color: var(--text-2); font-size: .8125rem; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
td { padding: 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tbody tr { cursor: default; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; flex: 1 1 150px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* Toasts & dialog */
.toasts { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--canvas); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .9375rem; display: flex; gap: 12px; align-items: center; animation: fadein .2s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }
.toast button { margin-left: auto; background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 8px; min-height: 32px; padding: 0 10px; cursor: pointer; }
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-body { padding: 24px; display: grid; gap: 16px; overflow-y: auto; max-height: calc(100dvh - 140px); }
.dialog-body h2 { font-size: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 24px; flex-wrap: wrap; }
.drawer-detail pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 12px; border-radius: 10px; font-size: .8125rem; }

/* Auth */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(440px, 100%); display: grid; gap: 18px; }
.auth-card .brand { padding: 0; justify-content: center; }
.auth-card h2 { font-size: 1.5rem; text-align: center; }
.auth-card .card { padding: 28px; display: grid; gap: 16px; }

/* Dashboard */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.hero-visual { position: relative; border-radius: var(--radius); overflow: hidden; background: radial-gradient(120% 90% at 20% 10%, #1b3a6b 0%, #0B0C0F 60%); min-height: 260px; color: #fff; padding: 24px; display: flex; flex-direction: column; justify-content: flex-end; }
.hero-visual .face-demo { position: absolute; left: 50%; top: 42%; width: 150px; height: 180px; transform: translate(-50%, -50%); }
.hero-visual h3 { font-size: 1.375rem; position: relative; }
.hero-visual p { color: #C9D6EA; position: relative; font-size: .9375rem; }
.corner { position: absolute; width: 28px; height: 28px; border-color: #5AC8FA; border-style: solid; border-width: 0; }
.corner.tl { left: 0; top: 0; border-left-width: 3px; border-top-width: 3px; border-top-left-radius: 8px; }
.corner.tr { right: 0; top: 0; border-right-width: 3px; border-top-width: 3px; border-top-right-radius: 8px; }
.corner.bl { left: 0; bottom: 0; border-left-width: 3px; border-bottom-width: 3px; border-bottom-left-radius: 8px; }
.corner.br { right: 0; bottom: 0; border-right-width: 3px; border-bottom-width: 3px; border-bottom-right-radius: 8px; }
.scanline { position: absolute; left: 6px; right: 6px; height: 2px; top: 0; background: linear-gradient(90deg, transparent, #5AC8FA, transparent); box-shadow: 0 0 12px #5AC8FA; animation: scan 2.4s cubic-bezier(.45, 0, .55, 1) infinite; }
.scanline::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 40px; background: linear-gradient(to top, rgba(90, 200, 250, .18), transparent); }
@keyframes scan { 0% { top: 4%; } 50% { top: 94%; } 100% { top: 4%; } }
.recent-list { display: grid; }
.recent-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-soft); font-size: .9375rem; }
.recent-item:last-child { border-bottom: 0; }
.recent-item time { color: var(--text-2); font-size: .8125rem; font-variant-numeric: tabular-nums; }

/* Live camera */
.live { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.live-main { display: grid; gap: 16px; min-width: 0; }
.live-side { display: grid; gap: 16px; min-width: 0; }
.stage-card { padding: 0; overflow: hidden; }
.stage-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border-soft); }
.stage-toolbar select { max-width: 260px; min-height: 40px; }
.stage { position: relative; background: var(--stage); aspect-ratio: 16 / 10; width: 100%; overflow: hidden; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage.mirrored video { transform: scaleX(-1); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: #D6DCE6; text-align: center; padding: 20px; }
.stage-empty .glyph { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: rgba(255, 255, 255, .08); }
.stage-empty .glyph svg { width: 34px; height: 34px; fill: none; stroke: #9EC9FF; stroke-width: 1.6; }
.stage-empty strong { color: #fff; font-size: 1.0625rem; }
.stage-empty small { color: #AEB8C8; max-width: 44ch; }
.stage-hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.hud-pill { background: rgba(0, 0, 0, .55); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-variant-numeric: tabular-nums; }
.hud-pill.hud-rec { color: #FF8A84; }
.stage-status { display: flex; align-items: center; gap: 10px; padding: 12px; flex-wrap: wrap; font-size: .875rem; }
.stage-status .msg { flex: 1; min-width: 180px; color: var(--text-2); }
.stage-status .msg.ok { color: var(--ok); }
.stage-status .msg.warn { color: var(--warn); }
.stage-status .msg.bad { color: var(--danger); }
.stage-status .xsmall { flex-basis: 100%; }
.person-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.person-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .875rem; }
.person-tab[aria-selected="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--nav-active); }
.person-tab .swatch { width: 10px; height: 10px; border-radius: 3px; }
.tone-gauge { display: grid; gap: 8px; }
.tone-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tone-head strong { font-size: 1.375rem; letter-spacing: -.01em; transition: color .6s; }
.tone-track { position: relative; height: 12px; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--warn) 55%, var(--surface-2)), var(--surface-3) 50%, color-mix(in srgb, var(--primary) 55%, var(--surface-2))); }
.tone-track .zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--text-3); border-radius: 1px; opacity: .6; }
.tone-track .base { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); opacity: .35; transition: left 1.2s ease; }
.tone-knob { position: absolute; top: 50%; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 3px solid var(--text); transform: translate(-50%, -50%); transition: left 1.2s cubic-bezier(.22, .61, .36, 1), border-color .6s; box-shadow: var(--shadow); }
.tone-scale { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-2); }
.tone-note { font-size: .75rem; color: var(--text-2); }
.spark { width: 100%; height: 56px; display: block; }
.change-flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 60%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px 16px; gap: 4px 8px; align-items: center; font-size: .8125rem; }
.bar-row .name { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.bar-row .trend { font-size: .75rem; color: var(--text-2); text-align: center; }
.bar-row .meter { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; background: var(--primary); width: 0; transition: width .9s cubic-bezier(.22, .61, .36, 1); }
.bar-row.na .fill { background: transparent; }
.bar-row.na .val { color: var(--text-3); }
.insight-card .headline { font-size: 1.125rem; font-weight: 700; }
.insight-lines { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.insight-lines li { padding-left: 16px; position: relative; font-size: .9375rem; }
.insight-lines li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.suggestion { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px; border-radius: 12px; background: var(--primary-soft); flex-wrap: wrap; }
.suggestion p { flex: 1 1 240px; font-size: .875rem; }
.timeline { display: grid; gap: 8px; max-height: 260px; overflow-y: auto; }
.tl-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; font-size: .875rem; align-items: baseline; }
.tl-item time { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: .8125rem; }
.tl-item.change strong { color: var(--primary); }
.evidence-list { display: grid; gap: 2px; }
.ev-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.ev-row:last-child { border-bottom: 0; }
.ev-row .label { font-weight: 600; font-size: .9375rem; }
.ev-row .value { font-size: .875rem; font-weight: 600; text-align: right; }
.ev-row .detail { grid-column: 1 / -1; font-size: .8125rem; color: var(--text-2); }
.ev-row .meta { grid-column: 1 / -1; font-size: .75rem; color: var(--text-3); display: flex; gap: 10px; flex-wrap: wrap; }
.ev-row.self_reported .value { color: var(--ok); }
.ev-row.utterance .value { color: var(--indigo); }
.mic-meter { width: 80px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.mic-meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
details.collapsible > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 700; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::after { content: "＋"; color: var(--text-2); }
details.collapsible[open] > summary::after { content: "－"; }

/* Research / settings */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { min-height: 44px; border: 0; background: transparent; padding: 0 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.save-state { font-size: .8125rem; color: var(--text-2); min-height: 20px; }
.save-state.bad { color: var(--danger); }
.save-state.ok { color: var(--ok); }
.model-status { display: grid; gap: 10px; }
.model-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.model-row:last-child { border-bottom: 0; }
.model-row small { grid-column: 1 / -1; color: var(--text-2); font-size: .8125rem; }
.gate-table td, .gate-table th { font-size: .8125rem; }

/* Responsive */
@media (max-width: 1180px) {
  .live { grid-template-columns: minmax(0, 1fr); }
  .live-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .hero, .cols-2, .cols-3, .settings-grid, .live-side { grid-template-columns: minmax(0, 1fr); }
  main { padding: 20px 16px 40px; }
  .topbar { padding: 0 12px; }
  .app-foot { padding: 12px 16px 20px; }
}
@media (max-width: 560px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 16px; }
  .stage { aspect-ratio: 3 / 4; }
  .stage-toolbar select { max-width: none; flex: 1 1 100%; }
  .metric .value { font-size: 1.5rem; }
  .live-chip #liveChipText { display: none; }
  .page-head h2 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .scanline { display: none; }
}
@media print {
  .sidebar, .topbar, .app-foot, .toasts { display: none !important; }
}
