:root {
  --blue: #007aff;
  --blue-hover: #0062e0;
  --blue-light: #f0f6ff;
  --blue-border: #80bfff;
  --gold: #f5a623;
  --ink: #191c21;
  --ink-secondary: #3a3d45;
  --muted: #8e8e93;
  --muted-light: #c7c7cc;
  --bg: #f0f2f8;
  --card: #ffffff;
  --line: #e8eaef;
  --green: #34c759;
  --red: #ff3b30;
  --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

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

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

img, svg {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

body.dark {
  --bg: #15161e;
  --card: #20222e;
  --ink: #f0f1f5;
  --ink-secondary: #c8cbd6;
  --muted: #8a8d9a;
  --line: #2e3142;
  --blue-light: #1c2742;
}

button, input, select, textarea {
  font: inherit;
}

input, select, textarea {
  font-size: 16px !important; /* Prevents iOS auto-zoom on input focus */
}

/* Hide navigation and FAB when virtual keyboard opens to prevent design bugs */
body.keyboard-open .bottom-nav,
body.keyboard-open .fab {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* ===== Login ===== */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #e4e7fa 0%, var(--bg) 50%);
}

.login-card {
  width: min(100%, 390px);
  background: var(--card);
  border-radius: 28px;
  padding: 34px 26px;
  box-shadow: 0 16px 48px rgba(25, 30, 60, 0.08);
  text-align: center;
}

.brand-icon {
  width: 78px;
  height: 78px;
  margin-bottom: 12px;
  border-radius: 18px;
}

h1, h2, h3, p {
  margin-top: 0;
}

.login-card h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 6px 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 4px;
}

.muted, .hint {
  color: var(--muted);
  line-height: 1.45;
}

.hint {
  font-size: 0.8rem;
  margin: 14px 0 0;
}

.primary, .ghost, .danger {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.28);
}

.primary:active {
  opacity: 0.9;
  transform: scale(0.99);
}

.ghost {
  background: var(--blue-light);
  color: var(--blue);
  margin-top: 10px;
}

.danger {
  background: var(--card);
  color: var(--red);
  border: 1.5px solid #fbd2d6;
  margin-top: 14px;
}

.code-login {
  display: grid;
  grid-template-columns: 1fr 95px;
  gap: 8px;
  margin-top: 18px;
}

.code-login input {
  min-width: 0;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: var(--card);
}

.code-login input:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.code-login .primary {
  padding-inline: 10px;
  width: auto;
}

.bot-link {
  display: block;
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: var(--blue-light);
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
}

.telegram-only {
  display: none;
  margin-top: 10px;
}

body.in-telegram .telegram-only {
  display: block;
}

/* ===== App Container ===== */
.app {
  width: min(100%, 640px);
  margin: auto;
  min-height: 100vh;
  padding: 0 0 calc(var(--nav-h) + 16px);
  position: relative;
}

/* ===== Top Bar: Лента (Screenshot 1) ===== */
.topbar-feed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
  height: 60px;
}

.icon-btn-qr {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.topbar-avatar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px #7c4dff, 0 2px 8px rgba(0, 0, 0, 0.12);
  background: linear-gradient(135deg, #2b3a55, #1e283b);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.avatar.big {
  width: 80px;
  height: 80px;
  font-size: 1.35rem;
  box-shadow: 0 0 0 3px var(--blue), 0 4px 16px rgba(0, 0, 0, 0.1);
}

.topbar-sphere {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sphere-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7bf5ff 0%, #2979ff 45%, #9c27b0 85%, #651fff 100%);
  box-shadow: 0 2px 10px rgba(41, 121, 255, 0.35);
}

/* ===== Top Bar: Inner Pages (Screenshots 2 & 4) ===== */
.topbar-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  height: 54px;
}

.page-header-btn {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0;
}

.page-title-text {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
  text-align: center;
  color: var(--ink);
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 38px;
  justify-content: flex-end;
}

.kp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 24px;
  border: 1.8px solid var(--ink);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.05em;
}

.tasks-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-sub-btn {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ===== Content Views ===== */
.content {
  padding: 0 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Date Badge (Лента - Screenshot 1) ===== */
.date-badge {
  text-align: center;
  margin: 8px 0 20px;
}

.date-badge span {
  display: inline-block;
  background: #e9ecf3;
  color: #6a7384;
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 0.85rem;
  font-weight: 600;
}

body.dark .date-badge span {
  background: #252838;
  color: #9ba0b4;
}

.feed-empty-msg {
  text-align: center;
  color: #848e9f;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 36px 0 28px;
}

/* ===== Day Picker Carousel (Screenshots 2 & 4) ===== */
.day-picker {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 4px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.day-picker::-webkit-scrollbar {
  display: none;
}

.day-picker-cal {
  width: 48px;
  height: 48px;
  border: 0;
  background: var(--card);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.day-item-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.day-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: background 0.15s, color 0.15s;
}

.day-circle.active {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.35);
}

.day-circle .day-num {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
}

.day-circle .day-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}

.day-circle.active .day-name {
  color: rgba(255, 255, 255, 0.9);
}

.day-today-label {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ===== Empty State Illustration (Screenshots 2 & 4) ===== */
.empty-state {
  text-align: center;
  padding: 36px 16px 24px;
}

.cat-illustration {
  width: min(100%, 250px);
  height: auto;
  margin: 0 auto 14px;
  display: block;
}

.empty-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  margin: 10px 0 6px;
}

.empty-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

/* ===== Lessons & Cards ===== */
.lesson-list {
  display: grid;
  gap: 10px;
}

.lesson {
  background: var(--card);
  border-radius: 18px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.lesson-mark {
  width: 4px;
  height: 38px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--blue), #7b3fbe, #ff2d55);
}

.lesson-no {
  width: 18px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.lesson-time {
  width: 52px;
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.2;
}

.lesson-time small {
  display: block;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.75rem;
}

.lesson-main {
  flex: 1;
}

.lesson-main strong {
  display: block;
  font-size: 0.95rem;
}

.lesson-main small {
  color: var(--muted);
  font-size: 0.82rem;
}

.lesson-room {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ===== Tasks ===== */
.cards {
  display: grid;
  gap: 10px;
}

.task {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.task-check {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid #cbd5e1;
  background: var(--card);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0;
}

.task.done {
  opacity: 0.52;
}

.task.done strong {
  text-decoration: line-through;
}

.task-content {
  flex: 1;
}

.task-content strong {
  display: block;
  font-size: 0.95rem;
}

.task-content small {
  color: var(--muted);
  font-size: 0.82rem;
}

.task-date {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
}

.segmented {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.segmented button {
  border: 0;
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.86rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.segmented button.active {
  background: var(--blue);
  color: #fff;
}

/* ===== Grades ===== */
.grade-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.grade-chip {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.grade {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0 auto 6px;
  border-radius: 11px;
  background: #ddf6e9;
  color: #14784e;
  font-size: 1.05rem;
  font-weight: 900;
}

.grade.low {
  background: #fff0d6;
  color: #9a6412;
}

.grade-chip small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card div {
  background: var(--card);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-card strong {
  font-size: 1.55rem;
}

.subject-list {
  display: grid;
  gap: 8px;
}

.subject {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.subject strong {
  display: block;
}

.subject small {
  color: var(--muted);
}

.subject-score {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--blue);
}

/* ===== Section Head ===== */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 4px 12px;
}

.section-head h2 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
}

.section-head button {
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
}

/* ===== Focus Card (Лента) ===== */
.focus-card {
  background: var(--card);
  border-radius: 22px;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 3px 12px rgba(25, 30, 60, 0.05);
  margin-bottom: 12px;
}

.focus-card h2 {
  font-size: 1.25rem;
  margin: 2px 0 6px;
  color: var(--ink);
}

.focus-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.time-badge {
  background: #fff3c7;
  color: #735500;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1.15rem;
  font-weight: 800;
}

/* ===== Profile & Form Cards ===== */
.profile-hero {
  text-align: center;
  margin: 16px 0 22px;
}

.profile-hero .avatar {
  margin: 0 auto 12px;
}

.profile-hero h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
}

.profile-hero p {
  color: var(--muted);
  margin: 0;
}

.form-card, .link-card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.form-card label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--muted);
}

.form-card input, .form-card select {
  width: 100%;
  margin-top: 5px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
  background: var(--card);
  font-size: 0.95rem;
}

.form-card input:focus, .form-card select:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.link-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

code {
  font-weight: 900;
  color: var(--blue);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
}

.small-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--blue);
  background: var(--blue-light);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ===== Settings Screen (Screenshot 3) ===== */
.settings-card {
  background: var(--card);
  border-radius: 20px;
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.settings-card h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  cursor: pointer;
}

.settings-row span {
  font-size: 0.92rem;
  font-weight: 500;
}

.settings-row .chevron {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 12px 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
  transition: border-color 0.15s, background 0.15s;
}

.theme-btn svg {
  width: 24px;
  height: 24px;
}

.theme-btn.active {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue);
}

.radio-group {
  display: flex;
  gap: 24px;
  margin: 8px 0 10px;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
}

.radio-group input[type=radio] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted-light);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  margin: 0;
}

.radio-group input[type=radio]:checked {
  border-color: var(--blue);
}

.radio-group input[type=radio]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  margin-top: 10px;
}

.toggle-row span {
  font-size: 0.88rem;
  color: var(--ink);
  max-width: 80%;
  line-height: 1.35;
}

.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: #e2e5eb;
  border: 0;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle.on {
  background: var(--blue);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.toggle.on::after {
  transform: translateX(20px);
}

/* ===== Parent Account Card ===== */
.parent-section {
  background: var(--card);
  border-radius: 20px;
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(25, 30, 60, 0.04);
}

.parent-section h3 {
  margin: 0 0 8px;
  font-size: 0.98rem;
  font-weight: 700;
}

.parent-badge {
  display: inline-block;
  background: #e9f3ff;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.parent-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.unlink-btn {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 6px;
}

.child-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--blue-light);
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.1s;
}

.child-chip:active {
  transform: scale(0.98);
}

.child-chip strong {
  font-size: 0.95rem;
  color: var(--ink);
}

.child-chip small {
  color: var(--muted);
  font-size: 0.8rem;
}

.parent-link-input {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 8px;
  margin-top: 10px;
}

.parent-link-input input {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.9rem;
  background: var(--card);
  color: var(--ink);
}

.parent-link-input button {
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
}

/* ===== Floating Action Button (FAB) ===== */
.fab {
  position: fixed;
  z-index: 15;
  bottom: calc(var(--nav-h) + 20px);
  right: max(18px, calc(50% - 310px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, #1884fe, #007aff);
  color: #ffffff;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 122, 255, 0.4);
  display: none;
  place-items: center;
  transition: transform 0.15s;
}

.fab:active {
  transform: scale(0.92);
}

.fab.show {
  display: grid;
}

/* ===== Bottom Navigation (Screenshots 1, 2, 4) ===== */
.bottom-nav {
  position: fixed;
  z-index: 20;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 640px);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 2px 2px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: color 0.15s;
}

.bottom-nav svg {
  width: 26px;
  height: 26px;
  stroke: var(--muted);
  fill: none;
  transition: stroke 0.15s, fill 0.15s;
}

.bottom-nav button.active {
  color: var(--ink);
  font-weight: 700;
}

.bottom-nav button.active svg {
  stroke: var(--gold);
  fill: var(--gold);
  fill-opacity: 0.2;
}

/* ===== Quick Add Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: min(100%, 540px);
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-sheet h2 {
  font-size: 1.25rem;
  margin-bottom: 16px;
}

/* ===== Paywall ===== */
.paywall {
  width: min(100%, 400px);
  margin: 32px auto 0;
  background: var(--card);
  border-radius: 24px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(25, 30, 60, 0.06);
}

.pay-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #fff0c7;
  color: #a56800;
  font-size: 1.4rem;
}

.paywall h2 {
  margin-bottom: 6px;
  font-size: 1.2rem;
}

.paywall p {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.paywall small {
  display: block;
  color: var(--muted);
  margin-top: 12px;
  font-size: 0.78rem;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px);
  transform: translate(-50%, 20px);
  background: #1e2538;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  font-size: 0.88rem;
  text-align: center;
  width: min(calc(100% - 32px), 380px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 680px) {
  .app {
    box-shadow: 0 0 60px rgba(25, 30, 60, 0.08);
  }
}
