/* Quiet Deep — phone-first dark theme */
:root {
  --bg: #0b0e14;
  --panel: #12161f;
  --card: #171c28;
  --border: #232a3a;
  --text: #dce3ee;
  --muted: #8b96ab;
  --accent: #7aa2f7;
  --accent-soft: rgba(122, 162, 247, 0.16);
  --good: #9ece6a;
  --bad: #f7768e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 800px at 70% -10%, #141a2a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.error { color: var(--bad); min-height: 1.2em; margin: 0.5em 0; font-size: 0.9em; }
.hint { color: var(--muted); font-size: 0.8em; }
.fineprint { color: var(--muted); font-size: 0.75em; }

/* top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; position: sticky; top: 0; z-index: 5;
  background: rgba(11, 14, 20, 0.85); backdrop-filter: blur(8px);
}
.brand { font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; flex-shrink: 0; }
.topnav { display: flex; align-items: center; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; min-width: 0; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { margin-left: 16px; color: var(--muted); font-size: 0.9em; white-space: nowrap; }
.topnav a:hover { color: var(--text); }
.install-btn {
  margin-left: 16px; padding: 5px 12px; font-size: 0.8em; font-weight: 600;
  color: var(--text); background: rgba(122, 160, 255, 0.15);
  border: 1px solid rgba(122, 160, 255, 0.4); border-radius: 999px;
  cursor: pointer;
}
.install-btn:hover { background: rgba(122, 160, 255, 0.28); }

/* Standardised collapsible navbar — same behaviour as quick-time-management.com:
   inline links on desktop, hamburger toggle below 992px. */
.nav-toggle {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 8px;
  background: none; border: 0; border-radius: 8px; cursor: pointer;
  color: var(--text); flex-shrink: 0;
}
.nav-toggle span {
  display: block; width: 100%; height: 2.5px; margin: 2.5px 0;
  border-radius: 2px; background-color: currentColor;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
@media (max-width: 991.98px) {
  .topbar { flex-wrap: wrap; }
  .nav-toggle { display: inline-flex; }
  .topnav {
    display: none; flex-basis: 100%;
    flex-direction: column; align-items: stretch;
    overflow-x: visible; padding-top: 6px;
  }
  .topnav.open { display: flex; }
  .topnav a { margin: 0; padding: 10px 4px; font-size: 1em; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
  .topnav .install-btn { margin: 8px 0 0; align-self: flex-start; }
}

main { max-width: 560px; margin: 0 auto; padding: 8px 18px 60px; }

/* hero */
.hero { text-align: center; padding: 48px 8px 24px; }
.hero h1 { font-size: 1.9em; margin: 0 0 10px; font-weight: 650; }
.hero .sub { color: var(--muted); line-height: 1.5; margin: 0 auto 26px; max-width: 40ch; }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; max-width: 540px; margin: 0 auto 18px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 14px; cursor: pointer; transition: border-color 0.15s, transform 0.05s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:active { transform: scale(0.98); }
.mode-card h3 { margin: 0; font-size: 1.15em; font-weight: 650; }
.mode-card p { margin: 0; color: var(--muted); font-size: 0.82em; line-height: 1.4; }
.mode-glyph { font-size: 2.2em; line-height: 1; }
.mode-card.active { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 380px) { .mode-cards { grid-template-columns: 1fr; } }

/* support page — supporter tiers (Ripple / Current / Abyss). Full-width
 * cards, single column (phone-first). The active tier gets the accent. */
.tier-list { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 14px 0 6px; }
.tier-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.tier-card:active { transform: scale(0.99); }
.tier-card.active { border-color: var(--accent); background: var(--accent-soft); }
.tier-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tier-name { font-size: 1.1em; font-weight: 650; }
.tier-price { font-size: 1.15em; font-weight: 700; white-space: nowrap; }
.tier-price span { font-size: 0.6em; font-weight: 500; color: var(--muted); }
.tier-tagline { color: var(--accent); font-size: 0.85em; font-style: italic; }
.tier-blurb { color: var(--muted); font-size: 0.8em; line-height: 1.45; }

/* home page — signup call-to-action (shown only when signed out) */
.signup-cta { text-align: center; border-color: var(--accent); }
.signup-cta h2 { margin-top: 0; }
.signup-cta .btn { margin-top: 12px; }

/* tile pages (/meditate/, /game/): phone-first menu of entry tiles.
 * One full-width row per tile on phones; two-column cards on wider
 * screens. Tiles are <a> links into the config page. */
.sub-tiles {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  max-width: 460px; margin: 0 auto 18px;
}
.sub-tile {
  display: flex; flex-direction: row; align-items: center; gap: 14px;
  text-align: left; color: inherit; text-decoration: none;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: border-color 0.15s, transform 0.05s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sub-tile:hover { border-color: var(--accent); }
.sub-tile:active { transform: scale(0.98); }
.sub-tile .sub-glyph { font-size: 1.9em; line-height: 1; flex: none; }
.sub-tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sub-tile h4 { margin: 0; font-size: 1em; font-weight: 600; }
.sub-tile p { margin: 0; color: var(--muted); font-size: 0.8em; line-height: 1.35; }
@media (min-width: 480px) {
  .sub-tiles { grid-template-columns: 1fr 1fr; }
  .sub-tile { flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 16px 10px; }
  .sub-tile .sub-glyph { font-size: 1.7em; }
}

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--border); background: var(--card);
  color: var(--text); border-radius: 12px; padding: 12px 22px; font-size: 1em;
  cursor: pointer; margin: 6px 4px; transition: background 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0e14; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.big { padding: 15px 34px; font-size: 1.05em; }

/* panels & cards */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin: 18px 0;
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 10px 0; }
.card h3 { margin: 0 0 6px; font-size: 1em; }
.card p { margin: 0; color: var(--muted); font-size: 0.9em; line-height: 1.5; }
.section-title { font-size: 1.1em; margin: 30px 0 10px; }
.page-title { font-size: 1.4em; margin: 24px 0 6px; }

/* forms */
.field { display: block; margin: 14px 0; }
.field label { display: block; font-size: 0.9em; color: var(--muted); margin-bottom: 6px; }
.field .val { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field select, .field textarea {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 1em;
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.check { display: flex; gap: 8px; align-items: center; margin: 12px 0; font-size: 0.92em; color: var(--muted); }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }
.row-actions { margin-top: 20px; text-align: center; }
.narrow { max-width: 400px; margin-left: auto; margin-right: auto; }

/* segmented control */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font-size: 0.85em; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seg button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* advanced settings disclosure (config page) */
.advanced-row { margin-top: 22px; }
.advanced-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  border-style: dashed; color: var(--muted); font-size: 0.95em; padding: 12px 16px;
  margin: 0;
}
.advanced-btn .adv-caret { transition: transform 0.2s ease; font-size: 0.85em; }
.advanced-btn[aria-expanded="true"] .adv-caret { transform: rotate(180deg); }
.advanced { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 2px; }

/* slow-down sliders (config) */
.slowdown { display: grid; gap: 4px; margin: 4px 0 10px; }
.slowdown label { display: block; font-size: 0.85em; color: var(--muted); margin: 0; }
.slowdown .val { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.slowdown input[type="range"] { width: 100%; accent-color: var(--accent); height: 24px; }
.slowdown-preview {
  color: var(--accent); font-size: 0.85em; background: var(--accent-soft);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-variant-numeric: tabular-nums;
}

/* presets */
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preset-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; position: relative; transition: border-color 0.15s;
}
.preset-card:active { border-color: var(--accent); }
.preset-card h3 { margin: 0 0 4px; font-size: 0.95em; }
.preset-card .meta { color: var(--muted); font-size: 0.75em; line-height: 1.4; }
.preset-card .del {
  position: absolute; top: 6px; right: 8px; background: none; border: none;
  color: var(--muted); font-size: 1.1em; cursor: pointer; padding: 4px;
}

/* log */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 0.88em;
}
.log-row .top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.log-row .muted { font-size: 0.85em; }

/* summary stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.stat .k { color: var(--muted); font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .v { font-size: 1.3em; font-weight: 600; margin-top: 2px; }
.stat .v.good { color: var(--good); }

/* progress page */
.stats-section { margin-top: 22px; }
.stats-heading { font-size: 1em; font-weight: 600; margin: 0 0 4px; }
.stats-hint { font-size: 0.8em; margin: 0 0 8px; }
.stats-totals, .stats-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat-card .stat-num { font-size: 1.6em; font-weight: 600; }
.stat-card .stat-label { color: var(--muted); font-size: 0.78em; margin-top: 2px; }
.chart { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 8px 6px 4px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-label { fill: var(--muted); font-size: 9px; }

/* social login */
.social-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.btn.social {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; color: var(--fg); font-weight: 500; text-decoration: none;
}
.btn.social:active { transform: scale(0.99); }
.social-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; font-weight: 700; font-size: 0.9em;
  color: #fff;
}
.social-g { background: #4285F4; }
.social-f { background: #1877F2; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8em; margin: 4px 0 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.divider span { white-space: nowrap; }

/* QR */
.qr-wrap { display: flex; justify-content: center; padding: 12px 0; }
.qr-wrap img { border-radius: 10px; background: #fff; padding: 8px; }

/* ============ SESSION ============ */
.session { position: fixed; inset: 0; background: #05070c; overflow: hidden; touch-action: manipulation; }
.viz { position: absolute; inset: 0; width: 100%; height: 100%; }
.begin-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0b1018 0%, #05070c 75%);
  text-align: center; padding: 24px;
}
.begin-inner { max-width: 340px; }
.begin-glyph { font-size: 3.4em; color: var(--accent); opacity: 0.9; margin-bottom: 6px; }
.begin-title { font-size: 1.5em; font-weight: 600; margin: 0 0 6px; }
.begin-sub { color: var(--muted); font-size: 0.95em; margin: 0 0 22px; }
.begin-btn { padding: 16px 52px; font-size: 1.15em; border-radius: 999px; }
.session-hud {
  position: absolute; top: calc(env(safe-area-inset-top) + 18px); left: 0; right: 0;
  text-align: center; pointer-events: none; z-index: 2;
}
.phase { color: var(--muted); font-size: 0.95em; letter-spacing: 0.06em; }
.freq { font-size: 2.2em; font-weight: 250; margin-top: 6px; font-variant-numeric: tabular-nums; }
.clock { color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stillness {
  width: 160px; height: 5px; background: rgba(255, 255, 255, 0.08);
  border-radius: 3px; margin: 14px auto 4px; overflow: hidden; position: relative;
}
.stillness-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--good)); transition: width 1.2s ease; }
.stillness-label { color: var(--muted); font-size: 0.65em; letter-spacing: 0.2em; text-transform: uppercase; }
.thoughts { color: var(--muted); font-size: 0.8em; margin-top: 6px; }
.game-score { color: var(--accent); font-size: 0.9em; margin-top: 8px; letter-spacing: 0.04em; }
.slow-readout { color: var(--muted); font-size: 0.72em; margin-top: 8px; opacity: 0.8; font-variant-numeric: tabular-nums; }
.sensor-status { color: var(--accent); font-size: 0.72em; margin-top: 6px; opacity: 0.85; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.hint-inline { color: var(--muted); font-size: 0.82em; opacity: 0.8; margin-left: 4px; }
.session-controls {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 22px); left: 0; right: 0;
  text-align: center; z-index: 2; padding: 0 24px;
}
.session-controls label { color: var(--muted); font-size: 0.8em; display: block; margin-bottom: 8px; }
.session-controls input[type="range"] { width: min(70vw, 320px); accent-color: var(--accent); }
.session-controls .hint { margin: 10px 0; }
.session-controls .btn { min-width: 150px; }
.control-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.control-row .btn { min-width: 120px; flex: 0 1 auto; }

/* thought flash */
.thought-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(circle at 50% 50%, rgba(247, 118, 142, 0.18), transparent 60%);
  opacity: 0; transition: opacity 0.4s;
}
.thought-flash.on { opacity: 1; transition: opacity 0.05s; }

/* info icons + popover */
.info-icon {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 6px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.62em; font-weight: 700; font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  cursor: pointer; vertical-align: middle; user-select: none; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
/* enlarge the tap target (visual stays 15px) so it's easy to hit on a phone */
.info-icon::before {
  content: ''; position: absolute; top: -8px; left: -8px; right: -8px; bottom: -8px;
}
.info-icon:active { background: var(--accent); color: #0b0e14; }
.info-pop {
  position: fixed; z-index: 60; max-width: min(78vw, 280px);
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 0.85em; line-height: 1.5; color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.info-pop::before {
  content: ''; position: absolute; top: -5px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px; background: var(--card);
  border-left: 1px solid var(--border); border-top: 1px solid var(--border);
}

/* settings page */
.panel-head { font-size: 1.05em; margin: 0 0 4px; }
.reminder-list { margin: 12px 0; }
.reminder-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.reminder-row:last-child { border-bottom: none; }
.rem-time { font-weight: 600; min-width: 56px; font-variant-numeric: tabular-nums; }
.rem-label { flex: 1; color: var(--muted); font-size: 0.92em; }
.rem-toggle { accent-color: var(--accent); width: 18px; height: 18px; }
.rem-del {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  font-size: 1em; line-height: 1; flex: 0 0 auto;
}
.rem-del:active { background: var(--bad); border-color: var(--bad); color: #fff; }
.reminder-form { display: flex; gap: 8px; margin-top: 12px; }
.reminder-form input[type="time"],
.reminder-form input[type="text"] {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 0.95em;
}
.reminder-form input[type="text"] { flex: 1; min-width: 0; }

/* Wearable HRV (Phase 3) */
.hrv-form { margin-top: 12px; }
.hrv-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hrv-row select,
.hrv-row input {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 0.95em;
}
.hrv-row input { width: 96px; }
.hrv-row .btn { flex: 0 0 auto; }
.hrv-list { margin-top: 12px; }
.hrv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.hrv-item:last-child { border-bottom: none; }
.hrv-meta { flex: 1; color: var(--muted); font-size: 0.92em; font-variant-numeric: tabular-nums; }
.hrv-del {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  font-size: 1em; line-height: 1; flex: 0 0 auto;
}
.hrv-del:active { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ============ SLEEP ============ */
/* A simple "drift off" mode: pick a sound, press Start, and a rough timer
 * marks how long you stayed. Self-contained in sleep.js (no entrainment). */
.sleep-page { max-width: 480px; margin: 0 auto; }
.sleep-timer-panel { text-align: center; }
.sleep-timer {
  font-size: 3.2em; font-weight: 250; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; color: var(--text); margin: 4px 0 8px;
}
