:root {
  --bg: #14161c;
  --card: #1d2029;
  --card2: #252935;
  --line: #2f3442;
  --text: #ece8e1;
  --muted: #9ba1ad;
  --faint: #6c7280;
  --accent: #8fc3a6;
  --accent-ink: #10231a;
  --rest: #ab9fd8;
  --gentle: #8fb6dc;
  --steady: #8fc3a6;
  --strong: #dcbc8f;
  --easy: #7fc8c3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --r: 22px;
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 17px; color: var(--text); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.boot { display: grid; place-items: center; height: 100dvh; color: var(--faint); font-size: 22px; }

/* Layout */
.screen { padding: calc(var(--safe-top) + 12px) 20px calc(var(--safe-bot) + 96px); max-width: 560px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 8px; }
.topbar .date { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .right { display: flex; gap: 6px; align-items: center; }
.support-link { white-space: nowrap; color: var(--muted); font-size: 15px; padding: 10px 12px; border-radius: 999px; background: var(--card); }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; color: var(--muted); background: var(--card); }
.icon-btn svg { width: 20px; height: 20px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(var(--safe-bot) + 8px);
  background: rgba(20, 22, 28, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button { flex: 1; max-width: 160px; padding: 10px 0; border-radius: 14px; color: var(--faint); font-size: 15px; font-weight: 600; }
.tabbar button.on { color: var(--text); background: var(--card); }

/* Cards */
.card { background: var(--card); border-radius: var(--r); padding: 22px; }
.today-card { min-height: 58dvh; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; margin-top: 8px; }
.zone-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.zone-chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--z, var(--accent)); display: inline-block; }
.say { color: var(--muted); font-size: 17px; margin-top: 14px; }
.big { font-size: 32px; line-height: 1.15; font-weight: 680; letter-spacing: -0.02em; margin-top: 18px; }
.cue { color: var(--muted); margin-top: 10px; font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.primary {
  width: 100%; min-height: 64px; border-radius: 20px; font-size: 20px; font-weight: 700;
  background: var(--z, var(--accent)); color: var(--accent-ink);
}
.primary:active, .secondary:active, .choice:active, .tile:active { transform: scale(0.98); }
.secondary { width: 100%; min-height: 56px; border-radius: 18px; background: var(--card2); font-weight: 600; font-size: 17px; }
.quiet { color: var(--muted); font-size: 16px; padding: 12px; text-align: center; width: 100%; }
.quiet u { text-decoration-color: var(--faint); text-underline-offset: 3px; }
.note-line { font-size: 15px; color: var(--muted); background: var(--card2); border-radius: 14px; padding: 12px 14px; }
.small { font-size: 14px; color: var(--faint); }
.center { text-align: center; }

/* Sheets (full-screen flows) */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 10px) 20px calc(var(--safe-bot) + 24px);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(18px); } to { transform: none; } }
.sheet-inner { max-width: 520px; margin: 0 auto; min-height: calc(100dvh - var(--safe-top) - var(--safe-bot) - 34px); display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.sheet-head .x { padding: 10px 4px; color: var(--muted); font-size: 16px; }
.sheet-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 10px 0 18px; }
.sheet-foot { display: flex; flex-direction: column; gap: 6px; }
.q { font-size: 28px; font-weight: 680; line-height: 1.2; letter-spacing: -0.02em; }
.q-sub { color: var(--muted); margin-top: -8px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--text); }

.scale { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 60px; padding: 12px 18px; border-radius: 18px; background: var(--card); font-size: 18px; font-weight: 560;
  border: 2px solid transparent;
}
.choice .n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); font-size: 15px; color: var(--muted); flex: none; }
.choice.sel { border-color: var(--accent); }
.choice .sub { display: block; font-size: 14px; color: var(--muted); font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 12px 16px; border-radius: 999px; background: var(--card); font-size: 16px; font-weight: 560; border: 2px solid transparent; }
.chip.sel { border-color: var(--accent); background: var(--card2); }

.time-big { display: flex; align-items: center; justify-content: center; gap: 12px; }
.time-big input {
  font-size: 40px; font-weight: 700; background: var(--card); border: 0; border-radius: 18px; padding: 14px 18px; text-align: center; width: 100%;
  -webkit-appearance: none; appearance: none; min-height: 84px;
}
.nudge { min-width: 76px; min-height: 56px; border-radius: 16px; background: var(--card); font-weight: 600; color: var(--muted); }
.field { width: 100%; background: var(--card); border: 0; border-radius: 16px; padding: 16px; outline: none; }
.field:focus { box-shadow: 0 0 0 2px var(--accent); }
textarea.field { min-height: 110px; resize: vertical; }
label.lbl { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px 4px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; }
.stepper button { width: 72px; height: 72px; border-radius: 50%; background: var(--card); font-size: 34px; font-weight: 500; }
.stepper .val { font-size: 56px; font-weight: 700; min-width: 70px; text-align: center; }

/* Log tab */
.section-t { font-size: 14px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 24px 4px 10px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: 18px; padding: 14px 14px 12px; text-align: left; min-height: 86px; display: flex; flex-direction: column; justify-content: space-between; }
.tile .t { font-weight: 640; font-size: 16px; }
.tile .v { font-size: 14px; color: var(--muted); }
.tile .v b { color: var(--text); font-weight: 650; }
.tile.pin { box-shadow: inset 0 0 0 1.5px var(--line); }
.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); padding: 12px 14px; border-radius: 14px; font-size: 15px; }
.li .when { color: var(--faint); font-size: 13px; }
.li .del { color: var(--faint); padding: 6px 10px; font-size: 14px; }

/* History */
.stat { font-size: 26px; font-weight: 680; line-height: 1.2; letter-spacing: -0.01em; }
.week { display: grid; grid-template-columns: 74px repeat(7, 1fr); gap: 6px 4px; align-items: center; font-size: 13px; }
.week .h { color: var(--faint); text-align: center; font-size: 12px; }
.week .h.today { color: var(--text); font-weight: 700; }
.week .lab { color: var(--muted); font-size: 13px; }
.cell { height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 13px; font-weight: 650; color: var(--bg); background: var(--card2); }
.cell.empty { color: var(--faint); background: transparent; border: 1px dashed var(--line); font-weight: 400; }
.ladder { display: flex; flex-direction: column; gap: 8px; }
.ladder .rung { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.ladder .bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ladder .bar i { height: 12px; border-radius: 4px; background: var(--card2); }
.ladder .bar i.on { background: var(--accent); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--faint); margin-top: 10px; }

/* Breathing */
.breath-wrap { display: grid; place-items: center; height: 260px; }
.breath { width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, var(--easy), rgba(127,200,195,.25)); animation: breathe 10s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(.7); opacity: .7; } 40% { transform: scale(1.6); opacity: 1; } 50% { transform: scale(1.6); opacity: 1; } }
.breath-label { text-align: center; color: var(--muted); font-size: 18px; min-height: 26px; }

/* Login */
.login { display: flex; flex-direction: column; justify-content: center; gap: 18px; min-height: 100dvh; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; }
.err { color: var(--strong); font-size: 15px; min-height: 20px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-top) + 8px); z-index: 40;
  background: var(--text); color: var(--bg); border-radius: 999px; padding: 12px 18px; font-weight: 600; font-size: 15px;
  display: flex; gap: 14px; align-items: center; white-space: nowrap; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px);
}
.toast button { color: #3c6f55; font-weight: 750; }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .breath { animation-duration: 20s; }
}

.nudge.mini { min-width: 36px; min-height: 36px; border-radius: 10px; font-size: 18px; padding: 0; }
button.li { font: inherit; color: inherit; }
.tabbar button { font-size: 14px; }
