:root {
  --bg: #0f1417; --surface: #172026; --surface2: #1f2a31; --text: #e7eef0; --muted: #9aaab0;
  --accent: #7cc4b4; --accent-ink: #0b1a17; --happy: #e8c57a; --hard: #8fa8d8; --line: #2a363d;
  --radius: 18px; --tap: 56px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f1ec; --surface: #ffffff; --surface2: #ece8e1; --text: #1f2a2e; --muted: #5d6b70;
  --accent: #2f7d6d; --accent-ink: #ffffff; --happy: #a87a12; --hard: #3f5f9e; --line: #dcd6cc;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f1ec; --surface: #ffffff; --surface2: #ece8e1; --text: #1f2a2e; --muted: #5d6b70;
    --accent: #2f7d6d; --accent-ink: #ffffff; --happy: #a87a12; --hard: #3f5f9e; --line: #dcd6cc;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang HK", sans-serif; -webkit-font-smoothing: antialiased; }
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding: max(16px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 26px; font-weight: 600; margin: 8px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 600; margin: 22px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 12px 0; border: 1px solid var(--line); }
.card.soft { background: var(--surface2); border: none; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: var(--tap); padding: 12px 18px; margin: 10px 0;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { min-height: 76px; font-size: 20px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: .45; }
.btn:active { transform: scale(.985); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 8px 0 4px; }
.chips.c6 { grid-template-columns: repeat(6, 1fr); }
.chip { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 18px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.scale-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.valence { min-height: 84px; font-size: 20px; }
.valence.on.happy { background: var(--happy); color: #1b1503; border-color: transparent; }
.valence.on.hard { background: var(--hard); color: #0b1430; border-color: transparent; }
textarea, input[type=text], input[type=time], input[type=password], input[type=url], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-height: var(--tap); }
textarea { min-height: 110px; resize: vertical; }
label.field { display: block; margin: 14px 0 6px; font-weight: 600; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.check input { width: 26px; height: 26px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.status { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.pill { padding: 6px 12px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 14px; }
.pill.done { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.dots { display: flex; justify-content: space-between; margin: 10px 0 4px; }
.dot { width: 38px; text-align: center; font-size: 12px; color: var(--muted); }
.dot i { display: block; width: 30px; height: 30px; margin: 0 auto 4px; border-radius: 50%; border: 2px solid var(--line); }
.dot.done i { background: var(--accent); border-color: var(--accent); }
.dot.today i { border-color: var(--accent); }
.moment { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 14px; margin: 8px 0; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; min-height: var(--tap); }
.moment.on { outline: 2px solid var(--accent); }
.moment .tag { font-size: 22px; }
.moment .meta { font-size: 13px; color: var(--muted); }
.player { text-align: center; padding: 20px 4px; }
.ring { width: 200px; height: 200px; margin: 10px auto 18px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 300; }
.beat { min-height: 120px; font-size: 22px; line-height: 1.45; padding: 0 6px; transition: opacity .4s; }
.breath { width: 160px; height: 160px; border-radius: 50%; margin: 30px auto; background: color-mix(in srgb, var(--accent) 35%, transparent); animation: breathe 10s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.6); } 40% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .breath { animation: none; } }
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav a { flex: 1; max-width: 130px; text-align: center; padding: 12px 4px 14px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav a.on { color: var(--accent); }
.nav a span { display: block; font-size: 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.topbar a, .topbar button { color: var(--muted); background: none; border: none; font: inherit; padding: 10px 0; text-decoration: none; cursor: pointer; }
.steps { display: flex; gap: 4px; margin: 6px 0 14px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--accent); }
.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: none; }
.stat b { font-weight: 600; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.overlay .sheet { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
.sheet ul { padding-left: 0; list-style: none; }
.sheet li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sheet li a { color: var(--accent); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--surface2); color: var(--text); padding: 12px 18px; border-radius: 14px; z-index: 30; max-width: 90vw; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.lock { opacity: .55; }
.tool { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chart { width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 5px; }
.win { font-size: 20px; line-height: 1.45; }
