:root {
  --navy: #0a3d62;
  --navy-2: #0c4a78;
  --navy-deep: #072a44;
  --red: #c0392b;
  --gold: #d4a017;
  --ink: #1a2330;
  --muted: #5b6770;
  --line: #e2e8f0;
  --bg: #f4f6f9;
  --card: #ffffff;
  --green: #2e7d32;
  --shadow: 0 1px 3px rgba(10,61,98,.08), 0 6px 24px rgba(10,61,98,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-2); }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; flex: 0 0 252px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #cfe0f0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 0;
}
.brand { padding: 20px 22px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand .logo { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: .5px; }
.brand .logo span { color: var(--gold); }
.brand .tag { font-size: 12px; color: #9fbcd6; margin-top: 3px; }
.nav { padding: 10px 0; overflow-y: auto; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: none; border: none; color: #cfe0f0; padding: 11px 22px;
  font-size: 14.5px; cursor: pointer; font-family: inherit; border-left: 3px solid transparent;
}
.nav button .ic { width: 20px; text-align: center; font-size: 16px; opacity: .9; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--gold); font-weight: 600; }
.sidebar .foot { padding: 14px 22px; font-size: 11.5px; color: #7fa0bd; border-top: 1px solid rgba(255,255,255,.1); }

.main { flex: 1; min-width: 0; padding: 0 0 60px; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 16px 34px; position: sticky; top: 0; z-index: 20;
  display: flex; align-items: baseline; gap: 14px;
}
.topbar h1 { margin: 0; font-size: 20px; color: var(--navy); }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.wrap { padding: 26px 34px; max-width: 1080px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.card .hd { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card .hd h2 { margin: 0; font-size: 16.5px; color: var(--navy); }
.card .hd .sub { font-size: 12.5px; color: var(--muted); }
.card .bd { padding: 18px 20px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px){ .g2,.g3,.g4 { grid-template-columns: 1fr; } }

/* mobile menu button + scrim (hidden on desktop) */
.menu-btn { display: none; background: none; border: none; font-size: 23px; line-height: 1; cursor: pointer; color: var(--navy); padding: 2px 6px; margin: -2px 2px -2px -4px; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(7,42,68,.5); z-index: 40; }
.scrim.open { display: block; }

/* hero */
.hero {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 60%, #105a8c 100%);
  color: #fff; border-radius: 14px; padding: 26px 28px; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.hero h2 { margin: 0 0 4px; font-size: 24px; }
.hero p { margin: 0; color: #d4e4f3; max-width: 720px; }
.hero .chips { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  padding: 6px 13px; border-radius: 999px; font-size: 13px;
}
.chip b { color: var(--gold); }

/* stat tiles */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 26px; font-weight: 800; color: var(--navy); margin-top: 3px; }
.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* quick links */
.qlinks { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
@media (max-width:860px){ .qlinks{grid-template-columns:1fr;} }
.ql { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; box-shadow: var(--shadow); font-family: inherit; transition: transform .12s, border-color .12s; }
.ql:hover { transform: translateY(-2px); border-color: var(--navy-2); }
.ql .t { font-weight: 700; color: var(--navy); font-size: 15px; }
.ql .ic { font-size: 22px; }
.ql .x { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f1f5fa; color: var(--navy); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hl { background: #fff8e6; }

/* pills / tags */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.tag.r { background: #fde8e6; color: var(--red); }
.tag.b { background: #e6f0fa; color: var(--navy-2); }
.tag.g { background: #e6f4ea; color: var(--green); }
.tag.y { background: #fdf3da; color: #9a7314; }

/* script beats */
.beat { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.beat > summary { cursor: pointer; padding: 13px 16px; background: #f7fafc; font-weight: 700; color: var(--navy); list-style: none; display: flex; align-items: center; gap: 12px; }
.beat > summary::-webkit-details-marker { display:none; }
.beat > summary .n { background: var(--navy); color: #fff; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: 0 0 26px; }
.beat > summary .lbl { flex:1; }
.beat > summary .tech { font-weight: 500; font-size: 12px; color: var(--muted); }
.beat[open] > summary { border-bottom: 1px solid var(--line); }
.beat .inner { padding: 14px 18px; }
.line { background: #fff; border-left: 3px solid var(--gold); padding: 8px 14px; margin: 8px 0; border-radius: 0 6px 6px 0; font-size: 14.5px; }
.line.say { font-style: normal; }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.note b { color: var(--ink); }

/* checklist */
.chk { list-style: none; padding: 0; margin: 0; }
.chk li { display: flex; gap: 11px; padding: 8px 4px; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.chk li:last-child { border-bottom: none; }
.chk input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--navy); flex: 0 0 auto; cursor: pointer; }
.chk label { cursor: pointer; font-size: 14px; }
.chk li.done label { color: var(--muted); text-decoration: line-through; }
.weekhd { display:flex; align-items:center; gap:10px; }
.weekhd .bar { flex:1; height:7px; background:var(--line); border-radius:999px; overflow:hidden; }
.weekhd .bar i { display:block; height:100%; background:var(--green); width:0; transition: width .3s; }
.weekhd .pct { font-size:12px; color:var(--muted); width:42px; text-align:right; }

/* callouts */
.callout { border-radius: 10px; padding: 13px 16px; font-size: 14px; margin: 14px 0; border: 1px solid; }
.callout.warn { background: #fff8e6; border-color: #f0d98c; }
.callout.info { background: #eef5fb; border-color: #cfe0f0; }
.callout.do { background: #e9f6ec; border-color: #b6dfc0; }
.callout.dont { background: #fdeceb; border-color: #f1bcb6; }
.callout b { color: var(--navy); }

/* coach */
.coach-setup { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.coach-setup .field { flex: 1 1 180px; min-width: 150px; }
.coach-setup .btn { flex: 0 0 auto; }
@media (max-width:860px){ .coach-setup .field { flex: 1 1 100%; } .coach-setup .btn { width: 100%; } }
.field label { display:block; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; margin-bottom:5px; font-weight:600; }
select, .btn, textarea, input[type=text] { font-family: inherit; font-size: 14.5px; }
select { width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:9px; background:#fff; color:var(--ink); }
.btn { background: var(--navy); color:#fff; border:none; padding:11px 18px; border-radius:9px; cursor:pointer; font-weight:600; }
.btn:hover { background: var(--navy-2); }
.btn.ghost { background:#fff; color:var(--navy); border:1px solid var(--navy); }
.btn.ghost:hover { background:#eef5fb; }
.btn.gold { background: var(--gold); color:#3a2c00; }
.btn.red { background: var(--red); color:#fff; }
.btn.red:hover { background: #a93226; }
.btn:disabled { opacity:.5; cursor:not-allowed; }

/* Account for the sticky topbar so scrollIntoView does not hide the scenario header. */
#c-stage { scroll-margin-top: 70px; }
.chatwin { background:#f7fafc; border:1px solid var(--line); border-radius:12px; padding:16px; height:46vh; height:46dvh; min-height:320px; overflow-y:auto; }

/* live beat tracker (pills above the chat) */
.beats-track { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:10px; }
.beats-track:empty { display:none; }
.bt-pill { width:24px; height:24px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; background:#eef2f7; color:var(--muted); border:1px solid var(--line); }
.bt-pill.on { background:var(--green); color:#fff; border-color:var(--green); }
.bt-pill.next { background:#fff; color:var(--navy); border:2px solid var(--gold); }
.bt-cap { font-size:12px; color:var(--muted); margin-left:6px; }

/* history trend / readiness / weak-spots banner */
#c-history-trend:empty { display:none; }
#c-history-trend { margin-bottom:12px; }
.trend-row, .ready-row, .weak-row { display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-size:13px; color:var(--ink); margin:4px 0; }
.trend-cap, .ready-row { color:var(--muted); }
.spark { display:block; }
.weak { display:inline-flex; align-items:center; gap:6px; background:#fdf3da; border:1px solid #f0d98c; border-radius:999px; padding:3px 8px 3px 12px; font-size:12.5px; }
.btn.mini { padding:4px 10px; font-size:12px; border-radius:7px; }
.hist-transcript { margin-top:10px; border-top:1px dashed var(--line); padding-top:8px; }
.hist-transcript > summary { cursor:pointer; font-size:13px; color:var(--navy-2); list-style:none; }
.hist-transcript > summary::-webkit-details-marker { display:none; }
.hist-convo { margin-top:8px; max-height:300px; overflow-y:auto; }
.hist-convo .msg .bub { max-width:86%; font-size:13.5px; }
.msg { display:flex; margin-bottom:12px; }
.msg .bub { max-width:74%; padding:10px 14px; border-radius:14px; font-size:14.5px; line-height:1.5; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.msg.owner { justify-content:flex-start; }
.msg.owner .bub { background:#fff; border:1px solid var(--line); border-bottom-left-radius:4px; }
.msg.rep { justify-content:flex-end; }
.msg.rep .bub { background:var(--navy); color:#fff; border-bottom-right-radius:4px; }
.msg .who { font-size:11px; opacity:.7; margin-bottom:2px; }
.typing { color:var(--muted); font-style:italic; font-size:13.5px; padding:4px 6px; }
.composer { display:flex; gap:10px; margin-top:14px; }
.composer textarea { flex:1; resize:none; padding:11px 13px; border:1px solid var(--line); border-radius:10px; min-height:46px; max-height:120px; }
.coach-actions { display:flex; gap:10px; margin-top:12px; flex-wrap:wrap; }
.scorebox { margin-top:16px; }
.scorebox .bd { font-size:14px; }
.scorebox h2 { font-size:16px; color:var(--navy); margin:14px 0 6px; }
.scorebox h2:first-child { margin-top:0; }
.scorebox ul { margin:6px 0; padding-left:20px; }
.scorebox li { margin:3px 0; }
.hintbar { background:#fdf3da; border:1px solid #f0d98c; border-radius:8px; padding:8px 12px; font-size:13px; margin-bottom:10px; display:none; }
.hintbar.on { display:block; }

/* voice */
.vtog { display:flex; gap:6px; align-items:center; cursor:pointer; white-space:nowrap; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192,57,43,.45); }
  70% { box-shadow: 0 0 0 12px rgba(192,57,43,0); }
  100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); }
}
.micstate { font-size:14px; color:var(--muted); min-height:18px; font-weight:600; }
.micstate.live { color:var(--red); }
.micstate.think { color:var(--navy-2); }
.micstate.speak { color:var(--green); }
.micstate.warn { color:#9a7314; }

/* hands-free live status bar */
.livebar {
  margin-top:14px; background:#f7fafc; border:1px solid var(--line);
  border-radius:12px; padding:12px 16px;
}
.livehead { display:flex; align-items:center; gap:11px; }
.livedot {
  width:13px; height:13px; border-radius:50%; flex:0 0 13px;
  background:var(--muted); transition: background .2s;
}
.livedot.live { background:var(--red); animation: pulse 1.3s infinite; }
.livedot.think { background:var(--navy-2); }
.livedot.speak { background:var(--green); animation: pulse 1.3s infinite; }
.livedot.warn { background:var(--gold); }
.liveinterim {
  margin-top:8px; font-size:15px; color:var(--ink); min-height:20px;
  font-style:italic; word-break:break-word;
}
.liveinterim:empty { display:none; }

/* typing fallback */
.typefall { margin-top:12px; }
.typefall > summary {
  cursor:pointer; font-size:13px; color:var(--muted); list-style:none;
  padding:4px 2px; user-select:none;
}
.typefall > summary::-webkit-details-marker { display:none; }
.typefall > summary:hover { color:var(--navy-2); }
.typefall .composer { margin-top:10px; }
.securewarn {
  background:#fff4e6; border:1px solid #f0c98c; border-radius:12px; padding:16px 18px;
  margin-bottom:20px; box-shadow:var(--shadow); font-size:14px;
}
.securewarn a { display:inline-block; margin-top:8px; font-weight:700; color:var(--navy-2); }
.msg.speaking .bub { box-shadow:0 0 0 2px var(--green); }

.kv { display:grid; grid-template-columns: 150px 1fr; gap:6px 14px; font-size:14px; }
.kv dt { color:var(--muted); }
.kv dd { margin:0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.reslist { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width:860px){ .reslist{grid-template-columns:1fr;} }
.resitem { display:flex; align-items:center; gap:10px; padding:11px 14px; border:1px solid var(--line); border-radius:10px; background:#fff; text-decoration:none; color:var(--ink); }
.resitem:hover { border-color:var(--navy-2); }
.resitem .ic { font-size:20px; }
.resitem .t { font-weight:600; color:var(--navy); font-size:14px; }
.resitem .x { font-size:12px; color:var(--muted); }

/* session history */
#c-history-stats { font-size: 12.5px; color: var(--muted); }
.hist { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.hist > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #f7fafc; }
.hist > summary::-webkit-details-marker { display: none; }
.hist > summary:hover { background: #eef4fa; }
.hist-date { font-weight: 700; color: var(--navy); min-width: 116px; font-size: 13.5px; }
.hist-scn { flex: 1; color: var(--ink); font-size: 14px; }
.hist-scn .vc { color: var(--muted); }
.hist-score { font-weight: 800; border-radius: 999px; padding: 3px 12px; font-size: 13px; flex: 0 0 auto; }
.sc-good { background: #e6f4ea; color: var(--green); }
.sc-mid  { background: #fdf3da; color: #9a7314; }
.sc-low  { background: #fde8e6; color: var(--red); }
.hist[open] > summary { border-bottom: 1px solid var(--line); }
.hist-body { padding: 4px 16px 14px; font-size: 14px; }
.hist-body h2 { font-size: 15px; color: var(--navy); margin: 13px 0 6px; }
.hist-body h2:first-child { margin-top: 8px; }
.hist-body ul { margin: 6px 0; padding-left: 20px; }
.hist-body li { margin: 3px 0; }
.hist-empty { color: var(--muted); font-size: 14px; }
@media (max-width: 860px) { .hist > summary { flex-wrap: wrap; } .hist-date { min-width: 0; } }

/* ===================== MOBILE ===================== */
@media (max-width: 860px) {
  /* sidebar becomes a slide-in drawer */
  .app { display: block; }
  .sidebar {
    position: fixed; right: 0; left: auto; top: 0; height: 100%; z-index: 50;
    width: 82%; max-width: 300px; flex: none;
    transform: translateX(100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .nav button { padding: 14px 22px; font-size: 16px; }   /* bigger tap targets */
  .topbar .menu-btn { order: 3; margin-left: auto; margin-right: 0; }   /* hamburger on the right */

  .main { padding-bottom: 40px; }
  .topbar { padding: 11px 14px; gap: 10px; }
  .topbar h1 { font-size: 18px; }
  .topbar .crumb { display: none; }                       /* save space on small screens */
  .menu-btn { display: inline-block; }
  .wrap { padding: 16px 14px; }

  body { font-size: 15px; }
  .hero { padding: 20px 18px; border-radius: 12px; }
  .hero h2 { font-size: 21px; }
  .card .bd { padding: 15px 15px; }
  .qlinks { grid-template-columns: 1fr; }

  /* wide tables scroll horizontally inside their card instead of breaking layout */
  .card .bd { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 460px; font-size: 13.5px; }
  th, td { padding: 8px 10px; }

  /* coach: smaller chat on phones so the composer is never pushed under the keyboard */
  .chatwin { height: 42vh; height: 42dvh; min-height: 240px; }
  .coach-actions { gap: 8px; }
  .coach-actions .btn { flex: 1 1 auto; }
  .subtabs { gap: 6px; }
  .subtab { padding: 8px 13px; font-size: 13px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-weight: 700; color: var(--navy); }
  .hist-date { min-width: 0; }
}

/* tap-to-talk button (mobile / no SpeechRecognition voice path) */
.talkrow { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 14px 0 4px; }
.talkbtn {
  display: inline-flex; align-items: center; gap: 12px; border: none; cursor: pointer;
  background: var(--navy); color: #fff; padding: 16px 30px; border-radius: 999px;
  font-family: inherit; font-size: 17px; font-weight: 700; box-shadow: var(--shadow);
}
.talkbtn:hover { background: var(--navy-2); }
.talkbtn:disabled { opacity: .5; }
.talkbtn .tk-ic { font-size: 22px; }
.talkbtn.rec { background: var(--red); animation: pulse 1.3s infinite; }
.talkhint { font-size: 12.5px; color: var(--muted); text-align: center; }
