/* Happy School — mobile-first, matches the light theme of the React app. */

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

:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --text: #1c1b1f;
  --muted: #6f6c75;
  --accent: #6d4de0;
  --accent-soft: #ece7fc;
  --border: #e6e3de;
  --green-bg: #e3f4e6; --green-fg: #1e7c33;
  --amber-bg: #fdf0d8; --amber-fg: #9a6b0c;
  --blue-bg: #e3edfc;  --blue-fg: #1d5cb8;
  --red-bg: #fce5e3;   --red-fg: #b3271e;
  --grey-bg: #eeedeb;  --grey-fg: #6f6c75;
  --radius: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 84px;
}

/* In Telegram fullscreen the status bar + native controls (Back, ⋯) overlay the
   top of the page — the --tg-*-inset vars come from telegram-web-app.js. */
.page {
  max-width: 36rem; margin: 0 auto; display: flex; flex-direction: column; gap: 12px;
  padding: calc(16px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)) 16px 16px;
}

h1 { font-size: 1.35rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin-bottom: 8px; }
h3 { font-size: 1rem; margin-bottom: 8px; }
p { line-height: 1.45; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.eyebrow { color: var(--muted); font-size: 0.82rem; margin-bottom: 2px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.avatar { font-size: 2rem; background: var(--card); border-radius: 50%; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgb(0 0 0 / 6%); }

.section { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* Cards */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  display: block;
}
.card-link { text-decoration: none; color: inherit; transition: transform 0.06s ease; }
.card-link:active { transform: scale(0.985); }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-emoji { font-size: 1.6rem; flex-shrink: 0; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 600; }
.chevron { color: var(--muted); font-size: 1.3rem; }
.nav-cards { display: flex; flex-direction: column; gap: 10px; }
.nav-cards .card-link { display: flex; align-items: center; gap: 12px; font-weight: 600; }

.empty-card { text-align: center; display: flex; flex-direction: column; gap: 12px; padding: 24px 14px; color: var(--muted); }
.info-card { background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.warn-card { background: var(--amber-bg); color: var(--amber-fg); border-color: transparent; }
.error-card { background: var(--red-bg); color: var(--red-fg); border-color: transparent; }
.cta-card { background: var(--accent-soft); border-color: transparent; }
.success-card { text-align: center; padding: 28px 16px; }
.success-card .card-emoji { font-size: 2.4rem; margin-bottom: 8px; }
.conflict { border: 1.5px solid var(--red-fg); }

/* Badges */
.badge { font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.badge-green { background: var(--green-bg); color: var(--green-fg); }
.badge-amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge-blue { background: var(--blue-bg); color: var(--blue-fg); }
.badge-red { background: var(--red-bg); color: var(--red-fg); }
.badge-grey { background: var(--grey-bg); color: var(--grey-fg); }
.badge-purple { background: var(--accent-soft); color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  border: none; border-radius: 14px; padding: 13px 18px;
  font-size: 0.95rem; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { background: #c9c3e8; cursor: default; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-small { padding: 9px 12px; font-size: 0.85rem; margin-top: 10px; }
.btn-reset { width: 100%; text-align: left; font-family: inherit; font-size: inherit; cursor: pointer; }

/* Progress */
.progress-block { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.progress { height: 8px; background: var(--grey-bg); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* Pills — horizontal scroll strip */
.pills { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex-shrink: 0; }
button.pill, .pill-radio .pill {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.pill.active { background: var(--text); color: #fff; border-color: var(--text); }
.pill-radio input { display: none; }
.pill-radio input:checked + .pill { background: var(--text); color: #fff; border-color: var(--text); }
.pill-radio .pill { display: inline-block; }

/* Option lists (slots, wizard, toggles) */
.option-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.option {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer; font-weight: 600;
}
.option input { accent-color: var(--accent); width: 18px; height: 18px; }
.option-toggle input { display: none; }
.option-toggle .check { margin-left: auto; color: transparent; font-weight: 700; }
.option-toggle:has(input:checked) { border-color: var(--text); }
.option-toggle:has(input:checked) .check { color: var(--accent); }
.option-title { flex: 1; }
.toggle-label { margin-left: auto; }
.option-toggle:has(input:checked) .toggle-label::after { content: " ✓"; color: var(--accent); }

/* Detail pages */
.detail-header { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.detail-emoji { font-size: 2.6rem; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; border: none; background: none; display: inline-block; padding: 4px 0; }
.slot-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.slot-row:last-child { border-bottom: none; }
.time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; }

/* Program stages */
.stages { display: flex; flex-direction: column; gap: 8px; }
.stage {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.stage.current { border-color: var(--accent); }
.stage-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--grey-bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700;
}
.stage.done .stage-num { background: var(--accent); color: #fff; }
.stage.current .stage-num { background: var(--accent-soft); color: var(--accent); }
.stage-name { flex: 1; }
.position-badge {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700;
}

/* Wizard */
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.step { flex: 1; height: 5px; border-radius: 999px; background: var(--grey-bg); }
.step.active { background: var(--accent); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.input {
  border: 1.5px solid var(--border); border-radius: 12px; padding: 12px;
  font-size: 1rem; font-family: inherit; background: var(--card); color: var(--text); width: 100%;
}
.input:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; margin-bottom: 12px; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 8px 4px calc(8px + max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px)));
  z-index: 20;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; font-weight: 600;
  min-width: 64px; user-select: none;
}
.tab span { font-size: 1.25rem; }
.tab.active { color: var(--accent); }

/* Bottom sheet */
.sheet-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 40%); z-index: 30; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 31;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  max-width: 36rem; margin: 0 auto;
}
.sheet-dialog {
  border: none; border-radius: 20px; padding: 20px;
  max-width: 20rem; width: calc(100vw - 48px);
  display: flex; flex-direction: column; gap: 10px;
}
dialog.sheet-dialog:not([open]) { display: none; }
.sheet-dialog::backdrop { background: rgb(0 0 0 / 40%); }

/* Login */
.login-card { text-align: center; margin-top: 20vh; display: flex; flex-direction: column; gap: 12px; padding: 28px 20px; }
.login-emoji { font-size: 3rem; }

/* Profile */
.profile-card { display: flex; flex-direction: column; }
.profile-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.profile-row:last-child { border-bottom: none; }

/* htmx */
.htmx-request { opacity: 0.6; pointer-events: none; }
