:root {
  --coral: oklch(68% 0.19 35);
  --coral-dark: oklch(58% 0.18 35);
  --coral-tint: oklch(94% 0.05 35);
  --cream: oklch(96% 0.02 85);
  --ink: oklch(26% 0.03 280);
  --amber: oklch(75% 0.14 70);
  --card: oklch(99% 0.005 85);
  --border: oklch(88% 0.02 85);
  --muted: oklch(52% 0.02 280);

  --bg: var(--cream);
  --fg: var(--ink);

  --shadow-sm: 0 2px 6px oklch(30% 0.04 40 / 0.10);
  --shadow-md: 0 6px 18px oklch(30% 0.04 40 / 0.12);
  --shadow-lg: 0 10px 26px oklch(30% 0.04 40 / 0.16);
}

[data-theme="dark"] {
  --bg: oklch(22% 0.02 280);
  --fg: oklch(94% 0.01 85);
  --card: oklch(27% 0.02 280);
  --border: oklch(34% 0.02 280);
  --muted: oklch(70% 0.01 85);
  --coral-tint: oklch(30% 0.06 35);

  --shadow-sm: 0 2px 6px oklch(0% 0 0 / 0.30);
  --shadow-md: 0 6px 18px oklch(0% 0 0 / 0.35);
  --shadow-lg: 0 10px 26px oklch(0% 0 0 / 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Nunito", -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, .wordmark, .cta-btn, .stats-title {
  font-family: "Unbounded", "Nunito", sans-serif;
}

#app { max-width: 480px; margin: 0 auto; padding: 20px 16px 44px; }

.view { display: flex; flex-direction: column; gap: 20px; }
.view[hidden] { display: none; }

/* Header */
.header { text-align: center; padding: 10px 0 6px; }
.owl { font-size: 56px; line-height: 1; filter: drop-shadow(0 4px 10px oklch(30% 0.04 40 / 0.18)); }
.wordmark { font-size: 25px; font-weight: 700; margin-top: 8px; }
.tagline { color: var(--muted); font-size: 14px; margin-top: 4px; }

.subheader { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.subheader-title { font-family: "Unbounded", sans-serif; font-size: 18px; font-weight: 600; }
.back-btn {
  border: none; background: var(--card); color: var(--fg);
  width: 38px; height: 38px; border-radius: 50%; font-size: 17px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  transition: transform .08s ease;
}
.back-btn:active { transform: scale(.9); }

/* How it works */
.how-it-works {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--card); border-radius: 18px; padding: 14px 10px;
  box-shadow: var(--shadow-sm);
}
.how-step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11.5px; text-align: center; color: var(--muted); font-weight: 600;
}
.how-icon { font-size: 26px; }

.section-title { font-size: 16px; font-weight: 700; margin: 0; }

/* Subjects grid */
.subjects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.subject-tile {
  border: 2px solid var(--border); background: var(--card); border-radius: 18px;
  padding: 16px 6px 14px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--fg);
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  position: relative;
  transition: transform .1s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
  font-family: inherit;
}
.subject-tile:active:not(:disabled) { transform: scale(.95); }
.subject-tile .dot {
  width: 34px; height: 34px; border-radius: 50%;
  background: oklch(68% 0.15 var(--hue, 250));
  box-shadow: 0 3px 8px oklch(68% 0.15 var(--hue, 250) / 0.45);
}
.subject-tile .tile-title { line-height: 1.2; }
.subject-tile.selected {
  border-color: transparent;
  background: oklch(68% 0.15 var(--hue, 250) / 0.14);
  box-shadow: 0 0 0 3px oklch(68% 0.15 var(--hue, 250)), var(--shadow-md);
  transform: translateY(-2px);
}
.subject-tile.selected::after {
  content: "✓";
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: oklch(68% 0.15 var(--hue, 250)); color: white;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.subject-tile.disabled, .subject-tile:disabled { opacity: .45; cursor: default; box-shadow: none; }
.subject-tile .soon { font-size: 9.5px; color: var(--muted); font-weight: 700; }

/* Mode toggle */
.mode-toggle { display: flex; gap: 8px; }
.mode-pill {
  flex: 1; border: 2px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: 999px; padding: 12px 8px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.mode-pill:active { transform: scale(.96); }
.mode-pill.active { background: var(--coral); border-color: var(--coral); color: white; box-shadow: var(--shadow-md); }

/* CTA — "гамдроп"-кнопка с объёмным нижним краем, проседает при нажатии */
.cta-btn {
  border: none; background: var(--coral); color: white; font-size: 16px; font-weight: 700;
  padding: 18px; border-radius: 18px; cursor: pointer; width: 100%;
  box-shadow: 0 4px 0 var(--coral-dark), 0 8px 18px oklch(30% 0.04 40 / 0.16);
  transform: translateY(0);
  transition: transform .08s ease, box-shadow .08s ease;
  touch-action: manipulation;
}
.cta-btn:disabled {
  background: var(--border); color: var(--muted); cursor: default;
  box-shadow: none;
}
.cta-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--coral-dark), 0 3px 8px oklch(30% 0.04 40 / 0.14);
}

/* Secondary row */
.secondary-row { display: flex; gap: 10px; }
.pill-btn {
  flex: 1; border: 2px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: 999px; padding: 12px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  transition: transform .08s ease;
}
.pill-btn:active { transform: scale(.96); }
.pill-dashed { border-style: dashed; }

/* Stats card */
.stats-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 18px;
  box-shadow: var(--shadow-md);
}
.stats-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.stats-tiles { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-tile { flex: 1; text-align: center; }
.stat-tile .num { font-size: 22px; font-weight: 800; color: var(--coral); }
.stat-tile .label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.stats-split { margin-bottom: 14px; }
.split-bar { display: flex; height: 9px; border-radius: 999px; overflow: hidden; background: var(--border); }
.split-bar .fast { background: var(--coral); }
.split-bar .step { background: var(--amber); }
.split-legend { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 5px; }

.stats-top .top-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-top: 7px; }
.stats-top .top-dot { width: 9px; height: 9px; border-radius: 50%; background: oklch(68% 0.15 var(--hue, 250)); }
.stats-top .top-name { flex: 1; }
.stats-top .top-count { color: var(--muted); font-weight: 700; }

/* Lists (история / дневник) */
.list { display: flex; flex-direction: column; gap: 9px; }
.list-row {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.list-row .dot { width: 11px; height: 11px; border-radius: 50%; background: oklch(68% 0.15 var(--hue, 250)); flex-shrink: 0; }
.list-row .row-main { flex: 1; }
.list-row .row-subject { font-size: 13.5px; font-weight: 700; }
.list-row .row-meta { font-size: 11.5px; color: var(--muted); }
.list-row .row-mode { font-size: 11.5px; color: var(--muted); font-weight: 600; }

.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 28px 0; }

/* PIN screen */
.lock-box { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 0; }
.lock-hint { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0; }
.pin-input {
  width: 170px; text-align: center; font-size: 28px; letter-spacing: 11px;
  padding: 14px; border-radius: 14px; border: 2px solid var(--border); background: var(--card);
  color: var(--fg); box-shadow: var(--shadow-sm);
}
.pin-input:focus { outline: none; border-color: var(--coral); }
.lock-error { color: var(--coral-dark); font-size: 12.5px; margin: 0; font-weight: 600; }

/* Diary */
.diary-summary { display: flex; gap: 10px; }
.diary-summary .tile {
  flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; text-align: center; box-shadow: var(--shadow-sm);
}
.diary-summary .tile .num { font-size: 19px; font-weight: 800; color: var(--coral); }
.diary-summary .tile .label { font-size: 10.5px; color: var(--muted); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 448px; margin: 0 auto;
  background: var(--ink); color: white; padding: 13px 16px; border-radius: 14px;
  font-size: 13.5px; text-align: center; box-shadow: var(--shadow-lg);
  font-weight: 600;
}
