:root {
  --navy-900: #0b1f3a;
  --navy-800: #12294a;
  --navy-700: #1b3760;
  --ink: #1c2330;
  --ink-2: #3c4657;
  --muted: #6b7484;
  --faint: #98a1b0;
  --line: #e3e7ed;
  --line-2: #eef1f5;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --accent: #0e6b80;
  --accent-2: #138aa3;
  --accent-soft: #e6f3f6;
  --ok: #1f7a4d;
  --ok-soft: #e7f5ee;
  --warn: #9a6200;
  --warn-soft: #fff4de;
  --bad: #b3261e;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --spk-0: #0e6b80; --spk-1: #7a4fb5; --spk-2: #b5562b; --spk-3: #2f7d32; --spk-4: #a3336b; --spk-5: #3d5a99;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.topbar {
  height: 56px; background: var(--navy-900); color: #fff; display: flex; align-items: center;
  padding: 0 20px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #1aa0b8, #0e6b80); display: grid; place-items: center; }
.brand small { color: #9fb3c8; font-weight: 500; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.env-pill { font-size: 11px; font-weight: 600; letter-spacing: .4px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.1); color: #cfe3ee; }
.phi-pill { font-size: 11px; font-weight: 600; letter-spacing: .4px; padding: 3px 8px; border-radius: 99px; background: #3b2a0a; color: #ffd27a; }
.user-btn { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; color: #dfe8f1; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.user-btn:hover { background: rgba(255,255,255,.08); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #2b4c78; display: grid; place-items: center; font-weight: 650; font-size: 12px; color: #fff; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 56px); }
.sidenav { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 56px; height: calc(100vh - 56px); }
.sidenav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink-2);
  text-decoration: none; font-weight: 520; margin-bottom: 2px;
}
.sidenav a:hover { background: var(--line-2); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.sidenav .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.sidenav .foot { position: absolute; bottom: 14px; left: 14px; right: 14px; font-size: 11.5px; color: var(--faint); line-height: 1.45; }
main { min-width: 0; }

/* ---------- generic ---------- */
.page { padding: 24px 28px 48px; max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; margin: 0; font-weight: 680; letter-spacing: -.2px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 560; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--line-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.icon { width: 16px; height: 16px; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 620; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-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(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.spin .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 11px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 107, 128, .14); }
textarea.input { min-height: 220px; resize: vertical; font-family: var(--mono); font-size: 12.8px; line-height: 1.55; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12px; font-weight: 640; color: var(--ink-2); margin-bottom: 5px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin: 10px 0 4px; font-size: 16px; }

/* ---------- recordings ---------- */
.rec-layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.rec-list { overflow: hidden; position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.rec-list .tools { padding: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.rec-list .items { overflow: auto; }
.rec-item { padding: 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; display: block; width: 100%; text-align: left; background: none; border-left: 3px solid transparent; border-top: 0; border-right: 0; }
.rec-item:hover { background: #fafbfc; }
.rec-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.rec-item .t { font-weight: 620; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-item .m { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.rec-item .s { color: var(--ink-2); font-size: 12.5px; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.group-label { padding: 10px 14px 6px; font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--faint); text-transform: uppercase; background: #fbfcfd; border-bottom: 1px solid var(--line-2); }
.dropzone { border: 1.5px dashed var(--line); border-radius: 8px; padding: 10px; text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px 12px 0; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.detail-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.detail-head .ref { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.detail-head h2 { margin: 4px 0 8px; font-size: 20px; font-weight: 680; letter-spacing: -.2px; display: flex; gap: 8px; align-items: center; }
.detail-head h2 .edit { opacity: 0; transition: opacity .15s; }
.detail-head h2:hover .edit { opacity: 1; }
.meta-row { display: flex; flex-wrap: wrap; gap: 16px; color: var(--ink-2); font-size: 13px; }
.meta-row span { display: inline-flex; gap: 6px; align-items: center; }
.detail-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.player { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--navy-800); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.play:hover { background: var(--navy-700); }
.play:disabled { opacity: .5; }
.scrub { flex: 1; position: relative; height: 34px; cursor: pointer; }
.scrub .track { position: absolute; left: 0; right: 0; top: 15px; height: 4px; border-radius: 4px; background: #dfe4ea; }
.scrub .buf { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #c7d0db; border-radius: 4px; }
.scrub .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); border-radius: 4px; }
.scrub .knob { position: absolute; top: -5px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: var(--shadow); left: 0; }
.scrub:hover .track { height: 6px; top: 14px; }
.time { font-family: var(--mono); font-size: 12px; color: var(--ink-2); min-width: 104px; text-align: right; }
.speed { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 6px; font-size: 12px; font-weight: 600; cursor: pointer; }

.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tab { padding: 12px 12px 10px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { padding: 20px 22px 28px; }

.versions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.version { border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; background: #fff; cursor: pointer; text-align: left; min-width: 180px; }
.version.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.version .vn { font-weight: 620; font-size: 13px; display: flex; gap: 6px; align-items: center; }
.version .vm { font-size: 11.5px; color: var(--muted); }

.report { max-width: 820px; color: var(--ink); font-size: 14.5px; line-height: 1.65; }
.report h1 { font-size: 22px; margin: 0 0 12px; }
.report h2 { font-size: 16px; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--navy-900); }
.report h3 { font-size: 14.5px; margin: 18px 0 6px; color: var(--navy-900); }
.report p { margin: 0 0 10px; }
.report ul, .report ol { margin: 0 0 12px; padding-left: 22px; }
.report li { margin: 3px 0; }
.report table { border-collapse: collapse; width: 100%; margin: 6px 0 16px; font-size: 13.5px; }
.report th, .report td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.report th { background: #f6f8fa; font-weight: 650; color: var(--navy-900); }
.report blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--ink-2); }
.report .ts { font-family: var(--mono); font-size: 12px; color: var(--accent); cursor: pointer; background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.disclaimer { display: flex; gap: 10px; background: var(--warn-soft); color: #6d4a00; border-radius: 8px; padding: 10px 12px; font-size: 12.8px; margin-bottom: 16px; max-width: 820px; }

.pdf-frame { width: 100%; height: calc(100vh - 220px); min-height: 640px; border: 1px solid var(--line); border-radius: 8px; background: #525659; }

.transcript-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.speakers { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 8px 10px; border-radius: 8px; }
.seg:hover { background: #fafbfc; }
.seg.now { background: var(--accent-soft); }
.seg .when { font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer; padding-top: 2px; }
.seg .when:hover { color: var(--accent); }
.seg .who { font-weight: 650; font-size: 12.5px; margin-bottom: 1px; }
.seg .txt { color: var(--ink); line-height: 1.6; }
mark { background: #ffe58a; border-radius: 2px; padding: 0 1px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 170px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.timeline .tw { color: var(--muted); font-size: 12.5px; }
.timeline .ta { font-weight: 600; }
.timeline .td { color: var(--muted); font-size: 12.5px; word-break: break-all; }

.processing { padding: 48px 24px; text-align: center; }
.steps { display: flex; justify-content: center; gap: 0; margin: 22px auto 0; max-width: 560px; }
.step { flex: 1; text-align: center; position: relative; font-size: 12.5px; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step .b { width: 24px; height: 24px; border-radius: 50%; background: var(--line); margin: 0 auto 6px; position: relative; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.step.done .b, .step.done::before { background: var(--ok); }
.step.cur .b { background: var(--accent); animation: pulse 1.2s infinite; }
.step.done, .step.cur { color: var(--ink); }

/* ---------- tables ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }

/* ---------- prompts ---------- */
.prompt-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.prompt-item { padding: 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; background: none; border-top: 0; border-right: 0; border-left: 3px solid transparent; width: 100%; text-align: left; display: block; }
.prompt-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.prompt-item .t { font-weight: 620; display: flex; align-items: center; gap: 6px; }
.prompt-item .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.star { color: #c58a00; }

/* ---------- modal / toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(11, 31, 58, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: min(620px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.modal header { padding: 18px 22px 0; }
.modal header h3 { margin: 0; font-size: 17px; }
.modal header p { margin: 4px 0 0; color: var(--muted); }
.modal .body { padding: 18px 22px; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcfd; border-radius: 0 0 12px 12px; }
.choice { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; cursor: pointer; margin-bottom: 8px; align-items: flex-start; }
.choice:hover { background: #fafbfc; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice b { display: block; font-weight: 620; }
.choice small { color: var(--muted); font-size: 12.5px; }
.token-box { font-family: var(--mono); font-size: 12.5px; background: var(--navy-900); color: #d7f3fa; padding: 12px 14px; border-radius: 8px; word-break: break-all; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy-900); color: #fff; padding: 11px 15px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 380px; display: flex; gap: 9px; align-items: center; }
.toast.bad { background: var(--bad); }

.signin { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, #1b3760, var(--navy-900)); }
.signin .box { background: #fff; border-radius: 14px; padding: 34px 34px 28px; width: min(420px, calc(100% - 32px)); box-shadow: var(--shadow-lg); text-align: center; }
.signin h1 { margin: 14px 0 4px; font-size: 21px; }
.signin p { color: var(--muted); margin: 0 0 22px; }
.signin .fine { font-size: 11.5px; color: var(--faint); margin-top: 18px; line-height: 1.5; }

@media (max-width: 1100px) {
  .rec-layout, .prompt-layout { grid-template-columns: 1fr; }
  .rec-list { position: static; max-height: 360px; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { position: static; height: auto; display: flex; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav .foot { display: none; }
  .page { padding: 16px; }
  .brand small, .env-pill { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}
