:root {
  --brand: #0f766e; --brand-d: #115e59; --brand-l: #ccfbf1; --accent: #f59e0b;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc; --card: #fff;
  --bad: #b91c1c; --ok: #15803d; --r: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .4rem 0 .6rem; }
h2 { font-size: 1.2rem; margin: .2rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
small { font-size: .8rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin: .4rem 0; }
.hint.ok { color: var(--ok); } .hint.bad, .err { color: var(--bad); }
.err:empty { display: none; }
.center { text-align: center; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: 14px; font-size: .9rem; }
.top nav a { text-decoration: none; color: var(--muted); font-weight: 600; }

main { max-width: 680px; margin: 0 auto; padding: 16px; }
.hero { padding: 8px 0 4px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 700; color: var(--brand); margin: 0; }
.lead { color: #334155; font-size: 1rem; line-height: 1.5; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 14px 0; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.stack > * + * { margin-top: 12px; }
label { display: block; font-weight: 600; font-size: .92rem; }
input, select { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 16px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 12px; background: #fff; color: var(--ink); min-height: 48px; }
input:focus, select:focus { outline: 3px solid var(--brand-l); border-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; cursor: pointer; font-weight: 400; }
.opt input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; accent-color: var(--brand); }
.opt small { display: block; color: var(--muted); }
.opt:has(input:checked) { border-color: var(--brand); background: #f0fdfa; }
details.more summary { cursor: pointer; font-weight: 600; padding: 8px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid #cbd5e1;
  background: #fff; color: var(--ink); font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.pulse { animation: pulse 1.2s ease-in-out infinite; border-color: var(--accent); }
.linkbtn { background: none; border: 0; color: var(--bad); text-decoration: underline; font: inherit; font-size: .85rem; cursor: pointer; padding: 6px 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.how ol { padding-left: 1.2rem; line-height: 1.6; }

/* session: fixed-height column, only the chat scrolls */
body.in-session { overflow: hidden; }
body.in-session main { padding: 0 12px; }
.session { display: flex; flex-direction: column; height: calc(100dvh - 52px - env(safe-area-inset-top)); }
.phasebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0 4px; flex: none; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; }
.steps span { font-size: .7rem; font-weight: 700; padding: 4px 8px; border-radius: 99px; background: #e2e8f0; color: var(--muted); }
.steps span.on { background: var(--brand); color: #fff; }
.steps span.done { background: var(--brand-l); color: var(--brand-d); }
.clock { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.15rem; min-width: 64px; text-align: right; }
.clock.low { color: var(--bad); }
.task { margin: 4px 0; padding: 12px; flex: none; }
.task h2 { font-size: 1.02rem; margin-bottom: 8px; }
.mind { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mind li { background: #fef3c7; border: 1px solid #fde68a; color: #78350f; border-radius: 99px; padding: 4px 10px; font-size: .85rem; font-weight: 600; }
.examiner { font-size: .85rem; color: #334155; background: #f1f5f9; border-left: 4px solid #94a3b8; padding: 8px 10px; border-radius: 8px; margin: 4px 0; flex: none; }
.partner { display: flex; align-items: center; gap: 10px; flex: none; padding: 4px 0; font-size: .92rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.chat { flex: 1 1 auto; min-height: 90px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 2px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overscroll-behavior: contain; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 16px; flex: none; }
.msg small { font-weight: 700; color: var(--muted); }
.msg p { margin: 2px 0 0; line-height: 1.42; }
.msg.partner { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.student { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.student small { color: #ccfbf1; }
.msg.thinking p { animation: blink 1s infinite; }
.controls { flex: none; background: var(--bg); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); text-align: center; }
.status { min-height: 1.3em; font-weight: 600; font-size: .9rem; color: #334155; margin: 0 0 8px; }
.mic { position: relative; width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; cursor: pointer; display: inline-grid; place-items: center; box-shadow: 0 6px 20px rgba(15,118,110,.35); }
.mic:disabled { background: #94a3b8; box-shadow: none; cursor: not-allowed; }
.mic.rec { background: #dc2626; }
.mic.rec .ring { position: absolute; inset: -8px; border-radius: 50%; border: 4px solid #fca5a5; animation: ring 1.2s ease-out infinite; }
.controls .row { justify-content: center; margin-top: 8px; }
.controls .btn { min-height: 40px; padding: 8px 12px; font-size: .88rem; }
.typeform { display: flex; gap: 8px; margin-top: 8px; }
.typeform input { margin: 0; }
@media (max-height: 700px) { .task .mind li { padding: 3px 8px; font-size: .8rem; } .examiner { display: none; } }

/* results */
.back { display: inline-block; margin: 4px 0; text-decoration: none; font-weight: 600; }
.scores p { line-height: 1.5; }
.big-score { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.big-score b { font-size: 3rem; line-height: 1; color: var(--brand); }
.big-score em { font-style: normal; background: var(--brand-l); color: var(--brand-d); font-weight: 700; padding: 3px 10px; border-radius: 99px; font-size: .85rem; }
.band { display: grid; grid-template-columns: 1fr 1.2fr 40px; align-items: center; gap: 10px; margin: 8px 0; font-size: .9rem; }
.band.compact { grid-template-columns: 60px 1fr 34px; font-size: .8rem; margin: 6px 0 0; }
.bar { height: 10px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.bar i.w0 { width: 0; } .bar i.w1 { width: 16.7%; } .bar i.w2 { width: 33.3%; } .bar i.w3 { width: 50%; } .bar i.w4 { width: 66.7%; } .bar i.w5 { width: 83.3%; } .bar i.w6 { width: 100%; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #14b8a6); border-radius: 99px; }
.inter dt { font-weight: 700; margin-top: 10px; }
.inter dd { margin: 2px 0 0; color: #334155; line-height: 1.45; }
.fix { border-top: 1px solid var(--line); padding: 10px 0; }
.fix:first-of-type { border-top: 0; padding-top: 0; }
.fix p { margin: 2px 0; }
.said { color: var(--bad); text-decoration: line-through; text-decoration-color: rgba(185,28,28,.4); }
.better { color: var(--ok); font-weight: 700; }
.why { color: var(--muted); font-size: .88rem; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.chips li { background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 99px; padding: 6px 12px; font-size: .9rem; }
.goal { background: #fffbeb; border-color: #fde68a; }
.tline { margin: 8px 0; line-height: 1.45; }
.tline.partner { color: #475569; }
details.card summary { cursor: pointer; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li a { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.hist li a span { display: block; font-weight: 600; }
.hist li a small { color: var(--muted); }
.center-screen { text-align: center; padding: 60px 16px; }
.spinner { width: 42px; height: 42px; margin: 0 auto 16px; border: 4px solid var(--brand-l); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }

/* teacher */
.share { text-align: center; }
.share .code { font-size: 2.4rem; font-weight: 900; letter-spacing: .2em; color: var(--brand); font-variant-numeric: tabular-nums; }
.share .row { justify-content: center; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; text-align: center; }
.stats b { display: block; font-size: 1.5rem; color: var(--brand); }
.stats span { font-size: .8rem; color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; display: block; overflow-x: auto; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }

@media (min-width: 600px) {
  h1 { font-size: 2rem; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .tbl { display: table; }
}
@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .3; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(245,158,11,.25); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

.guide h3.inline { display: inline; }
.guide summary { cursor: pointer; }
.steps-list { padding-left: 1.3rem; line-height: 1.6; }
.steps-list li { margin: 6px 0; }
.guide ul { padding-left: 1.2rem; line-height: 1.55; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 6px; font-size: .9em; }
