/* Sinov. Same visual language as the econometrics prep site: dotted paper, teal accent, sun yellow,
   rounded Fredoka headings. One centred column that works as a Telegram mini-app and on a laptop. */
:root {
  --bg: #eef3f9; --dot: rgba(46, 84, 140, .07); --surface: #fff; --surface-2: #f4f7fc; --surface-3: #e7eef8;
  --ink: #18233a; --ink-2: #47536a; --muted: #76829a; --line: #d9e2ef;
  --accent: #0d7f86; --accent-ink: #fff; --accent-soft: #d8f1f0; --accent-strong: #0a6a70;
  --sun: #f4b63f; --sun-soft: #fff1d2; --good: #1a9a57; --good-soft: #dcf5e7; --bad: #d9475a; --bad-soft: #fde4e7; --warn: #c98100;
  --shadow: 0 1px 2px rgba(24, 35, 58, .06), 0 6px 18px rgba(24, 35, 58, .07);
  --font-display: "Fredoka", "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "Lexend", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --r-lg: 24px; --r-md: 16px; --r-sm: 11px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1624; --dot: rgba(150, 185, 235, .06); --surface: #172133; --surface-2: #1c283c; --surface-3: #233149;
    --ink: #e6ecf6; --ink-2: #b4bfd2; --muted: #8592a8; --line: #2b3a54;
    --accent: #2bb5b8; --accent-ink: #062224; --accent-soft: #143c43; --accent-strong: #5fd3d4;
    --sun: #f6c35c; --sun-soft: #3a3020; --good: #3ccf84; --good-soft: #143a2a; --bad: #ff7083; --bad-soft: #43202a; --warn: #f0b545;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1624; --dot: rgba(150, 185, 235, .06); --surface: #172133; --surface-2: #1c283c; --surface-3: #233149;
  --ink: #e6ecf6; --ink-2: #b4bfd2; --muted: #8592a8; --line: #2b3a54;
  --accent: #2bb5b8; --accent-ink: #062224; --accent-soft: #143c43; --accent-strong: #5fd3d4;
  --sun: #f6c35c; --sun-soft: #3a3020; --good: #3ccf84; --good-soft: #143a2a; --bad: #ff7083; --bad-soft: #43202a; --warn: #f0b545;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.6px), radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 46px 46px, 29px 29px; background-position: 0 0, 13px 19px;
  color: var(--ink); font-family: var(--font-body); font-size: 15.5px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 5vw, 2.1rem); } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.eyebrow { font-size: .73rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

#app { max-width: 760px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: 0 16px; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.brand svg { width: 38px; height: 38px; }
.top-right { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 13px; flex: none; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--sun-soft); color: var(--ink); font-size: .8rem; font-weight: 600; border: 1px solid color-mix(in srgb, var(--sun) 55%, transparent); }
.pill.off { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }

#view { flex: 1; padding: 8px 0 110px; display: flex; flex-direction: column; gap: 16px; outline: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 15px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; box-shadow: 0 4px 0 var(--accent-strong); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-strong); }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.white { background: #fff; color: #0a4f54; box-shadow: 0 4px 0 rgba(0, 0, 0, .18); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .9rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn svg { width: 19px; height: 19px; }

/* create */
.hero { background: linear-gradient(140deg, #0d7f86, #116a9a); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero h2 { font-size: 1.55rem; max-width: 14ch; }
.hero p { opacity: .9; max-width: 30ch; }
.hero .art { position: absolute; right: -6px; top: 10px; width: 150px; opacity: .95; pointer-events: none; }
.hero.drag { outline: 3px dashed var(--sun); outline-offset: -8px; }
.hero .drop { font-size: .82rem; opacity: .8; text-align: center; }
.hero details { font-size: .85rem; }
.hero summary { cursor: pointer; opacity: .9; }
.hero select { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .4); color: #fff; border-radius: 9px; padding: 3px 8px; margin-left: 8px; }
.hero select option { color: #18233a; }
.tile { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.tile:hover { border-color: var(--accent); }
.tile .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; margin-bottom: 6px; }
.tile .ic svg { width: 24px; height: 24px; }
.tile .ic.face { background: none; } .tile .ic.face svg { width: 46px; height: 46px; }
.tile b { font-family: var(--font-display); font-size: 1.05rem; }
.tile span { font-size: .85rem; color: var(--ink-2); }
textarea, .field { width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
textarea { min-height: 170px; resize: vertical; font-family: var(--font-mono); font-size: .86rem; }
.resume { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; }
.ring { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring i { width: 34px; height: 34px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--accent); }
.ring svg { width: 16px; height: 16px; }
.busy { display: flex; align-items: center; gap: 12px; }
.busy svg { width: 44px; height: 44px; animation: bob .6s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-6px) rotate(6deg); } }

/* library */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 13px; padding: 8px 14px; font-weight: 600; font-size: .9rem; box-shadow: 0 3px 0 var(--line); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 var(--accent-strong); }
.chip em { font-style: normal; opacity: .75; margin-left: 5px; }
.qcard { position: relative; }
.qcard .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; flex: none; font-family: var(--font-display); font-weight: 600; }
.qcard h3 { overflow-wrap: anywhere; }
.qcard .meta { font-size: .82rem; color: var(--muted); }
.bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 8px; background: var(--accent); transition: width .3s; }
.menu { position: absolute; right: 14px; top: 56px; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 200px; }
.menu button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 10px; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--bad); }

/* quiz */
.qhead { display: flex; align-items: center; gap: 12px; }
.qhead h2 { flex: 1; text-align: center; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; }
.prog .bar { flex: 1; height: 12px; }
.nums { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.nums button { flex: none; width: 42px; height: 42px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; box-shadow: 0 3px 0 var(--line); font-variant-numeric: tabular-nums; }
.nums button.ok { background: var(--good-soft); border-color: var(--good); color: var(--good); box-shadow: 0 3px 0 var(--good); }
.nums button.no { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); box-shadow: 0 3px 0 var(--bad); }
.nums button.cur { outline: 3px solid var(--accent); outline-offset: 1px; }
.stem { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.stem .katex { font-size: 1em; }
pre.ctx { margin: 0; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-family: var(--font-mono); font-size: .72rem; line-height: 1.35; overflow-x: auto; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 13px 14px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); box-shadow: 0 4px 0 var(--line); font-weight: 500; overflow-wrap: anywhere; }
.opt:not([disabled]):hover { border-color: var(--accent); }
.opt:not([disabled]):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt .k { width: 34px; height: 34px; flex: none; border-radius: 11px; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; }
.opt .mk { margin-left: auto; flex: none; width: 24px; height: 24px; }
.opt[disabled] { cursor: default; color: var(--ink-2); }
.opt.ok { border-color: var(--good); background: var(--good-soft); box-shadow: 0 4px 0 var(--good); color: var(--ink); }
.opt.ok .k { background: var(--good); color: #fff; }
.opt.no { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 4px 0 var(--bad); color: var(--ink); }
.opt.no .k { background: var(--bad); color: #fff; }
.verdict { border-radius: var(--r-lg); padding: 16px; display: grid; gap: 12px; border: 1.5px solid; animation: rise .3s ease-out; }
.verdict.ok { background: var(--good-soft); border-color: var(--good); }
.verdict.no { background: var(--bad-soft); border-color: var(--bad); }
.verdict h3 { display: flex; align-items: center; gap: 8px; }
.verdict.ok h3 { color: var(--good); } .verdict.no h3 { color: var(--bad); }
.verdict h3 svg { width: 24px; height: 24px; }
.verdict .why { font-size: .92rem; }
.verdict .nq-chip { justify-self: start; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

/* results */
.score { text-align: center; }
.score .big { font-family: var(--font-display); font-size: 3.2rem; font-weight: 600; line-height: 1; color: var(--accent); }
.fix { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; }
.fix .a { font-size: .9rem; } .fix .a.ok { color: var(--good); } .fix .a.no { color: var(--bad); }

/* tutor tab */
.tutor-hero { text-align: center; display: grid; justify-items: center; gap: 6px; padding: 18px 0 4px; }
.tutor-hero svg { width: 96px; height: 96px; animation: bob 1.4s ease-in-out infinite alternate; }
.sugs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sugs button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 12px 14px; font-weight: 500; box-shadow: 0 3px 0 var(--line); }
.sugs button:hover { border-color: var(--accent); }
.askbar { display: flex; gap: 8px; padding: 8px; border-radius: 20px; background: var(--surface); border: 1.5px solid var(--accent); box-shadow: var(--shadow); }
.askbar input { flex: 1; min-width: 0; border: 0; background: none; padding: 0 8px; outline: none; }
.hist button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 10px 8px; border-radius: 12px; }
.hist button:hover { background: var(--surface-2); }
.hist svg { width: 18px; height: 18px; color: var(--muted); flex: none; }

/* tabs */
.tabs { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20; display: flex; gap: 4px; padding: 6px; border-radius: 22px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.tabs button { display: grid; justify-items: center; gap: 2px; min-width: 92px; padding: 7px 10px; border: 0; background: none; border-radius: 16px; font-size: .76rem; font-weight: 600; color: var(--ink-2); }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
body.in-quiz .tabs { display: none; }
body.in-quiz #view { padding-bottom: 24px; }

.toasts { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 2000; display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: .9rem; box-shadow: var(--shadow); animation: rise .25s ease-out; }
.toast.err { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
