/* ЄДКІ GO — Soft Neobank (ваніль). Токени — docs/DESIGN.md */
:root {
  --canvas: #f1f5f9; --surface: #fff; --surface-2: #f8fafc;
  --text: #0f172a; --muted: #64748b; --hint: #94a3b8;
  --accent: #6366f1; --accent-soft: #eef2ff; --accent-ink: #4f46e5;
  --pos: #10b981; --pos-ink: #059669; --pos-soft: #ecfdf5;
  --bad: #f43f5e; --bad-ink: #e11d48; --bad-soft: #fff1f2;
  --wait: #f59e0b; --wait-ink: #d97706; --wait-soft: #fffbeb;
  --neutral-soft: #f1f5f9; --neutral-ink: #475569;
  --shadow-card: 0 8px 30px rgba(40,50,90,.06);
  --shadow-soft: 0 2px 8px rgba(60,60,120,.08);
  --shadow-btn: 0 6px 18px rgba(99,102,241,.35);
  --hero: linear-gradient(135deg, #eef2ff, #ede9fe);
  --r-card: 24px; --r-btn: 16px; --r-inner: 12px; --r-pill: 999px;
  --gap: 14px; --pad: 18px; --page-pad: 16px; --gap-sm: 8px; --kpi-gap: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: light;
}
[data-theme=dark] {
  --canvas: #0b1120; --surface: #1e293b; --surface-2: #273449;
  --text: #f1f5f9; --muted: #94a3b8; --hint: #64748b;
  --accent-soft: rgba(99,102,241,.18); --accent-ink: #a5b4fc;
  --pos-ink: #34d399; --pos-soft: rgba(16,185,129,.16);
  --bad-ink: #fb7185; --bad-soft: rgba(244,63,94,.16);
  --wait-ink: #fbbf24; --wait-soft: rgba(245,158,11,.16);
  --neutral-soft: #334155; --neutral-ink: #cbd5e1;
  --shadow-card: inset 0 0 0 1px rgba(255,255,255,.06);
  --shadow-soft: inset 0 0 0 1px rgba(255,255,255,.06);
  --hero: linear-gradient(135deg, #1e1b4b, #2e1065);
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--canvas); color: var(--text); font: 14px/1.4 var(--font); }
body { min-height: 100vh; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }

#app { padding: var(--page-pad); padding-bottom: calc(84px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
#app.no-tabs { padding-bottom: calc(24px + var(--safe-b)); }
.stack > * + * { margin-top: var(--gap); }
h1 { font-size: 19px; font-weight: 700; letter-spacing: -.3px; margin: 4px 2px 0; }
.sec-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--hint); margin: 22px 4px 8px; }
.muted { color: var(--muted); } .hint { color: var(--hint); } .small { font-size: 11px; }
.row { display: flex; align-items: center; gap: var(--gap-sm); }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* картки */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: var(--pad); }
.card-hero { background: var(--hero); border-radius: var(--r-card); padding: 20px var(--pad); }
.hero-num { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi { font-size: 24px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--kpi-gap); }
.kpi-grid .card { padding: 14px 16px; }
.label { font-size: 11px; color: var(--muted); }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
  border-radius: var(--r-btn); font-weight: 700; transition: transform .1s, opacity .2s, background .2s; user-select: none; }
.btn:active { transform: scale(.98); } .btn:disabled { opacity: .5; pointer-events: none; }
.btn.lg { height: 48px; font-size: 15px; } .btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.full { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-btn); }
.btn-secondary { background: var(--surface); box-shadow: var(--shadow-soft); }
.btn-ghost { background: var(--accent-soft); color: var(--accent-ink); }
.btn-ghost.pos { background: var(--pos-soft); color: var(--pos-ink); }
.btn-ghost.bad { background: var(--bad-soft); color: var(--bad-ink); }
.btn-ghost.wait { background: var(--wait-soft); color: var(--wait-ink); }
.btn-ghost.neutral { background: var(--neutral-soft); color: var(--neutral-ink); }
.btn-pos { background: var(--pos); color: #fff; box-shadow: 0 6px 18px rgba(16,185,129,.35); }
.btn-bad { background: var(--bad); color: #fff; box-shadow: 0 6px 18px rgba(244,63,94,.35); }

/* сегмент, чипи, пілюлі */
.seg { display: flex; background: var(--surface); border-radius: var(--r-btn); padding: 6px; box-shadow: var(--shadow-card); gap: 4px; }
.seg button { flex: 1; height: 32px; border-radius: var(--r-inner); font-size: 12px; font-weight: 700; color: var(--hint); }
.seg button.on { background: var(--accent); color: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chip { flex: none; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; padding: 6px 12px; background: var(--surface);
  box-shadow: var(--shadow-soft); color: var(--muted); white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; box-shadow: var(--shadow-btn); }
.chip .cnt { opacity: .7; font-variant-numeric: tabular-nums; margin-left: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; padding: 3px 9px; }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill.pos { background: var(--pos-soft); color: var(--pos-ink); }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); }
.pill.wait { background: var(--wait-soft); color: var(--wait-ink); }
.pill.neutral { background: var(--neutral-soft); color: var(--neutral-ink); }

/* прогрес */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
[data-theme=dark] .progress { background: #334155; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s; }
.progress > i.bad { background: var(--bad); } .progress > i.wait { background: var(--wait); } .progress > i.pos { background: var(--pos); }

/* списки */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list-row + .list-row { border-top: 1px solid var(--surface-2); }
[data-theme=dark] .list-row + .list-row { border-top-color: #334155; }
.tile { width: 38px; height: 38px; flex: none; border-radius: var(--r-inner); display: grid; place-items: center; font-size: 18px; background: var(--accent-soft); }
.tile.pos { background: var(--pos-soft); } .tile.wait { background: var(--wait-soft); } .tile.bad { background: var(--bad-soft); }
.list-row .name { font-size: 14px; font-weight: 600; }
.chev { color: var(--hint); font-size: 18px; }

/* режими */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--kpi-gap); }
.mode { text-align: left; padding: 14px 16px; }
.mode .ico { font-size: 22px; } .mode .t { font-weight: 700; margin-top: 6px; } .mode .s { font-size: 11px; color: var(--muted); }
.mode:active { transform: scale(.98); }

/* навчальна сесія */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topbar .progress { flex: 1; }
.q-text { font-size: 17px; line-height: 1.45; }
.expl { font-size: 15px; line-height: 1.5; }
.banner { border-radius: var(--r-inner); padding: 12px 14px; font-size: 15px; line-height: 1.5; }
.banner.info { background: var(--accent-soft); } .banner.pos { background: var(--pos-soft); } .banner.bad { background: var(--bad-soft); }
.banner .h { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.banner.pos .h { color: var(--pos-ink); } .banner.bad .h { color: var(--bad-ink); } .banner.info .h { color: var(--accent-ink); }
.src { font-size: 11px; color: var(--hint); margin-top: 10px; }
.opt { display: block; width: 100%; text-align: left; background: var(--surface-2); border-radius: var(--r-inner); padding: 14px;
  font-size: 15px; line-height: 1.4; margin-top: 8px; transition: opacity .2s, background .2s; }
[data-theme=dark] .opt { background: #273449; }
.opt.sel { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.opt.ok { background: var(--pos-soft); box-shadow: inset 0 0 0 2px var(--pos); }
.opt.ok::after { content: " ✓"; color: var(--pos-ink); font-weight: 700; }
.opt.no { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad); }
.opt.dim { opacity: .5; }
.opt .letter { font-weight: 700; color: var(--hint); margin-right: 8px; }
.guess { margin-top: 12px; }
.guess .chip { font-size: 12px; }
.guess .chip.on { background: var(--wait); box-shadow: 0 6px 18px rgba(245,158,11,.35); }

/* свайп */
.swipe-wrap { position: relative; touch-action: pan-y; }
.swipe-card { position: relative; touch-action: none; user-select: none; will-change: transform; transition: transform .25s ease, opacity .25s; }
.swipe-card.drag { transition: none; }
.swipe-card .claim { margin-top: 14px; padding: 14px; border-radius: var(--r-inner); background: var(--surface-2); font-size: 17px; line-height: 1.45; font-weight: 600; }
[data-theme=dark] .swipe-card .claim { background: #273449; }
.swipe-tint { position: absolute; inset: 0; border-radius: var(--r-card); pointer-events: none; opacity: 0; }
.stamp { position: absolute; top: 16px; padding: 6px 14px; font-size: 14px; font-weight: 800; opacity: 0; letter-spacing: .04em; }
.stamp.yes { right: 16px; background: var(--pos-soft); color: var(--pos-ink); }
.stamp.no { left: 16px; background: var(--bad-soft); color: var(--bad-ink); }
.swipe-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 14px; }
.swipe-hint { text-align: center; font-size: 11px; color: var(--hint); margin-top: 8px; }

/* переворот */
.flip { perspective: 1200px; }
.flip-inner { display: grid; transition: transform .45s; transform-style: preserve-3d; }
.flip.turned .flip-inner { transform: rotateY(180deg); }
.flip-face { grid-area: 1/1; backface-visibility: hidden; -webkit-backface-visibility: hidden; min-height: 260px; }
.flip-back { transform: rotateY(180deg); }
.face-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--hint); margin-bottom: 10px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate .btn { flex-direction: column; height: 56px; gap: 0; padding: 0 4px; }
.rate .ivl { font-size: 10px; font-family: ui-monospace, monospace; opacity: .75; font-weight: 600; }
.rate .btn-ghost.easy { background: var(--accent-soft); color: var(--accent-ink); }

.bottom-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--canvas) 30%); margin-top: 6px; }

/* іспит */
.timer { font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.timer.wait { color: var(--wait-ink); } .timer.bad { color: var(--bad-ink); }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 6px; }
.navgrid button { height: 32px; border-radius: var(--r-inner); background: var(--surface-2); font-size: 11px; font-weight: 600; color: var(--muted); }
[data-theme=dark] .navgrid button { background: #273449; }
.navgrid button.ans { background: var(--accent-soft); color: var(--accent-ink); }
.navgrid button.flag { background: var(--wait-soft); color: var(--wait-ink); }
.navgrid button.cur { background: var(--accent); color: #fff; }
.navgrid button.ok { background: var(--pos-soft); color: var(--pos-ink); }
.navgrid button.no { background: var(--bad-soft); color: var(--bad-ink); }

/* статистика */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 90px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--accent); min-height: 3px; }
.bars .b.zero i { background: var(--surface-2); }
.bars .b span { font-size: 10px; color: var(--hint); }

/* таб-бар */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; background: var(--surface);
  box-shadow: 0 -4px 20px rgba(40,50,90,.06); padding: 8px 12px calc(8px + var(--safe-b)); z-index: 10; }
[data-theme=dark] .tabbar { box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
.tabbar button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px;
  font-weight: 600; color: var(--hint); padding: 4px 0; border-radius: var(--r-inner); }
.tabbar button .i { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--accent-ink); }
.tabbar button.on .i { filter: none; opacity: 1; }

/* шторка, тост */
.sheet-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-end; animation: fade .2s; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 24px 24px 0 0;
  padding: 20px var(--pad) calc(20px + var(--safe-b)); max-height: 88vh; overflow: auto; animation: up .25s; }
.sheet h2 { font-size: 17px; margin: 0 0 8px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: var(--text); color: var(--canvas);
  padding: 10px 16px; border-radius: var(--r-btn); font-weight: 600; z-index: 60; animation: fade .2s; max-width: 90vw; }
textarea { width: 100%; min-height: 140px; border: 0; border-radius: var(--r-inner); background: var(--surface-2); color: var(--text);
  padding: 12px; font: 15px/1.5 var(--font); resize: vertical; }
[data-theme=dark] textarea { background: #273449; }
textarea:focus { outline: 2px solid var(--accent); }

/* стани */
.skel { background: var(--surface-2); border-radius: var(--r-card); animation: pulse 1.2s infinite; }
[data-theme=dark] .skel { background: #1e293b; }
.empty { text-align: center; padding: 28px var(--pad); }
.empty .e { font-size: 42px; } .empty p { color: var(--muted); margin: 8px 0 0; }
.err { background: var(--bad-soft); color: var(--bad-ink); border-radius: var(--r-inner); padding: 12px 14px; font-weight: 600; }

@keyframes pulse { 50% { opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .flip.turned .flip-inner { transform: none; }
  .flip.turned .flip-front { display: none; } .flip:not(.turned) .flip-back { display: none; }
  .flip-back { transform: none; }
}
