/* ==========================================================================
   Quanta — design system
   Modern CSS: custom properties, color-mix(), View Transitions API,
   @property animations, prefers-reduced-motion support.
   ========================================================================== */

:root {
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --on-accent: #ffffff;
  --radius: 18px;
  --font: "Inter", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-scale: 1;
  --speed: 1;

  --bg: #0b0d17;
  --bg-2: #11142a;
  --surface: color-mix(in srgb, #ffffff 6%, transparent);
  --surface-solid: #151933;
  --surface-2: color-mix(in srgb, #ffffff 10%, transparent);
  --border: color-mix(in srgb, #ffffff 12%, transparent);
  --text: #eef0ff;
  --muted: #a3a8c7;
  --faint: #6b7096;
  --good: #22c55e;
  --bad: #f43f5e;
  --warn: #f59e0b;
  --shadow: 0 10px 40px -12px rgb(0 0 0 / .55);
  --glass-blur: 18px;

  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  color-scheme: dark;
}

html[data-mode="light"] {
  --bg: #f4f5fb;
  --bg-2: #e9ebf7;
  --surface: color-mix(in srgb, #ffffff 72%, transparent);
  --surface-solid: #ffffff;
  --surface-2: color-mix(in srgb, #0b0d17 5%, transparent);
  --border: color-mix(in srgb, #0b0d17 10%, transparent);
  --text: #12142a;
  --muted: #555a7a;
  --faint: #8a8fae;
  --shadow: 0 10px 30px -14px rgb(30 35 90 / .25);
  color-scheme: light;
}
html[data-glass="off"] { --surface: var(--surface-solid); --glass-blur: 0px; }

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--font-scale)); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a.card, a.list-row, a.ch-card, a.btn { color: inherit; }
a.btn.primary { color: var(--on-accent); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: .82rem; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- animated background ---------- */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-fx .blob { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(80px); opacity: .32; animation: drift calc(28s / var(--speed)) ease-in-out infinite alternate; }
.bg-fx .b1 { background: var(--accent); top: -18vmax; left: -12vmax; }
.bg-fx .b2 { background: var(--accent-2); bottom: -20vmax; right: -14vmax; animation-delay: -9s; }
.bg-fx .b3 { background: color-mix(in srgb, var(--accent) 50%, var(--accent-2)); top: 30%; left: 45%; width: 30vmax; height: 30vmax; opacity: .16; animation-delay: -16s; }
html[data-mode="light"] .bg-fx .blob { opacity: .18; }
.bg-fx .grid { position: absolute; inset: 0; display: none; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 42px 42px; mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 75%); }
html[data-bg="grid"] .bg-fx .grid { display: block; }
html[data-bg="plain"] .bg-fx .blob { display: none; }
@keyframes drift { 0% { transform: translate(0,0) scale(1); } 50% { transform: translate(6vmax, 4vmax) scale(1.1); } 100% { transform: translate(-4vmax, 7vmax) scale(.95); } }

.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash .logo { width: 64px; height: 64px; border-radius: 20px; background: var(--grad); display: grid; place-items: center; font-size: 2rem; color: #fff; animation: pulseLogo 1.2s ease-in-out infinite; }
@keyframes pulseLogo { 50% { transform: scale(1.08); box-shadow: 0 0 40px var(--accent); } }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; scrollbar-width: thin; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(var(--glass-blur)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 1.25rem; }
.brand .logo { width: 38px; height: 38px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; flex: none; box-shadow: 0 6px 20px -6px var(--accent); color: var(--on-accent); font-size: 1.2rem; }
.brand small { display: block; font-size: .68rem; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.nav-sec { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); padding: 14px 12px 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 550; transition: background .2s, color .2s; position: relative; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--text); }
.nav-link.active::before { content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--grad); }
.nav-link .ico { width: 22px; text-align: center; font-size: 1.05rem; }
.nav-link .pill { margin-left: auto; }
.sidebar .spacer { flex: 1; }
.pro-card { padding: 14px; border-radius: var(--radius); background: var(--grad); color: var(--on-accent); }
.pro-card b { display: block; font-size: 1rem; }
.pro-card small { opacity: .9; }
.pro-card .btn { margin-top: 10px; background: rgb(255 255 255 / .22); color: inherit; border: 0; width: 100%; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(var(--glass-blur)); border-bottom: 1px solid var(--border); }
.topbar .title { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { display: none; }
.topbar .grow { flex: 1; }
.search-trigger { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; min-width: 240px; }
.search-trigger kbd { margin-left: auto; }
kbd { font-family: inherit; font-size: .72rem; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }
.chip-stat { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 650; font-size: .88rem; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; transition: transform .15s, background .2s; font-size: 1.05rem; flex: none; }
.icon-btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--grad); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; cursor: pointer; flex: none; position: relative; }
.avatar .sync-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg); background: var(--faint); }
.avatar .sync-dot.ok { background: var(--good); } .avatar .sync-dot.busy { background: var(--warn); } .avatar .sync-dot.err { background: var(--bad); }

main#view { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; view-transition-name: page; flex: 1; }
.bottom-nav { display: none; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; backdrop-filter: blur(var(--glass-blur)); box-shadow: var(--shadow); position: relative; }
.card.hover { transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s, box-shadow .25s; cursor: pointer; }
.card.hover:hover { transform: translateY(-4px); border-color: var(--accent-line); box-shadow: 0 18px 40px -16px color-mix(in srgb, var(--accent) 50%, transparent); }
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.hero { padding: 28px; overflow: hidden; background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 55%), radial-gradient(120% 140% at 0% 100%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 55%), var(--surface); }
.hero .atom { position: absolute; right: 24px; top: 50%; translate: 0 -50%; width: 150px; opacity: .9; color: var(--text); }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.span2 { grid-column: span 2; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 18px; }
.mt { margin-top: 18px; } .mt-s { margin-top: 10px; } .mb { margin-bottom: 18px; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 650; cursor: pointer; transition: transform .15s, filter .2s, background .2s, box-shadow .2s; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--text) 12%, transparent); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: var(--on-accent); border: 0; box-shadow: 0 8px 22px -10px var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn.lg { padding: 14px 24px; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.google { background: #fff; color: #1f1f1f; border-color: #dadce0; }

.input, select.input, textarea.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); outline: none; transition: border-color .2s, box-shadow .2s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 90px; }
label.lbl { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.field + .field { margin-top: 14px; }
select.input option { background: var(--surface-solid); }
.otp { letter-spacing: .6em; text-align: center; font-size: 1.4rem; font-weight: 800; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .85rem; color: var(--muted); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); transition: all .2s; }
.seg button.on { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 10px -4px rgb(0 0 0 / .4); }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent-line); white-space: nowrap; }
.pill.good { background: color-mix(in srgb, var(--good) 18%, transparent); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.pill.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; transition: .25s; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; border-radius: 50%; background: var(--text); transition: .25s; }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { translate: 20px 0; background: #fff; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- stats & progress ---------- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.stat .l { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); font-size: 1.2rem; margin-bottom: 6px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--grad); width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.bar.good > i { background: var(--good); } .bar.bad > i { background: var(--bad); } .bar.warn > i { background: var(--warn); }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.ring { --p: 0; width: 120px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); transition: --p 1s; }
.ring > div { width: 82%; aspect-ratio: 1; border-radius: 50%; background: var(--surface-solid); display: grid; place-items: center; text-align: center; }
.ring b { font-size: 1.5rem; display: block; line-height: 1; }
.ring small { color: var(--muted); font-size: .72rem; }

.list-row { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 14px; transition: background .2s; }
.list-row:hover { background: var(--surface-2); }
.list-row .em { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 650; }
.list-row .s { font-size: .82rem; color: var(--muted); }

/* ---------- teacher tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .name { font-weight: 650; }
.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.heat-cell { padding: 12px; border-radius: 12px; border: 1px solid var(--border); }
.heat-cell b { display: block; font-size: 1.2rem; }
.heat-cell small { color: var(--muted); font-size: .75rem; }
.code-box { font-family: ui-monospace, Consolas, monospace; font-size: 1.6rem; font-weight: 800; letter-spacing: .18em; padding: 8px 16px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--accent-line); }

.ch-card .em { font-size: 1.8rem; width: 54px; height: 54px; border-radius: 16px; background: var(--accent-soft); display: grid; place-items: center; margin-bottom: 12px; }
.ch-card h3 { margin-bottom: 4px; }
.ch-card .meta { font-size: .8rem; color: var(--muted); margin-bottom: 12px; }

/* ---------- quiz ---------- */
.quiz-wrap { max-width: 820px; margin: 0 auto; }
.q-progress { display: flex; gap: 6px; margin-bottom: 18px; }
.q-progress span { flex: 1; height: 6px; border-radius: 9px; background: var(--surface-2); transition: background .3s; }
.q-progress span.cur { background: var(--accent-line); }
.q-progress span.ok { background: var(--good); } .q-progress span.no { background: var(--bad); }
.q-text { font-size: 1.15rem; font-weight: 600; white-space: pre-line; margin-bottom: 18px; }
.q-fig { display: block; max-width: min(380px, 100%); margin: 0 auto 18px; color: var(--text); }
.q-fig svg { width: 100%; height: auto; display: block; }
img.q-fig { border-radius: 12px; background: #fff; padding: 6px; }
.opts { display: grid; gap: 12px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; padding: 15px 16px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color .2s, background .2s, transform .15s; font-weight: 550; width: 100%; }
.opt:hover { border-color: var(--accent-line); transform: translateX(3px); }
.opt .k { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: .85rem; flex: none; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); animation: pop .35s; }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); animation: shake .4s; }
.opt.right .k { background: var(--good); color: #fff; } .opt.wrong .k { background: var(--bad); color: #fff; }
.opts.locked .opt { pointer-events: none; }
.solution { margin-top: 18px; padding: 16px 18px; border-radius: 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); animation: rise .4s both; }
.solution h4 { margin: 0 0 6px; }
@keyframes pop { 50% { transform: scale(1.025); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.mock-layout { display: grid; grid-template-columns: 1fr 290px; gap: 18px; align-items: start; }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.palette button { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 700; cursor: pointer; font-size: .85rem; }
.palette button.ans { background: var(--good); color: #fff; border-color: transparent; }
.palette button.rev { background: #8b5cf6; color: #fff; border-color: transparent; }
.palette button.ansrev { background: #8b5cf6; color: #fff; box-shadow: inset 0 -4px 0 var(--good); }
.palette button.seen { background: color-mix(in srgb, var(--bad) 70%, transparent); color: #fff; border-color: transparent; }
.palette button.cur { outline: 2px solid var(--accent); outline-offset: 2px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: .75rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.4rem; }
.timer.low { color: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .5; } }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100dvh - 140px); max-width: 900px; margin: 0 auto; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 4px 20px; scroll-behavior: smooth; }
.msg { display: flex; gap: 12px; margin-bottom: 18px; animation: rise .35s both; }
.msg .av { width: 36px; height: 36px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 1.05rem; background: var(--grad); color: var(--on-accent); }
.msg.user { flex-direction: row-reverse; }
.msg.user .av { background: var(--surface-2); color: var(--text); }
.bubble { padding: 14px 16px; border-radius: 18px; max-width: min(720px, 85%); background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent-soft); border-color: var(--accent-line); border-top-right-radius: 6px; }
.msg.bot .bubble { border-top-left-radius: 6px; }
.bubble img.att { max-width: 220px; border-radius: 12px; display: block; margin-bottom: 8px; }
.bubble .tools { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.md h3, .md h4 { margin: 14px 0 6px; font-size: 1rem; color: var(--text); }
.md h3:first-child, .md h4:first-child { margin-top: 0; }
.md p { margin: 0 0 8px; } .md ul, .md ol { margin: 4px 0 10px; padding-left: 22px; } .md li { margin: 3px 0; }
.md code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: 12px; overflow-x: auto; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 4px; animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 10px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(var(--glass-blur)); box-shadow: var(--shadow); }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer textarea { min-width: 0; flex: 1; border: 0; background: transparent; outline: none; resize: none; max-height: 160px; min-height: 24px; padding: 9px 6px; }
.composer .preview img { height: 44px; border-radius: 8px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.suggest button { border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: .85rem; color: var(--muted); transition: .2s; }
.suggest button:hover { color: var(--text); border-color: var(--accent); }
.mic.rec { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 60%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* ---------- formulas & flashcards ---------- */
.formula { padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); cursor: copy; }
.formula .n { font-size: .8rem; color: var(--muted); font-weight: 650; margin-bottom: 4px; }
.formula .f { font-size: 1.08rem; font-weight: 700; font-family: "Cambria Math", "STIX Two Math", Georgia, serif; }
.formula .k { font-size: .78rem; color: var(--faint); margin-top: 4px; }
.flip { perspective: 1200px; max-width: 560px; margin: 0 auto; height: 300px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .7s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d; }
.flip.on .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: calc(var(--radius) + 6px); display: grid; place-items: center; text-align: center; padding: 28px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.flip-face.back { transform: rotateY(180deg); background: var(--grad); color: var(--on-accent); }
.flip-face .big { font-size: 1.45rem; font-weight: 800; }
.flip-face.back .big { font-family: "Cambria Math", Georgia, serif; }

/* ---------- labs ---------- */
.lab { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.lab canvas { width: 100%; height: 440px; display: block; border-radius: var(--radius); background: color-mix(in srgb, var(--bg) 70%, transparent); border: 1px solid var(--border); }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.readouts div { padding: 10px; border-radius: 12px; background: var(--surface-2); }
.readouts b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.readouts small { color: var(--muted); font-size: .72rem; }
.ctrl + .ctrl { margin-top: 14px; }
.ctrl .row { justify-content: space-between; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }

.chart { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--border); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

.theme-swatch { border-radius: 16px; padding: 12px; border: 2px solid var(--border); cursor: pointer; background: var(--surface); transition: .2s; text-align: left; }
.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch.on { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.theme-swatch .sw { height: 54px; border-radius: 11px; margin-bottom: 8px; }
.theme-swatch b { font-size: .85rem; }

.price-card { display: flex; flex-direction: column; }
.price-card.featured { border: 2px solid var(--accent); box-shadow: 0 20px 50px -20px var(--accent); }
.price-card .amt { font-size: 2.3rem; font-weight: 800; letter-spacing: -.03em; }
.price-card ul { list-style: none; padding: 0; margin: 14px 0 20px; flex: 1; }
.price-card li { padding: 6px 0; } .price-card li::before { content: "✓"; color: var(--good); font-weight: 800; margin-right: 10px; }

/* ---------- overlays ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgb(5 6 15 / .55); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; animation: fadeIn .2s both; }
.modal { width: min(520px, 100%); max-height: 88dvh; overflow: auto; background: var(--surface-solid); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); padding: 24px; box-shadow: 0 30px 80px -20px rgb(0 0 0 / .6); animation: modalIn .35s cubic-bezier(.2,.9,.3,1.2) both; }
.modal.wide { width: min(820px, 100%); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.96); } }
.palette-box { width: min(620px, 100%); align-self: start; margin-top: 10vh; padding: 0; overflow: hidden; }
.palette-box input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 18px 20px; font-size: 1.05rem; background: transparent; }
.palette-box .results { max-height: 50vh; overflow: auto; padding: 8px; }
.palette-box .item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.palette-box .item.on, .palette-box .item:hover { background: var(--accent-soft); }
.palette-box .item small { margin-left: auto; color: var(--faint); }
.toasts { position: fixed; z-index: 200; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 16px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; font-weight: 600; animation: toastIn .4s cubic-bezier(.2,.9,.3,1.2) both; max-width: 360px; }
.toast.out { animation: toastOut .3s both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; }
.focus-pop { position: fixed; right: 24px; top: 76px; z-index: 50; width: 270px; text-align: center; animation: modalIn .3s both; }
.focus-pop .timer { font-size: 2.6rem; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 3rem; margin-bottom: 10px; }
.notice { padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); font-size: .88rem; }

/* ---------- onboarding / auth ---------- */
.onboard { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.onboard > .card { width: min(560px, 100%); padding: 32px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice-grid.two { grid-template-columns: 1fr 1fr; }
.choice { padding: 16px 10px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: center; font-weight: 700; transition: .2s; }
.choice span { display: block; font-size: 1.6rem; margin-bottom: 4px; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.steps-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 20px; }
.steps-dots i { width: 8px; height: 8px; border-radius: 9px; background: var(--surface-2); transition: .3s; }
.steps-dots i.on { width: 26px; background: var(--grad); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: .8rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.lang-toggle { position: absolute; top: 16px; right: 16px; }

.reveal > * { animation: rise calc(.5s / var(--speed)) cubic-bezier(.2,.8,.2,1) both; }
.reveal > *:nth-child(2) { animation-delay: .04s; } .reveal > *:nth-child(3) { animation-delay: .08s; }
.reveal > *:nth-child(4) { animation-delay: .12s; } .reveal > *:nth-child(5) { animation-delay: .16s; }
.reveal > *:nth-child(6) { animation-delay: .2s; } .reveal > *:nth-child(n+7) { animation-delay: .24s; }

/* ---------- page transitions (View Transitions API) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(page), ::view-transition-new(page) { animation-duration: calc(.42s / var(--speed)); animation-timing-function: cubic-bezier(.22,.8,.2,1); }
html[data-transition="slide"]::view-transition-old(page) { animation-name: slideOutL; }
html[data-transition="slide"]::view-transition-new(page) { animation-name: slideInR; }
html[data-transition="slide"][data-dir="back"]::view-transition-old(page) { animation-name: slideOutR; }
html[data-transition="slide"][data-dir="back"]::view-transition-new(page) { animation-name: slideInL; }
html[data-transition="fade"]::view-transition-old(page) { animation-name: fadeOut; }
html[data-transition="fade"]::view-transition-new(page) { animation-name: fadeUp; }
html[data-transition="zoom"]::view-transition-old(page) { animation-name: zoomOut; }
html[data-transition="zoom"]::view-transition-new(page) { animation-name: zoomIn; }
html[data-transition="flip"]::view-transition-old(page) { animation-name: flipOut; }
html[data-transition="flip"]::view-transition-new(page) { animation-name: flipIn; }
html[data-transition="none"]::view-transition-old(page), html[data-transition="none"]::view-transition-new(page) { animation: none; }
@keyframes slideOutL { to { opacity: 0; transform: translateX(-60px); filter: blur(4px); } }
@keyframes slideInR { from { opacity: 0; transform: translateX(60px); filter: blur(4px); } }
@keyframes slideOutR { to { opacity: 0; transform: translateX(60px); filter: blur(4px); } }
@keyframes slideInL { from { opacity: 0; transform: translateX(-60px); filter: blur(4px); } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } }
@keyframes zoomOut { to { opacity: 0; transform: scale(.94); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(1.05); } }
@keyframes flipOut { to { opacity: 0; transform: perspective(1200px) rotateY(-18deg) translateX(-40px); } }
@keyframes flipIn { from { opacity: 0; transform: perspective(1200px) rotateY(18deg) translateX(40px); } }
.page-enter { animation: fadeUp calc(.4s / var(--speed)) cubic-bezier(.22,.8,.2,1) both; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .lab, .mock-layout { grid-template-columns: 1fr; }
  .search-trigger { min-width: 0; } .search-trigger span, .search-trigger kbd { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar .back { display: grid; }
  .hide-m { display: none !important; }
  main#view { padding: 18px 16px 110px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .hero .atom { display: none; }
  .bottom-nav { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; padding: 8px; border-radius: 22px; background: color-mix(in srgb, var(--surface-solid) 82%, transparent); border: 1px solid var(--border); backdrop-filter: blur(20px); box-shadow: var(--shadow); justify-content: space-around; }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 14px; color: var(--muted); font-size: .68rem; font-weight: 650; transition: .2s; }
  .bottom-nav a .ico { font-size: 1.25rem; transition: transform .3s; }
  .bottom-nav a.active { color: var(--text); background: var(--accent-soft); }
  .bottom-nav a.active .ico { transform: translateY(-2px) scale(1.12); }
  .bottom-nav a.fab .ico { width: 46px; height: 46px; margin-top: -24px; border-radius: 16px; background: var(--grad); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 8px 20px -6px var(--accent); }
  .bottom-nav a.fab.active { background: transparent; }
  .chat { height: calc(100dvh - 200px); }
  .lab canvas { height: 320px; }
  .toasts { left: 16px; right: 16px; bottom: 96px; }
  .focus-pop { right: 12px; left: 12px; width: auto; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .chip-stat.hide-xs, .search-trigger, #focusChip { display: none; }
  .topbar { gap: 8px; }
  .onboard > .card { padding: 24px 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
@media print {
  .sidebar, .topbar, .bottom-nav, .bg-fx, .no-print, .qm-btn { display: none !important; }
  .shell { display: block; } .card { box-shadow: none; backdrop-filter: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
