/* Flow&Glow — приложение ученика. Цвета — из брендбука; один шрифт (Inter); правила мобильных интерфейсов:
   нижнее меню под большим пальцем, зоны нажатия ≥ 44px, одно главное действие на экран, сетка 4px. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('fonts/inter-normal-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('fonts/inter-normal-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; }

:root {
  /* брендбук */
  --cream: #F3F1E0; --blue: #3F668F; --violet: #8E7EED; --orange: #FF7D50; --sky: #B8D7FF; --beige: #FFE9E1;

  --bg: var(--cream);
  --surface: #FFFEF8;
  --surface-2: #F9F7EA;                 /* нажатое / вложенное */
  --ink: #24405E;                       /* основной текст: тот же синий, темнее — для чтения */
  --ink-2: #506B8B;                     /* второстепенный текст */
  --line: rgba(36, 64, 94, .10);
  --primary: var(--blue);
  --on-primary: #FFFDF5;
  --accent: var(--violet);
  --accent-ink: #5445BF;
  --warn-ink: #B8481F;
  --tonal: var(--sky);
  --on-tonal: #24405E;

  --r-s: 12px; --r-m: 16px; --r-l: 22px;
  --tabbar-h: 62px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow: 0 1px 2px rgba(36, 64, 94, .05), 0 10px 28px -18px rgba(36, 64, 94, .35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
html.dark {
  --bg: #14243A;
  --surface: #1D3350;
  --surface-2: #26405F;
  --ink: #F3F1E0;
  --ink-2: #A8B9CC;
  --line: rgba(243, 241, 224, .10);
  --primary: #F3F1E0;
  --on-primary: #24405E;
  --accent-ink: #BDB3FF;
  --warn-ink: #FF9C78;
  --tonal: #2F5278;
  --on-tonal: #F3F1E0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 28px -18px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
::selection { background: color-mix(in srgb, var(--violet) 30%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- каркас ---------- */
.app { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
.screen { display: none; }
.screen.active { display: block; animation: screen-in .28s var(--ease); }
@keyframes screen-in { from { opacity: 0; transform: translate3d(0, 6px, 0); } }
body.studying .app, body.studying .tabbar { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 560px; margin: 0 auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 50px; padding: 2px 0 0;
  border: 0; background: none; color: var(--ink-2); font-size: 11.5px; font-weight: 500; }
.tabbar .tb-ic { display: grid; place-items: center; width: 58px; height: 30px; border-radius: 15px; transition: background .25s var(--ease), color .25s; }
.tabbar button[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabbar button[aria-current="page"] .tb-ic { background: var(--tonal); color: var(--on-tonal); }
.tabbar button:active .tb-ic { transform: scale(.94); }
.tb-badge { position: absolute; top: 0; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center;
  background: var(--orange); color: #1B3350; font-size: 11px; font-weight: 600; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- типографика ---------- */
.page-title { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; margin: 6px 2px 16px; }
.section { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 2px 10px; }
.section h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.section .more { border: 0; background: none; min-height: 44px; margin: -10px 0; padding: 6px 0; color: var(--accent-ink); font-size: 14.5px; font-weight: 500; }
.caption { font-size: 13.5px; color: var(--ink-2); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 12px 18px;
  border: 0; border-radius: var(--r-m); font-size: 16px; font-weight: 600; letter-spacing: -0.005em;
  background: var(--primary); color: var(--on-primary); transition: transform .18s var(--ease), opacity .2s, filter .2s;
}
.btn:active { transform: scale(.98); filter: brightness(.94); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.tonal { background: var(--tonal); color: var(--on-tonal); }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.plain { background: none; color: var(--accent-ink); min-height: 44px; }
.btn.on-blue { background: #FFFDF5; color: #24405E; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink);
  transition: transform .18s var(--ease), background .2s; }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .3; }
.icon-btn.on { background: var(--violet); color: #fff; }
.icon-btn.quiet { background: transparent; color: var(--ink-2); }

/* ---------- главная ---------- */
.home-top { display: flex; align-items: center; justify-content: space-between; margin: 2px 2px 14px; }
.logo { width: 76px; height: 40px; fill: currentColor; color: var(--blue); }
html.dark .logo { color: var(--cream); }
.avatar { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--sky); color: #24405E; font-weight: 600; font-size: 17px; }
.avatar.big { width: 60px; height: 60px; font-size: 22px; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 8px 16px; border: 0; border-radius: 20px; background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 500; box-shadow: inset 0 0 0 1px var(--line); }
.chip[aria-pressed="true"] { background: var(--blue); color: #FFFDF5; box-shadow: none; }

.balance { position: relative; overflow: hidden; isolation: isolate; padding: 20px; border-radius: 26px; background: var(--blue); color: #FFFDF5; }
.balance::before, .balance::after { content: ''; position: absolute; z-index: -1; border-radius: 50%; }
.balance::before { width: 150px; height: 150px; right: -44px; top: -58px; background: var(--violet); }
.balance::after { width: 34px; height: 34px; right: 96px; top: 30px; background: var(--sky); }
.balance-label { font-size: 14.5px; opacity: .88; max-width: 70%; }
.balance-value { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.balance-value b { font-size: 60px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.balance-value span { font-size: 18px; font-weight: 500; opacity: .92; }
.balance-meta { margin-top: 10px; font-size: 14px; opacity: .86; }
.balance-note { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 7px 12px; border-radius: 12px; background: var(--beige); color: #A13C17; font-size: 13.5px; font-weight: 600; }
.balance .btn { margin-top: 18px; }

.hero { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; width: 100%; padding: 18px; border: 0; border-radius: var(--r-l); text-align: left;
  background: var(--sky); color: #24405E; transition: transform .2s var(--ease); }
.hero:active { transform: scale(.985); }
.hero b { display: block; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.hero > span > span { display: block; margin-top: 2px; font-size: 14.5px; color: #3A5878; }
.hero .go { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--violet); color: #fff; }
.calm { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: var(--r-l); background: var(--surface); }
.calm .dot { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--sky); color: #24405E; }
.calm b { display: block; font-size: 16px; font-weight: 600; }
.calm div span { font-size: 14px; color: var(--ink-2); }

/* ---------- списки ---------- */
.list { background: var(--surface); border-radius: var(--r-l); overflow: hidden; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 12px 14px 12px 16px;
  border: 0; background: none; text-align: left; transition: background .2s; }
.row + .row { border-top: 1px solid var(--line); }
button.row:active, label.row:active { background: var(--surface-2); }
.row.no-lead { grid-template-columns: 1fr auto; }
.row-title { font-size: 16px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.row-sub { margin-top: 2px; font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
.row-end { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.row-end .ic { opacity: .7; }
.date { width: 44px; text-align: center; }
.date b { display: block; font-size: 21px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.date span { display: block; font-size: 12px; color: var(--ink-2); }
.lead-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.lead-ic.sky { background: var(--sky); color: #24405E; }
.lead-ic.beige { background: var(--beige); color: #B8481F; }
.lead-ic.violet { background: color-mix(in srgb, var(--violet) 22%, var(--surface)); color: var(--accent-ink); }
.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px; border-radius: 12px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); }
.tag.warn { background: var(--beige); color: #B8481F; }
.tag.ok { background: var(--sky); color: #24405E; }
.month { margin: 22px 2px 10px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.month::first-letter { text-transform: uppercase; }
.meter { height: 4px; margin-top: 8px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 2px; background: var(--violet); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px 16px; border-radius: var(--r-l); background: var(--surface); }
.stat b { display: block; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13.5px; color: var(--ink-2); }

.empty { padding: 32px 22px; border-radius: var(--r-l); background: var(--surface); text-align: center; }
.empty .dot { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: var(--sky); color: #24405E; }
.empty b { display: block; font-size: 17px; font-weight: 600; }
.empty p { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); }
.empty .btn { margin-top: 16px; }

/* ---------- профиль ---------- */
.me { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r-l); background: var(--surface); }
.me > div { min-width: 0; overflow-wrap: anywhere; }
.me b { display: block; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.me div span { display: block; font-size: 14px; color: var(--ink-2); }
.check { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line); color: transparent; }
.row[aria-checked="true"] .check, .opt[aria-checked="true"] .check { background: var(--blue); box-shadow: none; color: #FFFDF5; }
html.dark .row[aria-checked="true"] .check, html.dark .opt[aria-checked="true"] .check { background: var(--sky); color: #24405E; }
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; width: 50px; height: 30px; border-radius: 15px; background: color-mix(in srgb, var(--ink) 18%, transparent); transition: background .3s var(--ease); }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(20, 36, 58, .3); transition: transform .32s var(--ease); }
.switch input:checked + .switch-ui { background: var(--violet); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.select { min-height: 44px; padding: 6px 12px; border: 0; border-radius: 12px; background: var(--surface-2); font-size: 15px; font-weight: 500; }
.foot { margin: 28px 0 0; text-align: center; font-size: 13px; color: var(--ink-2); }

/* ---------- шторка ---------- */
.sheet-scrim { position: fixed; inset: 0; z-index: 20; background: rgba(20, 36, 58, .42); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 560px; max-height: 92vh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 20px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; background: var(--bg); color: var(--ink);
  box-shadow: 0 -18px 48px -20px rgba(20, 36, 58, .5); touch-action: pan-y;
}
.sheet-grip { display: grid; place-items: center; padding: 6px 0 12px; }
.sheet-grip span { width: 38px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 22%, transparent); }
.sheet-title { overflow-wrap: anywhere; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
.sheet-sub { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); }
.sheet-label { margin: 20px 2px 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.sheet-actions { display: grid; gap: 10px; margin-top: 20px; }
.sheet-actions.sticky { position: sticky; bottom: calc(-22px - env(safe-area-inset-bottom)); margin: 8px -20px 0; padding: 14px 20px calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 22%); }
.sheet-hint { margin-top: 12px; text-align: center; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.kv { background: var(--surface); border-radius: var(--r-l); overflow: hidden; margin-top: 16px; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 16px; font-size: 15px; }
.kv > div + div { border-top: 1px solid var(--line); }
.kv dt, .kv .k { color: var(--ink-2); }
.kv .v { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

.opts { display: grid; gap: 8px; }
.opt { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 12px 16px; border: 0; border-radius: var(--r-m);
  background: var(--surface); text-align: left; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s, background .2s; }
.opt[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--blue); }
html.dark .opt[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--sky); }
.opt > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.opt b { display: block; font-size: 16px; font-weight: 600; }
.opt > span > span { display: block; font-size: 13.5px; color: var(--ink-2); }
.opt .price { font-size: 16px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.field { display: block; width: 100%; min-height: 52px; padding: 12px 16px; border: 0; border-radius: var(--r-m); background: var(--surface); font-size: 16px; outline: none;
  box-shadow: inset 0 0 0 1px var(--line); caret-color: var(--violet); }
.field:focus { box-shadow: inset 0 0 0 2px var(--violet); }
.field.bad { box-shadow: inset 0 0 0 2px var(--orange); }
.field::placeholder { color: var(--ink-2); opacity: .7; }
.field-err { min-height: 18px; margin: 6px 2px 0; font-size: 13.5px; color: var(--warn-ink); }
.copy-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 12px 8px 12px 16px; border: 0; background: none; text-align: left; }
.copy-row + .copy-row { border-top: 1px solid var(--line); }
.copy-row .k { display: block; font-size: 13px; color: var(--ink-2); }
.copy-row .v { display: block; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.copy-row .v.small { font-size: 14px; }
.copy-row .cp { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--accent-ink); }
.copy-row:active { background: var(--surface-2); }
.state { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 8px; }
.state .dot { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 14px; border-radius: 50%; background: var(--sky); color: #24405E; }
.state .dot.wait { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.07); } }
.state p { margin-top: 6px; max-width: 34ch; font-size: 15px; color: var(--ink-2); line-height: 1.5; }
.note { display: flex; gap: 10px; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-m); background: var(--beige); color: #7A3212; font-size: 13.5px; line-height: 1.45; }

/* ---------- загрузка, сообщения ---------- */
.skeleton { border-radius: var(--r-l); background: var(--surface); animation: pulse 1.4s ease-in-out infinite; }
.sk-title { width: 60%; height: 30px; margin: 60px 0 16px; border-radius: 10px; }
.sk-card { height: 210px; }
.sk-row { height: 72px; margin-top: 12px; }
@keyframes pulse { 50% { opacity: .5; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 22px + env(safe-area-inset-bottom)); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: #24405E; color: #FFFDF5; font-size: 14.5px; font-weight: 500; opacity: 0; pointer-events: none; transform: translate(-50%, 12px);
  transition: opacity .25s, transform .35s var(--ease); }
html.dark .toast { background: var(--cream); color: #24405E; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.burst { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.burst i { position: absolute; border-radius: 50%; will-change: transform, opacity; }

@media (max-width: 350px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .sheet { padding-left: 14px; padding-right: 14px; }
  .opt { grid-template-columns: auto 1fr; padding: 12px; }
  .opt .price { grid-column: 2; }
  .balance-value b { font-size: 52px; }
  .page-title { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen.active, .skeleton, .state .dot.wait { animation: none; }
  .switch-ui::after, .toast, .btn, .tabbar .tb-ic { transition: none; }
}
