/* Пари — Дія's structure, monobank's warmth. Mobile-first. */

/* e-Ukraine: put the woff2 files in /fonts (see PLAN.md, Phase 3).
   Until they're there, the system font is used. */
@font-face { font-family: "e-Ukraine"; src: url("../fonts/e-Ukraine-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "e-Ukraine"; src: url("../fonts/e-Ukraine-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "e-Ukraine"; src: url("../fonts/e-Ukraine-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Icon font, self-hosted and subset to the icons we use (see scripts/icons.mjs). */
@font-face {
  font-family: "Material Symbols Rounded";
  src: url("../fonts/material-symbols-rounded.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: block;
}

/* ---------- Tokens ---------- */
:root {
  --bg-1: #dcebff;
  --bg-2: #d8f4e6;
  --card: #ffffff;
  --text: #0b0d12;
  --muted: #566070;
  --line: rgba(15, 23, 42, 0.08);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.07);
  --btn-bg: #0b0d12;
  --btn-text: #ffffff;
  --track: #e7ebf0;
  --neutral-soft: #eef1f5;
  --input-bg: #f5f7fa;
  --input-border: rgba(15, 23, 42, 0.2);

  /* Accents: only for meaning */
  --live: #147a39;
  --live-soft: #dcf5e4;
  --soon: #9a5700;
  --soon-soft: #fdefd3;
  --alarm: #c21f18;
  --alarm-soft: #fde1df;

  /* Subject accents: each subject hashes to one (js/voice.js accentIndex).
     Used for the hero's soft wash and the class type chip, never for body text. */
  --accent-1: #1d5bb8;
  --accent-1-soft: #e4eefc;
  --accent-2: #6b3fbf;
  --accent-2-soft: #efe8fc;
  --accent-3: #0a716c;
  --accent-3-soft: #dcf3f0;
  --accent-4: #ad2f5c;
  --accent-4-soft: #fce6ee;
  --accent-5: #8e3a8e;
  --accent-5-soft: #f8e6f7;
  --accent-6: #0b6590;
  --accent-6-soft: #def0f9;

  --radius: 24px;
  --radius-sm: 16px;
  --gap: 16px;
  --font: "e-Ukraine", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #0e1116;
    --bg-2: #0d1713;
    --card: #1b1e24;
    --text: #f3f5f8;
    --muted: #a3acb9;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    /* Black on a dark card would vanish, so the pill turns white. */
    --btn-bg: #ffffff;
    --btn-text: #0b0d12;
    --track: rgba(255, 255, 255, 0.1);
    --neutral-soft: rgba(255, 255, 255, 0.07);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.22);

    --live: #62d68e;
    --live-soft: rgba(98, 214, 142, 0.14);
    --soon: #f3b94d;
    --soon-soft: rgba(243, 185, 77, 0.14);
    --alarm: #ff6d63;
    --alarm-soft: rgba(255, 109, 99, 0.16);

    --accent-1: #8db5ff;
    --accent-1-soft: rgba(141, 181, 255, 0.16);
    --accent-2: #bda3ff;
    --accent-2-soft: rgba(189, 163, 255, 0.16);
    --accent-3: #5fd2c6;
    --accent-3-soft: rgba(95, 210, 198, 0.14);
    --accent-4: #ff8fb4;
    --accent-4-soft: rgba(255, 143, 180, 0.15);
    --accent-5: #f09ef0;
    --accent-5-soft: rgba(240, 158, 240, 0.15);
    --accent-6: #6fc6ef;
    --accent-6-soft: rgba(111, 198, 239, 0.15);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* The scrollbar's space is always kept, so switching between a short and a long screen
   doesn't shift the page (and the tab bar) sideways. */
html { background: var(--bg-2); scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(165deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* iOS draws a grey box over anything tapped; our buttons have their own press state. */
  -webkit-tap-highlight-color: transparent;
}

/* Controls behave like app controls: a long press doesn't select their text or pop up
   the link preview. Content text stays selectable. */
.btn, .btn-join, .no-link, .icon-btn, .switch-row, .segment, .type-chip, .share-row, .tomorrow,
.tab, .chip, .task-check, .task-remove, .avatar-btn, .glyph-btn, .stats-link {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

p, h1, h2, h3, ul { margin: 0; }
[hidden] { display: none !important; }

/* Visible to screen readers only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 3px;
  border-radius: 8px;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ---------- Icons (Material Symbols Rounded, filled) ---------- */
.icon {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
  /* Reserve the square and hide ligature text until the font is ready. */
  display: inline-block;
  width: 1em;
  height: 1em;
  overflow: hidden;
  flex-shrink: 0;
  visibility: hidden;
}
.icons-ready .icon { visibility: visible; }
.icon--20 { font-size: 20px; font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 20; }
.icon--40 { font-size: 40px; font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 40; }

/* ---------- Header ---------- */
/* A top row like a banking app's: the avatar on the left, plain glyph buttons on the right
   (no circles, no shadows), then the date, greeting and day summary. */
.top {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 4px 4px;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: -8px; /* the glyph, not its tap area, lines up with the cards' edge */
}
.glyph-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.glyph-btn .icon { font-size: 28px; font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 28; }
.glyph-btn:active { transform: scale(0.9); background: var(--neutral-soft); }
.avatar-btn {
  display: block;
  border-radius: 50%;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.avatar-btn:active { transform: scale(0.94); }

/* The avatar: the name's initial on its accent colour (person icon without a name). */
.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--neutral-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.avatar[data-accent] { background: var(--accent-soft); color: var(--accent); }
.avatar--big { width: 72px; height: 72px; font-size: 30px; }
.avatar--big .icon { font-size: 40px; font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 40; }

/* Date + time: small, above the greeting */
.date {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.date::first-letter { text-transform: uppercase; }

.greeting {
  margin-top: 6px;
  font-size: clamp(24px, 7.4vw, 28px); /* 28px from ~380px wide, a bit smaller on an iPhone SE */
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.day-summary {
  margin-top: 6px;
  font-size: 17px;
  line-height: 1.35;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  text-decoration: none;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card--compact { padding: 16px 20px; }

.card-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ---------- Hero ---------- */
/* A soft wash in the corner: the subject's accent, or the state colour when that matters more. */
.hero {
  --wash: var(--accent-soft, transparent);
  padding: 24px 20px 20px;
  background:
    radial-gradient(130% 90% at 100% 0%, var(--wash) 0%, transparent 65%),
    var(--card);
}
[data-accent="1"] { --accent: var(--accent-1); --accent-soft: var(--accent-1-soft); }
[data-accent="2"] { --accent: var(--accent-2); --accent-soft: var(--accent-2-soft); }
[data-accent="3"] { --accent: var(--accent-3); --accent-soft: var(--accent-3-soft); }
[data-accent="4"] { --accent: var(--accent-4); --accent-soft: var(--accent-4-soft); }
[data-accent="5"] { --accent: var(--accent-5); --accent-soft: var(--accent-5-soft); }
[data-accent="6"] { --accent: var(--accent-6); --accent-soft: var(--accent-6-soft); }
.hero[data-state="soon"] { --wash: var(--soon-soft); }
.hero[data-state="paused"] { --wash: var(--alarm-soft); }

.status {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--neutral-soft);
  color: var(--text);
}
/* Smaller glyph so it sits inside the circle instead of touching its edge. */
.status-icon .icon {
  font-size: 30px;
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 30;
}
.hero[data-state="live"] .status-icon { background: var(--live-soft); color: var(--live); }
.hero[data-state="soon"] .status-icon { background: var(--soon-soft); color: var(--soon); }
.hero[data-state="paused"] .status-icon { background: var(--alarm-soft); color: var(--alarm); }
.hero[data-state="resumed"] .status-icon { background: var(--live-soft); color: var(--live); }
.hero[data-state="paused"] { box-shadow: var(--shadow), inset 0 0 0 2px var(--alarm); }

.status-label {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.hero[data-state="live"] .status-label { color: var(--live); }
.hero[data-state="soon"] .status-label { color: var(--soon); }
.hero[data-state="paused"] .status-label { color: var(--alarm); }
.hero[data-state="resumed"] .status-label { color: var(--live); }
.hero[data-state="paused"] .progress-fill { background: var(--alarm); }

.alarm-note {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.alarm-note--active {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--alarm-soft);
  color: var(--alarm);
  font-weight: 500;
}

.status-detail {
  margin-top: 2px;
  color: var(--muted);
}

/* Лекції: filled chip. Практичні / Лабораторні: outlined. */
.class-kicker { margin-top: 20px; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 12px 4px 9px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent, var(--text));
  box-shadow: inset 0 0 0 1.5px currentColor;
}
.type-chip--filled {
  background: var(--accent-soft, var(--neutral-soft));
  box-shadow: none;
}

.class-title {
  margin-top: 10px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.class-meta {
  margin-top: 6px;
  color: var(--muted);
}

.timing {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.progress {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--live);
  transform-origin: left;
  transition: transform 0.6s ease;
}

.btn-join {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 17px;
  font-weight: 500;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
/* Hover only with a real pointer: on iPhone a tap would leave it "stuck" dimmed. */
@media (hover: hover) {
  .btn-join:hover { opacity: 0.9; }
}
.btn-join:active { transform: scale(0.98); }
/* During an alert: still there, but shelter comes first. */
.btn-join--secondary {
  background: var(--neutral-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--input-border);
}

/* No link yet: a quiet full-width pill that is itself the "add" action. */
.no-link {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--input-border);
  font-size: clamp(15px, 4.6vw, 17px); /* stays on one line down to 320px wide */
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.no-link:active { transform: scale(0.98); }

/* ---------- Today list ---------- */
.rows { list-style: none; padding: 0; }

.row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; padding-top: 0; }
/* Let the middle column shrink and long subject names wrap, so the «зараз» badge never
   gets pushed off-screen on narrow phones. */
.row > * { min-width: 0; }
.row-title span, .row-sub { overflow-wrap: anywhere; }
.row:last-child { padding-bottom: 0; }

.row-time {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.25;
}
.row-time small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

.row-title {
  display: flex;
  gap: 6px;
  align-items: center;
  font-weight: 500;
  line-height: 1.3;
}
.row-title .icon { color: var(--muted); }
.row-sub {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

.row.is-past .row-time,
.row.is-past .row-title { color: var(--muted); font-weight: 400; }

.badge {
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--live-soft);
  color: var(--live);
}

/* ---------- Tomorrow (the whole card opens the days ahead) ---------- */
.tomorrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -16px -20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: transform 0.15s ease;
}
.tomorrow:active { transform: scale(0.99); }
.tomorrow .icon { color: var(--muted); }
.tomorrow-line { font-weight: 500; line-height: 1.35; }
.tomorrow-sub {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- Footer ---------- */
.foot {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}
.foot .stale {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--soon-soft);
  color: var(--soon);
  font-weight: 500;
}

/* ---------- Settings ---------- */
.settings-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 4px 0;
}
.settings-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}
.settings-title:focus { outline: none; }

.device-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  font-size: 14px;
}
.device-note .icon { margin-top: 1px; }

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.group-title {
  margin-top: 8px;
  padding: 0 4px;
  font-size: 17px;
  font-weight: 700;
}

.section-hint { margin: -4px 0 14px; }

/* Collapsible card (<details>) */
.disclosure summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary .icon {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
}
.disclosure[open] summary .icon { transform: rotate(180deg); }
.disclosure[open] summary { margin-bottom: 12px; }
.disclosure-count {
  font-size: 13px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--muted);
}

/* Credits footer: quiet attribution, no card */
.about {
  margin-top: 12px;
  padding: 0 8px;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.about-tagline { font-size: 13px; font-weight: 500; color: var(--text); }
.about-credits {
  margin-top: 8px;
  padding: 0;
  list-style: none;
}
.about-credits a { color: inherit; text-underline-offset: 2px; }

.field {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.card-title + .field,
.section-hint + .field { border-top: 0; padding-top: 0; }
.field:first-child { border-top: 0; padding-top: 0; }
.field:last-child { padding-bottom: 0; }

.field-label {
  display: block;
  font-weight: 500;
  line-height: 1.3;
}
.field-context {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

.field input:not([type="checkbox"]):not([type="radio"]) {
  display: block;
  width: 100%;
  margin-top: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px+ stops iOS from zooming in on focus */
}
.field textarea {
  display: block;
  width: 100%;
  margin-top: 10px;
  min-height: 88px;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px+ stops iOS from zooming in on focus */
  line-height: 1.4;
  resize: vertical;
}
.field textarea:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }
.field textarea::placeholder,
.field input::placeholder { color: var(--muted); opacity: 0.7; }
.field input:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }
.field input[aria-invalid="true"] { border-color: var(--alarm); border-width: 2px; }

.field-msg {
  font-size: 13px;
  min-height: 0;
}
.field-msg:not(:empty) { margin-top: 6px; }
.field-msg.is-error { color: var(--alarm); font-weight: 500; }
.field-msg.is-saved { color: var(--live); }

.settings-actions {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}
@media (min-width: 420px) {
  .settings-actions { grid-template-columns: 1fr 1fr; }
}
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
@media (hover: hover) {
  .btn:hover { opacity: 0.9; }
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--btn-bg); color: var(--btn-text); }
.btn--secondary { background: var(--neutral-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--input-border); }
.btn--text { background: transparent; color: var(--muted); min-height: 48px; }
.btn--wide { width: 100%; }

.settings-status {
  text-align: center;
  font-size: 14px;
  color: var(--live);
  font-weight: 500;
}
.settings-status:empty { display: none; }
.settings-status.is-error { color: var(--alarm); }

/* On/off switch row (whole row is the tap target) */
.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  cursor: pointer;
}
.switch-text { display: flex; flex-direction: column; flex: 1; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 999px;
  background: var(--track);
  box-shadow: inset 0 0 0 1px var(--input-border);
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.switch:checked { background: var(--live); box-shadow: none; }
.switch:checked::before { transform: translateX(20px); }
.switch:disabled { opacity: 0.5; }
.switch:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }

/* 5 / 10 / 15 хв */
.segmented { margin: 14px 0 0; padding: 0; border: 0; min-width: 0; }
.segmented legend { padding: 0; margin-bottom: 10px; }
.segmented-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--neutral-soft);
}
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 999px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.segment input:checked + span { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.segment input:focus-visible + span { outline: 3px solid var(--text); outline-offset: 1px; }
.segment input:disabled + span { opacity: 0.5; }

/* iOS: "add to home screen first", with the actual Safari icons as the illustration */
.install-card:focus { outline: none; }
.install-title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.install-steps {
  margin-top: 16px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}
.install-steps li {
  display: grid;
  grid-template-columns: 24px 44px 1fr;
  gap: 10px;
  align-items: center;
}
.install-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 13px;
  font-weight: 700;
}
.install-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-1-soft);
  color: var(--accent-1);
}
.card[data-key="push"]:focus { outline: none; }

/* Home card: "Нагадувати про пари?" */
.push-card-title { font-size: 17px; font-weight: 700; }
.push-card-body { margin-top: 4px; color: var(--muted); }
.push-card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 16px;
}
.push-card-actions .btn { text-decoration: none; }
.push-card-done { font-weight: 500; color: var(--live); text-align: center; }

/* ---------- Stats card: a big number, a friendly sentence ---------- */
.stats-card {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stats-number {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stats-line { font-weight: 500; line-height: 1.3; }
/* The whole home card opens «Статистика». */
.stats-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: -20px;
  padding: 20px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: transform 0.15s ease;
}
.stats-link:active { transform: scale(0.99); }
.stats-link > div { flex: 1; }
.stats-link > .icon { color: var(--muted); }
.stats-sub { margin-top: 2px; font-size: 14px; color: var(--muted); }
.stats-actions { margin-top: 14px; }
.btn--danger { background: var(--alarm-soft); color: var(--alarm); box-shadow: none; }

/* ---------- Share with the group ---------- */
.share-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--soon-soft);
  color: var(--soon);
  font-size: 14px;
  font-weight: 500;
}
.share-warning .icon { margin-top: 1px; }
.share-manual { margin-top: 12px; }
.share-manual input {
  display: block;
  width: 100%;
  margin-top: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

/* ---------- Onboarding: one page at a time, buttons pinned to the bottom ---------- */
#onboarding-view { min-height: calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.onb {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0;
  animation: rise 0.4s ease both;
}
.onb-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 4px 0;
}
.onb-badge {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 20px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
}
.onb-badge--good { color: var(--live); }
.onb-title {
  font-size: clamp(26px, 8vw, 32px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.onb-title:focus { outline: none; }
.onb-text {
  margin-top: 10px;
  font-size: 17px;
  color: var(--muted);
}
.onb-main > .card,
.onb-main > .onb-details { margin-top: 24px; }
.onb-hint {
  margin-top: 12px;
  padding: 0 4px;
  font-size: 14px;
  color: var(--muted);
}
.onb-steps { margin-top: 0; }
.onb-actions {
  display: grid;
  gap: 4px;
}
.onb-form input {
  display: block;
  width: 100%;
  margin-top: 24px;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 17px; /* 16px+ stops iOS from zooming in on focus */
}
.onb-form input::placeholder { color: var(--muted); opacity: 0.7; }
.onb-form input:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }

/* Links from the group: what's inside, collapsed by default */
.share-list { list-style: none; padding: 0; margin: 0; }
.share-item { border-top: 1px solid var(--line); }
.share-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  min-height: 44px;
  cursor: pointer;
}
.share-check {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--live);
  cursor: pointer;
}
.share-text { display: flex; align-items: center; gap: 8px; min-width: 0; }
.share-name { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.share-badge {
  flex-shrink: 0;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--soon-soft);
  color: var(--soon);
}

/* Icon + title + one line (welcome page, «Що нового») */
.features {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 18px;
}
.features li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: center;
}
.feature-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-1-soft);
  color: var(--accent-1);
}
.feature-title { font-weight: 700; line-height: 1.3; }
.feature-text { margin-top: 2px; font-size: 14px; color: var(--muted); }

/* ---------- «Що нового» sheet ---------- */
.news {
  width: min(100% - 32px, 440px);
  max-height: calc(100dvh - 48px);
  padding: 28px 24px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.news[open] { animation: rise 0.3s ease both; }
.news::backdrop { background: rgba(8, 10, 14, 0.45); }
.news-title {
  margin-bottom: 24px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}
.news .btn { margin-top: 28px; }

/* ---------- Days ahead (#days) ---------- */
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.day-name { font-size: 17px; font-weight: 700; line-height: 1.3; }
.day-name::first-letter { text-transform: uppercase; }
.day-count { flex-shrink: 0; font-size: 14px; color: var(--muted); }
.day-none { color: var(--muted); }
.day-head:has(+ .day-none) { margin-bottom: 4px; }

/* ---------- Join (#join): opened from a push ---------- */
#join-view { min-height: calc(100dvh - 48px); justify-content: center; }
.join-card { padding: 24px 20px 20px; animation: rise 0.3s ease both; }
.join-card .class-title:focus { outline: none; }
.join-label { font-weight: 700; color: var(--live); }
#join-view .btn--text { text-decoration: none; }

/* ---------- Tab bar: a floating pill (Пари · Завдання · Викладачі) ---------- */
/* Icon on top, label below; the current tab sits on a soft capsule. Frosted where the
   browser can blur what scrolls underneath, the plain card colour where it can't. */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line);
  transform: translateX(-50%);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .tabbar {
    background: color-mix(in srgb, var(--card) 80%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 76px;
  min-height: 52px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.tab[aria-current="page"] { background: var(--neutral-soft); color: var(--text); }
.tab:active { transform: scale(0.96); }
.tab-label { font-size: 11px; font-weight: 500; line-height: 1.2; }

/* Room for the bar under the last card. */
body.has-tabbar .app { padding-bottom: calc(max(16px, env(safe-area-inset-bottom)) + 88px); }
/* Out of the way while typing (on phones it would sit on top of the keyboard). */
body:has(.view :is(input, select, textarea):focus) .tabbar { display: none; }

/* Title of a tab screen: no back arrow, same height as a header with one. */
.tab-top { min-height: 48px; }

@media (prefers-reduced-motion: reduce) {
  .tab, .chip, .task-check, .task-remove { transition: none; }
}

/* ---------- Shared bits for the tabs ---------- */
.icon-btn--soft { background: var(--neutral-soft); box-shadow: none; color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-text); }
.chip--add { padding: 0 14px 0 10px; font-size: 14px; white-space: nowrap; }

.select {
  display: block;
  width: 100%;
  margin-top: 10px;
  min-height: 48px;
  padding: 0 40px 0 14px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background-color: var(--input-bg);
  /* A small chevron drawn with two gradients, so it follows the theme colours. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 21px) 50%, calc(100% - 16px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.select:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }

/* ---------- Tasks (#tasks) ---------- */
.task-add .card-title { display: block; }
.task-add-row { display: flex; gap: 10px; align-items: center; }
.task-add-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px+ stops iOS from zooming in on focus */
}
.task-add-row input::placeholder { color: var(--muted); opacity: 0.7; }
.task-add-row input:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }
.task-add-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.task-add-btn:active { transform: scale(0.95); }
.task-add-btn:disabled { opacity: 0.3; cursor: default; }
.task-options { margin-top: 14px; }
.task-options .field:first-child { border-top: 1px solid var(--line); padding-top: 14px; }
.task-due-hint { margin-top: 8px; }

.task-sections { display: flex; flex-direction: column; gap: var(--gap); }
.tasks { list-style: none; padding: 0; }
.task {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.task:first-child { border-top: 0; padding-top: 0; }
.task:last-child { padding-bottom: 0; }
.task > * { min-width: 0; }
.task-check, .task-remove {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.task-check { margin-left: -10px; }
.task-check:active, .task-remove:active { transform: scale(0.9); }
.task.is-done .task-check { color: var(--live); }
.task-remove.is-armed { background: var(--alarm-soft); color: var(--alarm); }
/* The text is a button that opens the task (title + notes editor). */
.task-open {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 44px;
  justify-content: center;
  padding: 6px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.task-title { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.task.is-done .task-title { color: var(--muted); font-weight: 400; text-decoration: line-through; }
.task-sub { margin-top: 2px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
/* Notes: the first two lines as a preview; the editor shows them all. */
.task-notes {
  display: -webkit-box;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.task-edit { grid-column: 1 / -1; padding: 4px 0 10px; }
.task-edit .field:first-child { padding-top: 4px; }
.task-edit .settings-actions { margin-top: 14px; }
/* A missed date: amber, never red (no guilt). */
.task-section--overdue .card-title,
.task.is-overdue .task-sub { color: var(--soon); }
.task-done .tasks { margin-bottom: 4px; }

/* On a class row: something for this subject is due that day. */
.due-mark {
  display: inline-grid;
  place-items: center;
  margin: -10px 0;
  padding: 10px 4px;
  text-decoration: none;
}
.row-title .due-mark .icon { color: var(--soon); }

/* ---------- Teachers (#teachers) ---------- */
.contacts { list-style: none; padding: 0; }
.contact {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.contact:first-child { border-top: 0; padding-top: 0; }
.contact:last-child { padding-bottom: 0; }
.contact > * { min-width: 0; }
.contact-name { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.contact-sub { margin-top: 2px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.contact-email {
  display: block;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-1);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.contact-edit, .contact-msg { grid-column: 1 / -1; }
.contact .contact-edit { padding: 4px 0 0; border-top: 0; }
.contact-edit-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.contact-edit .contact-edit-row input:not([type="checkbox"]):not([type="radio"]) { flex: 1; min-width: 0; margin-top: 0; }
.contact-done { flex-shrink: 0; min-height: 48px; }

/* ---------- Profile (#profile) ---------- */
.profile-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 0 4px;
}
.profile-head .settings-title { overflow-wrap: anywhere; }

/* ---------- Stats (#stats): title + period, a hero card, then a list ---------- */
.stat-head { padding: 0 4px; }
.stat-title { font-size: clamp(28px, 8vw, 32px); }
.stat-period { margin-top: 4px; font-size: 17px; font-weight: 500; color: var(--muted); }
#stats-view > .segmented { margin: 0; }

.stat-hero {
  padding: 20px;
  background:
    radial-gradient(130% 90% at 100% 0%, var(--live-soft) 0%, transparent 65%),
    var(--card);
}
.stat-badge {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--live-soft);
  color: var(--live);
}
.stat-label { margin-top: 16px; font-size: 20px; font-weight: 700; color: var(--muted); }
.stat-number {
  margin-top: 2px;
  font-size: clamp(52px, 16vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-unit { margin-left: 10px; font-size: 24px; letter-spacing: 0; color: var(--muted); }
.stat-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
  font-weight: 500;
  line-height: 1.35;
}
.stat-note .icon { color: var(--live); }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.stat-tile { padding: 16px; border-radius: var(--radius-sm); background: var(--neutral-soft); }
.stat-tile-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--card);
}
.stat-tile-number {
  margin-top: 12px;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-tile-label { margin-top: 4px; font-weight: 500; color: var(--muted); }

.stat-rows { list-style: none; padding: 0; }
.stat-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.stat-row:first-child { border-top: 0; padding-top: 0; }
.stat-row:last-child { padding-bottom: 0; }
.stat-row > * { min-width: 0; }
.stat-row-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft, var(--neutral-soft));
  color: var(--accent, var(--text));
  font-size: 17px;
  font-weight: 700;
}
.stat-row-name { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
/* Relative to the top row, not to a total: it's a shape, not a percentage. */
.stat-bar { height: 6px; margin-top: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.stat-bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent, var(--text)); }
.stat-row-count { font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
