@font-face { font-family: Onest; font-weight: 100 500; font-display: swap; src: url(onest-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Onest; font-weight: 100 500; font-display: swap; src: url(onest-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Onest; font-weight: 100 500; font-display: swap; src: url(onest-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; font-weight: 600 900; font-display: swap; src: url(onest-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Onest; font-weight: 600 900; font-display: swap; src: url(onest-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Onest; font-weight: 600 900; font-display: swap; src: url(onest-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
/* Math symbols (powers, indices, roots, π, ≤ ≥) from one font, so a² and a⁵ match. Subset of GNU FreeFont (GPL with font exception).
   Each weight range lists Onest and its math face together: Chrome only mixes faces whose descriptors are identical. */
@font-face { font-family: Onest; font-weight: 100 500; font-display: swap; src: url(math-regular.woff2) format('woff2'); unicode-range: U+00B2-00B3, U+00B9, U+2070-209F, U+02E3, U+221A-221C, U+03C0, U+2260, U+2264-2265, U+2248, U+221E; }
@font-face { font-family: Onest; font-weight: 600 900; font-display: swap; src: url(math-bold.woff2) format('woff2'); unicode-range: U+00B2-00B3, U+00B9, U+2070-209F, U+02E3, U+221A-221C, U+03C0, U+2260, U+2264-2265, U+2248, U+221E; }
:root { --sab: max(0px, max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)) - 14px);
  --sat: calc(max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px)); }
/* full screen: the top belongs to the phone and to Telegram's own buttons */
[data-root="1"] { padding-top: var(--sat); }
[data-strip] { pointer-events: none; background: #0C87F5; opacity: 0; transition: opacity 120ms; }
[data-scrolled] > [data-strip] { opacity: 1; }
/* a pinned title bar: rounded once the blue top under it has gone */
[data-scrolled] [data-bar] { border-radius: 0 0 28px 28px; }
[data-theme="dark"] [data-strip] { background: #172B42; }
/* a title bar the chat passes under */
[data-glass] { background: rgba(237, 245, 253, 0.8); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); box-shadow: 0 1px 0 rgba(11, 31, 56, 0.06); }
[data-theme="dark"] [data-glass] { background: rgba(15, 21, 29, 0.8); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06); }
[data-root] [style*="overflow-y: auto"] > * { flex-shrink: 0; }
/* no rubber band past the top: it showed the page behind the blue top */
[data-root] [style*="overflow-y: auto"] { overscroll-behavior-y: none; }
/* focus: the field's own rounded edge, not a square frame */
:is(input, textarea):focus { outline: none; border-color: #0070E0 !important; }
[data-search]:focus-within { box-shadow: inset 0 0 0 2px #0070E0; }
[data-theme="dark"] :is(input, textarea):focus { border-color: #62AEFF !important; }
[data-theme="dark"] [data-search]:focus-within { box-shadow: inset 0 0 0 2px #62AEFF; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #EDF5FD; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
html[data-theme="light"] body { background: url(girih.svg) repeat-x center top / auto 100% #EDF5FD; }
html[data-theme="dark"], html[data-theme="dark"] body { background: #0F151D; }
html[data-theme="dark"] body { background: url(girih-dark.svg) repeat-x center top / auto 100% #0F151D; }
#app { position: fixed; top: 0; bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: 520px; }
a, button { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
[data-root] ::-webkit-scrollbar { width: 0; height: 0; }
[data-root] * { scrollbar-width: none; }

/* opening screen: there before any script, until the first data arrive */
#splash { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: #0C87F5; color: #FFFFFF; font-family: Onest, Arial, sans-serif; transition: opacity 220ms ease-out; }
#splash.out { opacity: 0; pointer-events: none; }
#splash img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: left top; }
#splash .logo { position: relative; width: 190px; overflow: visible; }
#splash strong { position: relative; font-size: 34px; line-height: 1; font-weight: 800; letter-spacing: -0.025em; }
#splash .back { transform: rotate(-20deg); transform-origin: 75px 75px; animation: sp-back 460ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
#splash .front { transform: rotate(13deg); transform-origin: 127px 95px; animation: sp-front 460ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
#splash .check { stroke-dasharray: 1.01; animation: sp-check 320ms 240ms ease-out both; }
#splash .stars > * { opacity: 0.92; animation: sp-star 360ms 380ms ease-out backwards; }
#splash strong { animation: sp-name 320ms 160ms ease-out both; }
@keyframes sp-back { from { transform: rotate(4deg) scale(0.86); opacity: 0.4; } }
@keyframes sp-front { from { transform: rotate(-4deg) scale(0.86); } }
@keyframes sp-check { from { stroke-dashoffset: 1.01; } }
@keyframes sp-star { from { opacity: 0; } }
@keyframes sp-name { from { opacity: 0; translate: 0 8px; } }

/* ── movement ── */
:root { --ease: cubic-bezier(0.2, 0.8, 0.2, 1); }
/* pressing: like a pane of glass under a finger, the thing swells a little
   and catches light, then springs back when let go (no sinking in) */
:root { --spring: cubic-bezier(0.34, 1.56, 0.64, 1); }
a, button, label:has(> input[type="file"]) { transition: scale 420ms var(--spring), filter 280ms ease-out, background-color 180ms ease-out, color 180ms ease-out; }
:is(a, button, label:has(> input[type="file"])):active:not(:disabled) { scale: 1.04; filter: brightness(1.06) saturate(1.08); transition-duration: 160ms, 120ms, 180ms, 180ms; transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1), ease-out, ease-out, ease-out; }
[data-theme="dark"] :is(a, button, label:has(> input[type="file"])):active:not(:disabled) { filter: brightness(1.18); }
/* wide ones (cards, rows, full-width buttons) swell less */
:is(a[style*="min-height: 60px"], a[style*="min-height: 72px"], [data-card], [role="listitem"], [style*="width: 100%"], [style*="min-height: 92px"], [style*="height: 54px"], [style*="height: 56px"], [style*="height: 58px"], [data-root] > [style*="overflow-y: auto"] [style*="border-radius: 2"]):is(a, button):active:not(:disabled, nav *) { scale: 1.015; }
button[role="switch"]:active { scale: 1.03; }
nav > a:active { scale: 1.07 !important; }
[data-sheet] > button { transition: none; }
[data-sheet] > button:active { scale: 1; filter: none; }
input, textarea, [data-search] { transition: border-color 160ms, box-shadow 160ms; }
/* changing screens: the ground and the bottom menu stay, the rest comes in */
[data-enter="right"] > [data-root] > :not(nav, [data-topo], [data-strip], [data-sheet], canvas) { animation: go-right 300ms var(--ease) backwards; }
[data-enter="left"] > [data-root] > :not(nav, [data-topo], [data-strip], [data-sheet], canvas) { animation: go-left 300ms var(--ease) backwards; }
[data-enter="rise"] > [data-root] { animation: go-rise 300ms var(--ease) backwards; }
[data-enter] nav a[aria-current] svg { animation: go-tab 320ms cubic-bezier(0.3, 1.4, 0.5, 1); }
[data-enter="soft"] > [data-root] > :not(nav, [data-topo], [data-strip], [data-sheet], canvas) { animation: qz-fade 240ms ease-out backwards; }
@keyframes go-right { from { opacity: 0; translate: 22px 0; } }
@keyframes go-left { from { opacity: 0; translate: -22px 0; } }
@keyframes go-rise { from { opacity: 0; scale: 0.975; } }
@keyframes go-tab { from { scale: 0.78; } }
@keyframes qz-score { from { opacity: 0; scale: 0.7; } }
/* Weekly Top: the clock keeps time, a ring pulses out of it */
@keyframes tp-hand { to { rotate: 360deg; } }
@keyframes tp-halo { 0% { scale: 1; opacity: 0.85; } 70%, 100% { scale: 1.55; opacity: 0; } }
@keyframes tp-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }
@keyframes tp-twinkle { 0%, 100% { opacity: 0.35; scale: 0.7; } 50% { opacity: 1; scale: 1; } }
@keyframes tp-bob { 0%, 100% { scale: 1; } 12% { scale: 1.14; } 24% { scale: 1; } }
/* sheets go the way they came */
[data-closing] { pointer-events: none; }
[data-closing] > button { opacity: 0; transition: opacity 190ms ease-in !important; }
[data-closing] > [role="dialog"] { translate: 0 100%; transition: translate 190ms cubic-bezier(0.5, 0, 0.9, 0.5); }
/* waiting for the server */
[data-wait] { align-self: center; width: 34px; height: 34px; border-radius: 11px; background: #0C87F5; animation: wait 900ms ease-in-out 120ms infinite alternate both; }
@keyframes wait { from { opacity: 0.15; transform: rotate(-12deg) scale(0.8); } to { opacity: 0.6; transform: rotate(13deg); } }
/* the blinking cursor: without its own colour iOS paints it in Telegram's tint, which may be invisible here */
input, textarea { caret-color: #0070E0; -webkit-user-select: text; user-select: text; }
[data-theme="dark"] :is(input, textarea) { caret-color: #62AEFF; }

/* ── wide screens (desktop Telegram, tablets in landscape) ──
   The phone layout above stays as it is. Here: a side menu for every
   screen, the screens next to it, content centred at a readable width,
   lists and categories in columns, sheets as dialogs. */
html.desk { --sat: 0px; --sab: 0px; --sa-t: 0px; --csa-t: 0px; }
.side { display: none; }
.stage { position: absolute; inset: 0; }
.stage > [data-screen] { isolation: isolate; }
@media (min-width: 960px) {
  #app { max-width: none; }
  .side { position: absolute; z-index: 4; left: 0; top: 0; bottom: 0; width: 264px; box-sizing: border-box; padding: calc(22px + var(--sat)) 16px 22px;
    display: flex; flex-direction: column; gap: 18px; background: #FFFFFF; border-right: 1px solid #DCE8F4; font-family: Onest, Arial, sans-serif; }
  [data-theme="dark"] .side { background: #19212C; border-right-color: #2B3747; }
  .stage { left: 264px; }
  .frame.focus .side { display: none; }
  .frame.focus .stage { left: 0; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; text-decoration: none; color: #0B1F38; }
  [data-theme="dark"] .brand { color: #EAF0F7; }
  .brand strong { font-size: 24px; font-weight: 800; letter-spacing: -0.025em; }
  /* the bottom bar, as a vertical menu */
  .side nav { position: static !important; height: auto !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; display: flex !important; flex-direction: column; align-items: stretch !important; gap: 4px; }
  .side nav > a { height: 52px !important; padding: 0 14px; border-radius: 16px; flex-direction: row !important; justify-content: flex-start !important; gap: 14px !important; font-size: 16px !important; }
  .side nav > a:hover { background: #EDF5FD; }
  [data-theme="dark"] .side nav > a:hover { background: #243040; }
  .side nav > a[aria-current="page"] { background: #E1F0FF; }
  [data-theme="dark"] .side nav > a[aria-current="page"] { background: #1E3048; }
  .side nav > a svg { width: 24px; height: 24px; }
  /* "Create a quiz": a full button at the top of the menu */
  .side nav > a[href="#/Create"] { order: -1; margin-bottom: 10px; width: auto !important; height: 54px !important; border-radius: 18px !important; justify-content: center !important; transform: none !important; gap: 10px !important; color: #FFFFFF !important; }
  .side nav > a[href="#/Create"]:hover { background: #0062C7 !important; }
  .side nav > a[href="#/Create"] svg { transform: none !important; width: 22px; height: 22px; }
  .side nav > a[href="#/Create"]::after { content: attr(aria-label); font-size: 16px; font-weight: 700; }
  .side nav > a, .side nav > a::after { text-decoration: none !important; }
  [data-theme="dark"] .side nav > a[href="#/Create"] { background: #1F7AE0 !important; }
  /* each screen's own bottom bar is replaced by the side menu */
  .stage [data-root] > nav { display: none !important; }

  /* content width: wide for lists, narrower for reading and forms */
  .stage [data-screen] { --w: 1040px; --pad: max(32px, calc((100% - var(--w)) / 2)); }
  .stage :is([data-screen="Intro"], [data-screen="Play"], [data-screen="Result"], [data-screen="Manage"], [data-screen="Questions"], [data-screen="Stats"],
    [data-screen="FromText"], [data-screen="FromFile"], [data-screen="ProfileEdit"], [data-screen="Certs"], [data-screen="Verify"], [data-screen="Support"],
    [data-screen="Create"], [data-screen="Top"]) { --w: 760px; }
  .stage [data-root] > div[style*="overflow-y: auto"],
  .stage [data-root] > header:not(:has(> img[src^="pattern"])),
  .stage [data-root] > div:not([data-topo]):not([data-strip]):not([data-sheet]):last-child:not([style*="overflow-y: auto"]) {
    padding-left: var(--pad) !important; padding-right: var(--pad) !important; }
  .stage [data-root] > div[style*="overflow-y: auto"] { padding-top: 28px !important; }
  .stage [data-root] > [data-glass] + div[style*="overflow-y: auto"] { padding-top: 84px !important; }
  /* blue fields with the pattern: cards at the content width */
  .stage [data-root] > header:has(> img[src^="pattern"]),
  .stage [data-root] > div[style*="overflow-y: auto"] > header:has(> img[src^="pattern"]) {
    box-sizing: border-box; width: auto; max-width: var(--w); margin: 24px max(32px, calc((100% - var(--w)) / 2)) 0; border-radius: 34px !important; }
  .stage [data-root] > div[style*="overflow-y: auto"] > header:has(> img[src^="pattern"]) { margin: 0; }
  .stage [data-root="flush"] > [data-strip] { display: none; }

  /* home: categories in one row of five */
  [data-d="cats"] { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; padding: 0 !important; }
  [data-d="cats"] > a { grid-column: auto !important; height: 150px !important; }
  .stage [data-screen="Main"] section, .stage [data-screen="Main"] header { padding-left: 0 !important; padding-right: 0 !important; }
  .stage [data-screen="Main"] section > div:first-child { padding: 0 !important; }
  /* catalog: category filters at their own width */
  .stage [data-screen="Catalog"] button[aria-pressed] { flex: 0 0 auto !important; min-width: 120px; }
  /* catalog and my quizzes: cards in columns */
  [data-d="rows"] { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: stretch; }
  [data-d="rows"] > :not(a) { grid-column: 1 / -1; }
  .stage [data-screen="MyQuizzes"] [data-root] > div[style*="overflow-y: auto"] { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-content: start; }
  .stage [data-screen="MyQuizzes"] [data-root] > div[style*="overflow-y: auto"] > a { grid-column: 1 / -1; }
  /* profile: the card on top, the groups in two columns */
  .stage [data-screen="Profile"] [data-root] > div[style*="overflow-y: auto"] { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; column-gap: 20px; }
  .stage [data-screen="Profile"] [data-root] > div[style*="overflow-y: auto"] > header { grid-column: 1 / -1; }
  .stage [data-screen="Profile"] section { padding: 0 !important; }
  /* profile: the whole card, numbers and their labels */
  .stage [data-screen="Profile"] header { height: auto !important; }
  /* taking a quiz: the question and answers centred; the wider card's
     tilted backing reaches lower, so the answers start a bit further down */
  .stage [data-screen="Play"] [data-scroll] > div:first-child { margin-bottom: 18px; }
  .stage [data-screen="Play"] [data-root] { padding-left: var(--pad) !important; padding-right: var(--pad) !important; padding-top: 28px !important; }
  .stage [data-screen="Play"] [data-scroll] { padding-left: 0 !important; padding-right: 0 !important; }
  .stage [data-screen="Play"] button:hover:not(:disabled) { filter: brightness(0.97); }
  /* actions kept at the bottom of a phone screen sit right under the content */
  .stage [data-root] > div[style*="overflow-y: auto"] [style*="margin-top: auto"],
  .stage [data-root] > div[style*="overflow-y: auto"] > [style*="margin-top: auto"] { margin-top: 12px !important; }
  /* sheets: dialogs in the middle */
  [data-sheet] { justify-content: center !important; align-items: center; }
  [data-sheet] > [role="dialog"] { width: min(520px, calc(100% - 48px)); border-radius: 32px !important; max-height: 80% !important; padding-bottom: 28px !important; }
  [data-sheet] > [role="dialog"] > span[aria-hidden="true"]:first-child { display: none; }
  /* the notice above the content, not above a bottom bar */
  .stage .toast { left: 50% !important; right: auto !important; bottom: 28px !important; width: min(480px, calc(100% - 48px)); transform: translateX(-50%); }
  /* pointer: hover marks */
  .stage [data-root] a[href^="#/"]:hover, .stage [data-root] button:hover { filter: brightness(0.98); }
  .stage ::-webkit-scrollbar { width: 10px; }
  .stage ::-webkit-scrollbar-thumb { background: rgba(11, 31, 56, 0.18); border-radius: 5px; border: 3px solid transparent; background-clip: content-box; }
  .stage [data-root] * { scrollbar-width: thin; }
}
/* day streak */
@keyframes st-flick { from { scale: 1 1; } to { scale: 0.93 1.07; } }
/* Home: the streak ring fills toward the next badge; its end dot breathes */
@keyframes st-arc { from { stroke-dashoffset: 113.1; } }
@keyframes st-arc-end { from { rotate: 0deg; } }
@keyframes st-dot { 0%, 100% { scale: 1; } 50% { scale: 1.3; } }
@keyframes st-in { from { opacity: 0; translate: 0 14px; scale: 0.94; } }
@keyframes st-day { 0% { scale: 0.5; } 65% { scale: 1.14; } 100% { scale: 1; } }
@keyframes st-breathe { 0%, 100% { scale: 1; } 50% { scale: 1.08; } }
@keyframes st-ring { from { box-shadow: 0 0 0 0 rgba(12, 135, 245, 0.5); } to { box-shadow: 0 0 0 16px rgba(12, 135, 245, 0); } }
@keyframes st-wiggle { 0%, 100% { rotate: 0deg; } 20% { rotate: -12deg; } 45% { rotate: 10deg; } 70% { rotate: -5deg; } }
@keyframes st-rise { from { opacity: 0; translate: 0 10px; } }
[data-press] { transition: scale 420ms var(--spring), filter 280ms ease-out; }

/* support chat: the reply button beside a message only where there is a pointer to hover with */
[data-reply-btn] { opacity: 0; pointer-events: none; transition: opacity 120ms; }
@media (hover: hover) { [data-mid]:hover [data-reply-btn] { opacity: 1; pointer-events: auto; } }
[data-mid][data-flash] [data-bubble] { animation: sup-flash 900ms ease-out !important; }
@keyframes sup-flash { 0%, 40% { filter: brightness(0.86); } }

/* the verified badge comes in with a small bounce */
@keyframes vf-in { from { opacity: 0; scale: 0.4; rotate: -40deg; } }
[data-theme="dark"] path[stroke="#0C87F5"] { stroke: #1F7AE0; }

/* the streak badge, earned: rays, a glow, the badge popping in, sweets */
@keyframes bw-fade { from { opacity: 0; } }
@keyframes bw-spin { to { rotate: 360deg; } }
@keyframes bw-glow { from { opacity: 0.55; scale: 0.9; } to { opacity: 1; scale: 1.08; } }
@keyframes bw-pop { 0% { opacity: 0; scale: 0.2; rotate: -60deg; } 60% { opacity: 1; scale: 1.14; rotate: 8deg; } 100% { scale: 1; rotate: 0deg; } }
@keyframes bw-float { 50% { translate: 0 -8px; rotate: 3deg; } }
@keyframes bw-rise { from { opacity: 0; translate: 0 16px; } }
[data-win][data-closing] { opacity: 0; scale: 1.03; transition: opacity 240ms ease-in, scale 240ms ease-in; }
@keyframes bw-land { 0% { opacity: 0; scale: 1.6; filter: blur(8px); } 70% { opacity: 1; scale: 0.96; filter: blur(0); } 100% { scale: 1; } }
@keyframes bw-shine { 0% { left: -60%; } 35%, 100% { left: 130%; } }

/* streak badges: a glint sweeps over them every few seconds */
.sb-shine { transform: skewX(-20deg) translateX(0); animation: sb-shine 5.200s cubic-bezier(0.45, 0, 0.3, 1) infinite; }
@keyframes sb-shine { 0% { translate: 0 0; } 16%, 100% { translate: 44px 0; } }
.sb-glint { transform-box: fill-box; transform-origin: center; opacity: 0; animation: sb-glint 5.200s ease-out infinite; }
@keyframes sb-glint { 0%, 12% { opacity: 0; scale: 0.2; } 18% { opacity: 1; scale: 1.15; } 26%, 100% { opacity: 0; scale: 0.4; } }

/* ── winter theme (admin panel: winter_theme; drawn by winter.js) ── */
#snow { position: fixed; inset: 0; z-index: 15; width: 100%; height: 100%; pointer-events: none; }
html.winter :is([data-snow="on"], [data-snow="text"], nav[data-garland]) { position: relative; }
html.winter :is([data-snow="tile"], [data-hat]):not([style*="position: absolute"]) { position: relative; }
.w-deco { position: absolute; z-index: 4; pointer-events: none; }
.w-drift { transform-origin: 50% 100%; transform: scaleY(0.05); transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1); filter: drop-shadow(0 1px 1.500px rgba(28, 66, 112, 0.32)); }
.w-heap { filter: drop-shadow(0 1.500px 1.500px rgba(20, 50, 90, 0.28)); }
.w-hat { transform: rotate(-16deg); transform-origin: 40% 90%; filter: drop-shadow(0 2px 2px rgba(60, 0, 0, 0.25)); animation: w-hat-on 700ms cubic-bezier(0.3, 1.4, 0.5, 1) 200ms backwards; }
.w-hat .w-pom { transform-box: fill-box; }
.w-garland { left: 0; right: 0; height: 30px; z-index: 6; animation: qz-fade 600ms ease-out backwards; }
.w-garland-top { top: var(--sat); }
.w-garland-nav { top: -2px; }
.w-lit { animation: w-blink 2.500s ease-in-out infinite; }
.w-glow { animation: w-glow 2.500s ease-in-out infinite; }
@keyframes w-blink { 0%, 100% { opacity: 0.15; } 45%, 60% { opacity: 1; } }
@keyframes w-glow { 0%, 100% { opacity: 0; } 45%, 60% { opacity: 1; } }
@keyframes w-hat-on { from { opacity: 0; transform: translateY(-14px) rotate(-30deg); } }
[data-theme="dark"] .w-drift { filter: brightness(0.93) drop-shadow(0 1px 1.500px rgba(0, 0, 0, 0.45)); }
/* the snow is a child of the list: the last row keeps its missing line */
li:has(+ [data-wdeco]:last-child) { border-bottom-color: transparent !important; }

/* duels */
@keyframes dl-ping { from { scale: 0.7; opacity: 0.9; } to { scale: 2.1; opacity: 0; } }
@keyframes dl-orbit { to { rotate: 360deg; } }
@keyframes dl-blink { 50% { opacity: 0.35; } }
@keyframes dl-left { 50% { translate: 4px 0; } }
@keyframes dl-right { 50% { translate: -4px 0; } }
@keyframes dl-clash { 0%, 100% { rotate: 8deg; scale: 1; } 45% { rotate: -6deg; scale: 1.08; } }
@keyframes dl-count { 0% { scale: 2.2; opacity: 0; filter: blur(6px); } 55% { scale: 0.9; opacity: 1; filter: blur(0); } 100% { scale: 1; } }
@keyframes dl-from-left { from { opacity: 0; translate: -60px 0; } }
@keyframes dl-from-right { from { opacity: 0; translate: 60px 0; } }
@keyframes dl-drop { from { opacity: 0; translate: 0 -40px; scale: 0.94; } }
@keyframes dl-crown { from { opacity: 0; translate: -50% 8px; scale: 0.4; } }
@keyframes dl-fall { 0% { opacity: 0; translate: 0 0; } 10% { opacity: 1; } 100% { opacity: 0; translate: 0 300px; rotate: 540deg; } }
@keyframes ch-pop { 0% { opacity: 0; scale: 0.3; } 60% { opacity: 1; scale: 1.12; } 100% { scale: 1; } }
@keyframes ch-rise { 0% { opacity: 0; translate: 0 60px; } 70% { translate: 0 -6px; } 100% { opacity: 1; translate: 0 0; } }
@keyframes ch-spin { 0% { opacity: 0; scale: 0.4; rotate: -200deg; } 100% { opacity: 1; scale: 1; rotate: 0deg; } }
@keyframes ch-swing { 0% { opacity: 0; rotate: -14deg; translate: -40px 0; } 55% { opacity: 1; rotate: 6deg; } 80% { rotate: -3deg; } 100% { rotate: 0deg; translate: 0 0; } }
@keyframes ch-zoom { 0% { opacity: 0; scale: 2.2; filter: blur(8px); } 100% { opacity: 1; scale: 1; filter: blur(0); } }
@keyframes ch-drop { 0% { opacity: 0; translate: 0 -80px; } 60% { opacity: 1; translate: 0 8px; } 80% { translate: 0 -3px; } 100% { translate: 0 0; } }
@keyframes ch-spark { 0% { opacity: 0; scale: 0.2; } 40% { opacity: 1; scale: 1.2; } 100% { opacity: 0; scale: 0.6; translate: 0 -14px; } }
@keyframes ch-out { to { opacity: 0; scale: 1.15; translate: 0 -18px; } }
@keyframes dl-grow-l { from { transform: scaleX(0); } }
@keyframes dl-grow-r { from { transform: scaleX(0); } }

/* No long-press callout or dragging for links and pictures (their address stays hidden). */
img, svg, a, button { -webkit-touch-callout: none; -webkit-user-drag: none; }

/* Pictures take no touches (no long-press menu with their address); links
   carry their target in data-href (see app.js) and still look clickable. */
img { pointer-events: none; -webkit-touch-callout: none; -webkit-user-drag: none; user-select: none; }
[data-href] { cursor: pointer; -webkit-touch-callout: none; -webkit-user-drag: none; }

/* ── glass ──
   Telegram full screen: the phone's status bar (--sa-t), then the row of
   Telegram's buttons (--bar-h). A page's title sits in that row, centred
   between the buttons, on frost the page slips under. The bottom menu, the
   cards and the pills are glass: clear enough to show what is behind,
   blurred and brightened, with a lit top edge, a soft inner glow and a sheen
   across, the way a pane of glass catches light. */
:root { --sa-t: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --csa-t: var(--tg-content-safe-area-inset-top, 0px);
  --bar-h: max(var(--csa-t), 46px);
  --top-h: calc(var(--sa-t) + var(--bar-h));
  --nav-lift: calc(20px + var(--sab));
  --nav-h: calc(94px + var(--sab));
  /* glass, light */
  --g-tint: rgba(255, 255, 255, 0.38);
  --g-card-tint: rgba(255, 255, 255, 0.2);
  --g-card-blur: blur(5px) saturate(1.6);
  --g-sheen: linear-gradient(155deg, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.16) 34%, rgba(255, 255, 255, 0.04) 58%, rgba(255, 255, 255, 0.3) 100%);
  --g-blur: blur(24px) saturate(1.9) brightness(1.05);
  --g-edge: inset 0 1px 0.5px rgba(255, 255, 255, 0.95), inset 0 -1px 0.5px rgba(255, 255, 255, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.5), inset 0 0 18px rgba(255, 255, 255, 0.4);
  --g-drop: 0 10px 30px rgba(16, 70, 140, 0.12), 0 1px 3px rgba(16, 70, 140, 0.08); }
[data-theme="dark"] {
  /* dark: glass kept quiet; close to the slate surface, a hairline of light
     on top, no glow, a faint sheen */
  --g-tint: rgba(25, 33, 44, 0.74);
  --g-card-tint: rgba(25, 33, 44, 0.7);
  --g-card-blur: blur(10px) saturate(1.3);
  --g-sheen: linear-gradient(160deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.012) 45%, rgba(255, 255, 255, 0) 100%);
  --g-blur: blur(24px) saturate(1.4);
  --g-edge: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  --g-drop: 0 6px 18px rgba(0, 0, 0, 0.22); }

[data-titlebar] { --fade: 18px; position: absolute; z-index: 4; top: 0; left: 0; right: 0; box-sizing: border-box; height: calc(var(--top-h) + var(--fade)); padding: var(--sa-t) 104px var(--fade);
  display: flex; align-items: center; justify-content: center; text-align: center; pointer-events: none; isolation: isolate; transition: color 220ms; }
[data-titlebar] > * { pointer-events: auto; }
/* the frost: no edge, it thins out below the row of buttons */
[data-titlebar]::before { content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(237, 245, 253, 0.7), rgba(237, 245, 253, 0.5) calc(100% - var(--fade) - 6px), rgba(237, 245, 253, 0));
  -webkit-backdrop-filter: blur(20px) saturate(1.9); backdrop-filter: blur(20px) saturate(1.9);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - var(--fade) - 10px), rgba(0, 0, 0, 0.55) calc(100% - var(--fade) / 2), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - var(--fade) - 10px), rgba(0, 0, 0, 0.55) calc(100% - var(--fade) / 2), transparent 100%);
  transition: opacity 220ms, background 220ms; }
[data-titlebar] h1 { margin: 0; min-width: 0; font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] [data-titlebar]::before { background: linear-gradient(to bottom, rgba(15, 21, 29, 0.74), rgba(15, 21, 29, 0.56) calc(100% - var(--fade) - 6px), rgba(15, 21, 29, 0)); }
/* over a blue top: clear at rest; once the page moves, blue frost with the
   title still white; light frost once the blue has gone */
[data-titlebar][data-onhero] { color: #FFFFFF; }
/* while the blue top is under it: no frost at all, the blue shows as it is
   (display, not opacity: iOS draws a backdrop blur even at opacity 0) */
[data-titlebar][data-onhero]::before { display: none; }
[data-titlebar][data-onhero] h1 { text-shadow: 0 1px 6px rgba(0, 50, 120, 0.25); }
[data-scrolled] > [data-titlebar][data-onhero] { color: inherit; }
[data-scrolled] > [data-titlebar][data-onhero] h1 { text-shadow: none; }
[data-scrolled] > [data-titlebar][data-onhero]::before { display: block; -webkit-backdrop-filter: blur(20px) saturate(1.9); backdrop-filter: blur(20px) saturate(1.9); background: linear-gradient(to bottom, rgba(237, 245, 253, 0.7), rgba(237, 245, 253, 0.5) calc(100% - var(--fade) - 6px), rgba(237, 245, 253, 0)); }
[data-theme="dark"] [data-scrolled] > [data-titlebar][data-onhero]::before { background: linear-gradient(to bottom, rgba(15, 21, 29, 0.74), rgba(15, 21, 29, 0.56) calc(100% - var(--fade) - 6px), rgba(15, 21, 29, 0)); }
/* the page runs from the very top, under the bar */
[data-root]:has(> [data-titlebar]) { padding-top: 0 !important; }
[data-root] > [data-titlebar]:not([data-onhero]) ~ [style*="overflow-y: auto"] { padding-top: calc(var(--top-h) + 22px) !important; scroll-padding-top: calc(var(--top-h) + 22px); }
[data-root]:has(> [data-titlebar]) > .w-garland-top { top: var(--top-h); }

/* Home: the day streak in the bar, a flame and the count on a glass pill */
[data-streak] { display: flex; align-items: center; gap: 5px; height: 36px; padding: 0 14px 0 9px; border: 0; border-radius: 18px; font: inherit; color: #0B1F38; cursor: pointer;
  background: var(--g-sheen), var(--g-tint); box-shadow: var(--g-edge), var(--g-drop); -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur); }
[data-streak] svg { flex: none; display: block; overflow: visible; transform-origin: 50% 90%; }
[data-streak][data-on="true"] svg { filter: drop-shadow(0 2px 5px rgba(12, 135, 245, 0.45)); animation: st-flick 1.600s ease-in-out infinite alternate !important; }
[data-streak] [data-n] { font-size: 19px; line-height: 1; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
[data-streak] [data-u] { margin-top: 2px; font-size: 14px; line-height: 1; font-weight: 600; color: #51657D; }
[data-streak]:not([data-on="true"]) [data-n] { color: #51657D; }
[data-theme="dark"] [data-streak] { color: #EAF0F7; }
[data-theme="dark"] [data-streak] [data-u], [data-theme="dark"] [data-streak]:not([data-on="true"]) [data-n] { color: #9AA8B9; }

/* Home: the support chat and the bell beside the greeting, glass tiles
   like the other cards; a red count on them while something is unread */
[data-bell] { position: relative; flex: none; width: 48px; height: 48px; box-sizing: border-box; padding: 0; border: 0; border-radius: 16px; color: #0062C7; cursor: pointer;
  display: flex; align-items: center; justify-content: center; background: #FFFFFF;
  animation: st-in 380ms cubic-bezier(0.2, 0.9, 0.3, 1.25) 80ms backwards; }
[data-bell][data-chat] { animation-delay: 20ms; }
[data-bell]:active { scale: 0.92; transition-duration: 90ms; }
[data-bell] > svg { display: block; transform-origin: 50% 12%; }
[data-bell="on"] > svg { animation: nt-ring 1.100s ease-in-out 450ms both, nt-ring 1.100s ease-in-out 6s infinite; }
[data-bell] [data-badge] { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; box-sizing: border-box; padding: 0 5px; border-radius: 10px;
  background: #E5343D; color: #FFFFFF; font-size: 11px; line-height: 20px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center;
  box-shadow: 0 0 0 2.5px #EDF5FD, 0 3px 8px rgba(229, 52, 61, 0.45); animation: ch-pop 520ms cubic-bezier(0.2, 0.9, 0.3, 1.4) 300ms backwards; }
[data-bell] [data-badge]::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: #E5343D; z-index: -1; animation: tp-halo 1.800s ease-out 900ms infinite; }
[data-theme="dark"] [data-bell] { color: #62AEFF; background: #19212C; }
[data-theme="dark"] [data-bell] [data-badge] { background: #FF4D55; box-shadow: 0 0 0 2.5px #0F151D; }
/* Home: the title is the light / dark switch, with a moon or a sun after it */
[data-themebtn] { display: flex; align-items: center; gap: 6px; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: 18px; background: transparent; color: inherit; cursor: pointer;
  font: inherit; font-size: 17px; line-height: 22px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
[data-themebtn] > svg { flex: none; display: block; opacity: 0.75; animation: tb-turn 460ms cubic-bezier(0.2, 0.9, 0.3, 1.3); }
[data-themebtn]:active { scale: 0.95; }
@keyframes tb-turn { from { opacity: 0; rotate: -90deg; scale: 0.4; } }
@media (prefers-reduced-motion: reduce) { [data-themebtn] > svg { animation: none; } }
@keyframes nt-ring { 0%, 100% { rotate: 0deg; } 12% { rotate: 16deg; } 26% { rotate: -14deg; } 40% { rotate: 10deg; } 54% { rotate: -6deg; } 68% { rotate: 3deg; } 80% { rotate: 0deg; } }
@keyframes nt-in { from { opacity: 0; translate: 0 18px; scale: 0.96; } }
@keyframes nt-skel { from { opacity: 0.45; } to { opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) {
  [data-bell] > svg, [data-bell] [data-badge], [data-bell] [data-badge]::after { animation: none !important; }
}

/* the bottom menu: a floating pane of glass, the open tab a glass bubble in it */
[data-root] > nav[data-float] { bottom: var(--nav-lift) !important; border: 0;
  background: var(--g-sheen), var(--g-tint);
  /* the glass edge, then a hairline round it and a deeper, wider drop, so the
     menu stands off the page under it */
  box-shadow: var(--g-edge), 0 0 0 0.5px rgba(16, 70, 140, 0.14), 0 18px 44px rgba(16, 70, 140, 0.26), 0 6px 14px rgba(16, 70, 140, 0.12), 0 1px 3px rgba(16, 70, 140, 0.1);
  -webkit-backdrop-filter: blur(26px) saturate(2) brightness(1.06); backdrop-filter: blur(26px) saturate(2) brightness(1.06); }
[data-theme="dark"] [data-root] > nav[data-float] { box-shadow: var(--g-edge), 0 0 0 1px rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur); }
[data-root] > nav[data-float] > a[aria-current="page"] { background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.28)), rgba(0, 112, 224, 0.1);
  box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 1), inset 0 0 0 1px rgba(255, 255, 255, 0.6), inset 0 -6px 12px rgba(0, 112, 224, 0.08), 0 4px 12px rgba(0, 112, 224, 0.14);
  transition: scale 420ms var(--spring), filter 280ms ease-out, background-color 200ms ease-out; }
[data-theme="dark"] [data-root] > nav[data-float] > a[aria-current="page"] { background: rgba(98, 174, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
/* the "+" tile: on its own screen it stands upright in a glass ring, like an open tab */
[data-root] > nav[data-float] > a[data-plus] { transition: scale 420ms var(--spring), filter 280ms ease-out, transform 260ms cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 200ms; }
[data-root] > nav[data-float] > a[data-plus][aria-current="page"] { background: #0070E0 !important; transform: rotate(0deg) !important;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.75), 0 0 0 5px rgba(0, 112, 224, 0.22), 0 8px 20px rgba(0, 112, 224, 0.4) !important; }
[data-root] > nav[data-float] > a[data-plus][aria-current="page"] > svg { transform: none !important; }
[data-theme="dark"] [data-root] > nav[data-float] > a[data-plus][aria-current="page"] { background: #1F7AE0 !important; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12), 0 0 0 5px rgba(98, 174, 255, 0.3), 0 8px 20px rgba(0, 0, 0, 0.4) !important; }
/* the page scrolls under the menu, and its end clears it */
[data-root] > [style*="overflow-y: auto"]:has(~ nav[data-float]) { padding-bottom: calc(var(--nav-h) + 8px) !important; scroll-padding-bottom: var(--nav-h); }
/* a strip held above the menu (Weekly Top): the list ends at it, it sits over the menu */
[data-root] > [style*="overflow-y: auto"]:has(~ [data-overnav]) { padding-bottom: 16px !important; }
[data-root] > [data-overnav] { position: relative; z-index: 5; margin-bottom: calc(var(--nav-h) - 2px) !important; }

/* cards, fields and chips on the page: glass. Marked ones, and any white
   card (a rounded white block) in a page's list, but not on a blue field. */
[data-root] :is([data-card], [data-chip][aria-pressed="false"]),
[data-root] > [style*="overflow-y: auto"] :is([style*="background: rgb(255, 255, 255)"], [style*="background: rgb(25, 33, 44)"]):is([style*="border-radius: 18px"], [style*="border-radius: 2"]):not(input, textarea, :has(> img[src^="pattern"]) *, [data-hero] *) {
  background: var(--g-sheen), var(--g-card-tint) !important; box-shadow: var(--g-edge), var(--g-drop);
  -webkit-backdrop-filter: var(--g-card-blur); backdrop-filter: var(--g-card-blur); }
:root[data-theme="dark"] [data-root] :is([data-card], [data-chip][aria-pressed="false"]),
:root[data-theme="dark"] [data-root] > [style*="overflow-y: auto"] :is([style*="background: rgb(255, 255, 255)"], [style*="background: rgb(25, 33, 44)"]):is([style*="border-radius: 18px"], [style*="border-radius: 2"]):not(input, textarea, :has(> img[src^="pattern"]) *, [data-hero] *) {
  background: var(--g-sheen), var(--g-card-tint) !important; }
[data-root] [data-chip][aria-pressed="true"] { box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.5), 0 6px 16px rgba(0, 112, 224, 0.28); }
[data-theme="dark"] [data-root] [data-chip][aria-pressed="true"] { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
[data-root] [data-search][data-card]:focus-within { box-shadow: inset 0 0 0 2px #0070E0, var(--g-drop); }
[data-theme="dark"] [data-root] [data-search][data-card]:focus-within { box-shadow: inset 0 0 0 2px #62AEFF; }

/* Testlar: the category row — one line that swipes sideways, pinned under
   the title while the list scrolls, frosted behind, fading at its edges.
   (Its sticky top counts from the list's scroll-padding, which already
   leaves room for the title bar: -18px puts it just under the bar.) */
[data-catbar] { -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  background: linear-gradient(to bottom, rgba(237, 245, 253, 0.85), rgba(237, 245, 253, 0.72) 75%, rgba(237, 245, 253, 0));
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 8px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 8px), transparent); }
[data-theme="dark"] [data-catbar] { background: linear-gradient(to bottom, rgba(15, 21, 29, 0.88), rgba(15, 21, 29, 0.74) 75%, rgba(15, 21, 29, 0)); }
[data-catrow] { scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%); }
[data-catrow]::-webkit-scrollbar { display: none; }

/* Support: a photo opened over the chat grows out of its bubble */
@keyframes pv-in { from { transform: translate(var(--fx), var(--fy)) scale(var(--fk)); opacity: 0.4; } }
/* Support: the message field rests as high as the bottom menu; with the
   keyboard up it sits just above it */
html:not(.desk) [data-composer]:focus-within { padding-bottom: 10px !important; }
[data-composer] { transition: padding-bottom 180ms ease-out; }

/* A title over a blue top (Top 10): at rest nothing under it, the blue top
   as it was; once the page moves, the frost of the other pages' title bars
   (blue while the blue top is under it, light once it has gone), so what
   scrolls beneath never mixes with the words. */
[data-moved]:not([data-scrolled]) > [data-titlebar][data-onhero]::before { display: block;
  background: linear-gradient(to bottom, rgba(12, 135, 245, 0.72), rgba(12, 135, 245, 0.5) calc(100% - var(--fade) - 6px), rgba(12, 135, 245, 0)); }
[data-theme="dark"] [data-moved]:not([data-scrolled]) > [data-titlebar][data-onhero]::before {
  background: linear-gradient(to bottom, rgba(23, 43, 66, 0.78), rgba(23, 43, 66, 0.56) calc(100% - var(--fade) - 6px), rgba(23, 43, 66, 0)); }
