*, *::before, *::after { box-sizing: border-box; }
/* Single dark theme on purpose: the page is used in a dark bedroom; the accent is amber, the least alerting light at night. */
:root {
  --bg: #0a0d16;
  --surface: #111625;
  --line: #1f2638;
  --fg: #c8cddb;
  --muted: #767f97;
  --accent: #d69a5c;
  --accent-soft: rgba(214, 154, 92, .16);
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-data: ui-monospace, Consolas, "Roboto Mono", monospace;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font-body); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.wrap {
  max-width: 680px; margin: 0 auto;
  padding-top: max(32px, env(safe-area-inset-top, 0px));
  padding-bottom: 96px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body.has-player .wrap { padding-bottom: 300px; }
.tab { display: flex; flex-direction: column; gap: 24px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; margin: 0; color: #e6e1d8; }
h1 { font-size: 2.2rem; line-height: 1.1; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.1rem; overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 8px; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.lede { margin: 12px 0 0; color: var(--muted); max-width: 60ch; }
.note { margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.notice { margin: 0; color: var(--accent); }
.notice:empty { display: none; }
.suggest { display: grid; gap: 12px; }
.account { display: grid; gap: 14px; }
.account input[type="email"], .account input[type="text"] { width: 100%; padding: 10px 14px; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.account .check input { flex: none; }
.account .check a { color: var(--accent); }
.routine { display: grid; gap: 14px; }
.routine h2 { font-size: 1.25rem; }
.routine-step { margin: 0; color: var(--muted); font-size: .85rem; }
.routine-options { display: grid; gap: 10px; }
.routine-options button { text-align: left; width: 100%; }
.routine-options button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.routine-time { display: grid; gap: 6px; }
.routine-time input { width: 100%; padding: 10px 14px; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color-scheme: dark; }
.routine-times { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.routine-times div { min-width: 90px; }
.routine-times dt { color: var(--muted); font-size: .85rem; }
.routine-times dd { margin: 0; color: #e6e1d8; font: 1.5rem var(--font-display); }
.routine-block { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.routine-block h3 { margin: 0; font-size: 1.05rem; color: #e6e1d8; }
.routine-block p { margin: 0; }
.routine-block.urgent { border-color: var(--accent); }
.button-link { display: inline-block; justify-self: start; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; color: var(--fg); text-decoration: none; }
.button-link.primary { background: var(--accent); border-color: var(--accent); color: #1a1208; font-weight: 500; }
.splash {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  background: var(--bg) url(/splash.webp) center / cover no-repeat;
  animation: splash-out .7s ease 5.6s forwards;
}
.splash-leaving { animation: splash-out .7s ease forwards; }
.splash-video { display: block; width: 100%; height: 100%; object-fit: cover; }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .splash { animation-delay: 1s; }
  .splash-video { display: none; }
}
.welcome, .continue { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.welcome ol { margin: 0; padding-left: 20px; }
.welcome h2, .continue h2 { font-size: 1.25rem; }
.welcome .primary, .continue .primary { justify-self: start; min-width: 160px; }
.continue .eyebrow, .continue .story-meta { margin: 0; }
.story-shared { border: 1px solid var(--accent); border-radius: 14px; }
.scenes { flex-wrap: wrap; }
.suggest textarea { width: 100%; padding: 10px 14px; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; resize: vertical; }
.empty { margin: 0; padding: 24px 0; color: var(--muted); text-align: center; }
.legal { margin: 32px 0 0; font-size: .82rem; text-align: center; }
a { color: var(--muted); }

.stage { display: flex; flex-direction: column; align-items: center; gap: 24px; padding-block: 12px; }
.orb-wrap { position: relative; width: 220px; height: 220px; max-width: 100%; display: grid; place-items: center; }
.orb {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(214,154,92,.55), rgba(214,154,92,.12) 60%, transparent 72%);
  transform: scale(.55); will-change: transform;
}
.breath { position: absolute; font-family: var(--font-display); font-size: 1.1rem; color: #e6e1d8; letter-spacing: .04em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
button {
  font: 500 1rem var(--font-body); border-radius: 999px; padding: 12px 26px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--fg); min-height: 44px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1208; }
.actions button.primary { min-width: 160px; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.status { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; width: 100%; margin: 0; }
.status div { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.status dt { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.status dd { margin: 0; font: 400 .95rem var(--font-data); font-variant-numeric: tabular-nums; color: var(--fg); }

.groups { display: flex; flex-direction: column; gap: 16px; }
fieldset {
  margin: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
legend { padding: 0; float: left; width: 100%; }
legend + * { clear: both; }
.hint { margin: -6px 0 0; font-size: .85rem; color: var(--muted); max-width: 62ch; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.row label { font-size: .92rem; }
.row output { font: .85rem var(--font-data); font-variant-numeric: tabular-nums; color: var(--accent); }
.row input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.row select {
  grid-column: 1 / -1; width: 100%; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.check { display: flex; gap: 10px; align-items: center; font-size: .92rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }

footer { font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 20px; }
footer p { margin: 0; max-width: 64ch; }
.linkish { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: .82rem; align-self: flex-start; min-height: 0; }

.filters { display: flex; gap: 8px; }
.filters button { padding: 7px 16px; min-height: 38px; font-size: .9rem; }
.filters button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: #e6e1d8; }

.story-list { display: flex; flex-direction: column; gap: 14px; }
.story-card {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.story-cover { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; background: var(--line); }
.story-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.story-meta { margin: 0; font-size: .82rem; color: var(--muted); }
.story-text { margin: 4px 0 0; font-size: .92rem; overflow-wrap: anywhere; }
.story-text:empty { display: none; }
.story-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.story-actions button { padding: 8px 16px; min-height: 40px; font-size: .92rem; }
.dl-progress { flex: 1 1 120px; accent-color: var(--accent); }

.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding-bottom: env(safe-area-inset-bottom, 0px); }
body.has-player:not(.menu-open) .dock { background: var(--bg); border-top: 1px solid var(--line); }
body.menu-open { overflow: hidden; }
body.menu-open .dock { z-index: 25; }
body.menu-open .player { visibility: hidden; }

.moon-button {
  position: absolute; right: 14px; bottom: calc(100% + 14px);
  width: 72px; height: 72px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--accent);
}
.moon-button svg { display: block; width: 100%; height: 100%; }
.moon-shape { fill: currentColor; }
.moon-label { fill: var(--fg); font: 600 11px var(--font-body); letter-spacing: 2px; text-anchor: middle; }
body:not(.has-player) .moon-button { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

.menu {
  position: fixed; inset: 0; z-index: 20; background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 12% 8%, #fff, transparent), radial-gradient(1px 1px at 84% 12%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 46% 22%, #fff, transparent), radial-gradient(1px 1px at 8% 36%, #fff, transparent),
    radial-gradient(1px 1px at 90% 44%, #fff, transparent), radial-gradient(1.5px 1.5px at 18% 66%, #fff, transparent),
    radial-gradient(1px 1px at 74% 72%, #fff, transparent), radial-gradient(1px 1px at 38% 84%, #fff, transparent);
  animation: menu-in .25s ease-out;
}
.menu[hidden] { display: none; }
.menu-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.menu-lines polyline { fill: none; stroke: #3a4560; stroke-width: 1; vector-effect: non-scaling-stroke; }
.menu a {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -14px);
  display: grid; justify-items: center; gap: 10px; padding: 8px 12px; min-width: 96px;
  color: #e6e1d8; font: 1.05rem var(--font-display); text-align: center; text-decoration: none; white-space: nowrap;
  animation: star-in .4s ease-out backwards; animation-delay: calc(var(--i) * 60ms);
}
.menu a::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px 3px var(--accent-soft);
}
.menu a[aria-current="page"] { color: var(--accent); }
.menu a[aria-current="page"]::before { box-shadow: 0 0 0 5px var(--accent-soft), 0 0 18px 6px var(--accent-soft); }
@keyframes menu-in { from { opacity: 0; } }
@keyframes star-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .menu, .menu a { animation: none; } }

.player {
  max-width: 680px; margin: 0 auto; padding: 12px 16px;
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px 12px;
}
.player-cover { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--line); }
.player-main { min-width: 0; }
.player-title { margin: 0; color: #e6e1d8; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-main input { width: 100%; margin: 4px 0 0; accent-color: var(--accent); }
.player-time { margin: 0; font: .78rem var(--font-data); font-variant-numeric: tabular-nums; color: var(--muted); }
.player-buttons { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.player-buttons button { padding: 7px 14px; min-height: 40px; font-size: .9rem; }
.player-buttons .primary { min-width: 84px; }

#dim {
  position: fixed; inset: 0; z-index: 30; background: #000;
  display: flex; align-items: flex-end; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
}
#dim-hint { margin: 0; padding: 0 16px calc(32px + env(safe-area-inset-bottom, 0px)); color: #4a4e5a; font-size: .85rem; text-align: center; }

@media (max-width: 480px) {
  h1 { font-size: 1.9rem; }
  .status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orb-wrap { width: 180px; height: 180px; }
  .story-card { grid-template-columns: 72px minmax(0, 1fr); }
  .story-cover { width: 72px; height: 72px; }
}
