/* I love maths: styles (warm dark theme matching the progress hexagon) */
:root {
  --bg: #110e19; --card: #1b1727; --card2: #221c31; --ink: #f4eefc; --soft: #a99fbd; --line: #2e2840;
  --gold: #ffc53d; --coral: #ff8a65; --violet: #b17cff; --radius: 22px;
  --font: "Nunito", "Quicksand", ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--ink); min-height: 100vh; min-height: 100dvh; line-height: 1.45;
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 120, 80, .16) 0, transparent 38%),
    radial-gradient(circle at 100% 100%, rgba(160, 110, 255, .16) 0, transparent 40%),
    var(--bg);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 30px; text-align: center; }
h1, h2, h3 { line-height: 1.2; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); padding: 18px; }
.brand { margin: 0; font-size: clamp(1.5rem, 4vw, 2.1rem); letter-spacing: -.5px; font-weight: 800; }
.brand.big { font-size: clamp(2.3rem, 9vw, 3.2rem); }
.heart { color: #ff5a4e; }

/* buttons */
button { font: inherit; }
.btn {
  font-weight: 800; font-size: 1rem; border: 0; border-radius: 999px; padding: 12px 20px; cursor: pointer;
  background: #2d2550; color: #e3d8ff; transition: transform .1s ease, background .2s ease, opacity .2s;
}
.btn:hover { background: #3a3066; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--coral), var(--violet)); color: #1a1024; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.gold { background: linear-gradient(135deg, #ffd65a, #f4a91f); color: #3d2600; }
.btn.gold:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--soft); border: 1px solid #3a3150; }
.btn.ghost:hover { background: #241e35; color: var(--ink); }
.btn.danger { background: #3a1d28; color: #ffb3b3; }
.btn.small { padding: 8px 14px; font-size: .92rem; }
.btn.wide { width: 100%; margin-top: 12px; }
.link { background: none; border: 0; color: var(--soft); text-decoration: underline; cursor: pointer; padding: 4px; font-size: .9rem; }
.link:hover { color: var(--ink); }
.icon-btn { background: #241e35; border: 1px solid #332a48; color: var(--soft); width: 42px; height: 42px; border-radius: 50%; font-size: 1.25rem; cursor: pointer; }
.icon-btn:hover { color: var(--ink); background: #2d2550; }
.pill { display: inline-block; background: #221c31; border: 1px solid #332a48; border-radius: 999px; padding: 5px 12px; font-size: .85rem; font-weight: 800; color: #d9ccff; white-space: nowrap; }
.pill.demo { background: #3b2a12; border-color: #6b4a17; color: #ffd98a; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #ffd65a; outline-offset: 2px; }

/* ---------- onboarding ---------- */
#onboarding { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px 14px; }
.ob-card { width: 100%; max-width: 520px; padding: 28px 24px 24px; position: relative; overflow: hidden; }
.ob-progress { position: absolute; top: 0; left: 0; right: 0; height: 5px; background: #2a2340; }
.ob-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--coral), var(--violet)); transition: width .3s ease; }
.ob-step h2 { margin: 6px 0 14px; font-size: 1.5rem; }
.lead { font-size: 1.15rem; color: #e6dcf6; margin: 8px 0 14px; }
.ticks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.ticks li { padding-left: 28px; position: relative; color: #d8cfe8; }
.ticks li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 14px; height: 12px; background: var(--gold); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.ai-note { background: #231d33; border: 1px solid #3a3150; border-radius: 14px; padding: 10px 12px; font-size: .95rem; color: #d9ccff; }
.field { display: grid; gap: 6px; font-weight: 700; }
.field span { font-size: .95rem; color: var(--soft); }
.field input { font: inherit; font-size: 1.15rem; padding: 12px 14px; border-radius: 14px; border: 1px solid #3a3150; background: #120f1a; color: var(--ink); width: 100%; }
.field.small { margin-top: 14px; }
.field.small input { font-size: 1rem; }
.hint { color: var(--soft); font-size: .95rem; margin: 8px 0; }
.hint.small { font-size: .84rem; }
.err { color: #ff9b9b; font-weight: 700; min-height: 1.2em; margin: 6px 0 0; font-size: .95rem; }
.err:empty { min-height: 0; margin: 0; }
.ob-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.ob-step > .btn.primary { width: 100%; margin-top: 4px; }
.choice-grid { display: grid; gap: 12px; }
.choice-grid.two { grid-template-columns: 1fr 1fr; }
.choice { border: 2px solid #3a3150; background: #1f1a2e; color: var(--ink); border-radius: 18px; padding: 18px 12px; cursor: pointer; display: grid; gap: 4px; text-align: center; transition: border-color .2s, background .2s; }
.choice b { font-size: 1.4rem; }
.choice span { color: var(--soft); font-size: .92rem; }
.choice:hover { border-color: #5a4a80; }
.choice[aria-checked="true"] { border-color: var(--gold); background: #2a2233; box-shadow: 0 0 0 3px rgba(255, 197, 61, .15); }
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { border: 2px solid #3a3150; background: #1f1a2e; color: #e6dcf6; border-radius: 999px; padding: 9px 15px; cursor: pointer; font-weight: 700; font-size: .98rem; }
.chip:hover { border-color: #5a4a80; }
.chip[aria-checked="true"], .chip[aria-pressed="true"] { border-color: var(--gold); background: #3a2d14; color: #ffe7b0; }
.privacy-box { background: #1f1a2e; border: 1px solid #3a3150; border-radius: 16px; padding: 6px 14px; color: #ddd3ee; font-size: .97rem; }

/* ---------- home ---------- */
.topbar { max-width: 1180px; margin: 0 auto; padding: 18px 20px 6px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .hello { margin: 0; color: var(--soft); font-size: 1.05rem; flex: 1 1 auto; }
.layout { max-width: 1180px; margin: 0 auto; padding: 10px 20px 20px; display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .layout { grid-template-columns: minmax(0, 1.8fr) minmax(330px, 1fr); align-items: start; } }
@media (max-width: 520px) { .layout { padding: 8px 8px 16px; gap: 14px; } .card.hex-card { padding: 12px 2px 12px; } .topbar { padding: 14px 12px 4px; gap: 8px; } }
.card.hex-card { background: #050407; border: 1px solid #221d2e; }
.hex-wrap { position: relative; }
svg#hex { display: block; width: 100%; height: auto; max-height: 78vh; margin: 0 auto; overflow: visible; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.hex-help { text-align: center; color: var(--soft); font-size: .9rem; margin: 10px 0 0; }
.piece { transition: fill .35s ease, stroke .35s ease, opacity .25s ease; transform-box: fill-box; transform-origin: center; }
.piece.cell, .piece.topic-hole, .piece.hole { cursor: pointer; }
@media (hover: hover) { .piece.cell:hover { filter: brightness(1.3); } }
.piece.pop { animation: pop .55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 0% { transform: scale(.55); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.strand { transition: opacity .25s ease; }
svg.focus .strand:not(.focused) { opacity: .25; }
.hole-label { pointer-events: none; font-weight: 800; }
.hole-label .pct { font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .piece.pop { animation: none; } .piece { transition: none; } }
#tip { position: absolute; pointer-events: none; z-index: 5; max-width: 250px; background: #f7f2ff; color: #2a2236; border-radius: 14px; padding: 10px 12px; font-size: .9rem; line-height: 1.35; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); opacity: 0; transform: translateY(4px); transition: opacity .15s ease, transform .15s ease; }
#tip.show { opacity: 1; transform: none; }
#tip .sub { color: #6c6280; font-size: .82rem; }
#tip .status { margin-top: 5px; font-weight: 700; }
#tip .hint { margin-top: 4px; color: #8d84a0; font-size: .78rem; }

.panel { display: grid; gap: 16px; }
.overall { display: flex; align-items: center; gap: 16px; }
.ring { width: 96px; height: 96px; flex: none; }
#ringArc { transition: stroke-dashoffset .5s ease; }
.overall h2 { margin: 0 0 2px; font-size: 1.15rem; }
.overall .stat { color: var(--soft); font-size: .92rem; margin: 2px 0; }
.nudge { margin-top: 12px; background: #2b2333; border: 1px solid #4a3a26; border-radius: 14px; padding: 10px 12px; font-size: .95rem; color: #ffe7b0; }
.nudge b { color: #fff3d6; }
.card-title { margin: 0 0 6px; font-size: 1.05rem; }
.strands { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.strands li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 6px 10px; }
.strands .dot { width: 14px; height: 14px; border-radius: 50%; }
.strands .name { font-weight: 700; font-size: .95rem; }
.strands .pct { font-weight: 800; font-size: .95rem; }
.strands .bar { grid-column: 2 / 4; height: 10px; border-radius: 999px; background: #2c2638; overflow: hidden; }
.strands .bar span { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
.crown { color: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .85rem; color: var(--soft); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 12px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.topics details { border-top: 1px solid var(--line); padding: 8px 0; }
.topics details:first-child { border-top: 0; }
.topics summary { cursor: pointer; font-weight: 800; padding: 4px 0; list-style-position: inside; }
.topics h5 { margin: 10px 0 2px; font-size: .78rem; color: var(--soft); text-transform: uppercase; letter-spacing: .5px; }
.topic-btn { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; background: none; border: 0; color: var(--ink); text-align: left; padding: 7px 8px; border-radius: 10px; cursor: pointer; font-size: .93rem; }
.topic-btn:hover { background: #262038; }
.topic-btn .lv { white-space: nowrap; letter-spacing: 2px; font-size: .85rem; }
.foot { text-align: center; color: var(--soft); padding: 4px 12px 28px; display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* ---------- chat ---------- */
#chat { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 860px; margin: 0 auto; }
.chat-top { display: flex; align-items: center; gap: 12px; padding: 12px 14px 8px; }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title b { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { color: var(--soft); font-size: .88rem; }
.ai-banner { margin: 0 14px 6px; background: #231d33; border: 1px solid #3a3150; border-radius: 14px; padding: 8px 12px; font-size: .86rem; color: #d9ccff; }
.messages { flex: 1; overflow-y: auto; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.msg { max-width: 86%; padding: 11px 15px; border-radius: 20px; font-size: 1.02rem; overflow-wrap: anywhere; }
.msg p { margin: 0 0 .55em; }
.msg p:last-child { margin-bottom: 0; }
.msg.tutor { align-self: flex-start; background: var(--card); border-bottom-left-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.msg.student { align-self: flex-end; background: linear-gradient(135deg, #ff9a76, #c58dff); color: #1f1230; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg .katex-display { margin: .35em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.msg .katex { font-size: 1.08em; }
.msg.error { align-self: center; background: #3a1d28; color: #ffd0d0; text-align: center; font-size: .95rem; }
.msg.error .btn { margin-top: 8px; }
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--soft); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.celebrate { align-self: center; text-align: center; background: linear-gradient(135deg, #3b2b0f, #2b2140); border: 1px solid #7a5a1a; border-radius: 20px; padding: 14px 18px; max-width: 92%; }
.celebrate .big { font-size: 1.25rem; font-weight: 800; color: var(--gold); }
.celebrate svg { width: 46px; height: 40px; display: block; margin: 0 auto 6px; }
.celebrate .btn { margin-top: 10px; }
.support-card { align-self: center; background: #1d2433; border: 1px solid #34507a; color: #d6e6ff; border-radius: 18px; padding: 10px 14px; text-align: center; font-size: .95rem; }
.composer { position: relative; display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(17, 14, 25, .92); }
.composer textarea { flex: 1; font: inherit; font-size: 1.02rem; resize: none; max-height: 140px; padding: 12px 14px; border-radius: 20px; border: 1px solid #3a3150; background: #120f1a; color: var(--ink); line-height: 1.35; }
.composer .send { width: 48px; height: 48px; padding: 0; font-size: 1.15rem; flex: none; }
.counter { position: absolute; right: 76px; top: -18px; font-size: .78rem; color: var(--soft); }
.counter.warn { color: #ffb36b; }
@media (max-width: 420px) { .hide-xs { display: none; } .msg { max-width: 92%; } }

/* ---------- sheets (dialogs) ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(5, 3, 10, .6); z-index: 20; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100%);
  max-height: 88vh; overflow-y: auto; background: var(--card); border-radius: 26px 26px 0 0; padding: 22px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); animation: up .25s ease;
}
@media (min-width: 700px) { .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 26px; animation: none; } }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet h2 { margin: 2px 40px 10px 0; font-size: 1.35rem; }
.sheet .close { position: absolute; right: 14px; top: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #2a2340; color: var(--soft); font-size: 1.4rem; cursor: pointer; }
.eyebrow { margin: 0; color: var(--soft); font-size: .85rem; font-weight: 700; }
.levels { display: grid; gap: 8px; margin: 10px 0; }
.level-row { display: flex; gap: 10px; align-items: center; background: #211b30; border-radius: 14px; padding: 9px 12px; }
.level-row i { width: 18px; height: 16px; flex: none; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.level-row .lname { font-weight: 800; }
.level-row .lblurb { color: var(--soft); font-size: .88rem; }
.level-row.next { outline: 2px solid var(--gold); }
.level-row .tag { margin-left: auto; font-size: .8rem; font-weight: 800; color: var(--gold); white-space: nowrap; }
.ts-aim { color: #e6dcf6; }
.stack { display: grid; gap: 10px; margin: 12px 0; }
.plain-list { padding-left: 20px; color: #ddd3ee; }
.plain-list li { margin: 6px 0; }
.sheet.support { background: #19202c; }
.sheet.support h2 { color: #e3eeff; }
.helpline { background: #222c3d; border: 1px solid #34507a; border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.helpline b { display: block; }
.helpline.placeholder { border-style: dashed; border-color: #b08a3a; background: #2b2618; color: #ffe2a0; }
.emergency { font-weight: 800; color: #ffe0e0; background: #4a1820; border: 1px solid #8a2e3a; border-radius: 14px; padding: 10px 14px; font-size: 1.08rem; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; z-index: 30; pointer-events: none;
  background: linear-gradient(135deg, #ffd65a, #f4a91f); color: #3d2600; font-weight: 800; padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(255, 170, 0, .35); transition: all .3s ease; text-align: center; max-width: 92vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- accounts ---------- */
.pill.synced { background: #13301f; border-color: #1f5a36; color: #a6f0c0; }
.pill.synced.off { background: #2a2233; border-color: #3a3150; color: var(--soft); }
.acct-link { text-align: center; margin: 12px 0 0; }
.acct-offer { margin-top: 12px; background: #1d2433; border: 1px solid #2f3d58; border-radius: 16px; padding: 10px 14px; color: #d3def2; font-size: .95rem; }
.acct-offer p { margin: 4px 0 10px; }
.acct-box { margin: 14px 0; padding: 12px 14px; border-radius: 16px; background: #1f1a2e; border: 1px solid #3a3150; }
.acct-box p { margin: 0 0 10px; color: #ddd3ee; overflow-wrap: anywhere; }
#acForm { display: grid; gap: 12px; margin-top: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; color: #ddd3ee; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--gold); flex: none; }
.ok { color: #a6f0c0; font-weight: 700; margin: 0; }
.ok:empty, #acErr:empty { display: none; }
.ac-links { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; margin-top: 10px; }
.draft-note { background: #3b2a12; color: #ffd98a; border-radius: 10px; padding: 6px 10px; font-weight: 800; font-size: .88rem; }

/* ---------- photos ---------- */
.photo-btn { flex: none; width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 1.2rem; }
.photo-tray { display: flex; align-items: center; gap: 12px; margin: 0 12px; padding: 8px 10px; border-radius: 16px; background: #1f1a2e; border: 1px solid #3a3150; position: relative; }
.photo-tray img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #fff; }
.photo-meta { display: grid; gap: 2px; flex: 1; }
.photo-tray .close { position: static; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #2a2340; color: var(--soft); font-size: 1.3rem; cursor: pointer; flex: none; }
.msg-photo { display: block; max-width: min(260px, 100%); max-height: 320px; border-radius: 12px; margin: 0 0 6px auto; background: #fff; }
.photo-gone { font-size: .88rem; opacity: .8; margin-bottom: 4px; }
a.btn { text-decoration: none; text-align: center; display: block; overflow-wrap: anywhere; } a.link { display: inline-block; }

.help-addr { user-select: all; -webkit-user-select: all; font-weight: 800; font-size: 1.1rem; background: #120f1a; border: 1px solid #3a3150; border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere; text-align: center; }

.help-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.help-links .btn { text-decoration: none; display: inline-block; }
.emergency a { color: inherit; font-weight: 900; }
.other-country { margin-top: 10px; } .other-country summary { cursor: pointer; color: var(--soft); font-weight: 700; padding: 6px 0; }

.calm-emergency { color: var(--soft); font-size: .92rem; margin: 14px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.calm-emergency a { color: var(--ink); font-weight: 700; }
.privacy-text h3 { font-size: 1.02rem; margin: 18px 0 6px; color: var(--gold); }
.privacy-text p, .privacy-text li { font-size: .95rem; color: #ddd3ee; }
.privacy-text ul { padding-left: 20px; margin: 6px 0; }
.privacy-text a { color: #cbb6ff; overflow-wrap: anywhere; }

/* "Show me what you did in class" */
.btn.class-btn { background: #241d3a; color: var(--ink); border: 2px solid var(--violet); font-size: 1.05rem; padding: 14px 16px; }
.btn.class-btn:hover { background: #2e2550; }
.choices { display: grid; gap: 12px; margin-top: 14px; }
.cl-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 4px; }
.cl-thumbs .pg { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: #fff; }
.cl-thumbs .pg img { width: 100%; height: 100%; object-fit: cover; }
.cl-thumbs .pg span { position: absolute; left: 6px; top: 6px; background: rgba(20,16,30,.8); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .8rem; font-weight: 700; }
.cl-thumbs .pg button { position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(20,16,30,.85); color: #fff; font-size: 1.1rem; cursor: pointer; }
.stack.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suggested { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.suggested p { margin: 0 0 8px; color: var(--soft); font-size: .95rem; }
.suggested .chips { gap: 8px; }
.msg-pages { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 6px; }
.msg-pages img { width: 74px; height: 98px; object-fit: cover; border-radius: 8px; background: #fff; }
.msg.student .hint { color: rgba(26, 16, 36, .72); margin-bottom: 4px; }
.yr-head { margin: 10px 0 6px; font-weight: 700; }
#obYears .chips + .yr-head { margin-top: 16px; }
