/* ==========================================================================
   Design tokens — dark glassmorphism
   ========================================================================== */
:root {
  --bg-1: #1a1330;
  --bg-2: #24184a;
  --bg-3: #0f0a20;

  --text: #f5f1ff;
  --text-muted: #bdb3dd;
  --text-faint: #8b81ad;

  --accent: #a875f5;
  --accent-strong: #e29bff;
  --accent-2: #4fd6d1;
  --accent-2-strong: #7fe8e3;
  --accent-glow: rgba(184, 120, 255, 0.55);
  --accent-soft: rgba(184, 120, 255, 0.2);

  --bg-glow-1: rgba(184, 100, 255, 0.32);
  --bg-glow-2: rgba(79, 214, 209, 0.22);
  --bg-glow-3: rgba(255, 138, 178, 0.2);
  --bg-glow-4: rgba(255, 190, 90, 0.14);

  --success: #6be3b8;
  --success-glow: rgba(107, 227, 184, 0.45);
  --success-soft: rgba(107, 227, 184, 0.16);

  --danger: #ff8a8a;
  --danger-glow: rgba(255, 138, 138, 0.45);
  --danger-soft: rgba(255, 138, 138, 0.16);

  --glass-bg: rgba(255, 255, 255, 0.065);
  --glass-bg-strong: rgba(255, 255, 255, 0.11);
  --glass-border: rgba(215, 195, 255, 0.18);
  --glass-highlight: rgba(255, 255, 255, 0.38);
  --glass-blur: 20px;

  --shadow-edge: inset 0 1px 0 var(--glass-highlight), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  --shadow-elevate: 0 12px 34px rgba(0, 0, 0, 0.4);
  --shadow-elevate-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --font: 'Segoe UI', system-ui, -apple-system, 'Inter', Roboto, sans-serif;
}

/* Optional manual overrides, for a future light/dark toggle */
:root[data-theme="light"] {
  --text: #2c2a33; --text-muted: #716d7a; --text-faint: #a29daf;
  --glass-bg: rgba(255, 255, 255, 0.55); --glass-bg-strong: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(44, 42, 51, 0.1); --glass-highlight: rgba(255, 255, 255, 0.8);
  --shadow-edge: inset 0 1px 0 var(--glass-highlight), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  --shadow-elevate: 0 12px 30px rgba(40, 35, 60, 0.12); --shadow-elevate-lg: 0 20px 50px rgba(40, 35, 60, 0.18);
}

/* Unlockable "style case" palettes (Rewards page). Only the background
   gradient + accent colors shift — glass/blur/spacing stay identical so
   every screen keeps working regardless of which one is equipped. */
:root[data-case-theme="sunset"] {
  --bg-1: #2b140f; --bg-2: #3d1f14; --bg-3: #180b08;
  --accent: #f5934c; --accent-strong: #ffb37a;
  --accent-2: #ffd166; --accent-2-strong: #ffe29e;
  --accent-glow: rgba(245, 147, 76, 0.45); --accent-soft: rgba(245, 147, 76, 0.16);
  --bg-glow-1: rgba(245, 147, 76, 0.24); --bg-glow-2: rgba(255, 200, 120, 0.12); --bg-glow-3: rgba(214, 82, 67, 0.16); --bg-glow-4: rgba(255, 209, 102, 0.14);
}
:root[data-case-theme="forest"] {
  --bg-1: #10201a; --bg-2: #162b21; --bg-3: #0a1512;
  --accent: #6fcf97; --accent-strong: #a3e6bf;
  --accent-2: #c9e26b; --accent-2-strong: #dcee9a;
  --accent-glow: rgba(111, 207, 151, 0.45); --accent-soft: rgba(111, 207, 151, 0.16);
  --bg-glow-1: rgba(111, 207, 151, 0.2); --bg-glow-2: rgba(180, 224, 130, 0.12); --bg-glow-3: rgba(70, 150, 130, 0.12); --bg-glow-4: rgba(201, 226, 107, 0.12);
}
:root[data-case-theme="ocean"] {
  --bg-1: #0d1b2b; --bg-2: #12263d; --bg-3: #081220;
  --accent: #4fb0d9; --accent-strong: #8fd6ee;
  --accent-2: #6fe6d0; --accent-2-strong: #a6f3e6;
  --accent-glow: rgba(79, 176, 217, 0.45); --accent-soft: rgba(79, 176, 217, 0.16);
  --bg-glow-1: rgba(79, 176, 217, 0.22); --bg-glow-2: rgba(120, 220, 210, 0.12); --bg-glow-3: rgba(60, 110, 200, 0.14); --bg-glow-4: rgba(111, 230, 208, 0.12);
}
:root[data-case-theme="blossom"] {
  --bg-1: #2a1620; --bg-2: #3a1e2b; --bg-3: #180b12;
  --accent: #f28fb0; --accent-strong: #ffbfd6;
  --accent-2: #c890f2; --accent-2-strong: #ddb8ff;
  --accent-glow: rgba(242, 143, 176, 0.45); --accent-soft: rgba(242, 143, 176, 0.18);
  --bg-glow-1: rgba(242, 143, 176, 0.22); --bg-glow-2: rgba(255, 190, 220, 0.12); --bg-glow-3: rgba(200, 120, 200, 0.12); --bg-glow-4: rgba(200, 144, 242, 0.12);
}
:root[data-case-theme="neon"] {
  --bg-1: #120027; --bg-2: #1a0033; --bg-3: #05000f;
  --accent: #ff2ec4; --accent-strong: #ff8ee0;
  --accent-2: #22e6e6; --accent-2-strong: #7ef7f7;
  --accent-glow: rgba(255, 46, 196, 0.5); --accent-soft: rgba(255, 46, 196, 0.18);
  --bg-glow-1: rgba(255, 46, 196, 0.28); --bg-glow-2: rgba(34, 230, 230, 0.18); --bg-glow-3: rgba(140, 46, 255, 0.2); --bg-glow-4: rgba(255, 220, 60, 0.12);
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
button { -webkit-appearance: none; appearance: none; font-family: inherit; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 75% 55% at 12% 0%, var(--bg-glow-1), transparent 62%),
    radial-gradient(ellipse 65% 50% at 100% 15%, var(--bg-glow-2), transparent 58%),
    radial-gradient(ellipse 75% 65% at 92% 100%, var(--bg-glow-3), transparent 62%),
    radial-gradient(ellipse 60% 45% at 8% 95%, var(--bg-glow-4), transparent 60%),
    linear-gradient(160deg, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
  background-size: 140% 140%, 140% 140%, 140% 140%, 140% 140%, 100% 100%;
  animation: bg-drift 26s ease-in-out infinite alternate;
  min-height: 100vh;
  position: relative;
  transition: background 0.4s ease;
}
@keyframes bg-drift {
  0% { background-position: 0% 0%, 100% 0%, 100% 100%, 0% 100%, 0 0; }
  100% { background-position: 8% 6%, 92% 10%, 90% 92%, 6% 92%, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}
/* The background-position animation forces a full-viewport repaint every
   frame (unlike transform/opacity, it can't be GPU-composited), and every
   glass panel's backdrop-filter has to re-blur that ever-changing backdrop
   in turn. Cheap on a desktop GPU; a real mobile-perf killer stacked a dozen
   panels deep. Not worth it on small screens — kill it there. */
@media (max-width: 900px) {
  body { animation: none; background-position: 0 0; }
}

/* Subtle grain so the gradient doesn't look flat/banded */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

#app { position: relative; z-index: 1; }

h1, h2, h3, h4, h5 { margin: 0 0 var(--space-3); font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-3); }
input, textarea, select { font-family: inherit; font-size: 1rem; }
a { color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

input[type="text"], input[type="password"], input[type="number"], input[type="file"], textarea, select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-edge);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus { border-color: var(--accent); }
input:disabled { opacity: 0.55; cursor: not-allowed; }
textarea { resize: vertical; }

/* Shared glass-panel treatment */
.card, .settings-section, .auth-card, .modal-content,
.chart-card, .note-card, .task-item, .mood-item, .home-section,
.stat-card, .activity-item, .calendar-day {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-edge);
}

.card, .settings-section {
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-edge), var(--shadow-elevate);
  margin-bottom: var(--space-5);
}

.btn-primary, .btn-danger {
  border: none;
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-5);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 55%, var(--accent-strong));
  color: #1a1530;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18) inset, 0 6px 20px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(255,255,255,0.24) inset, 0 8px 28px var(--accent-glow); }
.btn-danger {
  background: var(--glass-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 157, 141, 0.35);
  backdrop-filter: blur(var(--glass-blur));
}
.btn-danger:hover { background: var(--danger-soft); box-shadow: 0 0 20px var(--danger-glow); }
.btn-primary:active, .btn-danger:active { transform: scale(0.98); }

.status-text { font-size: 0.9rem; margin-top: var(--space-2); }
.status-success { color: var(--success); }
.status-error { color: var(--danger); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-6) var(--space-4);
  font-size: 0.95rem;
}
.empty-state-small { padding: var(--space-4); font-size: 0.9rem; }

.skeleton {
  height: 60px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ==========================================================================
   App shell — full-screen, sidebar + divided panes (Proton Mail-style)
   ========================================================================== */
html { scroll-behavior: smooth; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
#main-section { flex: 1; min-height: 100vh; }

.app-shell { display: flex; min-height: 100vh; }

/* Left sidebar: brand, primary nav, and in-page section links, divided from
   the content by a single vertical rule rather than a floating gap. */
.sidebar {
  flex-shrink: 0;
  width: 250px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); margin-bottom: var(--space-6); }
.sidebar-brand .auth-logo { font-size: 1.5rem; text-shadow: 0 0 16px var(--accent-glow); }
.sidebar-title {
  font-weight: 750;
  font-size: 1.15rem;
  background: linear-gradient(120deg, var(--accent-2-strong), var(--accent-strong) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tab-bar { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--space-6); }
.tab-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  background: none;
  border: none;
  color: var(--text-muted);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.92rem;
  text-align: left;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab-btn:hover { background: rgba(255, 255, 255, 0.07); }
.tab-btn.active {
  color: var(--accent-strong);
  background: linear-gradient(120deg, var(--accent-soft), rgba(79, 214, 209, 0.14));
  box-shadow: inset 0 0 0 1px var(--glass-border);
}
.tab-icon { width: 20px; height: 20px; flex-shrink: 0; }

.sparks-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: auto;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.95rem;
}

.tab-content { flex: 1; min-width: 0; overflow-y: auto; height: 100vh; padding: var(--space-5) var(--space-6); }
.home-section-title { font-size: 1rem; flex-shrink: 0; margin-bottom: var(--space-3); }

/* Home is a fixed 2x2 dashboard grid that fills the viewport — each tile is
   its own glass panel, and only a tile's own body scrolls if its content
   overflows, so the page itself never needs to scroll on desktop. Calendar
   and Notes get their own full pages instead of living here as cramped tiles. */
#home-view {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  height: 100%;
}
.home-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-edge), var(--shadow-elevate);
  position: relative;
  overflow: hidden;
}
.home-section::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-strong));
  opacity: 0.85;
}
.home-section-body { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
.home-subsection-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: var(--space-4) 0 var(--space-2); }

#settings-view, #rewards-view, #calendar-view, #notes-view { max-width: 720px; }

/* Below this width: collapse to a single scrolling column with a bottom nav,
   same as the Android/mobile layout — the fixed dashboard grid only applies
   to the "main desktop view". */
@media (max-width: 900px) {
  /* Backdrop-filter cost scales with blur radius — halving it noticeably
     cuts per-frame compositing cost across every glass panel on a phone GPU. */
  :root { --glass-blur: 10px; }
  .app-shell { flex-direction: column; }
  .sidebar {
    position: static;
    height: auto;
    width: auto;
    border-right: none;
    padding: 0;
    background: none;
  }
  .sidebar-brand, .sparks-badge { display: none; }
  .tab-bar {
    position: fixed;
    bottom: var(--space-3);
    left: var(--space-3);
    right: var(--space-3);
    margin: 0;
    flex-direction: row;
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-edge), var(--shadow-elevate-lg);
    z-index: 50;
  }
  /* min-width:0 lets a flex item actually shrink below its content's natural
     width — without it, 7 tabs' worth of icon+label overflow the bar instead
     of compressing to fit. */
  .tab-btn { flex: 1; min-width: 0; flex-direction: column; gap: 2px; font-size: 0.68rem; padding: var(--space-2) 2px; }
  .tab-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .tab-icon { width: 18px; height: 18px; }
  .tab-btn.active { background: none; text-shadow: 0 0 16px var(--accent-glow); }
  .tab-content { height: auto; padding: var(--space-6) var(--space-4) calc(var(--space-7) + 72px); }
  #home-view { display: block; height: auto; }
  #settings-view, #rewards-view, #calendar-view, #notes-view, #analytics-view, #children-view { max-width: none; }
  .reward-form { grid-template-columns: 60px 1fr; }
  .reward-form button { grid-column: span 2; }
}

/* ==========================================================================
   Auth
   ========================================================================== */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-5); }
.auth-card { width: 100%; max-width: 380px; border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-edge), var(--shadow-elevate-lg); }
.auth-brand { text-align: center; margin-bottom: var(--space-5); }
.auth-logo { font-size: 2.2rem; color: var(--accent); text-shadow: 0 0 24px var(--accent-glow); }
.auth-tagline { color: var(--text-muted); font-size: 0.9rem; }
.field-label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: var(--space-1); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.auth-switch { text-align: center; font-size: 0.88rem; color: var(--text-muted); }
.auth-form .btn-primary { width: 100%; margin-top: var(--space-2); }

/* ==========================================================================
   Calendar
   ========================================================================== */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.month-nav {
  background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-edge);
  border-radius: var(--radius-pill); width: 36px; height: 36px; cursor: pointer; color: var(--text);
}
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--text-faint); font-size: 0.75rem; margin-bottom: var(--space-2); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--space-2); }
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.calendar-day:hover { box-shadow: var(--shadow-edge), 0 6px 18px rgba(0,0,0,0.35); transform: translateY(-1px); }
.calendar-day.other-month { color: var(--text-faint); opacity: 0.35; cursor: default; box-shadow: none; }
.calendar-day.is-today { border-color: var(--accent); font-weight: 700; box-shadow: var(--shadow-edge), 0 0 0 1px var(--accent), 0 0 18px var(--accent-glow); }
.day-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.calendar-day.has-data .day-dot { box-shadow: 0 0 8px 1px currentColor; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 14, 0.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}
.modal.modal-open { display: flex; }
.modal-content {
  background: var(--glass-bg-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-edge), var(--shadow-elevate-lg);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.modal-header input { margin: 0; }
.close-btn { background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text-muted); padding: var(--space-1) var(--space-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-3); }

.day-data { display: grid; gap: var(--space-4); }
.day-section h4 { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.mood-entry { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-2) 0; border-bottom: 1px solid var(--glass-border); cursor: pointer; }
.mood-entry:last-child { border-bottom: none; }
.mood-entry:hover .mood-desc { color: var(--text); }
.mood-score { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #17142a; font-weight: 700; font-size: 0.85rem; }
.mood-desc { font-size: 0.9rem; }
.mood-music { font-size: 0.8rem; color: var(--text-muted); }
.day-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin-bottom: var(--space-3); }
.stat-card { border-radius: var(--radius-md); padding: var(--space-3); }
.stat-card h5 { margin: 0 0 4px; font-size: 0.75rem; color: var(--text-muted); }
.stat-card p { margin: 0; font-weight: 600; }
.activities-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.activity-item { display: flex; justify-content: space-between; border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: 0.88rem; }

/* ==========================================================================
   Tasks
   ========================================================================== */
.tasks-nav { display: flex; background: rgba(255,255,255,0.05); border-radius: var(--radius-pill); padding: 4px; margin-bottom: var(--space-4); }
.sub-tab-btn { flex: 1; border: none; background: none; padding: var(--space-2); border-radius: var(--radius-pill); cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.sub-tab-btn.active { background: rgba(255,255,255,0.1); color: var(--text); box-shadow: var(--shadow-edge); }
.tasks-section { margin-bottom: var(--space-5); }
.tasks-section h4 { font-size: 0.95rem; color: var(--text-muted); margin: 0 0 var(--space-2); }
.task-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-2); }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.task-item.completed { opacity: 0.5; }
.task-item.completed .task-title { text-decoration: line-through; }
.task-checkbox {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  cursor: pointer;
  margin-top: 2px;
}
.task-checkbox.checked { background: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.task-body { flex: 1; cursor: pointer; }
.task-title { font-size: 0.95rem; }
.task-description { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.task-delete { background: none; border: none; color: var(--text-faint); font-size: 1.2rem; cursor: pointer; padding: 0 var(--space-1); }
.task-delete:hover { color: var(--danger); }
.add-task input { margin-bottom: 0; }

.finished-section { margin-top: var(--space-4); }
.finished-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-edge);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}
.finished-list { margin-top: var(--space-3); }

/* ==========================================================================
   Mood
   ========================================================================== */
.mood-logger { margin-bottom: var(--space-4); }
.mood-slider-container { margin-bottom: var(--space-4); }

/* The track itself is the full 1–10 mood-color spectrum (matching utils.js's
   moodColor()) so the slider reads as one cohesive control, not a generic
   handle sitting on top of an unrelated color strip. */
.mood-slider {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(to right,
    hsl(210, 55%, 55%) 0%,
    hsl(177, 55%, 55%) 25%,
    hsl(143, 55%, 55%) 50%,
    hsl(110, 55%, 55%) 75%,
    hsl(60, 55%, 55%) 100%);
  box-shadow: var(--shadow-edge);
  margin-bottom: var(--space-2);
  --thumb-glow: var(--accent-glow);
}
.mood-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(20, 17, 31, 0.55);
  box-shadow: 0 0 0 4px var(--thumb-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.mood-slider::-moz-range-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(to right,
    hsl(210, 55%, 55%) 0%,
    hsl(177, 55%, 55%) 25%,
    hsl(143, 55%, 55%) 50%,
    hsl(110, 55%, 55%) 75%,
    hsl(60, 55%, 55%) 100%);
}
.mood-slider::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid rgba(20, 17, 31, 0.55);
  box-shadow: 0 0 0 4px var(--thumb-glow), 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.mood-labels { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); }
.mood-score-value { font-weight: 700; transition: color 0.15s ease; }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.chip {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 6px var(--space-3);
  font-size: 0.82rem;
  cursor: pointer;
  transition: box-shadow 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip.chip-selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); box-shadow: 0 0 14px var(--accent-glow); }
.chip.chip-static { cursor: default; background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); margin-right: 4px; }

.music-section { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.music-section button {
  background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-edge);
  border-radius: var(--radius-pill); padding: var(--space-2) var(--space-3); cursor: pointer; white-space: nowrap; color: var(--text);
}
.music-section input { margin-bottom: 0; }

.recent-moods h3 { font-size: 1rem; color: var(--text-muted); margin-top: var(--space-5); }
.mood-list { display: flex; flex-direction: column; gap: var(--space-2); }
.mood-item { display: flex; gap: var(--space-3); border-radius: var(--radius-md); padding: var(--space-3); cursor: pointer; transition: box-shadow 0.15s ease; }
.mood-item:hover { box-shadow: var(--shadow-edge), 0 8px 20px rgba(0,0,0,0.35); }
.mood-item-score { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #17142a; font-weight: 700; }
.mood-item-tags { margin-bottom: 4px; }
.mood-item-date { font-size: 0.78rem; color: var(--text-faint); margin-top: 2px; }

.daily-chart-block { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--glass-border); }
.daily-chart-title-input {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 650;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  padding: var(--space-1) var(--space-2);
  margin-bottom: var(--space-2);
  width: auto;
  max-width: 100%;
}
.daily-chart-title-input:hover, .daily-chart-title-input:focus { border-color: var(--glass-border); background: rgba(255,255,255,0.03); }
.daily-chart-canvas { height: 190px; }
.daily-chart-hint { font-size: 0.76rem; color: var(--text-faint); margin: var(--space-2) 0 0; }

/* ==========================================================================
   Water
   ========================================================================== */
.water-widget { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; gap: var(--space-3); }
.water-count { font-size: clamp(1.3rem, 1.6vw, 1.7rem); font-weight: 700; color: var(--accent-strong); }
.water-goal-text { font-size: clamp(0.85rem, 0.9vw, 1rem); font-weight: 400; color: var(--text-muted); }

/* A drinking glass, not a bar: fills bottom-up, and spills over the rim once
   you've logged more than your goal. Sized with clamp() so it scales up on
   large/high-res monitors instead of staying pinned at a small fixed size. */
.water-glass {
  position: relative;
  width: clamp(84px, 9vw, 170px);
  height: clamp(118px, 16vh, 240px);
  border: 2px solid var(--glass-border);
  border-radius: 6px 6px 22px 22px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow-edge);
  overflow: hidden;
}
.water-glass-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0%;
  background: linear-gradient(180deg, hsl(195, 70%, 58%), hsl(206, 72%, 46%));
  border-top: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 2px 2px 0 0;
  transition: height 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.water-glass-fill::before {
  content: "";
  position: absolute;
  top: -3px; left: 0; right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  animation: water-wobble 2.6s ease-in-out infinite;
}
@keyframes water-wobble {
  0%, 100% { transform: scaleX(1) translateY(0); }
  50% { transform: scaleX(1.06) translateY(-1px); }
}
.water-glass.is-overflowing { box-shadow: var(--shadow-edge), 0 0 18px var(--success-glow); border-color: var(--success); }
.water-glass.is-overflowing .water-glass-fill { background: linear-gradient(180deg, hsl(160, 65%, 55%), hsl(178, 60%, 42%)); }

.water-glass-drops { position: absolute; top: -14px; left: 0; right: 0; height: 14px; opacity: 0; pointer-events: none; }
.water-glass.is-overflowing .water-glass-drops { opacity: 1; }
.water-drop {
  position: absolute;
  top: 0;
  width: 5px; height: 8px;
  border-radius: 50% 50% 50% 0;
  background: hsl(178, 60%, 50%);
  transform: rotate(45deg);
  animation: water-drip 1.4s ease-in infinite;
}
.water-drop:nth-child(1) { left: 20%; animation-delay: 0s; }
.water-drop:nth-child(2) { left: 46%; animation-delay: 0.45s; }
.water-drop:nth-child(3) { left: 70%; animation-delay: 0.85s; }
@keyframes water-drip {
  0% { transform: translateY(0) rotate(45deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(26px) rotate(45deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .water-glass-fill::before, .water-drop { animation: none; }
}

.water-actions { display: flex; gap: var(--space-3); align-items: center; }
.water-actions .btn-danger { padding: var(--space-2) var(--space-4); font-size: 1.1rem; line-height: 1; }

/* ==========================================================================
   Database management
   ========================================================================== */
.db-subsection { padding-bottom: var(--space-4); margin-bottom: var(--space-4); border-bottom: 1px solid var(--glass-border); }
.db-subsection:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.db-subsection h4 { font-size: 0.95rem; margin-bottom: var(--space-2); }
.db-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

/* ==========================================================================
   Family / parental oversight
   ========================================================================== */
.invite-code-display { margin-top: var(--space-3); }
.invite-code {
  font-family: var(--mono, monospace);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}
.family-list { display: flex; flex-direction: column; gap: var(--space-2); }
.family-item { display: flex; align-items: center; gap: var(--space-3); border-radius: var(--radius-md); padding: var(--space-3); background: rgba(255,255,255,0.03); }
.family-item-name { font-weight: 600; flex-shrink: 0; }
.family-item-meta { flex: 1; font-size: 0.8rem; color: var(--text-muted); }
.family-unlink-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid rgba(255, 157, 141, 0.35);
  color: var(--danger);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}
.family-unlink-btn:hover { background: var(--danger-soft); }

/* ==========================================================================
   Analytics
   ========================================================================== */
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.chart-card { border-radius: var(--radius-lg); padding: var(--space-3); box-shadow: var(--shadow-edge), var(--shadow-elevate); }
.chart-card h3 { font-size: 0.78rem; color: var(--text-muted); margin-bottom: var(--space-1); }
/* Chart.js with maintainAspectRatio:false needs a parent with a height that
   doesn't itself depend on the canvas, or the two resize each other forever. */
.chart-canvas { position: relative; height: 150px; }
.chart-canvas canvas { max-width: 100%; }
.day-data .chart-canvas { height: 220px; }

/* ==========================================================================
   Rewards
   ========================================================================== */
.sparks-balance-big { font-size: 2.2rem; font-weight: 700; color: var(--accent-strong); text-shadow: 0 0 20px var(--accent-glow); margin-bottom: var(--space-2); }
.sparks-history { display: flex; flex-direction: column; gap: var(--space-2); max-height: 220px; overflow-y: auto; }
.spark-entry { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: rgba(255,255,255,0.03); font-size: 0.88rem; }
.spark-amount { font-weight: 700; flex-shrink: 0; }
.spark-positive { color: var(--success); }
.spark-negative { color: var(--danger); }
.spark-reason { color: var(--text-muted); text-align: right; }

.rewards-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.reward-item { display: flex; align-items: center; gap: var(--space-3); border-radius: var(--radius-md); padding: var(--space-3); background: rgba(255,255,255,0.03); }
.reward-emoji { font-size: 1.3rem; }
.reward-name { flex: 1; cursor: pointer; }
.reward-cost { color: var(--accent-strong); font-weight: 600; white-space: nowrap; }
.reward-form { display: grid; grid-template-columns: 60px 1fr 90px auto; gap: var(--space-2); align-items: start; }
.reward-form input { margin-bottom: 0; }

.cases-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-3); }
.case-card {
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.case-card h4 { margin-bottom: 0; }
.case-card p { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0; }
.case-card.case-equipped { border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }
.case-cost { font-weight: 600; color: var(--accent-strong); font-size: 0.9rem; }
.case-action-btn:disabled { opacity: 0.6; cursor: default; }

/* ==========================================================================
   Mystery Case
   ========================================================================== */
.mystery-balances { display: flex; gap: var(--space-4); margin-bottom: var(--space-4); }
.mystery-balance-tile { flex: 1; text-align: center; background: rgba(255,255,255,0.03); border-radius: var(--radius-md); padding: var(--space-3); }
.mystery-balance-value { display: block; font-size: 1.4rem; font-weight: 700; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.mystery-balance-label { font-size: 0.75rem; color: var(--text-muted); }

.mystery-odds { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.mystery-odds-row { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; padding: 4px 10px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.04); color: var(--text-muted); }
.mystery-odds-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.mystery-actions { display: flex; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }

.mystery-reveal { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-6) 0; margin-bottom: var(--space-4); min-height: 160px; }
.mystery-orb {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-strong), var(--accent));
  box-shadow: 0 0 20px var(--accent-glow);
  animation: mystery-buildup 1.8s ease-in-out forwards;
}
@keyframes mystery-buildup {
  0% { transform: scale(0.6); box-shadow: 0 0 10px var(--accent-glow); opacity: 0.6; }
  70% { transform: scale(1.3); box-shadow: 0 0 50px var(--accent-glow); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .mystery-orb { animation: none; opacity: 0; } }

.mystery-result { text-align: center; animation: mystery-result-in 0.4s ease; }
@keyframes mystery-result-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
.mystery-tier-badge { display: inline-block; padding: 4px 14px; border-radius: var(--radius-pill); font-weight: 700; font-size: 0.85rem; margin-bottom: var(--space-2); color: #17142a; }
.mystery-result-label { font-size: 1.05rem; font-weight: 600; }
.mystery-pity-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.mystery-tier-chip { font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; margin-right: var(--space-2); flex-shrink: 0; }

.sidebar-title-badge {
  align-self: flex-start;
  margin: -8px 0 var(--space-5) var(--space-4);
  font-size: 0.7rem;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Analytics page (full page — this one is allowed to scroll)
   ========================================================================== */
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.analytics-section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-6); }
.analytics-section-grid .chart-card.wide { grid-column: span 2; }
@media (max-width: 640px) { .analytics-section-grid .chart-card.wide { grid-column: span 1; } }

.metric-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-edge), var(--shadow-elevate);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.metric-value { font-size: 1.6rem; font-weight: 700; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.metric-label { font-size: 0.78rem; color: var(--text-muted); }

.freq-list { display: flex; flex-direction: column; gap: var(--space-2); }
.freq-item { display: flex; align-items: center; gap: var(--space-2); font-size: 0.85rem; }
.freq-item .freq-name { flex-shrink: 0; width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.freq-item .freq-bar-track { flex: 1; height: 8px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.08); overflow: hidden; }
.freq-item .freq-bar-fill { height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.freq-item .freq-count { flex-shrink: 0; font-weight: 600; color: var(--text); width: 24px; text-align: right; }

/* ==========================================================================
   Notes
   ========================================================================== */
.notes-header { display: flex; gap: var(--space-3); margin-bottom: var(--space-4); }
.notes-header input { margin-bottom: 0; }
.notes-header button { white-space: nowrap; }
.notes-list { display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
@media (min-width: 560px) { .notes-list { grid-template-columns: 1fr 1fr; } }
.note-card { border-radius: var(--radius-md); padding: var(--space-4); cursor: pointer; transition: box-shadow 0.15s ease, transform 0.1s ease; }
.note-card:hover { box-shadow: var(--shadow-edge), 0 10px 26px rgba(0,0,0,0.4); transform: translateY(-1px); }
.note-card h4 { font-size: 1rem; }
.note-card p { font-size: 0.85rem; color: var(--text-muted); }
.note-meta { font-size: 0.75rem; color: var(--text-faint); }
.note-modal { max-width: 640px; }
.note-modal textarea { min-height: 260px; }

/* ==========================================================================
   Settings
   ========================================================================== */
.setting-item { margin-bottom: var(--space-3); }
.setting-item label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
#import-file { padding: var(--space-2); }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container { position: fixed; bottom: calc(88px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--space-2); z-index: 200; width: min(90vw, 360px); }
.toast {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-edge), var(--shadow-elevate);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(127, 224, 189, 0.4); box-shadow: var(--shadow-edge), 0 0 24px var(--success-glow); }
.toast-error { border-color: rgba(255, 157, 141, 0.4); box-shadow: var(--shadow-edge), 0 0 24px var(--danger-glow); }

/* ==========================================================================
   Update banner (Android app only)
   ========================================================================== */
.update-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 0.88rem;
  position: sticky;
  top: 0;
  z-index: 40;
}
.update-banner span:first-child { flex: 1; }
.update-banner .btn-primary { padding: var(--space-2) var(--space-4); font-size: 0.85rem; flex-shrink: 0; }
.update-banner .close-btn { flex-shrink: 0; }

/* ==========================================================================
   Calendar mood shapes — days with entries get a shape (instead of the plain
   squircle) colored by that day's average mood, picked deterministically per
   date so it doesn't change across reloads. Purely decorative.
   ========================================================================== */
.calendar-day.has-shape { border: none; }
.calendar-day.has-shape .day-dot { display: none; }
.calendar-day.shape-circle { clip-path: circle(46% at 50% 50%); }
.calendar-day.shape-hexagon { clip-path: polygon(25% 4%, 75% 4%, 98% 50%, 75% 96%, 25% 96%, 2% 50%); }
.calendar-day.shape-pentagon { clip-path: polygon(50% 2%, 98% 38%, 80% 96%, 20% 96%, 2% 38%); }
.calendar-day.shape-diamond { clip-path: polygon(50% 2%, 98% 50%, 50% 98%, 2% 50%); }
.calendar-day.shape-triangle { clip-path: polygon(50% 4%, 97% 94%, 3% 94%); }
.calendar-day.shape-star { clip-path: polygon(50% 2%, 62% 36%, 98% 36%, 68% 58%, 79% 93%, 50% 71%, 21% 93%, 32% 58%, 2% 36%, 38% 36%); }

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  .day-stats { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Mobile flat redesign + full-screen modals — deliberately the LAST rules in
   the file. Several components (.chart-card, .note-modal, etc.) each carry
   their own dedicated border-radius/shadow/width rule further up the file,
   unconditional and appearing after the first mobile media query — so an
   earlier mobile override of equal specificity would silently lose the
   cascade to them. Being last guarantees these always win instead, no
   matter what gets added elsewhere later.
   ========================================================================== */
@media (max-width: 900px) {
  /* Flatten the boxed-card look into a native-app-style flowing layout —
     full width, generous spacing, a subtle divider between sections instead
     of floating glass panels. Also drops backdrop-filter here entirely
     (on top of the earlier blur-radius cut), since these panels are the
     bulk of what's on screen at once. */
  .card, .settings-section, .home-section, .chart-card {
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: var(--space-6) 0;
    margin-bottom: 0;
    min-height: 0;
  }
  .card::before, .home-section::before { display: none; }
  .card, .settings-section, .home-section { border-bottom: 1px solid var(--glass-border); }
  #home-view > .home-section:last-child,
  .settings-section:last-child { border-bottom: none; }
  .home-section-body { overflow-y: visible; }
  .home-section-title { font-size: 1.2rem; }

  /* Small list-row items keep a flat (non-blurred) tint for scannability —
     they read as rows, not panels, so they're not part of the "boxed" feel. */
  .note-card, .task-item, .mood-item, .stat-card, .activity-item {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .modal { padding: 0; align-items: stretch; z-index: 200; }
  .modal-content {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    background: var(--bg-1);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    overflow-y: auto;
  }
  .modal-header {
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    background: var(--bg-1);
  }
  .close-btn {
    font-size: 0;
    padding: var(--space-2) var(--space-2) var(--space-2) 0;
  }
  .close-btn::before {
    content: '← Back';
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
  }
}
