:root {
  --bg: #fbf8f1;
  --surface: #ffffff;
  --text: #141210;
  --muted: #5a544b;
  --line: #e9e2d6;
  --beige: #c8b08a;
  --beige-2: #b79f79;
  --shadow: 0 10px 30px rgba(18, 18, 18, 0.06);
  --radius: 22px;
  --radius-sm: 16px;
  --max: 1100px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 72px;

  /* Backward-compatible aliases used by existing in-app markup. */
  --panel: var(--surface);
  --primary: var(--beige);
  --primary-strong: var(--beige-2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
button, input, select, textarea { font: inherit; }
body,
body.page {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Inter, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.6;
  font-size: 18px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a, a:visited { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; opacity: 0.85; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(20, 20, 20, 0.08);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}
.brand { font-size: 18px; font-weight: 750; letter-spacing: -0.02em; }
.nav {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.nav a {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav a.active { color: var(--text); background: #f7f2e9; border-color: #ddd2c0; }
.nav-muted { opacity: 0.55; pointer-events: none; }
.account { justify-self: end; position: relative; }
.account-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
  z-index: 10;
}
.account-menu a,
.account-menu button {
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  padding: 0 10px;
}
.account-menu button { cursor: pointer; }
.account-menu a:hover,
.account-menu button:hover { background: #f7f2e9; }

.ln-main { flex: 1; }
.ln-container {
  max-width: var(--max);
  margin: 0 auto;
  width: 100%;
  padding: 96px 20px 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.05; letter-spacing: -0.03em; }
h2 { font-size: clamp(24px, 3vw, 34px); line-height: 1.12; letter-spacing: -0.02em; }
h3 { font-size: 20px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

button,
.btn {
  height: 48px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
button.primary,
.btn-primary { background: var(--primary); border-color: var(--primary); }
button.primary:hover,
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
button.ghost,
.btn-ghost { color: var(--muted); }

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  appearance: none;
}
input:not([type="checkbox"]):not([type="radio"]),
select { height: 44px; padding: 0 12px; }
textarea { min-height: 96px; padding: 10px 12px; font-family: inherit; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

.today-shell {
  max-width: 660px;
  margin: 0 auto;
}
.today-progress {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.today-screen { text-align: center; }
.today-screen > * + * { margin-top: 14px; }
.today-question { font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.02em; }
.today-sub { color: var(--muted); }
.checkin-label {
  display: block;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 4px;
  text-align: left;
}
.today-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  text-align: left;
}
.today-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 4px;
}
.today-card-desc {
  color: var(--muted);
  margin: 0 0 12px;
}
.today-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.today-card-primary {
  border: 2px solid var(--beige, #c49e70);
}

.today-card-primary .today-card-label {
  color: var(--beige, #c49e70);
}

.today-card-subtle {
  opacity: 0.85;
  border-style: dashed;
}

.today-card-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 4px 0 8px;
}

.today-card-done {
  opacity: 0.5;
  border-color: var(--line);
  border-style: solid;
}

.today-card-done .today-card-label {
  color: var(--muted);
}

#day-status:not(:empty) {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.phase-progress {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

.exit-session {
  font-size: 0.8rem;
  margin-top: 8px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.choice-grid.time { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-grid button {
  height: 52px;
  border-radius: 999px;
}
.choice-grid button.active {
  background: #f3eadb;
  border-color: #dccfb9;
}
.today-next { margin-top: 18px; width: 100%; }
.today-links { margin-top: 8px; font-size: 14px; color: var(--muted); }
.today-links a { text-decoration: none; }
.today-links a:hover { text-decoration: none; opacity: 0.85; }

.secondary-page {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}
.list { display: grid; gap: 10px; }
.list-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.progressive details {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}
.progressive details + details { margin-top: 10px; }
.progressive summary { cursor: pointer; font-weight: 650; }
.grid-2 {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.footer {
  margin-top: 26px;
  padding: 0 20px 32px;
}
.footer-panel {
  max-width: var(--max);
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 24px;
}
.footer-head {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.footer-links { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
.footer-bottom {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: 1fr; }
  .brand, .account, .nav { justify-self: center; }
  .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .choice-grid.time, .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .ln-container { padding: 92px 16px 24px; }
  .footer { padding: 0 16px 28px; }
  button, .btn { width: 100%; }
  .today-options button { width: auto; }
}

/* Day page — guided reset */
.stress-slider,
.sleep-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  outline: none;
  cursor: pointer;
  border: none;
  padding: 0;
}
.stress-slider::-webkit-slider-thumb,
.sleep-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--beige);
  border: 2px solid var(--beige-2);
  cursor: pointer;
}
.stress-slider::-moz-range-thumb,
.sleep-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--beige);
  border: 2px solid var(--beige-2);
  cursor: pointer;
}
.slider-wrap { display: flex; flex-direction: column; gap: 8px; margin: 20px 0; }
.slider-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.slider-value { text-align: center; font-size: 36px; font-weight: 700; letter-spacing: -0.03em; color: var(--text); }

.today-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.today-options .time-opt,
.today-options .energy-opt,
.today-options .goal-opt,
.today-options .onboard-energy-opt,
.today-options .onboard-time-opt {
  flex: 1;
  min-width: 80px;
  border-radius: 999px;
}
.today-options .time-opt.active,
.today-options .energy-opt.active,
.today-options .goal-opt.active,
.today-options .onboard-energy-opt.active,
.today-options .onboard-time-opt.active {
  background: #f3eadb;
  border-color: #dccfb9;
}

.reset-instruction {
  font-size: clamp(18px, 2.5vw, 24px);
  line-height: 1.5;
  margin: 20px 0 12px;
  color: var(--text);
  text-align: left;
}
.reset-timer {
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--beige-2);
  line-height: 1;
  margin-bottom: 8px;
}

.onboard-step {
  animation: fadeIn 0.2s ease-in;
}

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

.onboard-value-prop {
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 12px 0 8px;
}

.onboard-goals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-opt {
  text-align: left;
  padding: 12px 16px;
}

.onboard-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.onboard-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
}

.onboard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
}

.progress-section {
  margin-bottom: 24px;
}

.stat-cards {
  display: flex;
  gap: 12px;
}

.stat-card {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.trend-canvas {
  width: 100%;
  height: 200px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.win-card {
  border-left: 3px solid var(--beige);
  padding: 10px 14px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
}

@media (max-width: 700px) {
  .stat-cards {
    flex-direction: column;
  }
}

.onboard-textarea {
  width: 100%;
  background: var(--surface, #1c1a17);
  border: 1px solid var(--line, rgba(196,168,108,0.1));
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--font-body, 'DM Sans', -apple-system, sans-serif);
  font-size: 0.95rem;
  color: var(--text, #e8e0d4);
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.2s;
}
.onboard-textarea:focus {
  border-color: var(--gold, #c4a86c);
}
.onboard-textarea::placeholder {
  color: var(--dim, #5a5248);
  font-size: 0.88rem;
}
