:root {
  --ink: #102c3d;
  --muted: #5c7280;
  --dim: #8498a3;
  --surface: #f4f9fc;
  --surface-raised: #ffffff;
  --line: #c5d9e5;
  --line-soft: #ddebf2;
  --accent: #07a7d8;
  --accent-light: #73c7eb;
  --accent-muted: #0673b3;
  --danger: #c84032;
  --warn: #916600;
  --speaker-1: #0673b3;
  --speaker-2: #176b9d;
  --speaker-3: #8051a4;
  --speaker-4: #a65418;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--surface); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 86% -8%, rgba(115, 199, 235, .22), transparent 34rem),
    var(--surface);
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.grain {
  display: none;
}

.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;
}

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(243, 246, 240, .98);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
  font: 700 15px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
}

.brand-slash { color: var(--accent); padding: 0 .2em; }
.brand-ai { color: var(--accent-muted); }
.brand-mark { height: 23px; display: flex; align-items: center; gap: 2px; }
.brand-mark i { width: 2px; height: 7px; background: var(--accent); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 17px; }
.brand-mark i:nth-child(3) { height: 23px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { padding: 8px 11px; border: 1px solid var(--line); color: var(--muted); background: var(--surface-raised); font: 12px/1 ui-monospace, monospace; }
.runtime-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.status-light { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.runtime-status.ready .status-light { background: var(--accent); box-shadow: 0 0 0 5px rgba(7, 167, 216, .12); }
.runtime-status.ready .runtime-label { color: var(--ink); }
.runtime-status.error .status-light { background: var(--danger); }

.quiet-button, .icon-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.quiet-button { padding: 9px 10px; font-size: 14px; }
.quiet-button:hover { color: var(--ink); }
.upload-open { border: 1px solid var(--accent-light); color: var(--accent-muted); background: rgba(115, 199, 235, .10); }
.upload-open:hover { border-color: var(--accent); color: var(--accent-muted); background: rgba(115, 199, 235, .18); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); font-size: 20px; }
.icon-button:hover { color: var(--accent); background: var(--surface-raised); transform: rotate(15deg); }
.icon-button.loading span { display: inline-block; animation: spin .7s linear infinite; }

main { padding: 0 clamp(20px, 4vw, 64px) 40px; }

.overview {
  min-height: 176px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 38px 0 30px;
  border-bottom: 1px solid var(--line);
  animation: rise .45s ease both;
}

.eyebrow { margin: 0 0 12px; color: var(--accent); font: 12px/1 ui-monospace, monospace; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(34px, 5vw, 64px); line-height: .95; letter-spacing: -.055em; font-weight: 600; }

.metrics { display: flex; align-items: flex-end; margin: 0; }
.metrics div { min-width: 94px; padding: 3px 20px; border-left: 1px solid var(--line); }
.metrics dt { color: var(--muted); font-size: 13px; }
.metrics dd { margin: 7px 0 0; font: 500 24px/1 ui-monospace, monospace; }
.metrics div:nth-child(3) dd { color: var(--accent); }
.metrics div:nth-child(4) dd:not(:empty) { color: var(--danger); }

.queue-monitor { padding: 24px 0 0; border-bottom: 1px solid var(--line); animation: rise .45s .04s ease both; }
.queue-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 18px; }
.queue-head .eyebrow { margin-bottom: 8px; }
.queue-head h2 { margin: 0; font-size: 24px; letter-spacing: -.025em; }
.queue-live { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font: 12px/1 ui-monospace, monospace; text-transform: uppercase; }
.queue-live span { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.queue-live.active span { background: var(--accent-muted); animation: pulse 1.2s ease infinite; }
.queue-live strong { color: var(--ink); font-size: 14px; }
.queue-lanes { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.queue-lane { min-width: 0; padding: 18px 24px 18px 0; }
.queue-lane + .queue-lane { padding: 18px 0 18px 24px; border-left: 1px solid var(--line); }
.queue-lane > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.queue-code { color: var(--accent-muted); font: 700 12px/1 ui-monospace, monospace; letter-spacing: .12em; }
.queue-lane h3 { margin: 8px 0 0; font-size: 15px; }
.queue-counts { color: var(--muted); font: 12px/1.5 ui-monospace, monospace; white-space: nowrap; }
.queue-counts strong { color: var(--ink); font-weight: 600; }
.queue-items { max-height: 218px; margin-top: 13px; overflow-y: auto; border-top: 1px solid var(--line-soft); }
.queue-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 11px 0; border: 0; border-bottom: 1px solid var(--line-soft); color: inherit; background: transparent; text-align: left; }
.queue-item:hover { background: rgba(7, 167, 216, .045); }
.queue-item-main { min-width: 0; display: flex; align-items: center; gap: 9px; }
.queue-item-state { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.queue-item.processing .queue-item-state { background: var(--accent-muted); animation: pulse 1.2s ease infinite; }
.queue-item-name { min-width: 0; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font: 600 14px/1.35 ui-monospace, monospace; }
.queue-item-time { align-self: center; color: var(--accent-muted); font: 600 14px/1 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.queue-item-detail { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding-left: 16px; color: var(--dim); font: 12px/1.4 ui-monospace, monospace; text-transform: uppercase; }
.queue-item-detail .queue-position { color: var(--warn); }
.queue-empty { margin: 0; padding: 18px 0 5px; color: var(--dim); font-size: 13px; }

.filters {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 160px 150px 150px auto;
  align-items: end;
  gap: 12px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
  animation: rise .45s .06s ease both;
}

.filters label:not(.search-field), .auth-panel label { display: grid; gap: 7px; }
.filters label > span, .auth-panel label > span { color: var(--muted); font: 12px/1 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }

.filters input, .filters select, .auth-panel input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--surface-raised);
  padding: 0 12px;
  font-size: 15px;
}

.search-field { position: relative; display: flex; align-items: center; }
.search-field input { height: 48px; padding: 0 48px 0 42px; font-size: 15px; }
.search-field input::placeholder { color: #879188; }
.search-icon { position: absolute; left: 15px; width: 14px; height: 14px; border: 1.5px solid var(--muted); border-radius: 50%; z-index: 1; }
.search-icon::after { content: ""; position: absolute; width: 6px; height: 1px; background: var(--muted); transform: rotate(45deg); right: -5px; bottom: -2px; }
kbd { position: absolute; right: 13px; color: var(--dim); border: 1px solid var(--line); padding: 2px 6px; font: 12px/1.2 ui-monospace, monospace; }
.filter-clear { height: 42px; border: 1px solid transparent; }

.workspace {
  min-height: calc(100vh - 331px);
  display: grid;
  grid-template-columns: minmax(350px, 430px) minmax(0, 1fr);
  animation: rise .45s .12s ease both;
}

.result-pane { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.pane-heading { height: 61px; padding-right: 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.pane-heading h2 { margin: 0; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.pane-heading span { color: var(--muted); font: 13px/1 ui-monospace, monospace; }
.result-list { flex: 1; }

.result-row {
  width: 100%;
  padding: 18px 22px 17px 0;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 13px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  transition: background .18s ease, padding .18s ease;
}
.result-row::before { content: ""; width: 3px; height: 100%; min-height: 54px; background: var(--line); transition: background .18s ease; }
.result-row:hover { background: rgba(7, 167, 216, .045); padding-left: 5px; }
.result-row.selected { background: rgba(115, 199, 235, .16); }
.result-row.selected::before { background: var(--accent); }
.result-primary, .result-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-call { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 15px/1.4 ui-monospace, monospace; }
.result-date { flex: none; color: var(--muted); font-size: 13px; }
.result-excerpt { margin: 7px 0 10px; color: #4f5b52; font-size: 14px; line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result-meta { justify-content: flex-start; color: var(--dim); font: 12px/1 ui-monospace, monospace; text-transform: uppercase; }

.status-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.status-tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-tag.completed { color: var(--accent-muted); }
.status-tag.processing, .status-tag.queued { color: var(--warn); }
.status-tag.processing::before, .status-tag.queued::before { animation: pulse 1.2s ease infinite; }
.status-tag.failed { color: var(--danger); }

.pagination { min-height: 55px; padding-right: 12px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); }
.pagination span { color: var(--dim); font: 12px/1 ui-monospace, monospace; }
.pagination button:disabled { opacity: .25; cursor: default; }

.detail-pane { min-width: 0; padding: 0 clamp(24px, 4vw, 58px) 50px; }
.detail-placeholder { min-height: 500px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.detail-placeholder p { margin: 22px 0 5px; color: var(--ink); font-size: 17px; }
.detail-placeholder small { color: var(--dim); font-size: 14px; }
.signal { height: 46px; display: flex; align-items: center; gap: 5px; }
.signal i { width: 3px; height: 10px; background: var(--accent); animation: signal 1s ease-in-out infinite alternate; }
.signal i:nth-child(2), .signal i:nth-child(6) { animation-delay: -.4s; }
.signal i:nth-child(3), .signal i:nth-child(5) { animation-delay: -.7s; }
.signal i:nth-child(4) { animation-delay: -.2s; }

.detail-head { padding: 34px 0 26px; border-bottom: 1px solid var(--line); animation: detail-in .25s ease both; }
.detail-kicker { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font: 12px/1 ui-monospace, monospace; letter-spacing: .1em; }
.detail-title { margin: 15px 0 9px; overflow-wrap: anywhere; font: 600 clamp(20px, 2.5vw, 32px)/1.2 ui-monospace, monospace; letter-spacing: -.025em; }
.detail-file { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 24px; color: var(--muted); font-size: 13px; }
.detail-meta strong { color: var(--ink); font-weight: 500; }
.process-timeline { margin-top: 22px; padding: 14px 0 2px; border-top: 1px solid var(--line); }
.process-timeline-title { display: block; margin-bottom: 12px; color: var(--accent-muted); font: 700 12px/1 ui-monospace, monospace; letter-spacing: .12em; }
.process-timing-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; }
.process-timing-grid > div { min-width: 0; padding: 2px 13px; border-left: 1px solid var(--line-soft); }
.process-timing-grid > div:first-child { padding-left: 0; border-left: 0; }
.process-timing-grid dt { color: var(--muted); font-size: 12px; }
.process-timing-grid dd { margin: 7px 0 0; color: var(--ink); font: 600 13px/1.4 ui-monospace, monospace; overflow-wrap: anywhere; }
.detail-actions { display: flex; gap: 8px; margin-top: 23px; }
.action-button, .primary-button {
  min-height: 39px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
  padding: 0 15px;
  font-size: 14px;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.action-button:hover { border-color: var(--muted); }
.action-button.danger { color: var(--danger); }
.action-button.danger:hover:not(:disabled) { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.action-button:disabled { opacity: .46; cursor: not-allowed; }

.audio-panel {
  min-height: 76px;
  padding: 14px 0;
  display: grid;
  grid-template-columns: minmax(170px, .65fr) minmax(260px, 1fr);
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.audio-copy { display: grid; gap: 5px; }
.audio-label { color: var(--accent-muted); font: 700 12px/1 ui-monospace, monospace; letter-spacing: .13em; }
.audio-panel small { color: var(--muted); font-size: 13px; }
.audio-panel.unavailable { display: flex; align-items: center; justify-content: space-between; }
.audio-stage { min-width: 0; display: flex; justify-content: flex-end; }
.audio-stage audio { width: min(100%, 520px); height: 40px; }
.audio-load { min-height: 39px; padding: 0 15px; border: 1px solid var(--accent-muted); color: var(--accent-muted); background: transparent; font: 700 14px/1 ui-monospace, monospace; }
.audio-load:hover { color: var(--ink); border-color: var(--ink); }
.audio-load:disabled { opacity: .55; cursor: wait; }
.audio-mark { color: var(--accent-muted); }

.analysis-panel { padding: 26px 0 30px; border-bottom: 1px solid var(--line); }
.analysis-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.analysis-head .eyebrow { margin-bottom: 8px; }
.analysis-head h3 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.analysis-actions { display: flex; align-items: center; gap: 10px; }
.analysis-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font: 12px/1 ui-monospace, monospace; }
.analysis-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.analysis-status.completed { color: var(--accent-muted); }
.analysis-status.queued, .analysis-status.processing { color: var(--warn); }
.analysis-status.queued::before, .analysis-status.processing::before { animation: pulse 1.2s ease infinite; }
.analysis-status.failed { color: var(--danger); }
.analysis-empty, .analysis-error, .analysis-stale { margin: 20px 0 0; font-size: 14px; line-height: 1.65; }
.analysis-empty { color: var(--muted); }
.analysis-error { color: var(--danger); }
.analysis-stale { padding: 10px 12px; border-left: 3px solid var(--warn); color: var(--warn); background: rgba(145, 102, 0, .06); }
.analysis-loading { min-height: 64px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.analysis-loading span { width: 3px; height: 12px; background: var(--accent); animation: signal .8s ease-in-out infinite alternate; }
.analysis-loading span:nth-last-child(2) { animation-delay: -.25s; }
.analysis-loading span:last-child { animation-delay: -.5s; }
.analysis-summary { margin-top: 22px; padding: 18px 20px; border-left: 3px solid var(--accent); background: rgba(115, 199, 235, .13); }
.analysis-label { color: var(--accent-muted); font: 700 12px/1 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.analysis-summary > p { margin: 9px 0 0; font-size: 15px; line-height: 1.75; }
.analysis-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.analysis-meta strong { color: var(--ink); font-weight: 500; }
.analysis-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; margin-top: 23px; }
.analysis-list-section { min-width: 0; padding-top: 13px; border-top: 1px solid var(--line); }
.analysis-list-section h4, .follow-up-section h4 { margin: 0 0 11px; font-size: 14px; letter-spacing: .06em; }
.analysis-list-section ul { margin: 0; padding-left: 17px; color: #39443c; font-size: 14px; line-height: 1.65; }
.analysis-list-section li + li { margin-top: 7px; }
.follow-up-section { margin-top: 25px; }
.follow-up-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 11px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.follow-up-index { color: var(--accent-muted); font: 12px/1.5 ui-monospace, monospace; }
.follow-up-body { display: grid; gap: 5px; }
.follow-up-body strong { font-size: 14px; line-height: 1.55; }
.follow-up-body small { color: var(--muted); font-size: 12px; }

.speaker-filter { display: flex; flex-wrap: wrap; gap: 8px; padding: 22px 0; border-bottom: 1px solid var(--line-soft); }
.speaker-chip { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); color: var(--muted); background: transparent; font: 12px/1 ui-monospace, monospace; }
.speaker-chip.active { border-color: var(--speaker-color, var(--accent)); color: var(--speaker-color, var(--accent)); background: color-mix(in srgb, var(--speaker-color, var(--accent)) 7%, transparent); }

.transcript-mode {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 14px 0 4px;
}
.transcript-mode button {
  min-height: 31px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-raised);
  font: 12px/1 ui-monospace, monospace;
}
.transcript-mode button.active {
  border-color: var(--accent-muted);
  color: var(--accent-muted);
  background: rgba(115, 199, 235, .17);
}
.transcript { padding-top: 5px; }
.segment {
  display: grid;
  grid-template-columns: 84px 110px minmax(0, 1fr);
  gap: 18px;
  margin: 4px -14px 0;
  padding: 18px 14px 18px 11px;
  border-left: 3px solid var(--speaker-color, var(--accent));
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--speaker-color, var(--accent)) 8%, var(--surface-raised));
  content-visibility: auto;
  contain-intrinsic-size: auto 82px;
  transition: background-color .15s ease;
}
.segment-time { color: var(--dim); font: 12px/1.5 ui-monospace, monospace; }
.segment-speaker { color: var(--speaker-color, var(--accent)); font: 600 12px/1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.segment-content { min-width: 0; }
.segment-text { margin: 0; color: #2f3932; font-size: 15px; line-height: 1.72; letter-spacing: .01em; }
.segment:hover { background: color-mix(in srgb, var(--speaker-color, var(--accent)) 13%, var(--surface-raised)); }
.segment:hover .segment-text { color: #09110b; }
.correction-audit {
  display: block;
  margin-top: 8px;
  color: var(--accent-muted);
  font: 12px/1.5 ui-monospace, monospace;
  overflow-wrap: anywhere;
}
.load-more {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  border: 1px solid var(--line);
  color: var(--accent-muted);
  background: var(--surface-raised);
  font: 600 14px/1 ui-monospace, monospace;
}
.load-more:hover { border-color: var(--accent-muted); background: rgba(115, 199, 235, .13); }

.error-panel { margin-top: 30px; padding: 22px 0; border-top: 1px solid var(--danger); color: #9e3026; line-height: 1.6; }
.empty-state { padding: 80px 22px; text-align: center; color: var(--muted); }
.empty-state p { margin: 14px 0 5px; color: var(--ink); }
.empty-state small { color: var(--dim); }
.empty-glyph { color: var(--accent); font: 30px/1 ui-monospace, monospace; }

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(239, 247, 251, .95);
  backdrop-filter: blur(20px);
}
.auth-overlay[hidden] { display: none; }
.auth-panel { width: min(100%, 470px); padding: 36px; border: 1px solid var(--line); background: var(--surface-raised); box-shadow: 20px 20px 0 rgba(6, 115, 179, .10); animation: auth-in .35s cubic-bezier(.2,.8,.2,1) both; }
.auth-index { color: var(--accent); font: 12px/1 ui-monospace, monospace; letter-spacing: .15em; }
.auth-wave { height: 70px; margin: 24px 0 15px; display: flex; align-items: center; gap: 8px; }
.auth-wave i { width: 3px; height: 12px; background: var(--accent); animation: signal 1s ease-in-out infinite alternate; }
.auth-wave i:nth-child(2n) { animation-delay: -.35s; }
.auth-wave i:nth-child(3n) { animation-delay: -.7s; }
.auth-panel h2 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.auth-panel > p { margin: 12px 0 25px; color: var(--muted); line-height: 1.6; font-size: 15px; }
.auth-panel label { margin-top: 20px; }
.auth-panel input { height: 48px; font-family: ui-monospace, monospace; }
.auth-panel .auth-error { min-height: 20px; margin: 10px 0; color: var(--danger); font-size: 14px; }
.primary-button { width: 100%; height: 48px; display: flex; align-items: center; justify-content: space-between; border-color: var(--accent); color: #052f43; background: var(--accent); font-weight: 700; }
.primary-button:hover { background: #30b5de; }

body.drawer-open { overflow: hidden; }
.summary-qr-shell[hidden] { display: none; }
.summary-qr-shell { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 22px; }
.summary-qr-scrim { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(16, 44, 61, .42); backdrop-filter: blur(3px); }
.summary-qr-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  padding: 28px clamp(20px, 4vw, 36px) 30px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  box-shadow: 0 24px 70px rgba(16, 44, 61, .22);
  animation: qr-dialog-in .22s cubic-bezier(.2,.8,.2,1) both;
}
.summary-qr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.summary-qr-head h2 { margin: 0; font-size: 26px; letter-spacing: -.035em; }
.summary-qr-intro { margin: 14px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.summary-qr-loading { min-height: 330px; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); }
.summary-qr-loading span { width: 3px; height: 18px; background: var(--accent); animation: signal .8s ease-in-out infinite alternate; }
.summary-qr-loading span:nth-child(2) { animation-delay: -.25s; }
.summary-qr-loading span:nth-child(3) { animation-delay: -.5s; }
.summary-qr-loading small { margin-left: 8px; font-size: 13px; }
.summary-qr-content { display: grid; gap: 14px; }
.summary-qr-canvas { min-height: 320px; display: grid; place-items: center; padding: 14px; border: 1px solid var(--line-soft); background: #fff; }
.summary-qr-canvas img { display: block; width: min(100%, 410px); height: auto; image-rendering: pixelated; animation: qr-image-in .16s ease both; }
.summary-qr-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font: 13px/1.4 ui-monospace, monospace; }
.summary-qr-meta strong { color: var(--ink); }
.summary-qr-nav { display: flex; justify-content: space-between; gap: 10px; padding-top: 3px; }
.summary-qr-nav button:disabled { opacity: .35; cursor: default; }
.summary-qr-error { min-height: 18px; margin: 14px 0 0; color: var(--danger); font-size: 13px; }
.drawer-shell[hidden] { display: none; }
.drawer-shell { position: fixed; inset: 0; z-index: 30; }
.drawer-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(34, 45, 37, .28);
}
.glossary-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(620px, 94vw);
  height: 100%;
  overflow-y: auto;
  padding: 30px clamp(22px, 4vw, 42px) 48px;
  border-left: 1px solid var(--line);
  background: var(--surface-raised);
  box-shadow: -22px 0 55px rgba(36, 49, 39, .14);
  animation: drawer-in .24s cubic-bezier(.2,.8,.2,1) both;
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.drawer-head h2 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.drawer-intro { margin: 16px 0 26px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.upload-drawer { width: min(700px, 96vw); }
.upload-form { display: grid; gap: 20px; }
.upload-dropzone {
  position: relative;
  min-height: 210px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 30px;
  border: 1px dashed var(--accent-light);
  color: var(--muted);
  background: rgba(115, 199, 235, .08);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.upload-dropzone:hover, .upload-dropzone.dragover { border-color: var(--accent); background: rgba(115, 199, 235, .16); transform: translateY(-2px); }
.upload-dropzone.selected { border-style: solid; color: var(--ink); background: var(--surface); }
.upload-dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-glyph { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--accent); color: var(--accent-muted); background: var(--surface-raised); font: 500 26px/1 ui-monospace, monospace; }
.upload-dropzone strong { max-width: 480px; overflow-wrap: anywhere; font-size: 16px; }
.upload-dropzone small { color: var(--dim); font-size: 13px; }
.upload-options { display: grid; grid-template-columns: 1.35fr .8fr 1fr; gap: 14px; }
.upload-options label { min-width: 0; display: grid; align-content: start; gap: 7px; }
.upload-options label > span { color: var(--muted); font: 12px/1.3 ui-monospace, monospace; letter-spacing: .07em; }
.upload-options select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 0; color: var(--ink); background: var(--surface-raised); }
.upload-options small { color: var(--dim); font-size: 12px; line-height: 1.45; }
.upload-analysis-option { display: flex; align-items: flex-start; gap: 11px; padding: 15px 0; border-block: 1px solid var(--line-soft); cursor: pointer; }
.upload-analysis-option input { flex: none; width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent-muted); }
.upload-analysis-option > span { display: grid; gap: 5px; }
.upload-analysis-option strong { font-size: 14px; }
.upload-analysis-option small { color: var(--muted); font-size: 13px; }
.upload-analysis-option.unavailable { opacity: .55; cursor: not-allowed; }
.upload-progress-shell { display: grid; gap: 8px; }
.upload-progress-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font: 12px/1.4 ui-monospace, monospace; }
.upload-progress-head strong { color: var(--accent-muted); }
.upload-progress-track { height: 5px; overflow: hidden; background: var(--line-soft); }
.upload-progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .18s ease; }
.upload-progress-shell.processing .upload-progress-track span { width: 100% !important; animation: upload-wait 1.1s ease-in-out infinite alternate; }
.upload-error { min-height: 19px; margin: -8px 0 0; color: var(--danger); font-size: 13px; }
.upload-form .primary-button:disabled { opacity: .55; cursor: wait; }
.glossary-form {
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.glossary-form label:not(.enabled-field) { display: grid; gap: 7px; }
.glossary-form label > span { color: var(--muted); font: 12px/1.3 ui-monospace, monospace; letter-spacing: .08em; }
.glossary-form input:not([type="checkbox"]), .glossary-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--surface-raised);
  padding: 11px 12px;
  font-size: 14px;
}
.glossary-form select { width: 100%; min-height: 40px; border: 1px solid var(--line); color: var(--ink); background: var(--surface-raised); padding: 8px 10px; font-size: 14px; }
.glossary-form textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.enabled-field { display: flex; align-items: center; gap: 9px; }
.enabled-field input { width: 16px; height: 16px; accent-color: var(--accent-muted); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.primary-inline {
  min-height: 39px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  color: #052f43;
  background: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.primary-inline:hover { background: #30b5de; }
.glossary-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 0 13px;
  border-bottom: 1px solid var(--line);
}
.glossary-toolbar > div { display: grid; gap: 5px; }
.glossary-toolbar strong { font-size: 15px; }
.glossary-toolbar small { color: var(--muted); font-size: 13px; }
.glossary-list { display: grid; }
.glossary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line-soft);
}
.glossary-row.disabled { opacity: .5; }
.glossary-row-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.glossary-row-title strong { font: 600 15px/1.4 ui-monospace, monospace; }
.glossary-row-title span { padding: 3px 6px; color: var(--muted); background: var(--surface); font: 12px/1 ui-monospace, monospace; text-transform: uppercase; }
.term-toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.term-toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent-muted); }
.term-toggle span::after { content: "啟用"; }
.term-toggle input:not(:checked) + span::after { content: "停用"; }
.glossary-alias-line { margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.glossary-row-body > small { display: block; margin-top: 5px; color: var(--dim); font-size: 12px; }
.glossary-row-actions { display: flex; align-items: flex-start; gap: 2px; }
.glossary-row-actions .quiet-button:last-child { color: var(--danger); }
.glossary-empty { margin: 0; padding: 30px 0; color: var(--muted); text-align: center; font-size: 14px; }

.extension-badge { padding: 3px 7px; border: 1px solid #9ed8f1; color: #0673b3; background: #eef9fd; font: 12px/1.2 ui-monospace, monospace; }
.admin-drawer { width: min(820px, 96vw); }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.permission-checks { display: flex; flex-wrap: wrap; gap: 18px; }
.permission-checks label, .extension-option { display: flex !important; align-items: center; gap: 8px !important; color: var(--ink); font-size: 14px; }
.permission-checks input, .extension-option input { accent-color: var(--accent-muted); }
.extension-picker { margin: 0; padding: 13px; border: 1px solid var(--line); }
.extension-picker legend { padding: 0 6px; color: var(--muted); font: 12px/1 ui-monospace, monospace; letter-spacing: .08em; }
.extension-options { display: flex; flex-wrap: wrap; gap: 7px; }
.extension-option { padding: 7px 9px; border: 1px solid var(--line-soft); background: var(--surface-raised); }
.extension-options small { color: var(--muted); }
.admin-user-list { display: grid; gap: 12px; padding: 14px 0; }
.admin-user-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); background: var(--surface); }
.admin-user-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.admin-user-head > div { display: grid; gap: 4px; }
.admin-user-head small { color: var(--muted); font: 12px/1.3 ui-monospace, monospace; }
.admin-user-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.admin-user-controls label { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: 7px; padding: 6px 8px; border: 1px solid var(--line-soft); background: var(--surface-raised); font-size: 13px; }
.admin-user-controls select { min-width: 78px; border: 0; background: transparent; }
.admin-user-controls input { accent-color: var(--accent-muted); }
.admin-card-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; max-width: min(380px, calc(100vw - 48px)); padding: 13px 17px; color: var(--surface); background: var(--accent); font-size: 14px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { color: white; background: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes detail-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes auth-in { from { opacity: 0; transform: scale(.97) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes pulse { 50% { opacity: .25; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes signal { from { height: 8px; opacity: .45; } to { height: 44px; opacity: 1; } }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes upload-wait { from { opacity: .35; transform: translateX(-35%); } to { opacity: 1; transform: translateX(0); } }
@keyframes qr-dialog-in { from { opacity: 0; transform: scale(.97) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes qr-image-in { from { opacity: .4; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 980px) {
  .overview { align-items: flex-start; flex-direction: column; }
  .metrics { width: 100%; }
  .metrics div { flex: 1; padding-left: 12px; }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-clear { justify-self: start; }
  .workspace { grid-template-columns: 330px minmax(0, 1fr); }
  .segment { grid-template-columns: 70px 90px minmax(0, 1fr); gap: 12px; }
}

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; }
  .brand { font-size: 12px; }
  .runtime-label, #lock-button { display: none; }
  main { padding: 0 16px 24px; }
  .overview { min-height: 145px; padding-top: 28px; }
  .metrics { overflow-x: auto; }
  .metrics div { min-width: 76px; }
  .metrics dd { font-size: 19px; }
  .queue-head { align-items: flex-end; }
  .queue-lanes { grid-template-columns: 1fr; }
  .queue-lane { padding-right: 0; }
  .queue-lane + .queue-lane { padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:nth-of-type(2) { grid-column: 1 / -1; }
  .workspace { display: block; }
  .result-pane { border-right: 0; }
  .detail-pane { padding: 0; }
  .detail-pane.has-detail { min-height: 100vh; }
  .detail-placeholder { min-height: 300px; }
  .segment { grid-template-columns: 72px minmax(0, 1fr); margin-inline: 0; padding-inline: 9px; }
  .segment-speaker { grid-column: 2; grid-row: 1; }
  .segment-content { grid-column: 2; }
  .audio-panel { grid-template-columns: 1fr; gap: 10px; }
  .audio-stage { justify-content: stretch; }
  .audio-stage audio, .audio-load { width: 100%; }
  .analysis-head { align-items: stretch; flex-direction: column; }
  .analysis-actions { justify-content: space-between; }
  .analysis-grid { grid-template-columns: 1fr; gap: 16px; }
  .analysis-summary { padding: 16px; }
  .process-timing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; }
  .process-timing-grid > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .result-pane.detail-open { display: none; }
  .detail-back { display: inline-flex !important; }
  .auth-panel { padding: 28px 22px; }
  .summary-qr-shell { padding: 10px; }
  .summary-qr-dialog { max-height: calc(100vh - 20px); padding: 22px 18px 24px; }
  .summary-qr-canvas { min-height: 280px; padding: 8px; }
  .upload-drawer { width: 100%; padding: 24px 18px 40px; }
  .upload-options { grid-template-columns: 1fr; }
  .upload-dropzone { min-height: 180px; padding: 24px 18px; }
  .glossary-drawer { width: 100%; padding: 24px 18px 40px; }
  .glossary-form { padding: 18px; }
  .glossary-toolbar { align-items: flex-start; flex-direction: column; }
  .glossary-row { grid-template-columns: 1fr; }
  .glossary-row-actions { justify-content: flex-end; }
  .admin-form-grid, .admin-user-controls { grid-template-columns: 1fr; }
  .user-chip { display: none; }
}

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