/* =====================================================================
   Learning surfaces: home, subjects, journey, topic, intro sequence,
   quizzes, surprise tests, tutor, certificates, notebook, calendar.
   Subject colour appears only as a small monogram badge or a thin line.
   ===================================================================== */

/* subject tone from a hue (--h), muted */
.subj-badge { --h: 4; display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px; font: 650 12.5px/1 var(--font-ui); letter-spacing: .02em;
  background: hsl(var(--h) 45% 95%); color: hsl(var(--h) 45% 32%); border: 1px solid hsl(var(--h) 35% 88%); }
.subj-badge.lg { width: 52px; height: 52px; border-radius: 12px; font-size: 14px; }
.subj-badge.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 10.5px; }
.subj-line { --h: 4; height: 3px; border-radius: 3px; background: hsl(var(--h) 60% 50%); }
.subj-dot { --h: 4; width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--h) 60% 50%); flex: none; }
:root[data-theme="dark"] .subj-badge { background: hsl(var(--h) 22% 16%); color: hsl(var(--h) 60% 78%); border-color: hsl(var(--h) 18% 24%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .subj-badge { background: hsl(var(--h) 22% 16%); color: hsl(var(--h) 60% 78%); border-color: hsl(var(--h) 18% 24%); } }

/* ---------------------------------------------------------------- bento */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.bento > * { min-width: 0; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
@media (max-width: 1180px) { .span-3 { grid-column: span 6; } .span-4 { grid-column: span 6; } .span-8, .span-7 { grid-column: span 12; } .span-5 { grid-column: span 12; } }
@media (max-width: 680px) { .bento { gap: 12px; } .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; } }
.reveal > * { animation: rise .5s var(--ease) both; }
.reveal > *:nth-child(2) { animation-delay: 40ms; } .reveal > *:nth-child(3) { animation-delay: 80ms; } .reveal > *:nth-child(4) { animation-delay: 120ms; }
.reveal > *:nth-child(5) { animation-delay: 160ms; } .reveal > *:nth-child(6) { animation-delay: 200ms; } .reveal > *:nth-child(n+7) { animation-delay: 240ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------- welcome */
.welcome { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; padding: 0; overflow: hidden; }
.welcome .greet { padding: 26px 26px 24px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; }
.welcome .greet h1 { font-size: clamp(24px, 2.6vw, 32px); }
.welcome .greet .sub { color: var(--ink-2); margin-top: 6px; }
.welcome .continue { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 24px; border-left: 1px solid var(--line); background: var(--surface-2); text-decoration: none; position: relative; transition: background .2s; }
.welcome .continue:hover { background: var(--surface-3); }
.welcome .continue .go { position: absolute; right: 20px; top: 20px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); transition: transform .25s var(--ease); }
.welcome .continue:hover .go { transform: translateX(3px); }
.welcome .facts { display: flex; gap: 22px; flex-wrap: wrap; }
.welcome .facts div { min-width: 0; }
.welcome .facts b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.welcome .facts span { font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 900px) { .welcome { grid-template-columns: 1fr; } .welcome .continue { border-left: 0; border-top: 1px solid var(--line); } }

/* book cover (typographic) */
.cover { --h: 4; position: relative; width: 46px; height: 62px; flex: none; border-radius: 3px 6px 6px 3px; overflow: hidden; color: #fff;
  background: linear-gradient(160deg, hsl(var(--h) 38% 30%), hsl(var(--h) 40% 18%)); box-shadow: inset 3px 0 0 rgba(0, 0, 0, .22), 0 4px 10px -4px rgba(0, 0, 0, .35); }
.cover::before { content: ''; position: absolute; left: 0; right: 0; top: 18%; height: 2px; background: rgba(255, 255, 255, .5); }
.cover .t { position: absolute; left: 12%; right: 8%; bottom: 9%; font: 600 7px/1.15 var(--font-ui); letter-spacing: .01em; }
.cover .code { position: absolute; top: 8%; left: 12%; font: 600 5.5px/1 var(--font-ui); letter-spacing: .12em; opacity: .8; }
.cover.big { width: 120px; height: 160px; border-radius: 4px 9px 9px 4px; }
.cover.big .t { font-size: 13px; } .cover.big .code { font-size: 9px; } .cover.big::before { height: 3px; }
.cover.md { width: 64px; height: 86px; } .cover.md .t { font-size: 9px; } .cover.md .code { font-size: 7px; }

/* streak + goal + level */
.metric { display: flex; align-items: center; gap: 14px; }
.metric .icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); flex: none; border: 1px solid var(--line); }
.metric .icon.live { color: var(--brand); background: var(--brand-tint); border-color: transparent; }
.metric .icon.live svg { animation: flicker 2.6s ease-in-out infinite; transform-origin: 50% 85%; }
@keyframes flicker { 30% { transform: scale(1.06) rotate(-2deg); } 60% { transform: scale(.98) rotate(1deg); } }
.week-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 16px; }
.week-dots span { text-align: center; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.week-dots i { display: grid; place-items: center; height: 26px; border-radius: 7px; margin-bottom: 5px; background: var(--surface-2); border: 1px solid var(--line); }
.week-dots .done i { background: var(--ink); border-color: var(--ink); color: var(--bg); animation: pop .4s var(--spring) both; }
.week-dots .today i { border-color: var(--brand); border-style: dashed; }
.week-dots .future i { opacity: .5; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.level { width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 650; font-size: 16px; flex: none; position: relative; }

/* surprise banner */
.surprise-banner { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; animation: rise .5s var(--ease) both; }
.surprise-banner::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.surprise-banner .gift { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; flex: none; }
.surprise-banner .pulse { position: absolute; right: 16px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.surprise-banner .pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--brand); animation: ping 1.8s var(--ease) infinite; }
@keyframes ping { to { transform: scale(3); opacity: 0; } }

/* subject cards */
.subj-card { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: var(--r-xl); text-decoration: none; background: var(--surface); border: 1px solid var(--line); min-height: 176px; transition: border-color .2s, box-shadow .25s, transform .25s var(--ease); }
.subj-card:hover { border-color: var(--line-2); box-shadow: var(--sh-2); transform: translateY(-2px); }
.subj-card .code { font: 500 12px/1 var(--font-ui); color: var(--ink-3); letter-spacing: .02em; }
.subj-card h3 { font-size: 16px; line-height: 1.3; }
.subj-card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); }

/* ---------------------------------------------------------- journey map */
.journey { position: relative; display: flex; flex-direction: column; padding: 4px 0; }
.stop { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 16px; }
.stop .node { position: relative; z-index: 2; width: 36px; height: 36px; margin: 14px 4px 0; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13.5px; background: var(--surface); border: 1.5px solid var(--line-2); color: var(--ink-2); transition: transform .3s var(--ease); }
.stop.done .node { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.stop.current .node { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-tint); }
.stop.current .node::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid var(--brand); opacity: .5; animation: ping 2.2s var(--ease) infinite; }
.stop .rail { position: absolute; left: 21px; top: 52px; bottom: -14px; width: 1.5px; background: var(--line-2); z-index: 1; }
.stop.done .rail { background: var(--ink); }
.stop:last-child .rail { display: none; }
.stop .body { display: block; padding: 14px 16px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); text-decoration: none; margin-bottom: 12px; transition: border-color .2s, box-shadow .2s, transform .25s var(--ease); }
.stop .body:hover { border-color: var(--line-2); box-shadow: var(--sh-2); transform: translateX(2px); }
.stop .body h3 { font-size: 16px; }
.stop .body .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.connector { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px 60px; font-size: 12.5px; color: var(--ink-3); }
.connector .strength { display: inline-flex; gap: 2px; }
.connector .strength i { width: 4px; height: 10px; border-radius: 1px; background: var(--line-2); }
.connector .strength i.on { background: var(--ink-2); }

/* ------------------------------------------------------------ topic page */
.topic-head { position: relative; overflow: hidden; }
.topic-head .num { position: absolute; right: 18px; top: -18px; font-weight: 700; font-size: 132px; line-height: 1; letter-spacing: -.06em; color: var(--surface-3); pointer-events: none; font-variant-numeric: tabular-nums; }
.topic-head > * { position: relative; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.steps a { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; text-decoration: none; font-size: 13px; background: var(--surface); transition: border-color .15s, color .15s; }
.steps a:hover { border-color: var(--ink-3); color: var(--ink); }
.steps a span { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--surface-2); }
.steps a.done span { background: var(--ink); color: var(--bg); }

/* intro sequence: a quiet title sequence */
.cine { --h: 4; position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-xl); overflow: hidden; background: #0E0E10; color: #F2F2F3; isolation: isolate; border: 1px solid var(--line); }
.cine::before { content: ''; position: absolute; inset: 0; z-index: -1; background:
  linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px) 0 0 / 100% 40px, radial-gradient(80% 70% at 50% 40%, rgba(255, 255, 255, .05), transparent 70%); }
.cine .accent { position: absolute; left: 8%; right: 8%; bottom: 72px; height: 1px; background: rgba(255, 255, 255, .1); }
.cine .accent i { position: absolute; left: 0; top: -1px; height: 3px; border-radius: 3px; background: hsl(var(--h) 75% 58%); transition: width .3s linear; }
.cine .scene { position: absolute; inset: 0; display: grid; place-items: center; padding: 6% 9% 16%; text-align: center; opacity: 0; transform: translateY(10px); transition: opacity .6s var(--ease), transform .8s var(--ease); pointer-events: none; }
.cine .scene.on { opacity: 1; transform: none; }
.cine .kicker { font: 600 11px/1 var(--font-ui); letter-spacing: .22em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.cine h2 { font-size: clamp(22px, 4.2vw, 48px); letter-spacing: -.035em; line-height: 1.05; margin-top: 14px; font-weight: 600; }
.cine .big-num { font-weight: 700; font-size: clamp(64px, 12vw, 150px); line-height: .9; letter-spacing: -.06em; color: #fff; }
.cine .big-num small { color: hsl(var(--h) 75% 62%); }
.cine .bridge { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; width: 100%; max-width: 780px; margin-top: 18px; }
.cine .bnode { padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .16); font-weight: 600; font-size: clamp(13px, 1.8vw, 20px); line-height: 1.2; text-align: left; background: rgba(255, 255, 255, .03); }
.cine .bnode.now { border-color: hsl(var(--h) 70% 55% / .7); }
.cine .bnode small { display: block; font: 600 10.5px/1 var(--font-ui); letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .5); margin-bottom: 8px; }
.cine .wire { width: clamp(50px, 12vw, 150px); height: 1px; background: rgba(255, 255, 255, .25); position: relative; }
.cine .wire::after { content: ''; position: absolute; top: -3px; left: 0; width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--h) 75% 62%); animation: travel 1.8s var(--ease) infinite; }
@keyframes travel { from { left: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } to { left: calc(100% - 7px); opacity: 0; } }
.cine .chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.cine .chips span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .18); color: #fff; font-weight: 500; font-size: clamp(11px, 1.3vw, 14px); opacity: 0; transform: translateY(6px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.cine .chips span svg { width: 14px; height: 14px; }
.cine .scene.on .chips span { opacity: 1; transform: none; }
.cine ul.obj { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 12px; text-align: left; max-width: 620px; }
.cine ul.obj li { display: flex; gap: 12px; align-items: baseline; font-size: clamp(13px, 1.7vw, 18px); font-weight: 500; opacity: 0; transform: translateX(-8px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.cine .scene.on ul.obj li { opacity: 1; transform: none; }
.cine ul.obj li i { flex: none; font-style: normal; font-size: .8em; color: hsl(var(--h) 75% 62%); font-variant-numeric: tabular-nums; }
.cine .hud { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 14px 16px; }
.cine .hud .bar { flex: 1; height: 3px; background: rgba(255, 255, 255, .15); }
.cine .hud .bar > i { background: #fff; transition: width .25s linear; animation: none; }
.cine .hud button { width: 32px; height: 32px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .1); color: #fff; display: grid; place-items: center; transition: background .15s; }
.cine .hud button:hover { background: rgba(255, 255, 255, .18); }
.cine .hud button svg { width: 16px; height: 16px; }
.cine .hud .skip { width: auto; padding: 0 10px; font-weight: 500; font-size: 12.5px; display: inline-flex; gap: 4px; }
.cine iframe, .cine video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.cine .caption { position: absolute; left: 10%; right: 10%; bottom: 52px; text-align: center; font-size: clamp(11.5px, 1.4vw, 14px); color: rgba(255, 255, 255, .78); }
.cine .start { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(14, 14, 16, .55); transition: opacity .3s; }
.cine .start[hidden] { display: none; }
.cine .playbig { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 20px 0 14px; border-radius: 99px; border: 0; background: #fff; color: #111; font-weight: 600; font-size: 14.5px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6); transition: transform .2s var(--ease); }
.cine .playbig:hover { transform: scale(1.03); }
.cine .playbig span { width: 30px; height: 30px; border-radius: 50%; background: #111; color: #fff; display: grid; place-items: center; }
.cine .playbig svg { width: 14px; height: 14px; }

/* relation */
.relation { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: start; }
.rel-graph { width: 132px; }
blockquote.evidence { margin: 14px 0 0; padding: 10px 14px; border-left: 2px solid var(--ink-3); background: var(--surface-2); border-radius: 0 8px 8px 0; font-family: var(--font-read); font-size: 15px; line-height: 1.6; }
@media (max-width: 680px) { .relation { grid-template-columns: 1fr; } .rel-graph { width: 110px; } }

/* videos */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.vcard { border-radius: var(--r-xl); overflow: hidden; background: var(--surface); border: 1px solid var(--line); text-align: left; padding: 0; transition: border-color .2s, box-shadow .25s, transform .25s var(--ease); }
.vcard:hover { border-color: var(--line-2); box-shadow: var(--sh-2); transform: translateY(-2px); }
.vcard .thumb { position: relative; aspect-ratio: 16/9; background: #111 center / cover no-repeat; }
.vcard .thumb::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, .12); transition: background .2s; }
.vcard:hover .thumb::after { background: rgba(0, 0, 0, .25); }
.vcard .play { position: absolute; z-index: 1; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .95); color: #111; display: grid; place-items: center; transition: transform .25s var(--ease); }
.vcard .play svg { width: 18px; height: 18px; margin-left: 2px; }
.vcard:hover .play { transform: translate(-50%, -50%) scale(1.08); }
.vcard .vmeta { padding: 12px 14px 14px; }
.vcard .vmeta b { display: block; font-size: 14px; line-height: 1.35; font-weight: 550; }
.vcard .vmeta span { font-size: 12.5px; color: var(--ink-3); }
.player { position: relative; aspect-ratio: 16/9; border-radius: var(--r-lg); overflow: hidden; background: #000; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* -------------------------------------------------------------- quiz */
.quiz-wrap { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.quiz-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.quiz-top .bar { flex: 1; height: 4px; }
.quiz-top .bar > i { animation: none; }
.quiz-top .title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.quiz-top .timer { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); display: inline-flex; gap: 6px; align-items: center; }
.quiz-top .timer svg { width: 15px; height: 15px; }
.quiz-top .timer.low { border-color: var(--bad); color: var(--bad); animation: breathe 1s infinite; }
.quiz-body { flex: 1; width: min(720px, 100%); margin: 0 auto; padding: 32px 20px 130px; }
.qcard.enter-next { animation: qNext .38s var(--ease) both; }
.qcard.enter-prev { animation: qPrev .38s var(--ease) both; }
@keyframes qNext { from { opacity: 0; transform: translateX(28px); } }
@keyframes qPrev { from { opacity: 0; transform: translateX(-28px); } }
.qcard .qnum { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.qcard h2 { font-size: clamp(20px, 2.4vw, 25px); line-height: 1.35; letter-spacing: -.02em; margin: 10px 0 24px; font-weight: 600; }
.opts { display: grid; gap: 10px; }
.opt { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); text-align: left; font-size: 15px; font-weight: 500; overflow: hidden;
  transition: border-color .15s, background .15s, transform .18s var(--ease), box-shadow .2s; }
.opt:hover { border-color: var(--ink-3); }
.opt:active { transform: scale(.99); }
.opt .key { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; border: 1px solid var(--line-2); font-weight: 600; font-size: 12.5px; color: var(--ink-2); flex: none; transition: all .2s var(--ease); }
.opt .mark { margin-left: auto; width: 22px; height: 22px; flex: none; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .3s var(--spring); }
.opt[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); animation: select .32s var(--spring); }
.opt[aria-pressed="true"] .key { background: var(--ink); border-color: var(--ink); color: var(--bg); }
@keyframes select { 40% { transform: scale(1.012); } }
.opt.right { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); background: var(--ok-tint); }
.opt.right .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.right .mark { opacity: 1; transform: none; color: var(--ok); }
.opt.wrong { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); background: var(--bad-tint); animation: shake .4s var(--ease); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.wrong .mark { opacity: 1; transform: none; color: var(--bad); }
.opt.dim { opacity: .5; }
.opt::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), color-mix(in srgb, var(--ink) 10%, transparent) 0, transparent 60%); opacity: 0; pointer-events: none; }
.opt.ripple::after { animation: ripple .5s var(--ease); }
@keyframes ripple { from { opacity: 1; transform: scale(.2); } to { opacity: 0; transform: scale(1.6); } }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); animation: rise .35s var(--ease) both; }
.feedback.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.feedback.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.feedback .head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.feedback.ok .head { color: var(--ok); } .feedback.bad .head { color: var(--bad); }
.quiz-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 6; }
.quiz-foot .inner { width: min(720px, 100%); display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.qdots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.qdots button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--surface); font-size: 11.5px; font-weight: 600; color: var(--ink-2); transition: all .2s var(--ease); }
.qdots button.answered { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.qdots button.r { background: var(--ok); border-color: var(--ok); color: #fff; } .qdots button.w { background: var(--bad); border-color: var(--bad); color: #fff; }
.qdots button[aria-current="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink-3); }
.result-hero { text-align: center; padding: 28px 20px 24px; }
.result-hero .score-ring { margin: 0 auto 18px; display: flex; justify-content: center; }
.result-hero .score { font-weight: 700; font-size: clamp(56px, 10vw, 88px); line-height: 1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.review-q { padding: 16px 0; border-bottom: 1px solid var(--line); }
.review-q:last-child { border-bottom: 0; }

/* surprise takeover */
.takeover { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 20px; background: rgba(12, 12, 14, .55); animation: fadeIn .25s; }
.takeover .box { width: min(460px, 100%); border-radius: 18px; background: var(--surface); padding: 28px; text-align: center; border: 1px solid var(--line); box-shadow: var(--sh-3); animation: takeIn .5s var(--ease) both; position: relative; overflow: hidden; }
.takeover .box::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand); transform-origin: left; animation: fillIn .9s .2s var(--ease) both; }
@keyframes takeIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.takeover .gift { width: 56px; height: 56px; margin: 4px auto 16px; border-radius: 14px; background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; animation: nudge 2.4s 0.6s var(--ease) infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 78% { transform: rotate(-7deg); } 86% { transform: rotate(6deg); } 94% { transform: rotate(-3deg); } }
.takeover h2 { font-size: 24px; letter-spacing: -.03em; }
.takeover .facts { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 16px 0 18px; }

/* -------------------------------------------------------------- tutor */
.tutor { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tutor .msgs { flex: 1; overflow-y: auto; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.bubble { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.6; animation: bubbleIn .3s var(--ease) both; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } }
.bubble.me { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.bot blockquote { margin: 8px 0; padding: 8px 12px; border-left: 2px solid var(--ink-3); background: var(--surface); border-radius: 0 8px 8px 0; font-family: var(--font-read); }
.bubble.bot ul { margin: 6px 0; padding-left: 18px; }
.bubble p + p { margin-top: 8px; }
.bubble .cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bubble .cites a { text-decoration: none; }
.bubble .mode { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.bubble .mode svg { width: 12px; height: 12px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: typ 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typ { 0%, 60%, 100% { transform: none; opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }
.tutor .compose { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.tutor .compose textarea { flex: 1; min-height: 40px; max-height: 140px; resize: none; }
.prompts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tutor-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--ink); color: var(--bg); flex: none; }
.tutor-mark svg { width: 18px; height: 18px; }
.miniquiz .opt { min-height: 42px; font-size: 13.5px; padding: 8px 10px; border-radius: 10px; }
.miniquiz .opt .key { width: 24px; height: 24px; font-size: 11.5px; }

/* -------------------------------------------------------- certificate */
.cert-sheet { position: relative; width: 100%; max-width: 980px; margin: 0 auto; aspect-ratio: 1.414; background: #FFFEFB; color: #16161C; border-radius: 4px; overflow: hidden; box-shadow: var(--sh-3); font-family: var(--font-read); animation: rise .6s var(--ease) both; }
.cert-sheet .frame { position: absolute; inset: 3%; border: 1.5px solid #1D1D22; }
.cert-sheet .frame::after { content: ''; position: absolute; inset: 5px; border: .75px solid rgba(29, 29, 34, .35); }
.cert-sheet .inner { position: absolute; inset: 8% 9%; display: flex; flex-direction: column; }
.cert-sheet .top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cert-sheet .top img { width: 11%; min-width: 54px; }
.cert-sheet .top .centre { font: 600 clamp(9px, 1.15vw, 13px)/1.3 var(--font-ui); color: #55555C; text-align: right; }
.cert-sheet .kicker { font: 600 clamp(8px, 1.05vw, 12px)/1 var(--font-ui); letter-spacing: .32em; text-transform: uppercase; color: #6B6A75; margin-top: 7%; }
.cert-sheet h1 { font: 600 clamp(22px, 4vw, 46px)/1.05 var(--font-read); letter-spacing: -.01em; margin-top: 1.8%; color: #16161C; }
.cert-sheet .rule { width: 9%; height: 2px; background: #D7141D; margin-top: 2.4%; }
.cert-sheet .presented { font-size: clamp(10px, 1.3vw, 15px); color: #4B4A55; margin-top: 3.6%; font-family: var(--font-ui); }
.cert-sheet .name { font: italic 500 clamp(24px, 4.6vw, 56px)/1.1 var(--font-read); margin-top: 1.2%; color: #16161C; }
.cert-sheet .for { font-size: clamp(10px, 1.4vw, 16px); margin-top: 2.4%; max-width: 74%; color: #2A2A33; line-height: 1.5; }
.cert-sheet .foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.cert-sheet .sig { font: 500 clamp(8px, 1.05vw, 12px)/1.4 var(--font-ui); color: #55555C; }
.cert-sheet .sig b { display: block; font: 500 clamp(11px, 1.5vw, 17px)/1.2 var(--font-read); color: #16161C; border-top: .75px solid rgba(22, 22, 28, .45); padding-top: 6px; margin-top: 26px; min-width: 160px; }
.cert-sheet .qr { width: clamp(60px, 10%, 104px); background: #fff; }
.cert-sheet .code { font: 500 clamp(7.5px, .95vw, 11px)/1.4 var(--font-ui); color: #6B6A75; text-align: right; }
.cert-sheet .seal { position: absolute; right: 9%; top: 26%; width: 14%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; color: #8A6A12; border: 1.5px solid #C9A646; font: 600 clamp(7px, 1vw, 11px)/1.25 var(--font-ui); text-align: center; letter-spacing: .08em; text-transform: uppercase; padding: 0 6px; }
.cert-sheet .seal::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; border: .75px dashed #C9A646; }
.cert-sheet .disclaimer { position: absolute; left: 9%; right: 9%; bottom: 4.6%; font: 400 clamp(6.5px, .78vw, 9px)/1.3 var(--font-ui); color: #8B8A95; text-align: center; }
.cert-mini { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); text-decoration: none; transition: border-color .2s, box-shadow .25s, transform .25s var(--ease); }
.cert-mini:hover { border-color: var(--line-2); box-shadow: var(--sh-2); transform: translateY(-2px); }
.cert-mini .seal { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid #C9A646; color: #A07F1C; display: grid; place-items: center; flex: none; }
.cert-mini .seal svg { width: 20px; height: 20px; }
@media print {
  body * { visibility: hidden; }
  .cert-sheet, .cert-sheet * { visibility: visible; }
  .cert-sheet { position: fixed; left: 0; top: 0; width: 297mm; max-width: none; height: 210mm; aspect-ratio: auto; box-shadow: none; border-radius: 0; animation: none; }
  @page { size: A4 landscape; margin: 0; }
}

/* ---------------------------------------------------------- notebook */
.hl-card { padding: 14px 16px; border-radius: var(--r-xl); border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.hl-card .quote { font-family: var(--font-read); font-size: 15px; line-height: 1.6; padding-left: 12px; border-left: 3px solid var(--hl, #E8C547); }
.hl-yellow { --hl: #E8C547; } .hl-green { --hl: #58B97F; } .hl-blue { --hl: #5B9BE0; } .hl-pink { --hl: #E2789F; }
.masonry { columns: 3 300px; column-gap: 14px; }
.masonry > * { break-inside: avoid; margin-bottom: 14px; }

/* ------------------------------------------------------------ calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-grid .dow { font-size: 11.5px; font-weight: 500; color: var(--ink-3); padding: 0 4px 4px; }
.cal-day { min-height: 88px; padding: 7px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.cal-day .d { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-day.out { opacity: .35; }
.cal-day.today { border-color: var(--ink); }
.cal-day.today .d { color: var(--brand); }
.cal-day.holiday { background: var(--surface-2); }
.cal-day .ev { padding: 2px 6px; border-radius: 5px; background: var(--surface-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-day.holiday .ev { background: var(--peach); color: var(--peach-ink); }
@media (max-width: 680px) { .cal-day { min-height: 50px; padding: 5px; } .cal-day .ev { display: none; } .cal-day.has-ev::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); } }
/* the intro adapts to its own width */
.cine { container-type: inline-size; }
@container (max-width: 620px) {
  .cine .caption { display: none; }
  .cine .scene { padding-bottom: 12%; }
  .cine .chips { gap: 6px; margin-top: 14px; }
  .cine .chips span { padding: 4px 8px; font-size: 11px; }
  .cine .bridge { gap: 10px; }
  .cine .bnode { padding: 10px 12px; }
}

/* floating "Ask the tutor" button (mounted on body by the topic page) */
.fab { position: fixed; right: 24px; bottom: 24px; z-index: 30; box-shadow: var(--sh-3); animation: fabIn .4s .3s var(--ease) backwards; }
@keyframes fabIn { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@media (max-width: 980px) { .fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); } }
@media (max-width: 420px) { .btn.fab { width: 52px; height: 52px; padding: 0; justify-content: center; border-radius: 50%; } .fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
