:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #3056d3;
  --brand-soft: #e8edfc;
  --ok: #0f8a5f;
  --ok-soft: #e3f6ee;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --bad: #c0392b;
  --bad-soft: #fdecea;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .2em 0 .5em; }
h2, .h2 { font-size: 1.25rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1.05rem; margin: 1em 0 .3em; }
code { background: #f0f2f5; padding: 0 .3em; border-radius: 4px; font-size: .9em; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 14px; align-items: center; font-size: .95rem; flex-wrap: wrap; }
.who { color: var(--muted); }
.mock-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .9rem; padding: 6px 16px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 16px 0; overflow-wrap: anywhere; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--brand); font-weight: 600; margin: 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0 0 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.error { color: var(--bad); }
.notice { background: var(--brand-soft); padding: 10px 14px; border-radius: 10px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.link { color: var(--brand); cursor: pointer; text-decoration: underline; }
ul.plain { list-style: none; padding: 0; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-size: .95rem; }
input, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; width: 100%; background: #fff; color: var(--text); }
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--brand); border-color: transparent; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.big { padding: 14px 22px; width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .6; cursor: default; }
.cta { margin: 24px 0; text-align: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-decoration: none; color: var(--text); }
a.tile:hover { border-color: var(--brand); }
.tile.disabled { opacity: .55; }
.tile-title { font-weight: 700; font-size: 1.15rem; }

.bar { display: block; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar.big { height: 12px; }
.bar > span { display: block; height: 100%; background: var(--ok); }

.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: #eef0f4; color: var(--muted); }
.pill.ok, .pill.correct { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.partially_correct, .pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.incorrect, .pill.unreadable, .pill.hard { background: var(--bad-soft); color: var(--bad); }
.pill.easy { background: var(--brand-soft); color: var(--brand); }

/* roadmap */
.roadmap { list-style: none; padding: 0; margin: 20px 0; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin-bottom: 12px; }
.group.soon { opacity: .6; }
.group-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-no { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }
.group-title { font-weight: 600; }
.concepts { list-style: none; padding: 6px 0 0 40px; margin: 0; }
.concept { display: flex; align-items: center; gap: 10px; padding: 5px 0; flex-wrap: wrap; }
.concept .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.concept.mastered .dot, .concept.passed .dot { background: var(--ok); border-color: var(--ok); }
.concept.current .dot, .concept.ready .dot { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand-soft); }
.concept.review .dot { background: var(--warn); border-color: var(--warn); }
.concept.locked { color: var(--muted); }
.concept.current a, .concept.ready a { font-weight: 700; }
.concept.check { font-style: italic; }

/* reading */
.writeup { font-size: 1.05rem; }
.writeup img, .question img { max-width: 100%; height: auto; display: block; margin: 12px auto; }
.writeup table, .question table { border-collapse: collapse; margin: 10px 0; }
.writeup th, .writeup td, .question th, .question td { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
blockquote { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 10px 10px 0; }

/* chat */
.chat { display: grid; gap: 10px; margin: 10px 0; }
.bubble { padding: 10px 14px; border-radius: 12px; max-width: 92%; }
.bubble p:first-child { margin-top: 0; } .bubble p:last-child { margin-bottom: 0; }
.bubble.student { background: var(--brand-soft); justify-self: end; }
.bubble.tutor { background: #f4f5f7; justify-self: start; }
.doubt { display: flex; gap: 8px; align-items: flex-end; }
.doubt textarea { flex: 1; }

/* quiz */
.question { font-size: 1.1rem; }
.q-meta { display: flex; gap: 6px; margin-bottom: 4px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { flex: 1 1 auto; padding: 10px 12px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font: inherit; font-size: .95rem; cursor: pointer; }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.preview { background: #fafbfc; border: 1px dashed var(--line); padding: 10px; border-radius: 10px; white-space: pre-wrap; }
.upload { display: block; border: 2px dashed var(--line); border-radius: 12px; padding: 28px 16px; text-align: center; cursor: pointer; color: var(--muted); }
.upload input { display: none; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; }
.thumb img { width: 110px; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 24px; height: 24px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.mic { width: 100%; padding: 16px; font-size: 1.05rem; margin-bottom: 8px; }
.mic.live { background: var(--bad); color: #fff; border-color: var(--bad); }
.verdict { font-size: 1.3rem; font-weight: 700; padding: 8px 14px; border-radius: 10px; display: inline-block; }
.verdict.correct { background: var(--ok-soft); color: var(--ok); }
.verdict.partially_correct { background: var(--warn-soft); color: var(--warn); }
.verdict.incorrect, .verdict.unreadable { background: var(--bad-soft); color: var(--bad); }
.answer, .solution, .transcription { background: #fafbfc; border-radius: 10px; padding: 4px 14px; }
details summary { cursor: pointer; font-weight: 600; }

/* results */
.result { text-align: center; }
.result.pass { border-color: var(--ok); }
.result.fail { border-color: var(--warn); }
.score { font-size: 2.6rem; font-weight: 800; margin: 0; }
.result.pass .score { color: var(--ok); }
.result.fail .score { color: var(--warn); }
.weak { text-align: left; display: inline-block; }
.review-item summary { display: flex; gap: 10px; align-items: center; }
.student-text { background: var(--brand-soft); padding: 8px 12px; border-radius: 10px; }
.answer-img { max-width: 100%; max-height: 420px; border-radius: 8px; border: 1px solid var(--line); margin: 6px 0; }

/* teacher */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; display: block; overflow-x: auto; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.review td { color: var(--warn); }
.table tr.mastered td:nth-child(2) { color: var(--ok); }
.toc { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 20px; }
.review-q { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; }

.loading { color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .concepts { padding-left: 8px; }
  .doubt { flex-direction: column; align-items: stretch; }
}
