/* ============================================================
   Future Self — design tokens + components
   Handoff-ready. Single source of truth for color, type, space.
   ============================================================ */

:root {
  /* Color */
  --bg-base: #0a0a0a;
  --bg-card: #141414;
  --bg-elev: #1e1e1e;
  --gold: #d4af37;
  --gold-dim: #8a7328;
  --gold-bright: #e8c14a;
  --text-primary: #f5f2ea;
  --text-muted: #8a8680;
  --text-faint: #5a5854;
  --success: #3dd68c;
  --danger: #e85c5c;
  --divider: #2a2a2a;
  --divider-strong: #3a3a3a;

  /* Type */
  --font-display: "Bebas Neue", Impact, "Haettenschweiler", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Spacing scale (4px base) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur-fast: 150ms;
  --dur-mid: 250ms;
  --dur-slow: 400ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: #000;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; background: transparent; border: 0; outline: 0; }

/* ---------- App shell ---------- */

.desktop-bg {
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 800px at 30% 10%, rgba(212,175,55,0.04), transparent 60%),
    radial-gradient(900px 700px at 80% 90%, rgba(212,175,55,0.02), transparent 60%),
    #050505;
  z-index: 0;
}

.app-frame {
  position: relative;
  width: 390px;
  max-width: 100vw;
  height: 844px;
  max-height: 100vh;
  margin: 0 auto;
  background: var(--bg-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 120px rgba(0,0,0,0.8);
  z-index: 1;
}

@media (max-width: 440px) {
  .app-frame { width: 100vw; height: 100vh; max-height: 100vh; box-shadow: none; }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  animation: screenIn var(--dur-mid) var(--ease);
  padding-bottom: 96px; /* room for tab bar */
}
.screen.no-tabs { padding-bottom: 0; }

@keyframes screenIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.screen::-webkit-scrollbar { display: none; }

/* ---------- Topbar ---------- */

.topbar {
  padding: 20px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topbar .greet {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.topbar .sub {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 0.02em;
  line-height: 1.05;
  color: var(--text-primary);
  padding: 4px 24px 40px;
}

/* ---------- Today hero card ---------- */

.hero-card {
  margin: 20px 20px 0;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 36px 24px 28px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--divider);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero-card::before {
  /* warm grain */
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(ellipse at top, rgba(212,175,55,0.10), transparent 65%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.83 0 0 0 0 0.69 0 0 0 0 0.22 0 0 0 0.18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
  opacity: 0.5;
  pointer-events: none;
}
.hero-card::after {
  /* thin top edge */
  content:"";
  position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,0.4), transparent);
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 14px;
  position: relative;
}
.hero-title {
  font-family: var(--font-display);
  font-size: 56px;
  line-height: 0.92;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  position: relative;
  margin-bottom: 14px;
}
.hero-subtitle {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-muted);
  position: relative;
}
.theme-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(212,175,55,0.5);
  border-radius: var(--r-pill);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  position: relative;
  margin-top: 18px;
  align-self: flex-start;
}
.theme-badge .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold);
}

/* ---------- Player ---------- */

.player {
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.progress-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.progress-track {
  position: relative;
  height: 2px;
  background: var(--divider);
  border-radius: 2px;
  overflow: visible;
}
.progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--p, 0%);
  background: var(--gold);
  border-radius: 2px;
  transition: width 200ms linear;
}
.progress-knob {
  position: absolute;
  left: var(--p, 0%);
  top: 50%;
  width: 10px; height: 10px;
  background: var(--gold);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.15);
}
.progress-times {
  display: flex; justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* Play button */
.play-btn {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--gold);
  color: #0a0a0a;
  display: grid; place-items: center;
  position: relative;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.play-btn::before {
  /* idle pulse ring */
  content: "";
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.35);
  animation: pulse 2s ease-out infinite;
}
.play-btn.playing::before { animation: none; opacity: 0; }
.play-btn:active { transform: scale(0.96); }
.play-btn svg { width: 30px; height: 30px; }
.play-btn.playing { background: var(--gold-bright); }

@keyframes pulse {
  0%   { transform: scale(1);    opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

.pull-quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  padding: 4px 32px;
  max-width: 300px;
}

.ghost-cta {
  display: inline-flex;
  align-items: center; gap: 8px;
  margin: 8px auto 24px;
  padding: 12px 20px;
  border: 1px solid var(--divider-strong);
  border-radius: var(--r-pill);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.ghost-cta:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Tab bar ---------- */

.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 80px;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--divider);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  transition: color var(--dur-fast);
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--gold); }
.tab:hover { color: var(--text-primary); }
.tab.active:hover { color: var(--gold-bright); }

/* ---------- Reflect ---------- */

.reflect-body { padding: 0 24px; display: flex; flex-direction: column; gap: 28px; }

.field-label {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 10px;
}

.stars { display: flex; gap: 10px; }
.star {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--divider-strong);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast);
}
.star svg { width: 32px; height: 32px; }
.star.on { color: var(--gold); }
.star:active { transform: scale(0.9); }

.text-input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text-primary);
  transition: border-color var(--dur-fast);
}
.text-input:focus { border-color: var(--gold-dim); }
.text-input::placeholder { color: var(--text-faint); }

textarea.text-input { resize: none; min-height: 96px; line-height: 1.5; }

.toggle-pills { display: flex; gap: 10px; }
.toggle-pill {
  flex: 1;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  font-weight: 600;
  letter-spacing: 0.14em;
  font-size: 13px;
  color: var(--text-muted);
  transition: all var(--dur-fast);
}
.toggle-pill.on {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(212,175,55,0.08);
}

.submit-btn {
  width: 100%;
  margin-top: 8px;
  padding: 16px;
  background: var(--gold);
  color: #0a0a0a;
  border-radius: var(--r-md);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 14px;
  text-transform: uppercase;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.submit-btn:active { transform: scale(0.985); }
.submit-btn:disabled {
  background: var(--gold-dim); color: rgba(10,10,10,0.6); cursor: not-allowed;
}

.submit-success {
  position: absolute; inset: 0;
  background: var(--bg-base);
  display: grid; place-items: center;
  animation: fadeIn 200ms var(--ease);
  z-index: 20;
}
.success-mark {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(61,214,140,0.12);
  border: 2px solid var(--success);
  display: grid; place-items: center;
  color: var(--success);
  animation: popIn 400ms var(--ease);
}
.success-mark svg { width: 36px; height: 36px; }
@keyframes popIn {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ---------- Journey ---------- */

.stat-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 0 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.stat-value .unit {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 2px;
}
.stat-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}
.trend { font-size: 10px; color: var(--text-muted); }
.trend.up   { color: var(--success); }
.trend.down { color: var(--danger); }

.phase-block {
  padding: 28px 24px 0;
}
.phase-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: 12px; }
.phase-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  white-space: nowrap;
}
.phase-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }
.phase-bar {
  height: 4px; background: var(--divider); border-radius: 2px; overflow: hidden; position: relative;
}
.phase-bar > span {
  display: block; height: 100%;
  background: var(--gold);
  width: 40%;
  border-radius: 2px;
}

.insights { padding: 28px 24px 0; display: flex; flex-direction: column; gap: 14px; }
.insights h3 {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.insight-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.insight-row:last-child { border-bottom: 0; }
.insight-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: none; }
.insight-name { flex: 1; font-size: 15px; color: var(--text-primary); }
.insight-value {
  font-size: 14px; color: var(--text-primary); font-variant-numeric: tabular-nums;
  display: inline-flex; gap: 6px; align-items: center;
}
.insight-value .star-tiny { color: var(--gold); }
.insight-value .trend-arrow { font-size: 11px; }
.trend-down { color: var(--danger); }
.trend-up   { color: var(--success); }

.sparkline-wrap { padding: 28px 24px 40px; }
.sparkline-label {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 14px;
}
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 56px;
}
.sparkline .bar {
  flex: 1;
  background: var(--gold-dim);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: background var(--dur-fast);
}
.sparkline .bar.last { background: var(--gold); }

/* ---------- Onboarding ---------- */

.onboard {
  position: absolute; inset: 0;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  padding: 60px 24px 32px;
  z-index: 30;
  animation: fadeIn var(--dur-mid) var(--ease);
}
.onboard-dots {
  display: flex; gap: 6px; justify-content: center;
  margin-bottom: 48px;
}
.onboard-dot {
  width: 18px; height: 3px; border-radius: 2px; background: var(--divider-strong);
  transition: background var(--dur-mid), width var(--dur-mid);
}
.onboard-dot.active { background: var(--gold); width: 24px; }
.onboard-dot.done { background: var(--gold-dim); }

.onboard-step { flex: 1; display: flex; flex-direction: column; animation: stepIn var(--dur-mid) var(--ease) both; }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.onboard-eyebrow {
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 14px;
}
.onboard-question {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.onboard-help {
  font-size: 14px; color: var(--text-muted);
  margin-bottom: 32px; max-width: 300px;
}
.onboard-field { margin-bottom: 24px; }
.onboard-choices { display: flex; flex-direction: column; gap: 10px; }
.onboard-choice {
  text-align: left;
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  font-size: 16px;
  color: var(--text-primary);
  transition: all var(--dur-fast);
  display: flex;
  align-items: center;
  gap: 12px;
}
.onboard-choice .mark {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--divider-strong);
  flex: none;
  display: grid; place-items: center;
  transition: all var(--dur-fast);
}
.onboard-choice.on {
  border-color: var(--gold);
  background: rgba(212,175,55,0.06);
}
.onboard-choice.on .mark {
  border-color: var(--gold);
  background: var(--gold);
}
.onboard-choice.on .mark::after {
  content: "";
  width: 6px; height: 6px; border-radius: 50%; background: #0a0a0a;
}

.onboard-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; }
.onboard-skip {
  font-size: 13px; color: var(--text-muted); letter-spacing: 0.12em; text-transform: uppercase;
}
.onboard-skip:hover { color: var(--text-primary); }
.onboard-next {
  padding: 14px 28px;
  background: var(--gold);
  color: #0a0a0a;
  border-radius: var(--r-pill);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 13px;
  text-transform: uppercase;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.onboard-next:disabled {
  background: var(--gold-dim); color: rgba(10,10,10,0.55); cursor: not-allowed;
}
.onboard-next:active:not(:disabled) { transform: scale(0.97); }
.onboard-error {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(220, 80, 80, 0.45);
  background: rgba(220, 80, 80, 0.08);
  color: #ffb8b8;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.onboard-textarea {
  min-height: 140px;
  font-family: inherit;
}
.onboard-charcount {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-align: right;
}

/* Splash */
.splash {
  position: absolute; inset: 0;
  background: var(--bg-base);
  display: grid; place-items: center;
  z-index: 40;
  pointer-events: none;
  transition: opacity 500ms var(--ease);
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash .mark {
  font-family: var(--font-display);
  font-size: 120px;
  color: var(--gold);
  line-height: 1;
  animation: markIn 600ms var(--ease) both;
}
@keyframes markIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- Tweaks panel ---------- */
.tweaks-panel {
  position: fixed;
  right: 16px; bottom: 16px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 16px;
  width: 240px;
  z-index: 100;
  font-family: var(--font-body);
  display: none;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.tweaks-panel.open { display: block; }
.tweaks-panel h4 {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}
.tweak-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.tweak-row label {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
}
.tweak-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.tweak-opt {
  flex: 1;
  padding: 8px 10px;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}
.tweak-opt.on {
  color: var(--gold); border-color: var(--gold);
  background: rgba(212,175,55,0.08);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
body[data-reduced-motion="true"] .play-btn::before { animation: none; opacity: 0; }
body[data-reduced-motion="true"] .splash { transition-duration: 0ms; }

/* Accent variations (Tweaks) */
body[data-accent="bronze"] { --gold: #c08850; --gold-dim: #7a5634; --gold-bright: #d9a06b; }
body[data-accent="brass"]  { --gold: #c9a227; --gold-dim: #7d651a; --gold-bright: #e5bf3c; }
