:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1b1d22; --muted: #6a6f7a; --line: #e4e2dc;
  --accent: #1f4fd6; --accent-ink: #ffffff;
  --ask: #1f4fd6; --say: #13804a; --notes: #0f7b85; --general: #a3620a; --flag: #c2341f;
  --card: #fff7e0; --card-line: #f0d88a;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --panel: #1a1d23; --ink: #eceef2; --muted: #9aa1ad; --line: #2b2f37;
    --accent: #6d93ff; --accent-ink: #0d1020;
    --ask: #7fa2ff; --say: #4cc98a; --notes: #48c3cc; --general: #e0a447; --flag: #ff7a63;
    --card: #2a2515; --card-line: #5c4d1d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--flag); border-color: currentColor; background: transparent; }
button:disabled { opacity: .55; cursor: default; }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 11px; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }

/* header */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .2px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.dot { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--say); box-shadow: 0 0 0 4px color-mix(in srgb, var(--say) 20%, transparent); }
.dot.off { background: var(--flag); }

/* live layout */
.live { display: grid; grid-template-columns: minmax(0, 660px) 300px; justify-content: center; gap: 20px; padding: 14px 16px; }
@media (max-width: 860px) { .live { grid-template-columns: 1fr; } }
.prompts { display: flex; flex-direction: column; gap: 10px; }
.prompt { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.prompt.newest { border-color: var(--accent); }
.prompt.card { background: var(--card); border-color: var(--card-line); }
.prompt .trig { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt .ln { font-size: 18px; line-height: 1.4; margin: 3px 0; }
.prompt .answer { font-size: 19px; line-height: 1.5; }
.prompt.old .answer { font-size: 15.5px; }
.prompt .src { margin-top: 6px; font-size: 12.5px; color: var(--general); }
.prompt.old .ln { font-size: 15px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .6px; padding: 2px 7px; border-radius: 5px; margin-right: 8px; vertical-align: 2px; color: #fff; }
.tag.ASK { background: var(--ask); } .tag.SAY { background: var(--say); } .tag.NOTES { background: var(--notes); }
.tag.GENERAL { background: var(--general); } .tag.FLAG { background: var(--flag); } .tag.CARD { background: #8a6d12; }
.side { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; gap: 9px; align-items: flex-start; padding: 6px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check .box { width: 18px; height: 18px; border: 2px solid var(--muted); border-radius: 5px; flex: none; margin-top: 2px; }
.check.done .box { background: var(--say); border-color: var(--say); }
.check.done span { color: var(--muted); text-decoration: line-through; }
.transcript { max-height: 38vh; overflow: auto; font-size: 13.5px; }
.tl { padding: 3px 0; }
.tl b { cursor: pointer; }
.tl.me b { color: var(--accent); }
.tl.partial { color: var(--muted); font-style: italic; }
.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.notice { margin: 10px 16px 0; padding: 9px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--card-line); font-size: 14px; }
.practice { display: flex; gap: 8px; padding: 0 16px 16px; max-width: 1012px; margin: 0 auto; }
.practice input[name=speaker] { max-width: 160px; }
.pill { font-size: 12px; border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; color: var(--muted); }
h1 { font-size: 20px; margin: 0 0 6px; } h2 { font-size: 16px; margin: 0 0 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.status { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; }
.status.active { color: var(--say); } .status.upcoming { color: var(--ask); } .status.ended, .status.revoked { color: var(--muted); }
.center { min-height: 80vh; display: grid; place-items: center; padding: 16px; }

/* Must-read setup instructions (browser-tab listening) */
.must { margin: 10px 0 4px; padding: 14px 16px; border: 2px solid var(--flag); border-radius: 10px; background: color-mix(in srgb, var(--flag) 8%, var(--panel, #fff)); color: var(--ink); font-size: 14.5px; }
.must-title { font-weight: 700; font-size: 16px; color: var(--flag); margin-bottom: 6px; }
.must ol { margin: 6px 0; padding-left: 20px; }
.must li { margin: 4px 0; }
.must-alt { margin: 8px 0; font-size: 13.5px; }
.must-ok { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--panel, #fff); border: 1px solid var(--line); font-weight: 600; color: var(--ink); cursor: pointer; }
.must-ok input { width: auto; transform: scale(1.25); }

/* Listening status: turns green while the meeting is heard */
#capStatus.hearing { color: var(--say); border-color: var(--say); }
#capStatus.hearing::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--say); margin-right: 6px; vertical-align: 1px; }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .top { gap: 8px; padding: 8px 12px; flex-wrap: nowrap; }
  .top .brand { flex: 1 1 auto; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top .brand small, #clock, #endsAt, #pin, .top .grow { display: none !important; }
  body.phone #popout { display: none !important; }
  .top button { padding: 7px 11px; font-size: 14px; white-space: nowrap; }
  #capStatus { white-space: nowrap; }
  .live { padding: 10px 12px 90px; gap: 12px; }
  .prompt .answer { font-size: 20px; line-height: 1.5; }
  .prompt .trig { white-space: normal; }
  .notice { margin: 8px 12px 0; }
  .wrap { padding: 10px; }
  .wrap .panel { margin-top: 8px !important; }
  /* side panels fold away under the answer; tap a heading to open it */
  .side .panel { padding: 12px 14px; }
  .side .panel > h2 { margin: 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
  .side .panel > h2::after { content: 'Show'; font-size: 13px; font-weight: 500; color: var(--accent); }
  .side .panel.open > h2 { margin-bottom: 10px; }
  .side .panel.open > h2::after { content: 'Hide'; }
  .side .panel:not(.open) > :not(h2) { display: none !important; }
  .transcript { max-height: 45vh; }
  /* typing bar stays at the bottom of the screen */
  .practice { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; margin: 0; max-width: none; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
  .practice input[name=speaker], .practice label { display: none; }
  .practice input { font-size: 16px; } /* stops iPhone zooming in */
  input, textarea, select { font-size: 16px; }
  .must { padding: 12px; }
  .doc-input { max-width: 100%; }
  .docs-panel label.row { max-width: 100%; overflow: hidden; }
}

/* ---------- question and answer ---------- */
.prompt .q { background: color-mix(in srgb, var(--ask) 9%, var(--panel)); border-left: 4px solid var(--ask); border-radius: 8px; padding: 7px 10px; margin-bottom: 10px; }
.prompt .qlabel, .prompt .alabel { font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; margin-bottom: 2px; }
.prompt .qlabel { color: var(--ask); }
.prompt .qtext { color: var(--ask); font-size: 15px; line-height: 1.4; }
.prompt .a { border-left: 4px solid var(--say); padding-left: 10px; }
.prompt .alabel { color: var(--say); }
.prompt .reveal { display: none; margin-top: 2px; }
/* answers hidden: only the question and a Show answer button */
.prompts.hide-answers .prompt .a { display: none; }
.prompts.hide-answers .prompt.peek .a { display: block; }
.prompts.hide-answers .prompt .reveal { display: inline-block; }
.prompts.hide-answers .prompt:not(.peek) { opacity: .75; }
.prompts.hide-answers .prompt:not(.peek) .q { margin-bottom: 8px; }

/* ---------- simple student setup ---------- */
.panel.simple { max-width: 600px; margin: 18px auto; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.step:first-of-type { margin-top: 10px; }
.step .num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px; margin-top: 2px; }
.step label { margin-top: 0; }
button.big { width: 100%; padding: 13px 16px; font-size: 17px; margin-top: 8px; }
.step > .grow { min-width: 0; }
.step input[type=file] { max-width: 100%; }

/* ---------- answer follows the student's voice ---------- */
.prompt .a .body { position: relative; max-height: 46vh; overflow-y: auto; scrollbar-width: thin; }
.prompt .answer .w { transition: color .25s; }
.prompt .answer .w.said { color: color-mix(in srgb, var(--ink) 35%, transparent); }
.prompt .answer .w.next { color: var(--ink); font-weight: 600; }
.prompts .nextq { display: block; width: 100%; margin-top: 8px; padding: 9px 12px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); color: var(--accent); border-radius: 10px; font-weight: 600; cursor: pointer; text-align: left; }

.or-line { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--muted); font-size: 12.5px; }
.or-line::before, .or-line::after { content: ''; flex: 1; border-top: 1px dashed var(--line); }

/* A query or code to say or type, under the spoken answer */
.prompt pre.code { margin: 8px 0 0; padding: 8px 10px; background: #f3f5f8; border: 1px solid var(--line); border-radius: 8px; font: 0.85em/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.notice.warn { border-color: #e8a33d; background: #fff7e8; }

/* Help chat (students) */
.help-btn { position: fixed; right: 18px; bottom: 18px; z-index: 50; border-radius: 22px; padding: 10px 18px; background: var(--accent); color: #fff; border: 0; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer; }
.help-box { position: fixed; right: 18px; bottom: 70px; z-index: 51; width: min(380px, calc(100vw - 24px)); height: min(520px, calc(100vh - 100px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.18); display: flex; flex-direction: column; overflow: hidden; }
.help-box.hidden { display: none; }
.help-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.help-head .small { flex: 1; }
.help-head button { border: 0; background: none; font-size: 20px; line-height: 1; padding: 0 4px; cursor: pointer; }
.help-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.help-msg { padding: 8px 10px; border-radius: 10px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; max-width: 88%; }
.help-msg.bot { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); align-self: flex-start; }
.help-msg.me { background: var(--accent); color: #fff; align-self: flex-end; }
.help-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.help-form textarea { flex: 1; resize: none; }

/* The question was not heard clearly: the line to ask for a repeat */
.prompt.unclear .a { border-left-color: #e8a33d; }
.prompt.unclear .alabel { color: #b06000; }

/* ---------- coding answers: approach, then steps that light up as the student types ---------- */
.prompt .code-answer .approach { margin-bottom: 10px; }
.prompt .code-answer .csteps { display: flex; flex-direction: column; gap: 8px; }
.prompt .code-answer .cstep { border-left: 4px solid transparent; padding: 4px 0 4px 10px; border-radius: 4px; transition: opacity .25s, background .25s, border-color .25s; }
.prompt .code-answer .cstep .say { font-size: .9em; line-height: 1.4; }
.prompt .code-answer .n { display: inline-block; font-size: .62em; font-weight: 700; letter-spacing: .03em; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; margin-right: 4px; vertical-align: 2px; }
.prompt .code-answer .cstep pre.code { margin-top: 5px; font-size: .86em; line-height: 1.5; white-space: pre; overflow-x: auto; overflow-wrap: normal; tab-size: 4;
  background: #1e2430; color: #e6e9ef; border-color: #1e2430; }
.prompt .code-answer .cstep.cur { border-left-color: var(--say); background: color-mix(in srgb, var(--say) 7%, transparent); }
.prompt .code-answer .cstep.cur .n { color: #fff; background: var(--say); border-color: var(--say); }
.prompt .code-answer .cstep.later { opacity: .38; }
.prompt .code-answer .cstep.done { opacity: .5; }
.prompt .code-answer .cstep.done pre.code { background: #f3f5f8; color: var(--ink); border-color: var(--line); }
.prompt .code-answer .cx { margin-top: 10px; font-size: .9em; opacity: .55; }
.prompt .code-answer .cx.cur { opacity: 1; }
.scrbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 12px; font-size: 13px; }
.scrbar .dotlive { width: 8px; height: 8px; border-radius: 50%; background: var(--say); }
.scrbar span:empty { display: none; }
.prompt .a .body:has(.code-answer) { max-height: 72vh; }

.actRange { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.actRange button { padding: 3px 10px; }
