/* Clear Start Tax — Sales Training portal
   ---------------------------------------------------------------------------
   Design system adopted from Client Portal 2.0 (client-portal-v2/public/css/
   app.css): Inter type, 12/8/16px radii, soft two-layer card shadows, 44/48px
   controls with teal focus rings, pill badges.

   Brand palette (--teal #1BBDE8 / --teal-dark #0d8ab0 / --gold #C9A040) is the
   SAME set used by the Approvals (approvals.clearstarttax.com) and Finance
   portals, so this stays consistent with the rest of the internal tooling —
   it's the shapes + type that move to the newer client-portal language.
   =========================================================================== */

:root {
  /* Brand */
  --teal: #1BBDE8;
  --teal-dark: #0d8ab0;
  --gold: #C9A040;
  --gold-soft: #e8d39a;

  /* Neutrals */
  --ink: #1a2835;
  --ink-2: #2c3e50;
  --muted: #5c6f7e;
  --border: #e8edf2;
  --border-strong: #cdd6de;
  --bg: #f4f7fa;
  --card: #ffffff;

  /* Status */
  --success: #16a34a;
  --success-bg: #ecfdf5;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --info: #2563eb;
  --info-bg: #eff6ff;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(20, 30, 50, 0.04);
  --shadow-card: 0 1px 3px rgba(20, 30, 50, 0.04), 0 8px 24px rgba(20, 30, 50, 0.05);
  --shadow-modal: 0 4px 12px rgba(20, 30, 50, 0.08), 0 24px 48px rgba(20, 30, 50, 0.12);

  /* Type + shape */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Back-compat aliases (older markup references these) */
  --text: var(--ink);
  --border-soft: var(--border);
  --pass: var(--success);
  --amber: var(--warning);
  --fail: var(--error);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: none; }

/* ---- Top bar (call / results / legacy pages) ---- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-divider { width: 1px; height: 22px; background: var(--border); }
.topbar-tool { color: var(--muted); font-size: 12px; letter-spacing: .4px; text-transform: uppercase; font-weight: 600; }
.welcome { color: var(--muted); font-size: 14px; }
.nav-link { color: var(--teal-dark); font-size: 14px; font-weight: 500; padding: 6px 10px; border-radius: var(--radius-sm); }
.nav-link:hover { background: var(--bg); }

/* legacy top tabs (superseded by the sidebar) */
.nav-tabs { display: flex; align-items: center; gap: 4px; }
.nav-tab { font-size: 14px; font-weight: 500; color: var(--muted); padding: 8px 14px; border-radius: var(--radius-sm); }
.nav-tab:hover { color: var(--ink); background: var(--bg); }
.nav-tab.active { color: var(--ink); background: var(--bg); }

/* ---- Buttons ---- */
.btn, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  border: 1px solid transparent;
  background: var(--teal); color: #fff;
  cursor: pointer; transition: all .15s ease;
  min-height: 44px; white-space: nowrap;
}
.btn:hover, .btn-primary:hover { background: var(--teal-dark); }
.btn-secondary, .btn-ghost {
  background: #fff; color: var(--ink); border-color: var(--border-strong);
}
.btn-secondary:hover, .btn-ghost:hover { background: var(--bg); border-color: var(--ink); }
.btn-red, .btn-danger { background: var(--error); color: #fff; border-color: transparent; }
.btn-red:hover, .btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-large { padding: 15px 26px; font-size: 16px; min-height: 52px; }
.btn-sm { padding: 7px 14px; font-size: 13px; min-height: 36px; }
.signout-btn {
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--ink); padding: 8px 16px; font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; min-height: 38px;
}
.signout-btn:hover { background: var(--bg); border-color: var(--ink); }
.rowbtn {
  border: 1px solid var(--border-strong); background: #fff; color: var(--muted);
  border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.4;
}
.rowbtn:hover { border-color: var(--ink); color: var(--ink); background: var(--bg); }
.iconbtn {
  border: 1px solid var(--border-strong); background: #fff; color: var(--muted);
  border-radius: var(--radius-sm); width: 32px; height: 32px; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.iconbtn:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--bg); }
.iconbtn.danger:hover { border-color: var(--error); color: var(--error); }
.iconbtn:disabled { opacity: .35; cursor: default; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* `hidden` is only display:none in the browser's own stylesheet, so ANY rule
   here that sets display beats it and the element stays on screen. It bit the
   sign-in page (a stray "or" divider) and then the call page (a Start button
   under "Not assigned to you"). Say it once, for the whole app. */
[hidden] { display: none !important; }

/* ---- Forms ---- */
.field { margin-bottom: 18px; }
.field label, label, .label {
  display: block; font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 6px;
}
.field input, .field textarea, .field select,
input.inp, select.inp, textarea, input[type="text"], input[type="email"],
input[type="password"], input[type="number"] {
  width: 100%;
  font-family: inherit; font-size: 15px; color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  min-height: 46px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(27, 189, 232, 0.18);
}
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
input.inp.num { width: 72px; min-width: 72px; }
.field-help, .field-error { font-size: 13px; margin-top: 6px; }
.field-help { color: var(--muted); }
.field-error { color: var(--error); }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 220px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }
.subhead { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 24px 0 10px; }
.inline-add { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.inline-add select { flex: 1 1 auto; }

/* ---- Alerts ---- */
.login-error, .alert {
  padding: 13px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; margin-bottom: 16px; text-align: left;
}
.login-error, .alert-error { background: var(--error-bg); color: #7f1d1d; border-color: #fecaca; }
.alert-success { background: var(--success-bg); color: #064e3b; border-color: #a7f3d0; }
.alert-warning { background: var(--warning-bg); color: #78350f; border-color: #fde68a; }
.alert-info, .notice { background: var(--info-bg); color: #1e3a8a; border-color: #bfdbfe; }

/* ---- Badges / pills / tags ---- */
.badge, .tag, .chip, .status-pill, .seat-pill, .pill, .side-badge, .role-tag, .soft-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.badge.easy, .badge-success { background: var(--success-bg); color: #065f46; }
.badge.medium, .badge-warning { background: var(--warning-bg); color: #92400e; }
.badge.hard, .badge-error { background: var(--error-bg); color: #991b1b; }
.badge.soon, .badge-neutral, .tag, .chip, .role-tag, .soft-tag { background: var(--bg); color: var(--muted); }
.tag.custom { background: var(--info-bg); color: #1e40af; }
.chip.gold { background: #fdf6e3; color: #8a6d1f; }
.chip.silver { background: var(--bg); color: #63727e; }
.chip.bronze { background: #fbf0e6; color: #92582c; }
.status-pill.live { background: var(--success-bg); color: #065f46; }
.status-pill.design { background: var(--warning-bg); color: #92400e; }
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.seat-pill.full { background: var(--warning-bg); color: #92400e; }
.seat-pill.basic { background: var(--bg); color: #63727e; }
.pill.g { background: var(--success-bg); color: #065f46; }
.pill.a { background: var(--warning-bg); color: #92400e; }
.pill.r { background: var(--error-bg); color: #991b1b; }
.pill.m { background: var(--bg); color: var(--muted); }
.side-badge { background: var(--info-bg); color: #1e40af; font-size: 10px; padding: 2px 7px; }

/* ---- Login ---- */
.login-wrap { min-height: calc(100vh - 64px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 36px 36px 32px; box-shadow: var(--shadow-card); text-align: center;
}
.login-card h1 { font-size: 20px; font-weight: 600; margin: 12px 0 4px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-card .field { text-align: left; }

/* ==========================================================================
   Left-sidebar app shell
   ========================================================================== */
.app-body { background: var(--bg); }
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column;
}
.side-top { padding: 16px 18px 12px; display: flex; align-items: center; gap: 10px; }
.side-top .brand-logo { height: 28px; }
.side-search { margin: 0 14px 12px; position: relative; }
.side-search input {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; padding: 9px 12px 9px 34px; font-size: 14px; min-height: 40px;
}
.side-search .si { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }

.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.side-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: #93a2ad; margin: 18px 10px 6px;
}
.side-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: 14px; cursor: pointer; user-select: none;
}
.side-item:hover { background: var(--bg); color: var(--ink); }
.side-item.active { color: var(--teal-dark); background: var(--info-bg); font-weight: 600; }
.side-item .ic { width: 18px; height: 18px; flex-shrink: 0; }
.side-item .chev { margin-left: auto; width: 14px; height: 14px; transition: transform .15s; color: #aab6bf; }
.side-item.open .chev { transform: rotate(90deg); }
.side-item .side-badge { margin-left: auto; }
.side-sub { overflow: hidden; }
.side-subitem {
  display: block; padding: 8px 11px 8px 41px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
}
.side-subitem:hover { background: var(--bg); color: var(--ink); }
.side-subitem.active { color: var(--teal-dark); background: var(--info-bg); font-weight: 600; }

.side-bottom { border-top: 1px solid var(--border); padding: 12px 16px; }
.side-help { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.side-help .ic { width: 18px; height: 18px; flex-shrink: 0; }
.side-help:hover { color: var(--teal-dark); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mainbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.mainbar .crumb { font-size: 14px; color: var(--muted); font-weight: 500; }
.mainbar-right { display: flex; align-items: center; gap: 14px; }
.view { padding: 28px 32px 72px; max-width: 1160px; width: 100%; }

/* ---- View header ---- */
.vh { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.vh h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.vh .sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.page { max-width: 900px; margin: 0 auto; padding: 32px 24px 60px; }
.page h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.page .lead { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.sec-h { font-size: 17px; font-weight: 600; margin: 24px 0 2px; }
.panel > .sec-h:first-child { margin-top: 0; }
.sec-sub { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.stage-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 6px; }
.loading, .empty-hint { color: var(--muted); font-size: 14px; padding: 16px 0; }

/* ---- Welcome banner ---- */
.welcome-banner {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff;
  border-radius: var(--radius-lg); padding: 30px 28px; text-align: center; margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.welcome-banner .date { font-size: 13px; opacity: .9; font-weight: 500; }
.welcome-banner h1 { font-size: 27px; font-weight: 700; margin: 6px 0 0; color: #fff; letter-spacing: -.3px; }

/* ---- Cards / panels ---- */
.card, .panel, .form-card, .call-card, .prog-card, .scenario-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.panel { padding: 22px 24px; margin-bottom: 20px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-h h2 { font-size: 17px; font-weight: 600; margin: 0; }
.panel-h .link { font-size: 14px; font-weight: 500; color: var(--teal-dark); cursor: pointer; }
.form-card { padding: 26px 28px; margin-bottom: 22px; }
.form-card h2 { font-size: 18px; font-weight: 600; margin: 0 0 4px; }

/* ---- Stat tiles ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.stat-card .sc-ic {
  width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--info-bg);
  color: var(--teal-dark); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card .sc-num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-card .sc-lbl { font-size: 13px; color: var(--muted); margin-top: 3px; font-weight: 500; }

/* ---- Data tables ---- */
.dtable { width: 100%; border-collapse: collapse; }
.dtable th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; padding: 12px; border-bottom: 1px solid var(--border);
}
.dtable td { padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.dtable tr:last-child td { border-bottom: none; }
.dtable tr.clickable:hover td { background: var(--bg); cursor: pointer; }
.dtable .t-name { font-weight: 600; }
.avatar, .avatar-sm, .scn-av {
  border-radius: 50%; background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.scn-av { width: 46px; height: 46px; font-size: 15px; }
.avatar { width: 64px; height: 64px; font-size: 24px; margin: 4px auto 12px; }
.u-cell { display: flex; align-items: center; gap: 11px; }
.u-cell .u-name { font-weight: 600; }
.u-cell .u-email { font-size: 13px; color: var(--muted); }

/* ---- Scenario rows ---- */
.scn-row { display: flex; align-items: center; gap: 15px; padding: 16px 4px; border-bottom: 1px solid var(--border); }
.scn-row:last-child { border-bottom: none; }
.scn-body { flex: 1; min-width: 0; }
.scn-title { font-size: 15px; font-weight: 600; }
.scn-desc { font-size: 13.5px; color: var(--muted); margin: 3px 0 8px; }
.scn-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.medal-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.medal-dot { width: 10px; height: 10px; border-radius: 50%; }
.medal-dot.gold { background: var(--gold); } .medal-dot.silver { background: #9aa7b0; } .medal-dot.bronze { background: #b87333; }

/* ---- Mini rows (home) ---- */
.mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.mini-row:hover { border-color: var(--border-strong); }
.mini-row .mr-name { font-weight: 600; font-size: 14px; }
.mini-row .mr-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.mini-count { display: inline-flex; align-items: center; gap: 4px; }

/* ---- Program cards / steps ---- */
.prog-card { padding: 20px 22px; margin-bottom: 16px; }
.prog-card .prog-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.prog-card .name { font-size: 16px; font-weight: 600; }
.prog-card .desc { font-size: 14px; color: var(--muted); margin-top: 2px; }
.prog-card .prog-meta { font-size: 13px; color: var(--muted); margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.prog-steps { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.prog-step { display: flex; align-items: center; gap: 11px; font-size: 14px; padding: 7px 0; }
.prog-step .num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--bg);
  color: var(--muted); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.prog-step .s-name { font-weight: 600; }
.prog-step .s-crit { color: var(--muted); font-size: 13px; }

/* ---- Builder item rows ---- */
.item-row {
  display: flex; align-items: center; gap: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px;
  flex-wrap: wrap;
}
.item-row .grip { color: #aab6bf; font-size: 13px; flex-shrink: 0; }
.item-row .i-name { flex: 1 1 180px; min-width: 140px; font-weight: 600; font-size: 14px; line-height: 1.35; }
.item-row .i-name small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 1px; }
.item-row .ctl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.item-row .inp { min-height: 38px; padding: 7px 10px; font-size: 14px; }
.item-row .ctl select.inp { width: 92px; padding: 7px 8px; }
.item-row .inp.num { width: 58px; min-width: 58px; padding: 7px 8px; text-align: center; }
.item-row .iconbtn { width: 30px; height: 30px; }
.assign-grid { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.assign-item { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.assign-item input { width: 18px; height: 18px; min-height: 0; }

/* ---- Settings two-column ---- */
.settings-layout { display: flex; align-items: flex-start; }
.subnav { width: 214px; flex-shrink: 0; padding-right: 18px; border-right: 1px solid var(--border); }
.subnav .side-section-label { margin-left: 11px; }
.subnav-content { flex: 1; min-width: 0; padding-left: 26px; }

/* ---- Empty / coming-soon ---- */
.section-empty {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 48px 28px; text-align: center; color: var(--muted);
}
.section-empty .se-ic { width: 44px; height: 44px; margin: 0 auto 14px; color: #b7c2cb; }
.section-empty h3 { font-size: 17px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.section-empty p { font-size: 14px; margin: 0 auto; max-width: 440px; }

/* ---- Scenario grid (legacy pages) ---- */
.scenario-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.scenario-card { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.scenario-card .name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.scenario-card .desc { font-size: 14px; color: var(--muted); }
.scenario-card .actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.scenario-card.locked { opacity: .6; }

/* ==========================================================================
   Call page
   ========================================================================== */
.call-page { max-width: 580px; }
.call-card { padding: 30px; text-align: center; }
.cname { font-size: 19px; font-weight: 600; }
.crole { font-size: 14px; color: var(--muted); margin-top: 3px; }
.call-hint { font-size: 14px; color: var(--muted); margin: 16px 0; }
.ontag {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--bg); padding: 5px 14px; border-radius: 999px; margin-bottom: 14px;
}
.ontag.on { color: var(--success); background: var(--success-bg); }
.ontag.speaking { color: var(--teal-dark); background: var(--info-bg); }
.timer { font-size: 14px; color: var(--muted); margin: 8px 0 14px; font-variant-numeric: tabular-nums; }
.transcript {
  text-align: left; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 14px; line-height: 1.6; max-height: 320px; overflow-y: auto; margin-bottom: 18px;
  /* Never scroll sideways. The transcript is prose; if a single token is ever
     long enough to overflow (an unspaced TTS turn did exactly that), break it
     rather than pushing the whole panel out to a horizontal scrollbar. */
  overflow-x: hidden; overflow-wrap: anywhere;
}
.recording-player { width: 100%; margin: 0 0 16px; height: 40px; }
.transcript-full { max-height: 460px; background: #fff; border-color: var(--border); }
.transcript-full .tline { padding: 7px 0; border-bottom: 1px solid var(--border); }
.transcript-full .tline:last-child { border-bottom: none; }
.tline { margin-bottom: 8px; }
.tline .who { color: var(--teal-dark); font-weight: 600; }
.tline .who.me { color: var(--gold); }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--teal);
  border-radius: 50%; margin: 8px auto 16px; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Results page
   ========================================================================== */
.results-page { max-width: 660px; }
.medal-block { text-align: center; margin: 6px 0 26px; }
.medal-circle {
  width: 66px; height: 66px; border-radius: 50%; margin: 0 auto 10px;
  color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-card);
}
.medal-rank { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.medal-sub { font-size: 14px; color: var(--muted); margin-top: 6px; max-width: 540px; margin-left: auto; margin-right: auto; }
.gate-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.gate-row:last-child { border-bottom: none; }

/* Collapsible scorecard rows. A <details> can't be a flex container and still
   show/hide its own content, so the flex row moves onto the <summary> and the
   element itself goes back to block. */
details.gate-row { display: block; padding: 0; }
details.gate-row > summary {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 0; cursor: pointer; list-style: none;
}
/* Safari/Chrome draw their own triangle; we supply a chevron instead. */
details.gate-row > summary::-webkit-details-marker { display: none; }
details.gate-row > summary::marker { content: ""; }
details.gate-row > summary:hover .gate-title { color: var(--teal-dark); }
details.gate-row > summary .gate-title { flex: 1; }
details.gate-row .gate-reason { padding: 0 0 13px 34px; margin-top: 0; }
.chev {
  flex: none; width: 9px; height: 9px; margin-right: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .15s ease;
}
details.gate-row[open] > summary .chev { transform: rotate(-135deg) translate(-2px, -2px); }

/* Section header with an action on the right (e.g. "Expand all"). */
.sec-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.sec-head .sec-sub { margin-bottom: 0; }
.link-btn {
  appearance: none; background: none; border: 0; padding: 4px 2px; flex: none;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.link-btn:hover { color: var(--teal-dark); }

/* Results page Analysis / Recording tabs — same visual language as the
   script-reference tabs on the call page. */
.res-tabs {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
  margin: 18px 0 -4px;
}

/* ==========================================================================
   Call player + timestamped transcript
   ========================================================================== */
.player-panel { padding: 16px 18px; }
.player { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.pbtn {
  appearance: none; border: 1px solid var(--border); background: #fff;
  color: var(--teal-dark); font-family: inherit; font-size: 13px; font-weight: 600;
  width: 38px; height: 38px; flex: none; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
.pbtn:hover { border-color: var(--teal); background: var(--info-bg); }
.pbtn-main {
  width: 46px; height: 46px; background: var(--teal); border-color: var(--teal);
  color: #fff;
}
.pbtn-main:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.pbtn-rate { width: auto; padding: 0 12px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.pskip { font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 1px; }
.parr { font-size: 13px; line-height: 1; }

/* Play triangle that becomes a pause bar pair, so the button never reflows. */
.tri {
  width: 0; height: 0; margin-left: 3px;
  border-left: 13px solid currentColor;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
}
.tri.is-pause {
  width: 12px; height: 15px; margin-left: 0; border: 0;
  border-left: 4px solid currentColor; border-right: 4px solid currentColor;
  box-sizing: border-box;
}

.seek-wrap { flex: 1 1 260px; min-width: 200px; position: relative; padding-top: 16px; }
.seek {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 5px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(to right, var(--teal) 0 var(--pct, 0%),
                              var(--border) var(--pct, 0%) 100%);
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--teal); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
}
.seek::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--teal);
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer;
}
.seek-times {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
/* Graded moments, pinned above the bar so they never steal its drag. */
.seek-marks { position: absolute; left: 0; right: 0; top: 0; height: 16px; }
.seek-mark {
  position: absolute; transform: translateX(-50%);
  appearance: none; padding: 0; cursor: pointer;
  width: 15px; height: 15px; border-radius: 4px; line-height: 13px;
  font-size: 9px; font-weight: 700; color: #fff;
  /* Gates cluster in the busy parts of a call, so two ticks often land within
     a few pixels. The ring keeps neighbours legible as separate marks instead
     of reading as one long smear. */
  border: 1px solid #fff;
}
.seek-mark.g { background: var(--success); }
.seek-mark.r { background: var(--error); }
.seek-mark.m { background: #c2cdd6; }
.seek-mark:hover { outline: 2px solid var(--border-strong); outline-offset: 1px; }

/* Transcript header: accuracy note on the left, the … menu on the right. */
.tx-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tx-note {
  flex: 1; margin: 0 0 6px; padding: 8px 12px; font-size: 12.5px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tx-menu-wrap { position: relative; flex: none; }
.pbtn-dots { width: 34px; height: 34px; font-size: 18px; line-height: 1; color: var(--muted); }
.tx-menu {
  position: absolute; right: 0; top: 38px; z-index: 20; min-width: 208px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card); padding: 5px; text-align: left;
}
.tx-menu button {
  display: block; width: 100%; text-align: left; appearance: none; border: 0;
  background: none; font-family: inherit; font-size: 13.5px; color: var(--ink);
  padding: 9px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.tx-menu button:hover { background: var(--bg); color: var(--teal-dark); }

/* One transcript line: avatar + name + clickable timestamp, then the text. */
.tline-ts {
  padding: 10px 10px; border-radius: var(--radius-sm); cursor: pointer;
  border-bottom: 1px solid var(--border); margin-bottom: 0;
}
.tline-ts:last-child { border-bottom: none; }
.tline-ts:hover { background: var(--bg); }
.tline-ts.is-now { background: var(--info-bg); }
.tline-ts.is-now .tl-text { color: var(--ink); }
.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.tl-av {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--teal); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tl-av.me { background: var(--gold); }
.tl-at {
  appearance: none; border: 0; background: none; padding: 2px 4px; cursor: pointer;
  font-family: inherit; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px;
}
.tl-at:hover { color: var(--teal-dark); }
.tl-tri {
  width: 0; height: 0; border-left: 6px solid currentColor;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.tl-text { font-size: 14px; line-height: 1.55; }

@media (max-width: 560px) {
  .player { gap: 8px; }
  .seek-wrap { flex-basis: 100%; }
}
.gate-mark {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; color: #fff; margin-top: 1px;
}
.gate-mark.g { background: var(--success); } .gate-mark.r { background: var(--error); } .gate-mark.m { background: #c2cdd6; }
.gate-body { min-width: 0; }
.gate-title { font-size: 14px; font-weight: 600; }
.gate-reason { font-size: 13px; color: var(--muted); margin-top: 3px; }
.coach {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; font-size: 14px; line-height: 1.65; margin-top: 18px;
}
.row2 { display: flex; gap: 10px; }
.row2 .btn { flex: 1; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-modal);
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60;
}
.toast.show { opacity: 1; }

/* ---- Utility ---- */
.muted { color: var(--muted); }
.center { text-align: center; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .side-workspace, .side-search, .side-item span, .side-section-label, .side-badge, .side-help span { display: none; }
  .side-item { justify-content: center; }
  .side-sub { display: none !important; }
  .view { padding: 20px 18px 60px; }
  .settings-layout { flex-direction: column; }
  .subnav { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 12px; }
  .subnav-content { padding-left: 0; padding-top: 18px; }
  .stat-row { grid-template-columns: 1fr; }
  .mainbar { padding: 0 18px; }
}

/* ── Script reference on the call page ──────────────────────────────────
   The call card is narrow by design, which left the rest of the viewport
   empty during a 30-minute roleplay. That space now carries the actual
   scripts — the Google Docs, exported and shown in an iframe so each keeps
   its own formatting instead of us maintaining a second copy. */
.call-page.with-ref { max-width: 1180px; }

.ref {
  margin-top: 20px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-card);
  text-align: left; overflow: hidden;
}
.ref-tabs {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.ref-tab {
  appearance: none; border: 1px solid transparent; background: transparent;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted);
  padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer;
}
.ref-tab:hover { color: var(--ink); background: #fff; }
.ref-tab[aria-selected="true"] {
  color: var(--teal-dark); background: #fff; border-color: var(--border-strong);
}
.ref-open { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ref-open:hover { color: var(--teal-dark); }

/* One frame per script, stacked on top of each other. The inactive ones are
   hidden with `visibility`, NOT `display:none` — display:none pulls the frame
   out of layout, and the browser resets the document's scroll when it comes
   back, which is exactly the "it forgot where I was" bug. visibility keeps
   each frame laid out, so every script holds its own place. */
.ref-stack { position: relative; height: 68vh; background: #fff; }
.ref-frame {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; background: #fff;
  visibility: hidden; z-index: 0;
}
.ref-frame.is-active { visibility: visible; z-index: 1; }

@media (max-width: 900px) {
  .call-page.with-ref { max-width: 620px; }
  .ref-stack { height: 75vh; }
}
