:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1f22;
  --muted: #6b6f76;
  --line: #e4e2dc;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --brand: #2f5d50;
  --brand-deep: #1f4339;
  --brand-darker: #15302a;
  --live: #1f9d55;
  --warn: #c27c0e;
  --danger: #b42318;
  --edited: #fff6d6;
  --edited-line: #e8c95b;
  --focus: #2f5d5033;
  --selected: #e4e5e8;
  --note-bg: #f3f6fb;
  --note-line: #d5deea;
  --radius: 10px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --text: #e8e9eb;
    --muted: #9aa0a8;
    --line: #2d3137;
    --accent: #6fb39c;
    --accent-ink: #0e1512;
    --edited: #3a3320;
    --edited-line: #8c7630;
    --focus: #6fb39c33;
    --selected: #2f3338;
    --note-bg: #22272e;
    --note-line: #39414c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface);
}
input:focus, textarea:focus, select:focus { outline: none; box-shadow: 0 0 0 3px var(--focus); border-color: var(--accent); }
.seg .text:focus { outline: none; background: var(--surface); border-color: var(--line); box-shadow: none; }

/* Top bar */
.bar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -.01em; }
.bar .meta { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.bar .actions { display: flex; gap: 8px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .08em; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.live { color: var(--live); } .badge.live::before { background: var(--live); animation: pulse 1.6s infinite; }
.badge.waiting { color: var(--warn); } .badge.waiting::before { background: var(--warn); }
@keyframes pulse { 50% { opacity: .35; } }

/* Simple centered pages */
.center { max-width: 560px; margin: 48px auto; padding: 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.card p.sub { margin: 0 0 20px; color: var(--muted); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; }
.code-input { text-transform: uppercase; font-family: ui-monospace, Menlo, monospace; letter-spacing: .15em; }
.sessions { list-style: none; padding: 0; margin: 0; }
.sessions li a {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.sessions li a:hover { background: var(--bg); }
.sessions .info { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); font-size: 14px; }

/* Session layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: calc(100% - 57px); }
body.app { display: flex; flex-direction: column; height: 100%; }
body.app .layout { flex: 1; min-height: 0; height: auto; }
.transcript-pane { overflow-y: auto; padding: 24px clamp(16px, 4vw, 48px) 16px; position: relative; display: flex; flex-direction: column; }
.transcript { max-width: 1220px; width: 100%; flex: 1 0 auto; }

/* Each line: the transcript box, then a margin for notes in the same row */
.line {
  display: grid; grid-template-columns: minmax(0, 760px) minmax(200px, 1fr); column-gap: 18px;
  align-items: start;
}
.margin {
  align-self: stretch; min-height: 34px; padding: 5px 0; cursor: text;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
}
.margin-add {
  opacity: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500;
  padding: 3px 8px; border: 1px dashed var(--line); border-radius: 8px; transition: opacity .12s;
}
.line:hover .margin-add, .margin-add:focus-visible { opacity: 1; }
.margin.has-notes .margin-add { padding: 1px 6px; }
.mnote {
  position: relative; width: 100%; max-width: 360px; font-size: 14px; line-height: 1.4;
  background: var(--note-bg); border: 1px solid var(--note-line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 6px 28px 6px 10px;
}
.mnote p { margin: 0; white-space: pre-wrap; cursor: text; }
.mnote .del { position: absolute; top: 3px; right: 4px; background: none; color: var(--muted); padding: 0 5px; font-size: 16px; line-height: 1.2; }
.mnote .del:hover { color: var(--danger); }
.mnote-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 4px; }
.mnote-form textarea { font-size: 14px; padding: 6px 10px; resize: none; min-height: 52px; line-height: 1.4; }
.mnote-form .hint { font-size: 11px; }
.seg.flash-line { animation: flash-line 1.2s ease-out; }
@keyframes flash-line { 0%, 40% { box-shadow: inset 0 0 0 2px var(--accent); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
.notes li.linked { cursor: pointer; }
.notes li.linked .ts::before { content: "↳ "; }
.seg {
  display: grid; grid-template-columns: 84px 1fr; gap: 8px;
  padding: 5px 8px 5px 10px; margin: 1px 0 1px -14px;
  border-left: 4px solid transparent; border-radius: 6px;
  transition: background-color .15s, border-color .15s;
}
.seg.has-speaker {
  border-left-color: var(--speaker);
  background: color-mix(in srgb, var(--speaker) 10%, transparent);
}
.seg.selected { background: var(--selected); }
.seg.selected .ts { font-weight: 700; }
.gutter {
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; user-select: none;
  padding-top: 4px; min-width: 0;
}
.gutter:hover .ts, .seg.selected .ts { color: var(--accent); }
.ts { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); user-select: none; }
.seg.edited .ts::after { content: " ✎"; }
.chips { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chip {
  display: block;
  font-size: 11px; font-weight: 700; line-height: 1.25; color: var(--tag);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seg .text { padding: 2px 6px; margin: 0 -6px; border-radius: 6px; border: 1px solid transparent; min-height: 1.5em; }
.seg .text:hover { border-color: var(--line); }
.seg.has-hl .text { background: color-mix(in srgb, var(--hl) 40%, transparent); }
.seg .text:empty::before { content: "(removed)"; color: var(--muted); font-style: italic; }
.volatile { max-width: 760px; padding-left: 92px; color: var(--muted); }
.placeholder { color: var(--muted); padding: 48px 0; }

/* Floating coding bar */
.dock {
  position: sticky; bottom: 12px; z-index: 3; margin-top: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none;
}
.dock > * { pointer-events: auto; }
.jump { box-shadow: 0 4px 16px #0003; }
.codebar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
  max-width: 100%; padding: 8px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 30px #0000002e, 0 1px 3px #0000001a;
}
.codebar .target { font-size: 12px; color: var(--muted); padding: 0 6px; min-width: 96px; text-align: center; white-space: nowrap; }
.tag-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tag-btn, .bar-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600;
  padding: 6px 10px; border-radius: 9px; transition: transform .08s, background-color .12s;
}
.tag-btn {
  background: color-mix(in srgb, var(--tag) 12%, var(--surface)); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--tag) 50%, var(--line));
}
.tag-btn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tag); flex: none; }
.tag-btn.is-highlight .dot { border-radius: 3px; }
.tag-btn[aria-pressed="true"] { background: var(--tag); color: var(--tag-ink); border-color: var(--tag); }
.tag-btn[aria-pressed="true"] .dot { background: var(--tag-ink); }
.tag-btn:active, .tag-btn.flash { transform: scale(.94); }
.tag-btn.cruising {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--tag);
  animation: cruise 1.8s ease-in-out infinite;
}
.tag-btn.cruising::after {
  content: "AUTO"; font: 700 9px ui-monospace, Menlo, monospace; letter-spacing: .06em;
  padding: 2px 4px; border-radius: 4px; background: var(--tag); color: var(--tag-ink);
}
.tag-btn.cruising[aria-pressed="true"]::after { background: var(--tag-ink); color: var(--tag); }
@keyframes cruise {
  50% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 7px color-mix(in srgb, var(--tag) 35%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .tag-btn.cruising { animation: none; } }
.codebar .target.cruise { color: var(--text); font-weight: 600; }
.bar-btn { background: transparent; color: var(--muted); border: 1px solid transparent; font-weight: 500; }
.bar-btn:hover { color: var(--text); border-color: var(--line); }
kbd {
  font: 600 11px ui-monospace, Menlo, monospace; padding: 0 4px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.tag-btn kbd { background: transparent; border-color: color-mix(in srgb, currentColor 30%, transparent); color: inherit; opacity: .8; }
.codebar .divider { width: 1px; align-self: stretch; background: var(--line); margin: 2px; }
.codebar .empty { font-size: 13px; color: var(--muted); padding: 0 6px; }

/* Talk-time stats */
.stats { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.stack span { height: 100%; background: var(--c); min-width: 2px; }
.stack span + span { box-shadow: inset 2px 0 0 var(--surface); }
.stat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stat-list li {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 1px 10px; align-items: baseline;
  padding: 6px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer;
}
.stat-list li:hover { background: var(--bg); }
.stat-list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); align-self: center; }
.stat-list .dot.square { border-radius: 3px; }
.stat-list .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-list .value { font: 600 13px ui-monospace, Menlo, monospace; text-align: right; }
.stat-list .sub { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }

/* Tag editor */
.dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0;
  background: var(--surface); color: var(--text); width: min(680px, calc(100vw - 32px));
}
.dialog::backdrop { background: #00000066; }
.dialog form { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { margin: 0; font-size: 19px; }
.tag-rows { display: flex; flex-direction: column; gap: 8px; }
.tag-row { display: grid; grid-template-columns: 22px 44px minmax(0, 1fr) 130px 62px 72px; gap: 8px; align-items: center; }
.tag-row .pos { text-align: center; padding: 3px 0; }
.tag-head { font-size: 12px; color: var(--muted); }
.tag-row input[type="color"] { width: 44px; height: 38px; padding: 3px; cursor: pointer; }
.tag-row input.key { text-align: center; text-transform: uppercase; font-family: ui-monospace, Menlo, monospace; }
.tag-row .row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.tag-row .row-actions button { background: none; color: var(--muted); padding: 4px 8px; font-size: 16px; }
.tag-row .row-actions button:hover { color: var(--text); }
.tag-row .row-actions button.remove:hover { color: var(--danger); }
.add-tag { align-self: flex-start; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.dialog-actions .spacer { flex: 1; }
.help { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.help ul { padding-left: 18px; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.notes-pane {
  border-left: 1px solid var(--line); background: var(--surface);
  padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.notes-pane h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.notes-pane form { display: flex; flex-direction: column; gap: 8px; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg);
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start;
}
.notes li .ts { padding-top: 2px; }
.notes li p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.notes li button { background: none; color: var(--muted); padding: 0 4px; font-size: 18px; line-height: 1; }
.notes li button:hover { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); margin: 0; }

@media (max-width: 1180px) {
  .line { grid-template-columns: minmax(0, 1fr) minmax(170px, 240px); column-gap: 12px; }
}
@media (max-width: 600px) {
  .tag-row { grid-template-columns: 22px 44px minmax(0, 1fr) 62px 72px; }
  .tag-row select { grid-column: 3 / 4; }
  .tag-head { display: none; }
  .codebar .target { min-width: 0; width: 100%; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .transcript-pane { overflow: visible; padding-left: 20px; padding-right: 16px; }
  .seg { grid-template-columns: 72px minmax(0, 1fr); margin-left: -8px; }
  .line { grid-template-columns: minmax(0, 1fr); }
  .margin { padding: 0 0 6px 80px; min-height: 0; }
  .margin:not(.has-notes) .margin-add { display: none; }
  .line:hover .margin-add, .seg.selected + .margin .margin-add { display: inline-block; opacity: 1; }
  .volatile { padding-left: 80px; }
  .bar { padding: 10px 16px; gap: 10px; }
  .bar .meta { flex: 1 1 auto; }
  .notes-pane { border-left: 0; border-top: 1px solid var(--line); }
  .bar { flex-wrap: wrap; }
}

/* ---------- accounts & navigation ---------- */
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a[aria-current="page"] { color: var(--text); background: var(--bg); }
.who { font-size: 14px; color: var(--muted); align-self: center; }
.ghost-link {
  display: inline-flex; align-items: center; text-decoration: none; color: var(--text); font-size: 14px; font-weight: 500;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
}
.ghost-link:hover { background: var(--bg); }
.back { text-decoration: none; color: var(--muted); font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--text); }

.auth .card { display: flex; flex-direction: column; gap: 14px; }
.auth h1 { font-size: 24px; margin: 0; }
.auth .sub { margin: -8px 0 4px; }
.brand-mark { margin: 0; font-weight: 800; color: var(--accent); letter-spacing: -.01em; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
label input { font-weight: 400; }
.field-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
button.wide { width: 100%; padding: 11px; }
.switch { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }
.success { color: var(--live); font-weight: 600; margin: 0 0 10px; }

/* ---------- lesson explorer ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 32px 20px 64px; }
.page.narrow { max-width: 760px; }
.page h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.01em; }
.page .sub { margin: 0; color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head input[type="search"] { width: min(320px, 100%); }
.onboarding { margin-bottom: 24px; }
.onboarding h2, .section h2 { margin: 0 0 10px; font-size: 17px; }
.onboarding ol { margin: 0 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 10px; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.lesson-list > li { position: relative; }
.lesson-card {
  display: flex; flex-direction: column; gap: 8px; height: 100%; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 44px;
  transition: border-color .12s, box-shadow .12s;
}
.lesson-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 4px 16px #00000014; }
.lesson-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.lesson-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.badges { display: flex; gap: 6px; flex: none; }
.pill { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.lesson-meta { margin: 0; font-size: 13px; color: var(--muted); }
.stack.small { height: 8px; border-radius: 4px; }
.legend { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.card-actions { position: absolute; left: 16px; bottom: 10px; display: flex; gap: 14px; }
.link-btn { background: none; color: var(--muted); padding: 2px 0; font-weight: 500; font-size: 13px; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.link-btn.danger:hover { color: var(--danger); }

/* ---------- account ---------- */
.section { margin-top: 16px; }
.connect { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: center; }
.qr-box { min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px; }
.qr { width: 210px; height: 210px; background: #fff; border-radius: 8px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.pair-code { margin: 0; font-size: 12px; color: var(--muted); }
.pair-code kbd { font-size: 13px; letter-spacing: .08em; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.devices li:last-child { border-bottom: 0; }
.devices li div { display: flex; flex-direction: column; gap: 2px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; align-items: center; gap: 12px; }
input:disabled { color: var(--muted); }
@media (max-width: 640px) { .connect { grid-template-columns: 1fr; } .nav { display: none; } }

/* ---------- lesson page header & audio ---------- */
.lesson-title {
  margin: 0; font-size: 17px; font-weight: 700; min-width: 4ch; max-width: 46vw; padding: 2px 6px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent;
}
.lesson-title:hover { border-color: var(--line); }
.lesson-title:focus { outline: none; border-color: var(--line); background: var(--bg); text-overflow: clip; }
.lesson-title:empty::before { content: attr(data-placeholder); color: var(--muted); font-weight: 500; }
.subbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.subbar .code { font-size: 12px; color: var(--muted); }
.player { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.player audio { height: 34px; width: min(420px, 60vw); }
.player[hidden] { display: none; }
.follow { white-space: nowrap; flex-direction: row; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; color: var(--muted); }
.play-here {
  display: none; background: none; color: var(--accent); padding: 0; font-size: 11px; line-height: 1; width: fit-content;
}
body.has-audio .seg:hover .play-here { display: inline-block; }
.seg.playing { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.seg.playing .ts { color: var(--accent); font-weight: 700; }
@media (max-width: 860px) {
  body.app { display: block; height: auto; }
  .lesson-title { max-width: 60vw; }
  .player { margin-left: 0; width: 100%; }
  .player audio { width: 100%; }
}

/* ---------- new lesson + card dates ---------- */
.head-actions { display: flex; gap: 10px; align-items: center; }
.head-actions input[type="search"] { width: 280px; }
@media (max-width: 640px) { .head-actions { width: 100%; } .head-actions input[type="search"] { flex: 1; width: auto; } }
.head-actions button { white-space: nowrap; padding: 10px 16px; }
.lesson-when { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.lesson-when time { font-weight: 600; }
.lesson-name.untitled { color: var(--muted); font-weight: 600; }
.dialog label { margin-top: 4px; }

/* =====================================================================
   Redesign: top bar with account menu, dropdowns, icon actions,
   prominent lesson title.
   ===================================================================== */
.topbar {
  display: flex; align-items: center; gap: 20px; min-height: 58px; padding: 8px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar .brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; }
.logo {
  width: 24px; height: 24px; border-radius: 7px; position: relative; flex: none;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #8fd6c2));
}
.logo::before {
  content: ""; position: absolute; left: 8.5px; top: 5px; width: 7px; height: 10px;
  border-radius: 4px; background: #fff;
}
.logo::after {
  content: ""; position: absolute; left: 11px; top: 15px; width: 2px; height: 4px; background: #fff;
}
.topbar .nav a { font-size: 14px; }

/* account button + dropdown */
.user-slot { min-width: 40px; display: flex; justify-content: flex-end; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px;
  background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  font-weight: 600; font-size: 14px;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--bg); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev svg { width: 16px; height: 16px; display: block; color: var(--muted); transition: transform .15s; }
.user-btn[aria-expanded="true"] .chev svg { transform: rotate(180deg); }

.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute; top: calc(100% + 6px); z-index: 60; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 36px #0000002e, 0 2px 6px #0000001a;
}
.menu-right { right: 0; }
.menu-left { left: 0; }
.menu-header { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.menu-header b { font-size: 14px; }
.menu-header span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  background: none; border: 0; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg); outline: none; }
.menu-item.danger { color: var(--danger); }
.mi-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.menu-item.danger .mi-icon { color: currentColor; }
.mi-icon svg { width: 18px; height: 18px; }
.menu-divider { height: 1px; margin: 6px 4px; background: var(--line); }

/* icon buttons */
.icon-btn {
  width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 9px;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled), .icon-btn[aria-expanded="true"] { background: var(--bg); color: var(--text); border-color: var(--line); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.bordered { border-color: var(--line); color: var(--text); background: var(--surface); width: 38px; height: 38px; }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 9px; font-weight: 600;
}
.btn-secondary svg { width: 18px; height: 18px; }
.btn-secondary:hover { background: var(--bg); }

/* lesson cards */
.lesson-card { padding-bottom: 52px; }
.lesson-name { font-size: 18px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.lesson-name.untitled { font-weight: 700; }
.card-actions { left: auto; right: 10px; bottom: 9px; gap: 2px; align-items: center; }

/* lesson page header: the lesson name is the star */
.lesson-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 24px; align-items: start;
  padding: 16px clamp(16px, 3vw, 36px) 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .code { font-size: 12px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lesson-head .lesson-title {
  font-size: clamp(24px, 2.6vw, 32px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15;
  max-width: none; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere;
  margin: 0 0 0 -8px; padding: 2px 8px; border-radius: 8px;
}
.lesson-head .lesson-meta { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.lesson-head-actions { display: flex; gap: 8px; align-items: center; padding-top: 22px; }
.lesson-head .player { grid-column: 1 / -1; margin: 10px 0 0; gap: 14px; }
.lesson-head .player audio { width: min(560px, 100%); height: 36px; }

@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 8px 14px; }
  .user-name { display: none; }
  .topbar .nav { display: flex; }
  .lesson-head { grid-template-columns: 1fr; }
  .lesson-head-actions { padding-top: 4px; }
  .lesson-head-actions .btn-secondary span { display: none; }
}
.menu-header > div { display: flex; flex-direction: column; gap: 2px; }
.devices button { white-space: nowrap; flex: none; }

/* iPhone link + remote recording */
.badge.ready { color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, var(--line)); }
.badge.ready::before { background: var(--live); }
.btn-record {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px;
  background: var(--danger); color: #fff; border-radius: 9px; font-weight: 700;
}
.btn-record .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.btn-record.stop { background: var(--text); color: var(--surface); }
.btn-record.stop .rec-dot { border-radius: 2px; background: var(--surface); }
.btn-record:disabled { opacity: .6; }
.notice {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 24px #0004; transition: opacity .2s, transform .2s; z-index: 80; max-width: calc(100vw - 32px);
}
.notice.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- side panel: recording player ---------- */
.panel-player, .notes-index { display: flex; flex-direction: column; gap: 10px; }
.panel-player { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.notes-index { padding-top: 2px; }
.aplayer { display: flex; flex-direction: column; gap: 8px; }
.ap-controls { display: flex; align-items: center; gap: 10px; }
.ap-play {
  width: 46px; height: 46px; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); flex: none;
}
.ap-play svg { width: 22px; height: 22px; }
.ap-skip {
  display: inline-flex; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 8px;
  background: transparent; color: var(--text); border: 1px solid var(--line); font: 600 12px ui-monospace, Menlo, monospace;
}
.ap-skip svg { width: 18px; height: 18px; }
.ap-skip:hover { background: var(--bg); }
#apRate { width: auto; margin-left: auto; padding: 6px 8px; font-size: 13px; font-weight: 600; }
#apSeek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; padding: 0; border: 0;
  background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--line) var(--pct, 0%)); cursor: pointer;
}
#apSeek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
#apSeek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
#apSeek:focus { box-shadow: none; outline: 2px solid var(--focus); outline-offset: 4px; }
.ap-times { display: flex; justify-content: space-between; font: 12px ui-monospace, Menlo, monospace; color: var(--muted); }
.lesson-head-actions .btn-secondary .chev svg { width: 14px; height: 14px; color: var(--muted); }
.btn-record[hidden], .btn-secondary[hidden] { display: none; }
.follow input { width: auto; margin: 0; }
.aplayer .follow { justify-content: flex-start; }

/* ---------- AI assistant ---------- */
.panel-ai { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.ai-panel { display: flex; flex-direction: column; gap: 10px; }
.ai-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.ai-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.ai-overview { margin: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.ai-actions, .ai-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-btn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 14px; border-radius: 8px; }
.ai-btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.ai-btn:disabled { opacity: .7; }
.ai-select { flex: 1; min-width: 0; padding: 7px 8px; font-size: 14px; }
.practice { margin: 0; font-size: 12px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--text); }
.hint.warn { color: var(--warn); }
.hint.usage { font-size: 12px; margin: 0; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.score-mini .hint { margin: 0 0 6px; }
.score-mini ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.score-mini li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.score-mini .code, .ai-dialog .code { font: 600 11px ui-monospace, Menlo, monospace; color: var(--muted); }
.score-mini .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { min-width: 28px; text-align: center; font: 700 12px ui-monospace, Menlo, monospace; padding: 1px 6px; border-radius: 6px; border: 1px dashed var(--line); color: var(--muted); }
.lvl.ai { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent); }
.lvl.final { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }

.ai-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; }
.ai-dialog.rubric-dialog { width: min(760px, calc(100vw - 32px)); }
.ai-dialog-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ai-dialog-head h2 { margin: 0; font-size: 19px; }
.icon-close { background: none; color: var(--muted); font-size: 24px; line-height: 1; padding: 2px 8px; }
.icon-close:hover { color: var(--text); }
.ai-dialog-body { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 16px; font-size: 15px; }
.ai-dialog-body h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ai-dialog-body p { margin: 0; }
.ai-dialog-body ul, .ai-dialog-body ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.ai-disclaimer { font-size: 13px; color: var(--muted); padding: 8px 12px; border-radius: 8px; background: var(--bg); }
.time-link {
  background: none; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent);
  font: 600 11px ui-monospace, Menlo, monospace; padding: 1px 6px; border-radius: 6px; margin-right: 6px; vertical-align: 1px;
}
.time-link:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.domain { display: flex; flex-direction: column; gap: 10px; }
.component { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.comp-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.suggest { margin-left: auto; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.suggest.conf-low { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.suggest.none { background: var(--bg); color: var(--muted); }
.rationale { color: var(--text); font-size: 14px; }
.evidence { list-style: none; padding: 0 !important; }
.evidence li { font-size: 14px; }
.evidence q { font-style: italic; }
.decide { display: flex; align-items: flex-end; gap: 12px; }
.decide label { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.decide select { width: auto; padding: 6px 8px; }
.component textarea { font-size: 13px; resize: vertical; }
.ai-dialog-foot { display: flex; align-items: center; gap: 12px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.ai-dialog-foot .hint { margin-right: auto; }
.file-label { gap: 8px; }
.scale-edit { display: flex; flex-direction: column; gap: 6px; }
.scale-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; }
.domains-edit { display: flex; flex-direction: column; gap: 14px; }
.domains-edit section { display: flex; flex-direction: column; gap: 6px; }
.domain-name { font-weight: 700; }
.comp-edit { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.comp-edit summary { cursor: pointer; font-size: 14px; }
.comp-fields { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.comp-fields label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.comp-fields label.inline input { width: auto; }
.levels-edit { display: flex; flex-direction: column; gap: 8px; }
.levels-edit textarea { font-size: 13px; }
.link-btn.danger { color: var(--danger); }
.aplayer[hidden] { display: none; }

.or { text-align: center; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; display: flex; align-items: center; gap: 10px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* =====================================================================
   Lesson Summary page
   ===================================================================== */
.summary-body { background: var(--bg); }
.sum-page { max-width: 980px; margin: 0 auto; padding: 28px 20px 64px; display: flex; flex-direction: column; gap: 18px; }
.sum-hero { padding: 6px 0 8px; }
.sum-hero .kicker { margin: 10px 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.sum-hero h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; letter-spacing: -.025em; font-weight: 800; }
.sum-meta { margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.sum-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.sum-actions a.btn-secondary { text-decoration: none; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tile-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.tile-sub { font-size: 13px; color: var(--muted); }
.sum-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.sum-card h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sum-card p { margin: 0; }
.ai-tag { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 999px; padding: 2px 8px; }
.overview .lead { font-size: 19px; line-height: 1.55; letter-spacing: -.005em; }
.callout { background: var(--bg); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.stack.big { height: 14px; border-radius: 7px; }
.talk-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 14px; }
.talk-legend li { display: flex; align-items: center; gap: 8px; }
.talk-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.talk-legend span { color: var(--muted); }
a.time-link { text-decoration: none; display: inline-block; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 33px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 68px 1fr; gap: 14px; padding: 8px 0; position: relative; }
.timeline .tl-time { text-align: right; padding-top: 2px; position: relative; z-index: 1; }
.timeline .tl-time .time-link { background: var(--surface); margin: 0; }
.tl-body b { font-size: 16px; }
.tl-body p { color: var(--text); margin-top: 2px; }
.practice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.practice { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.practice .refs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; }
.moments-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.moments-list li { display: grid; grid-template-columns: 68px 1fr; gap: 12px; align-items: start; }
.moments-list li .time-link { justify-self: end; margin: 2px 0 0; }
.debrief { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 16px; }

.score-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.score-head h2 { color: var(--text); font-size: 20px; text-transform: none; letter-spacing: -.01em; }
.status-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.status-pill.ok { background: color-mix(in srgb, var(--live) 16%, transparent); color: var(--live); }
.overall { margin-top: 8px !important; color: var(--text); }
.avg { text-align: right; flex: none; }
.avg b { display: block; font-size: 40px; line-height: 1; font-weight: 800; letter-spacing: -.03em; }
.avg span { font-size: 13px; color: var(--muted); }
.scale-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.scale-legend span { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; color: var(--lc); background: color-mix(in srgb, var(--lc) 12%, transparent); }
.score-domain { display: flex; flex-direction: column; gap: 10px; }
.score-domain h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.score-comp { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.score-comp.muted { background: var(--bg); }
.sc-top { display: flex; justify-content: space-between; gap: 14px; align-items: center; flex-wrap: wrap; }
.sc-name { display: flex; gap: 8px; align-items: baseline; }
.sc-name b { font-size: 16px; }
.sc-score { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.levelbar { display: flex; gap: 3px; }
.levelbar span { width: 22px; height: 8px; border-radius: 4px; background: var(--line); }
.score-pill { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 8px; color: #fff; background: var(--lc); white-space: nowrap; }
.score-pill.suggested { background: transparent; color: var(--lc); border: 1.5px dashed var(--lc); }
.score-pill.na { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.sc-note { font-size: 12px; color: var(--muted); }
.score-comp .rationale { font-size: 15px; }
.score-comp .evidence { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.score-comp .evidence q { font-style: italic; }
.reviewer { font-size: 14px; padding: 8px 12px; background: var(--bg); border-radius: 8px; }
.sum-foot { font-size: 13px; color: var(--muted); text-align: center; padding-top: 6px; }
@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-head { flex-direction: column; }
  .avg { text-align: left; }
}
@media print {
  .summary-body { background: #fff; }
  .topbar, .sum-actions, .crumbs { display: none !important; }
  .sum-page { padding: 0; max-width: none; }
  .sum-card, .tile { break-inside: avoid; border-color: #ddd; }
  .score-comp { break-inside: avoid; }
  html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.summary-page-link { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.summary-page-link:hover { text-decoration: underline; }

.rubric-scope { margin: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); padding: 8px 10px; background: var(--bg); border-radius: 8px; }
.rubric-scope .instr { color: var(--text); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ai-dialog .rubric-scope .instr { -webkit-line-clamp: unset; display: block; }
.domain-row { display: flex; gap: 10px; align-items: center; }
.domain-row .domain-name { flex: 1; }
.domain-row label.include { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.domain-row label.include input { width: auto; }
.domains-edit section.off .comp-edit { opacity: .45; }
.domains-edit section.off .domain-name { color: var(--muted); text-decoration: line-through; }
label textarea, label select { font-weight: 400; }

/* ---------- side panel tabs ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.side-tabs { padding-top: 0; gap: 0; }
.tabbar {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  margin: 0 -20px 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabbar [role="tab"] {
  background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 6px; border-radius: 9px;
  border: 1px solid transparent; white-space: nowrap;
}
.tabbar [role="tab"]:hover { color: var(--text); background: var(--bg); }
.tabbar [role="tab"][aria-selected="true"] { color: var(--text); background: var(--bg); border-color: var(--line); box-shadow: 0 1px 2px #0000000f; }
.tabpanel { display: flex; flex-direction: column; gap: 16px; padding-bottom: 20px; }
.tabpanel[hidden] { display: none; }
.tabpanel > section:last-child { border-bottom: 0; padding-bottom: 0; }
.tabpanel .stats { padding-bottom: 16px; }
#panel-ai .panel-ai { border-bottom: 0; padding-bottom: 0; }

/* ---------- Help tab ---------- */
.help-panel { gap: 12px; }
.help-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.help-card h2 { margin: 0; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); }
.help-card p { margin: 0; font-size: 14px; }
.steps-list { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.steps-list li { counter-increment: step; display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.steps-list li::before {
  content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 800; font-size: 12px;
}
.tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.tips li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.tip-icon {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: var(--bg); color: var(--accent); border: 1px solid var(--line);
}
.help-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.help-tags li { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 8px; border-radius: 8px; background: color-mix(in srgb, var(--tag) 9%, transparent); }
.help-tags kbd { min-width: 22px; text-align: center; }
.help-tags .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tag); margin-left: 2px; }
.help-tags .kind { margin-left: auto; font-size: 12px; color: var(--muted); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; font-size: 14px; align-items: center; }
.keys dt { white-space: nowrap; font-size: 13px; color: var(--muted); }
.keys dd { margin: 0; }
.steps-list li { display: block; position: relative; padding-left: 34px; min-height: 24px; }
.steps-list li::before { position: absolute; left: 0; top: 0; }

/* ---------- record button ---------- */
.rec-btn {
  --rec: #d92d20;
  position: relative; display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 18px 0 14px;
  border-radius: 999px; font-weight: 700; font-size: 14px; letter-spacing: .01em; cursor: pointer;
  transition: background-color .2s, color .2s, box-shadow .2s, border-color .2s;
}
.rec-btn[hidden] { display: none; }
.rec-icon { width: 14px; height: 14px; border-radius: 50%; flex: none; transition: border-radius .2s, background-color .2s; }

/* ready: white with a red ring */
.rec-btn.ready { background: var(--surface); color: var(--text); border: 1.5px solid color-mix(in srgb, var(--rec) 55%, var(--line)); }
.rec-btn.ready .rec-icon { background: var(--rec); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--rec) 35%, transparent); }
.rec-btn.ready:hover { background: var(--rec); color: #fff; border-color: var(--rec); }
.rec-btn.ready:hover .rec-icon { background: #fff; box-shadow: 0 0 0 3px var(--rec), 0 0 0 5px #ffffff66; }

/* live: solid red, slow breathing glow, blinking dot */
.rec-btn.live { background: var(--rec); color: #fff; border: 1.5px solid var(--rec); animation: rec-breathe 2.4s ease-in-out infinite; min-width: 132px; }
.rec-btn.live .rec-icon { background: #fff; animation: rec-blink 1.2s ease-in-out infinite; }
.rec-btn.live .rec-label { letter-spacing: .14em; }
.rec-time { font: 700 14px ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; opacity: .95; }
.rec-hover { display: none; }
.rec-btn.live:hover { animation-play-state: paused; background: #b42318; }
.rec-btn.live:hover .rec-icon { border-radius: 3px; animation: none; }
.rec-btn.live:hover .rec-label, .rec-btn.live:hover .rec-time { display: none; }
.rec-btn.live:hover .rec-hover { display: inline; }
@keyframes rec-breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 55%, transparent); filter: brightness(1); }
  50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--rec) 0%, transparent); filter: brightness(1.08); }
}
@keyframes rec-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* starting / stopping */
.rec-btn.busy { background: var(--surface); color: var(--muted); border: 1.5px solid var(--line); cursor: default; }
.rec-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--rec) 45%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .rec-btn.live, .rec-btn.live .rec-icon { animation: none; }
}

.badge.rec { color: #d92d20; border-color: color-mix(in srgb, #d92d20 35%, var(--line)); }
.badge.rec::before { background: #d92d20; animation: rec-blink 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .badge.rec::before { animation: none; } }


/* =====================================================================
   Brand: AdminScribe green + white
   ===================================================================== */
.topbar {
  background: linear-gradient(100deg, var(--brand-darker) 0%, var(--brand-deep) 45%, var(--brand) 100%);
  border-bottom: 0; color: #fff; box-shadow: 0 1px 0 #00000014, 0 4px 14px #0b1f1922;
}
.topbar .brand { color: #fff; font-size: 17px; letter-spacing: -.015em; gap: 10px; }
.logo-img { width: 30px; height: 30px; border-radius: 8px; display: block; flex: none; box-shadow: 0 0 0 1px #ffffff2e; }
.topbar .nav a { color: #ffffffb8; }
.topbar .nav a:hover { color: #fff; background: #ffffff1a; }
.topbar .nav a[aria-current="page"] { color: #fff; background: #ffffff24; }
.topbar .user-btn { color: #fff; border-color: #ffffff3d; }
.topbar .user-btn:hover, .topbar .user-btn[aria-expanded="true"] { background: #ffffff1a; }
.topbar .avatar { background: #fff; color: var(--brand-deep); }
.topbar .chev svg { color: #ffffffb3; }
.topbar .menu { color: var(--text); }

/* ---------- sign in / create account ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 46%) 1fr; }
.auth-brand {
  position: relative; overflow: hidden; color: #fff; padding: 44px 52px; display: flex; flex-direction: column; gap: 40px;
  background: radial-gradient(120% 90% at 0% 0%, #3f7a69 0%, transparent 55%), linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 55%, var(--brand-darker) 100%);
}
.auth-brand::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px;
  background: url(/static/icon.svg) center / contain no-repeat; opacity: .07; border-radius: 90px; pointer-events: none;
}
.auth-logo { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.auth-logo img { border-radius: 14px; box-shadow: 0 0 0 1px #ffffff33, 0 8px 24px #0b1f1940; }
.auth-pitch { margin-top: auto; margin-bottom: auto; max-width: 460px; position: relative; z-index: 1; }
.auth-pitch h2 { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 800; }
.auth-pitch p { font-size: 17px; line-height: 1.5; color: #ffffffcc; margin: 0 0 26px; }
.auth-pitch ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 16px; }
.auth-pitch li { display: flex; gap: 12px; align-items: flex-start; }
.auth-pitch li span { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: #ffffff24; color: #fff; }
.auth-fine { margin: 0; font-size: 13px; color: #ffffff99; position: relative; z-index: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card {
  width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 34px 32px;
  box-shadow: 0 20px 50px #0b1f1914;
}
.auth-card h1 { font-size: 28px; margin: 0; letter-spacing: -.025em; }
.auth-card .sub { margin: -8px 0 6px; color: var(--muted); }
.auth-card button.wide { padding: 12px; font-size: 16px; margin-top: 4px; }
.auth-card .switch { margin: 4px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.auth-card .switch a { color: var(--accent); font-weight: 600; }
.missing-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 18px; }
.missing-brand img { border-radius: 10px; }
@media (max-width: 820px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 22px; gap: 18px; }
  .auth-pitch { margin: 0; }
  .auth-pitch h2 { font-size: 26px; }
  .auth-pitch p { font-size: 15px; margin-bottom: 14px; }
  .auth-pitch ul { display: none; }
  .auth-fine { display: none; }
  .auth-brand::after { width: 220px; height: 220px; right: -60px; bottom: -60px; }
  .auth-form { padding: 24px 16px 40px; align-items: flex-start; }
}

/* forgot / reset */
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.forgot-link { font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }
.sent-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.notice-ok { margin: -4px 0 4px; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--live) 12%, transparent); color: var(--text); }
.email-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.email-status .pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.email-status .pill.ok { background: color-mix(in srgb, var(--live) 14%, transparent); color: var(--live); }
.email-status .pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
