/* ============ Токены ============ */
:root {
  --bg: #0b1020;
  --bg-2: #101730;
  --card: #151d36;
  --card-2: #1a2442;
  --line: #26314f;
  --text: #eef2ff;
  --muted: #97a4c4;
  --accent: #6ee7a8;
  --accent-ink: #06231a;
  --accent-soft: rgba(110, 231, 168, .12);
  --danger: #ff7a85;
  --danger-soft: rgba(255, 122, 133, .12);
  --r: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 8px; letter-spacing: -.02em; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 650; }
p { margin: 0 0 12px; }
button { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.fine { color: #7a86a6; font-size: 12.5px; line-height: 1.4; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ============ Каркас ============ */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 18px;
  background: rgba(11, 16, 32, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(38, 49, 79, .6);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.02em; }
.brand__mark {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--accent), #35b184);
  color: var(--accent-ink);
  font-size: 14px; font-weight: 800;
}
.streak-pill {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 168, 76, .35);
  background: rgba(255, 168, 76, .1);
  color: #ffc27a;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.main { flex: 1; padding: 18px 18px calc(84px + var(--safe-bottom)); }

.screen { display: none; animation: fade .18s ease; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-title { margin-bottom: 16px; }
.block-title { margin: 26px 0 12px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

/* ============ Кнопки ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: #83f0bb; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn--block { display: flex; width: 100%; }
.btn--lg { padding: 16px 20px; font-size: 16px; border-radius: 16px; }
.btn--sm { padding: 9px 14px; font-size: 13.5px; border-radius: 11px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

/* ============ Онбординг ============ */
.onb { padding-top: 8px; }
.onb h1 { font-size: 30px; margin-bottom: 10px; }
.onb__h { margin: 26px 0 12px; font-size: 15px; color: var(--text); }

.opt-grid { display: grid; gap: 10px; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
}
.opt.is-active { border-color: var(--accent); background: var(--accent-soft); }
.opt__emoji { font-size: 22px; }
.opt__title { display: block; font-weight: 650; font-size: 15px; }
.opt__sub { display: block; color: var(--muted); font-size: 12.5px; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.seg {
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}
.seg.is-active { background: var(--accent); color: var(--accent-ink); }

#onb-start { margin-top: 26px; }
.onb .fine { margin-top: 12px; text-align: center; }

/* ============ Главная ============ */
.hello { margin-bottom: 16px; }
.hello__title { font-size: 26px; }

.today-card {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(160deg, #1a2442, #131a30 70%);
}
.ring-wrap { position: relative; width: 116px; height: 116px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__bg { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 9; }
.ring__fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .5s ease;
}
.ring-label {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
}
.ring-label strong { display: block; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-label span { color: var(--muted); font-size: 11.5px; }
.today-card__title { font-weight: 650; margin-bottom: 2px; }
.today-card__text .btn { margin-top: 10px; }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.mini {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: center;
}
.mini strong { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.mini span { color: var(--muted); font-size: 11.5px; }

.word-day {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.word-day__en { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.word-day__ru { color: var(--accent); }

.deck-row { display: grid; gap: 8px; }
.deck {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
}
.deck.is-active { border-color: var(--accent); background: var(--accent-soft); }
.deck__emoji { font-size: 20px; }
.deck__title { display: block; font-weight: 620; font-size: 14.5px; }
.deck__sub { display: block; color: var(--muted); font-size: 12px; }
.deck__check { margin-left: auto; color: var(--accent); font-weight: 700; }

.premium-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 14px;
  border: 1px solid rgba(110, 231, 168, .35);
  border-radius: 16px;
  background: var(--accent-soft);
}
.premium-banner > div { flex: 1; }
.premium-banner p { margin: 2px 0 0; }

/* ============ Учёба ============ */
.screen--study { padding-top: 4px; }
.study-top { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.progress { flex: 1; height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress__fill { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .25s ease; }
.study-count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.flashcard {
  display: grid;
  place-content: center;
  min-height: 210px;
  margin-bottom: 18px;
  padding: 24px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(165deg, #1b2545, #141c33);
  text-align: center;
}
.flashcard__label { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.flashcard__word { font-size: clamp(26px, 8vw, 36px); margin: 0; word-break: break-word; }
.flashcard__hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; min-height: 18px; }

.options { display: grid; gap: 9px; }
.option {
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.option:active { background: var(--card-2); }
.option.is-correct { border-color: var(--accent); background: var(--accent-soft); }
.option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.option[disabled] { cursor: default; }

.study-foot { margin-top: 18px; }
.verdict { margin-bottom: 12px; font-size: 14px; }
.verdict strong { color: var(--accent); }
.verdict.is-wrong strong { color: var(--danger); }

/* ============ Финиш ============ */
.done { padding-top: 12px; text-align: center; }
.done__emoji { font-size: 56px; line-height: 1; margin-bottom: 10px; }
.done .mini-stats { text-align: center; }
.done .btn { margin-top: 12px; }

/* ============ Прогресс ============ */
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cell {
  aspect-ratio: 1;
  border-radius: 7px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .03);
}
.cell.l1 { background: rgba(110, 231, 168, .2); }
.cell.l2 { background: rgba(110, 231, 168, .45); }
.cell.l3 { background: rgba(110, 231, 168, .72); }
.cell.l4 { background: var(--accent); }

.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(38, 49, 79, .6);
  font-size: 14.5px;
}
.stat-line span { color: var(--muted); }

.weak-list { display: grid; gap: 8px; }
.weak {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 122, 133, .3);
  border-radius: 12px;
  background: var(--danger-soft);
  font-size: 14px;
}
.weak span { color: var(--muted); font-size: 12.5px; }

/* ============ Профиль ============ */
.panel {
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(38, 49, 79, .55);
}
.panel__row:last-child { border-bottom: 0; }
.panel__row p { margin: 2px 0 0; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  border-radius: 99px;
  background: #2a3454;
  transition: background .15s ease;
  cursor: pointer;
}
.switch span::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(19px); }

input[type="time"] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

/* ============ Таббар ============ */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(12, 18, 36, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(38, 49, 79, .7);
  z-index: 15;
}
.tab {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 6px 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.tab span { font-size: 17px; line-height: 1; }
.tab.is-active { color: var(--accent); background: rgba(110, 231, 168, .08); }

/* ============ Модалка ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 8, 18, .7);
  backdrop-filter: blur(4px);
  animation: fade .15s ease;
}
.modal[hidden] { display: none; }
.modal__sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  padding: 26px 20px calc(24px + var(--safe-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #1a2442, #101730);
  animation: sheet .22s ease;
}
@keyframes sheet { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal__close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  cursor: pointer;
}
.modal__sheet h2 { font-size: 24px; }
.tick { margin: 12px 0 20px; padding: 0; list-style: none; display: grid; gap: 9px; }
.tick li { position: relative; padding-left: 24px; color: var(--muted); font-size: 14.5px; }
.tick li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

/* ============ Тост ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1d2748;
  color: var(--text);
  font-size: 13.5px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .today-card { grid-template-columns: 96px 1fr; gap: 12px; }
  .ring-wrap { width: 96px; height: 96px; }
  .ring-label strong { font-size: 23px; }
}
