/* ---- design tokens ------------------------------------------------------------
   One scale for everything: spacing s1..s6, radii r-sm/md/lg, type xs..2xl, and a
   44px minimum for anything you tap. One dark theme: warm coal, cream everywhere (buttons, progress). */
:root {
  color-scheme: dark;
  --bg: #1e1b17;
  --surface: #2a2621;
  --surface-2: #3c362d;
  --text: #f1ebdd;
  --muted: #a39a88;
  --line: #3c362d;
  --accent: #e4d9bf;
  --accent-dark: #a89c78;
  --accent-soft: #3a3428;
  --accent-ink: #e4d9bf;
  --on-accent: #2b2415;
  --teal: #e4d9bf;
  --teal-soft: #3a3428;
  --on-teal: #2b2415;
  --ok: #7fd39a;
  --ok-soft: #1f3f22;
  --warn: #f2b84b;
  --danger: #f0796a;
  --gold: #f2be55;
  --flame: #ffc46b;
  --flame-soft: #3a2c14;
  --shadow: 0 0 #0000;
  --serif: Georgia, "Times New Roman", serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-sm: 10px; --r-md: 16px; --r-lg: 20px;
  --fs-xs: .75rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-lead: 1.25rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;
  --tap: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: var(--fs-md)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  min-height: 100vh;
  min-height: 100dvh;
}
main {
  max-width: 560px; margin: 0 auto; padding: var(--s4); min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; gap: var(--s4);
}
body.has-tabs main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
body.has-dock main { padding-bottom: calc(var(--dock-height, 208px) + env(safe-area-inset-bottom)); }
.screen { display: flex; flex-direction: column; gap: var(--s4); flex: 1; animation: screen-in .45s ease-out; }
.screen.forward { animation-name: screen-forward; }
.screen.back { animation-name: screen-back; }
.screen.plain { animation: none; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes screen-forward { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes screen-back { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { margin: 0; }
h1 { font-family: var(--serif); font-size: var(--fs-2xl); font-weight: 400; line-height: 1.15; }
h2 { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.grow { flex: 1; min-width: 0; }

/* ---- surfaces ---- */
.card {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4); box-shadow: var(--shadow);
}
.card > * + * { margin-top: var(--s3); }
.banner { position: sticky; top: 0; z-index: 8; background: var(--warn); color: #fff; text-align: center; padding: var(--s2) var(--s3); font-size: var(--fs-sm); }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: var(--tap); flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: var(--s2); }
.status-chips { display: flex; gap: var(--s2); }
.chip-s {
  display: inline-flex; align-items: center; gap: var(--s1); height: 32px; padding: 0 var(--s3);
  border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 700; font-size: var(--fs-sm);
}
.chip-s .icon { width: 18px; height: 18px; }
.chip-s.flame { color: var(--flame); background: var(--flame-soft); border-color: var(--flame-soft); }
.chip-s.goal { color: var(--muted); }
.chip-s.goal.done { color: var(--ok); border-color: var(--ok); }

/* ---- buttons ---- */
button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: var(--r-md); min-height: var(--tap); padding: var(--s3) var(--s4);
  background: var(--accent); color: var(--on-accent); cursor: pointer; width: 100%;
  box-shadow: 0 3px 0 var(--accent-dark); transition: transform .08s, box-shadow .08s, opacity .15s;
  -webkit-tap-highlight-color: transparent; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
}
button:active, .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-dark); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--accent); box-shadow: none; border: 1px solid var(--line); font-weight: 500; }
button.ghost:active, button.link:active, .icon-btn:active { transform: none; }
button.danger { background: transparent; color: var(--danger); box-shadow: none; border: 1px solid var(--line); }
button.link { background: none; color: var(--muted); box-shadow: none; width: auto; padding: var(--s2); font-weight: 500; }
a.btn { text-decoration: none; color: var(--on-accent); }
.icon-btn {
  width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0; border-radius: 50%;
  background: transparent; color: var(--text); box-shadow: none; flex: none;
}
.icon-btn .icon { width: 24px; height: 24px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- forms ---- */
input, textarea, select {
  font: inherit; width: 100%; min-height: var(--tap); padding: var(--s3); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 96px; }
label.field, div.field { display: flex; flex-direction: column; gap: var(--s1); font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
form { display: flex; flex-direction: column; gap: var(--s3); }
.error { color: var(--danger); font-size: var(--fs-sm); min-height: 1.2em; }

/* ---- bottom tabs: a floating pill, a highlight slides to the active tab, which shows its name ---- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 5;
  width: min(calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)), 400px); display: flex; gap: var(--s1); padding: 5px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px;
}
.tabs[hidden] { display: none; }
.tab-hl {
  position: absolute; top: 5px; bottom: 5px; left: 0; border-radius: 999px; background: var(--accent); z-index: 0;
  transition: transform .55s cubic-bezier(.4, 0, .2, 1), width .55s cubic-bezier(.4, 0, .2, 1);
}
.tab {
  position: relative; z-index: 1; flex: 1; width: auto; min-height: 46px; display: flex; flex-direction: row; align-items: center; justify-content: center;
  background: none; box-shadow: none; border-radius: 999px; padding: 0 var(--s3); color: var(--muted); font-size: var(--fs-sm); font-weight: 600;
  transition: flex-grow .55s cubic-bezier(.4, 0, .2, 1), color .35s;
}
.tab:active { transform: none; }
.tab .icon { width: 25px; height: 25px; }
.tab span { max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap; transition: max-width .55s cubic-bezier(.4, 0, .2, 1), opacity .45s, margin .55s cubic-bezier(.4, 0, .2, 1); }
.tab.active { flex-grow: 1.9; color: var(--on-accent); }
.tab.active span { max-width: 96px; opacity: 1; margin-left: var(--s2); }

/* ---- home ---- */
.hero { display: flex; align-items: center; gap: var(--s4); }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: var(--teal); transition: stroke-dashoffset 1.2s cubic-bezier(.3, 0, .2, 1), stroke .5s; }
.ring.done .bar { stroke: var(--ok); }
.ring.empty .bar { display: none; }
.ring.pulse { animation: ring-pulse .8s ease-in-out; }
@keyframes ring-pulse { 0% { transform: scale(1); } 45% { transform: scale(1.07); } 100% { transform: scale(1); } }
.ring .label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; font-weight: 800; font-size: var(--fs-2xl); }
.ring .label small { display: block; font-weight: 600; color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.hero-text { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.hero-text b { font-family: var(--serif); font-weight: 400; font-size: var(--fs-xl); line-height: 1.2; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s1); text-align: center; }
.week .d { display: flex; flex-direction: column; align-items: center; gap: var(--s1); font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); color: var(--on-accent); }
.dot .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.dot.some { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }
.dot.full { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.dot.today { box-shadow: 0 0 0 3px var(--teal-soft); }
.cta-sub { font-size: var(--fs-xs); font-weight: 500; opacity: .85; }
.cta { min-height: 56px; font-size: var(--fs-lg); flex-direction: column; gap: 0; }
.decks { padding: var(--s1) var(--s4); }
.deck {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; min-height: 52px;
  background: none; color: var(--text); box-shadow: none; border-radius: 0; border-top: 1px solid var(--line); padding: var(--s3) 0; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 400; text-align: left;
}
.deck:first-child { border-top: 0; }
.deck:active { transform: none; }
.deck .meta { color: var(--muted); font-size: var(--fs-xs); font-weight: 500; display: block; }
.deck-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.deck-row { display: flex; align-items: center; gap: var(--s2); border-top: 1px solid var(--line); }
.deck-row:first-child { border-top: 0; }
.deck-row .deck { flex: 1; min-width: 0; }
.deck-row > .ghost { width: auto; flex: none; font-size: var(--fs-xs); }
.mistake-row { min-height: 0; padding: var(--s3); display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: var(--s2); color: var(--text); }
.mistake-row > * + * { margin-top: 0; }
.history-chart { display: grid; grid-template-columns: repeat(30, 1fr); height: 120px; gap: 2px; margin: var(--s4) 0 var(--s2); }
.history-column { display: flex; align-items: flex-end; justify-content: center; background: var(--surface-2); }
.history-column i { display: block; width: 100%; background: var(--accent); opacity: .6; }
.history-column.selected i { opacity: 1; }
.deck-progress { display: block; margin-top: var(--s2); }
.deck-progress .bar-fill { display: block; }
.deck-progress-help summary { min-height: var(--tap); cursor: pointer; }
.badge { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 2px var(--s3); font-weight: 700; font-size: var(--fs-sm); min-width: 28px; text-align: center; }
.badge.zero { background: var(--surface-2); color: var(--muted); }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); border-radius: 6px; transition: width 1s cubic-bezier(.3, 0, .2, 1); }
.exam-days { font-family: var(--serif); font-size: var(--fs-2xl); font-weight: 400; line-height: 1; }

/* ---- empty states and skeletons ---- */
.empty { text-align: center; padding: var(--s6) var(--s4); display: flex; flex-direction: column; align-items: center; gap: var(--s3); color: var(--muted); }
.empty .icon { width: 44px; height: 44px; color: var(--teal); stroke-width: 1.5; }
.empty b { color: var(--text); font-family: var(--serif); font-weight: 400; font-size: var(--fs-xl); }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.toast {
  position: fixed; left: max(5vw, env(safe-area-inset-left)); right: max(5vw, env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom)); transform: none; z-index: 9;
  background: var(--text); color: var(--bg); padding: var(--s3) var(--s4); border-radius: 999px; font-size: var(--fs-sm); font-weight: 600;
  box-shadow: var(--shadow); max-width: 560px; margin: 0 auto; animation: screen-in .35s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }

/* ---- card session ---- */
.session-top { display: flex; align-items: center; gap: var(--s2); }
.session-top .bar-track { flex: 1; }
.flash {
  background: var(--surface); border: 1.5px solid var(--line); font-family: var(--serif); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: var(--s5) var(--s4); min-height: 240px; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: var(--s4);
  font-size: var(--fs-xl); text-align: center; overflow-wrap: anywhere; white-space: pre-wrap; animation: pop .5s ease-out;
}
.flash hr { width: 100%; border: 0; border-top: 1px dashed var(--line); margin: 0; }
.flash .deckname { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.flash .katex-display { overflow-x: auto; overflow-y: hidden; }
.flash.flip { animation: flip .6s ease-in-out; }
.answer-in { animation: pop .5s ease-out; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: var(--s3) max(var(--s4), env(safe-area-inset-right)) calc(var(--s5) + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-left));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.dock-inner { max-width: 560px; margin: 0 auto; }
.rates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.rate { min-height: 76px; padding: var(--s3) var(--s2); flex-direction: column; gap: 2px; line-height: 1.15; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.rate small { font-weight: 500; opacity: .85; font-size: var(--fs-sm); }
.rate.again { background: #4a2420; color: #ffb3a8; box-shadow: 0 4px 0 #2f1613; }
.rate.hard { background: #4a3512; color: #ffd08a; box-shadow: 0 4px 0 #2e200a; }
.rate.good { background: #1f3f22; color: #a9e3a0; box-shadow: 0 4px 0 #11260f; }
.rate.easy { background: #1d3560; color: #9ec1ff; box-shadow: 0 4px 0 #0f2040; }
.rate:active { box-shadow: 0 1px 0 #0003; }
.done-card { text-align: center; padding: var(--s6) var(--s4); }
.done-card .big { font-size: 3rem; line-height: 1; }
.flash.exit-hard { animation: out .38s ease-in-out forwards; border-color: #f2b84b; }
.flash.exit-good { animation: fly-up .45s ease-in-out forwards; border-color: #7fd39a; }
.flash.exit-easy { animation: fly-up .45s ease-in-out forwards; border-color: #9ec1ff; }
.flash.exit-again { animation: shake-out .65s ease-in-out forwards; border-color: #f0796a; }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }
@keyframes flip { 0% { transform: perspective(900px) rotateX(0); } 50% { transform: perspective(900px) rotateX(88deg); } 100% { transform: perspective(900px) rotateX(0); } }
@keyframes out { to { transform: translateX(-120%); opacity: 0; } }
@keyframes fly-up { to { transform: translateY(-130%) scale(.95); opacity: 0; } }
@keyframes shake-out {
  0% { transform: none; opacity: 1; } 15% { transform: translateX(-10px); } 30% { transform: translateX(10px); } 45% { transform: translateX(-8px); }
  60% { transform: translateX(8px); } 75% { transform: none; opacity: 1; } 100% { transform: scale(.96); opacity: 0; }
}
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .8; } }

/* ---- news ---- */
.chips { display: flex; gap: var(--s2); }
.chip { width: auto; min-height: 36px; padding: var(--s2) var(--s4); border-radius: 999px; background: var(--surface); color: var(--text);
  box-shadow: none; border: 1px solid var(--line); font-weight: 600; font-size: var(--fs-sm); }
.chip:active { transform: none; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.day { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); padding: var(--s2) var(--s1) 0; }
.news-list { padding: var(--s1) var(--s4); }
.lead {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); width: 100%; text-align: left;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1.5px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s4); font-weight: 400; justify-content: flex-start;
}
.lead:active { transform: none; }
.lead-title { font-family: var(--serif); font-size: var(--fs-lead); font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
.lead-reason { font-size: var(--fs-md); color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.lead.is-read .lead-title { color: var(--muted); }
.news-row { display: block; width: 100%; text-align: left; background: none; box-shadow: none; color: var(--text);
  border-radius: 0; border-top: 1px solid var(--line); padding: var(--s3) 0; font-weight: 500; min-height: 64px; }
.news-row:first-child { border-top: 0; }
.news-row:active { transform: none; }
.news-title { display: block; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; }
.news-row.is-read .news-title { color: var(--muted); }
.news-meta { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--muted); margin-top: 3px; flex-wrap: wrap; }
.lead .news-meta { margin-top: 0; }
.rating-badge { color: var(--gold); font-weight: 800; }
.news-h { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
.news-reason { margin: 0; overflow-wrap: anywhere; font-size: var(--fs-lg); }
.blk-name { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: var(--s2); }
.blk-text { margin: var(--s1) 0 0; overflow-wrap: anywhere; line-height: 1.5; }
.blk-text.first { font-family: var(--serif); font-size: var(--fs-lg); }
.news-view { display: flex; flex-direction: column; gap: var(--s3); }
.rate-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s2); }
.rate-btn { min-height: 52px; font-size: var(--fs-xl); background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.rate-btn:active { transform: none; }
.rate-btn.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---- settings and statistics ---- */
.list { padding: 0 var(--s4); }
.item { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; border-top: 1px solid var(--line); padding: var(--s2) 0; flex-wrap: wrap; }
.item:first-child { border-top: 0; }
.item > :first-child { min-width: 0; }
.item b { font-weight: 600; display: block; }
.item .hint { font-size: var(--fs-xs); color: var(--muted); display: block; }
button.item { width: 100%; background: none; color: var(--text); box-shadow: none; border-radius: 0; font-weight: 600; text-align: left; }
button.item:active { transform: none; }
.stepper { display: flex; align-items: center; gap: var(--s2); }
.stepper button { width: var(--tap); padding: 0; background: var(--surface-2); color: var(--text); box-shadow: none; border-radius: 50%; font-size: var(--fs-xl); }
.stepper output { min-width: 34px; text-align: center; font-weight: 800; font-size: var(--fs-lg); }
.switch { width: 52px; min-height: 32px; height: 32px; padding: 0; border-radius: 999px; background: var(--line); box-shadow: none; position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }
.item input[type="date"], .item select { width: auto; max-width: 190px; min-height: 40px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); }
.stat b { display: block; font-family: var(--serif); font-size: var(--fs-2xl); font-weight: 400; line-height: 1.1; }
.stat span { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat .c { aspect-ratio: 1; border-radius: 6px; background: var(--surface-2); }
.heat .c.l1 { background: color-mix(in srgb, var(--teal) 40%, var(--surface-2)); }
.heat .c.l2 { background: color-mix(in srgb, var(--teal) 70%, var(--surface-2)); }
.heat .c.l3 { background: var(--teal); }
.heat .c.blank { background: transparent; }
.heat .head { text-align: center; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s2); align-items: end; height: 120px; }
.bars .b { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: var(--s1); height: 100%; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.bars .b i { display: block; width: 100%; background: var(--teal); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bars .b.zero i { background: var(--surface-2); }
.preview { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3); font-size: var(--fs-md); overflow-wrap: anywhere; white-space: pre-wrap; }
.preview .label { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 700; text-transform: uppercase; margin-bottom: var(--s1); }

/* ---- lists appear one after another, from below ---- */
@keyframes row-in { from { opacity: 0; } }
.decks > *, .news-list > *, .list > *, .stat-grid > *, .lead { animation: row-in .6s ease-out backwards; }
.decks > :nth-child(2), .news-list > :nth-child(2), .list > :nth-child(2), .stat-grid > :nth-child(2) { animation-delay: 80ms; }
.decks > :nth-child(3), .news-list > :nth-child(3), .list > :nth-child(3), .stat-grid > :nth-child(3) { animation-delay: 160ms; }
.decks > :nth-child(4), .news-list > :nth-child(4), .list > :nth-child(4), .stat-grid > :nth-child(4) { animation-delay: 240ms; }
.decks > :nth-child(5), .news-list > :nth-child(5), .list > :nth-child(5), .stat-grid > :nth-child(5) { animation-delay: 320ms; }
.decks > :nth-child(6), .news-list > :nth-child(6), .list > :nth-child(6), .stat-grid > :nth-child(6) { animation-delay: 400ms; }
.decks > :nth-child(7), .news-list > :nth-child(7), .list > :nth-child(7), .stat-grid > :nth-child(7) { animation-delay: 480ms; }
.decks > :nth-child(8), .news-list > :nth-child(8), .list > :nth-child(8), .stat-grid > :nth-child(8) { animation-delay: 560ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}

/* ---- card browser, editor, link cards, pictures, help of the model, typed answer ---- */
button[hidden], input[hidden] { display: none; }
.chips.wrap { flex-wrap: wrap; }
.deck-cards { padding-left: var(--s3); border-top: 1px solid var(--line); }
.deck-cards[hidden], .ai-form[hidden], .ai-out[hidden] { display: none; }
.deck[aria-expanded="true"] { color: var(--accent); }
.item .clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); font-weight: 400; font-size: var(--fs-md); }
.card-row { padding-right: var(--s1); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: screen-in .3s ease-out; }
.sheet {
  width: min(100%, 560px); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s3) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--s1);
  max-height: 80vh; max-height: 80dvh; overflow-y: auto; overscroll-behavior: contain;
}
.sheet-title { font-family: var(--serif); font-size: var(--fs-lg); padding: var(--s2) 0 var(--s3); overflow-wrap: anywhere; }
.sheet-item.danger { color: var(--danger); border: 0; border-top: 1px solid var(--line); }
.card-img { display: block; max-width: 100%; max-height: 260px; margin: 0 auto; border-radius: var(--r-sm); object-fit: contain; }
.picture { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.picture .row { width: 100%; }
.picture .ghost { width: auto; flex: 1; }
.after-answer:empty { display: none; }
.ai { display: flex; flex-direction: column; gap: var(--s2); }
.ai-form { flex-direction: row; min-width: 0; }
.ai-form input { min-width: 0; }
.ai-form button { width: auto; flex: none; }
.ai-out { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; animation: pop .5s ease-out; }
.typed-form { gap: var(--s2); }
.typed { text-align: center; font-family: var(--serif); font-size: var(--fs-lg); }
.verdict { display: flex; flex-direction: column; gap: 2px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: var(--fs-md); font-weight: 700; white-space: normal; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--danger); }
button.weak { flex-direction: column; gap: 0; min-height: 56px; color: var(--accent); }
.check { width: 28px; height: 28px; min-height: 28px; padding: 0; border-radius: 8px; background: transparent; border: 2px solid var(--accent-dark); box-shadow: none; flex: none; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after { content: ""; width: 8px; height: 14px; border: solid var(--on-accent); border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -2px); }
.check:active { transform: none; }
.link-card { align-items: flex-start; padding: var(--s3) 0; }
.link-card .grow { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; flex: 1; overflow-wrap: anywhere; }
.link-card b { font-family: var(--serif); font-weight: 400; }
.day-chart { display: flex; align-items: flex-end; gap: 2px; height: 74px; }
.day-chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.day-chart i { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 0; }
.day-chart i.again { background: var(--danger); }
input[type="search"] { -webkit-appearance: none; appearance: none; }

/* ---- news topics: a scrolling row of chips and a coloured label on every news ---- */
.chips.scroll { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s6) 0 var(--s4); overscroll-behavior-x: contain; touch-action: pan-x pan-y; cursor: grab;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - var(--s6)), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - var(--s6)), transparent); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll, .chips.compact { gap: var(--s1); }
.chips.scroll .chip, .chips.compact .chip { flex: none; min-height: 32px; padding: var(--s1) 10px; font-size: var(--fs-xs); }
.topic-label { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px var(--s2); background: var(--accent-soft); color: var(--accent-ink); }
.topic-label[role="button"] { cursor: pointer; }
.t-sec { background: #3a2c2a; color: #f0a090; }
.t-dev { background: #2a3040; color: #9ab6f0; }
.t-ai { background: #2a3a30; color: #8fd3a8; }
.t-world { background: #3a3428; color: #e4d9bf; }
.t-useful { background: #3a3320; color: #f2c66b; }
.t-runet { background: #34303f; color: #c4b5f0; }
