/* Grind. Two moods on one layout:
 *   energize (mornings): pure black, neon green, heavy condensed italic type, gears.
 *   calm (evenings):     night blues, soft lavender, lighter type, breathing and stars.
 * --c / --on-c are the current routine's colour and the ink that reads on it. */

@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/barlow-condensed-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/barlow-condensed-600.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-style: normal; font-display: swap; src: url(../fonts/barlow-condensed-800.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-style: italic; font-display: swap; src: url(../fonts/barlow-condensed-800-italic.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 900; font-style: italic; font-display: swap; src: url(../fonts/barlow-condensed-900-italic.woff2) format("woff2"); }

:root {
  --display: "Barlow Condensed", "Helvetica Neue", "Arial Narrow", sans-serif;
  --body: system-ui, -apple-system, "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

:root, [data-mood="energize"] {
  --bg: #000;
  --surface: #0f0f0f;
  --surface-2: #1b1b1b;
  --surface-3: #2a2a2a;
  --border: #1f1f1f;
  --text: #fff;
  --muted: #8d8d8d;
  --faint: #545454;
  --accent: #ceff00;
  --on-accent: #000;
  --over: #ff4b3e;
  --g-ring: #141414;
  --g-dark: #232323;
  --g-edge: #2f2f2f;
}

[data-mood="calm"] {
  --bg: #07081a;
  --surface: #0e1029;
  --surface-2: #171a3a;
  --surface-3: #22264d;
  --border: #1b1e40;
  --text: #eef0ff;
  --muted: #8f94c4;
  --faint: #555a8a;
  --accent: #a9b4ff;
  --on-accent: #0a0b1f;
  --over: #ff8fa3;
  --g-ring: #12142f;
  --g-dark: #1d2044;
  --g-edge: #2a2e5c;
}

[data-mood] { --c: var(--accent); --on-c: var(--on-accent); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .6s;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, p, blockquote { margin: 0; }
small { color: var(--muted); }
.muted { color: var(--muted); }

.icon { width: 22px; height: 22px; flex: none; display: block; }
:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; }

/* Display type: uppercase condensed. Energize slants it; calm keeps it upright and airy. */
.brand, .hero-greet, .hero-tag, .hero-date, .section-title, .tile-mood, .tile-name, .tile-meta,
.pill, .btn, .seg, .tab span, .dial-time, .dial-sub, .task-title, .chip, .statline strong, .statline small,
.finish-kicker, .finish-title, .finish-sub, .topbar-title, .mini-time, .stat strong, .stat small, .badge,
.title-input, .sheet-title, .moment-kicker, .moment-label, .moment-title, .moment-sub, .moment-count,
.hero-quote cite, .quote-card cite, .moment-quote cite, .moment-skip, .breath-cue, .link {
  font-family: var(--display);
}

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

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  min-height: 64px;
  flex: none;
}
.topbar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.topbar-title > * { overflow: hidden; text-overflow: ellipsis; }
.topbar-title small { font-size: 12px; font-weight: 600; letter-spacing: .14em; }
.topbar-title.left { text-align: left; font-size: 40px; font-style: italic; font-weight: 900; letter-spacing: 0; line-height: 1; }
.spacer { width: 42px; flex: none; }

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: -.01em;
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 32px;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.content::-webkit-scrollbar { display: none; }

.footer { flex: none; background: var(--bg); }
.tabbar {
  display: flex;
  padding: 4px 8px calc(6px + var(--safe-b));
  border-top: 1px solid var(--border);
}
.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 4px;
  color: var(--faint);
}
.tab span { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.tab.active { color: var(--text); }
.tab.active::before {
  content: "";
  position: absolute;
  top: -5px;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

/* ---------- buttons ---------- */

.pill, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  border: 1px solid var(--surface-3);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  transition: transform .1s, filter .15s, background .15s;
}
.pill { padding: 15px 26px; font-size: 18px; }
.btn { padding: 10px 18px; font-size: 15px; }
.btn-sm { padding: 7px 15px; font-size: 14px; }
.pill .icon, .btn .icon { width: 18px; height: 18px; }
.pill:active, .btn:active { transform: scale(.96); }
.pill:hover, .btn:hover { filter: brightness(1.15); }
.pill-accent, .btn-primary { background: var(--c); color: var(--on-c); border-color: transparent; }
.btn-danger { background: var(--over); color: #000; border-color: transparent; }
.btn-danger-ghost { background: transparent; color: var(--over); border-color: color-mix(in srgb, var(--over) 40%, transparent); }

.icon-btn {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--surface-2);
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 32px; height: 32px; background: transparent; color: var(--faint); }
.icon-btn.sm:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.sm .icon { width: 18px; height: 18px; }

.link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font-size: 15px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.link .icon { width: 16px; height: 16px; }

/* ---------- shared bits ---------- */

.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-title {
  margin: 28px 2px 12px;
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .01em;
  line-height: 1;
}
.section-title .muted { font-size: 16px; letter-spacing: .06em; color: var(--muted); }

.hint { margin: 12px 4px 0; font-size: 13px; color: var(--faint); }
.hint b { color: var(--muted); font-weight: 600; }
.about { margin-top: 28px; text-align: center; font-size: 12px; color: var(--faint); }
.about a { color: var(--muted); text-decoration: underline; }

.emoji-badge {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 23px;
  border-radius: 50%;
  border: 0;
  background: color-mix(in srgb, var(--c) 16%, var(--surface-2));
}
.emoji-badge.sm { width: 40px; height: 40px; font-size: 19px; }
.emoji-badge.lg { width: 66px; height: 66px; font-size: 32px; box-shadow: inset 0 0 0 2px var(--c); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card.list { margin-top: 16px; }
.card.list > * + * { border-top: 1px solid var(--border); }

.row, .toggle-row { display: flex; align-items: center; gap: 14px; padding: 15px 16px; }
.row > span:first-child, .toggle-row > span:first-child { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.row strong, .toggle-row strong { font-weight: 650; }
.row small, .toggle-row small { font-size: 13px; line-height: 1.35; }
.toggle-row { cursor: pointer; }

.switch {
  appearance: none;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 99px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .2s, background .2s;
}
.switch:checked { background: var(--c); }
.switch:checked::after { transform: translateX(20px); background: var(--on-c); }

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.seg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background .2s, color .2s;
}
.seg.selected { background: var(--text); color: var(--bg); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 48px 20px; }
.empty h2 { font: 800 28px/1 var(--display); text-transform: uppercase; }
.empty p { color: var(--muted); max-width: 300px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); }
.stat strong { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat small { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; line-height: 1.2; }
.stat:first-child strong { color: var(--accent); }

/* ---------- stars & moon (calm) ---------- */

.stars { position: absolute; inset: 0; pointer-events: none; }
.stars i {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: .25;
  animation: twinkle 4.5s ease-in-out infinite;
}
.stars i:nth-child(3n) { width: 3px; height: 3px; }
.stars i:nth-child(4n) { animation-duration: 6s; }
@keyframes twinkle { 50% { opacity: .95; transform: scale(1.5); } }

.moon {
  position: absolute;
  right: 26px;
  top: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  box-shadow: inset 14px -8px 0 0 #eef0ff;
  transform: rotate(-25deg);
  filter: drop-shadow(0 0 16px rgba(238, 240, 255, .45));
  animation: drift 9s ease-in-out infinite;
}
@keyframes drift { 50% { translate: 0 6px; } }

/* ---------- home ---------- */

.hero {
  position: relative;
  overflow: hidden;
  margin-top: 4px;
  padding: 22px 20px 20px;
  border-radius: 26px;
  background: radial-gradient(110% 80% at 100% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), var(--surface);
  border: 1px solid var(--border);
}
.hero-gears { position: absolute; width: 240px; height: 240px; right: -112px; top: -82px; overflow: visible; }
.hero-date { position: relative; font-size: 14px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.hero-greet {
  position: relative;
  max-width: 78%;
  margin-top: 4px;
  font-size: 58px;
  font-weight: 900;
  font-style: italic;
  line-height: .86;
  text-transform: uppercase;
}
.hero-tag { position: relative; margin-top: 8px; font-size: 18px; font-weight: 800; font-style: italic; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.hero-quote {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 2px 0 2px 14px;
  border: 0;
  border-left: 3px solid var(--accent);
  background: none;
  text-align: left;
}
.hero-quote-text { display: block; font-size: 17px; line-height: 1.38; font-weight: 500; }
.hero-quote cite { display: block; margin-top: 8px; font-size: 13px; font-weight: 700; font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hero > .pill { position: relative; width: 100%; margin-top: 22px; }

[data-mood="calm"] .hero {
  background: radial-gradient(90% 70% at 85% 5%, rgba(169, 180, 255, .22), transparent 62%), linear-gradient(170deg, #171b4b 0%, #0b0d26 75%);
}
.hero-sky { position: absolute; inset: 0; pointer-events: none; }
[data-mood="calm"] .hero-greet { font-style: normal; font-weight: 500; font-size: 50px; letter-spacing: .02em; line-height: .95; }
[data-mood="calm"] .hero-tag { font-style: normal; font-weight: 500; letter-spacing: .14em; }
[data-mood="calm"] .hero-quote-text { font-style: italic; font-weight: 400; }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tile {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 132px;
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(125deg, var(--surface) 30%, color-mix(in srgb, var(--c) 30%, var(--surface)) 135%);
  border: 1px solid var(--border);
  transition: transform .15s, border-color .2s;
}
.tile:active { transform: scale(.985); }
.tile.live { border-color: var(--c); }
.tile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 18px 0 18px 20px; }
.tile-emoji {
  position: absolute;
  right: 58px;
  top: 50%;
  font-size: 96px;
  line-height: 1;
  opacity: .2;
  transform: translateY(-50%) rotate(-12deg);
  pointer-events: none;
}
.tile-mood { font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--c); }
.tile-name {
  position: relative;
  margin-top: 6px;
  font-size: 38px;
  font-weight: 900;
  font-style: italic;
  line-height: .88;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-meta { margin-top: 8px; font-size: 14px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tile-play {
  flex: none;
  width: 56px;
  height: 56px;
  margin: 0 16px 16px 8px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  color: var(--on-c);
  transition: transform .1s;
}
.tile-play:active { transform: scale(.9); }
.tile-play .icon { margin-left: 3px; }
.tile.live .tile-play { animation: pulse 2s infinite; }
[data-mood="calm"] .tile-name { font-style: normal; font-weight: 600; letter-spacing: .02em; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 60%, transparent); }
  70% { box-shadow: 0 0 0 14px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- gears ---------- */

.g-dark { fill: var(--g-dark); stroke: var(--g-edge); stroke-width: 1.5; }
.g-dark-2 { fill: var(--surface-3); }
.g-accent { fill: var(--c); }
.g-ring { fill: var(--g-ring); stroke: var(--g-edge); stroke-width: 1.5; }
.g-ink, .g-ink-2 { fill: currentColor; }

/* ---------- mini player ---------- */

.mini {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 10px 6px;
  padding: 8px 8px 8px 12px;
  border-radius: 18px;
  background: var(--surface-2);
  overflow: hidden;
}
.mini-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--c); transform-origin: left; transition: transform .25s linear; }
.mini-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.mini-emoji { font-size: 22px; }
.mini-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mini-text strong, .mini-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-text small { font-size: 12px; }
.mini-time { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--c); }
.mini-time.over { color: var(--over); }
.mini.paused .mini-time { color: var(--muted); }
.mini .icon-btn { background: var(--c); color: var(--on-c); }

/* ---------- editor ---------- */

.editor-head { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.title-input {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  border-bottom: 2px solid var(--surface-3);
  background: transparent;
  font-size: 34px;
  font-weight: 800;
  text-transform: uppercase;
  outline: none;
}
.title-input:focus { border-color: var(--c); }
.title-input::placeholder { color: var(--faint); }

.swatches { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--sw);
  transition: box-shadow .15s, transform .15s;
}
.swatch.selected { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--sw); transform: scale(1.05); }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 2px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform .15s ease;
}
.task-row.dragging { position: relative; z-index: 2; transition: none; background: var(--surface-2); box-shadow: 0 14px 30px -8px rgba(0, 0, 0, .8); }
.grip { width: 26px; height: 38px; flex: none; display: grid; place-items: center; border: 0; background: none; color: var(--faint); cursor: grab; touch-action: none; }
.grip .icon { width: 18px; height: 18px; }
.task-row.dragging .grip { cursor: grabbing; }
.task-emoji { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: var(--surface-2); font-size: 19px; }
.task-name, .task-dur { min-width: 0; padding: 9px 6px; border: 0; border-radius: 10px; background: transparent; outline: none; }
.task-name { flex: 1; }
.task-name::placeholder { color: var(--faint); }
.task-dur {
  width: 70px;
  flex: none;
  text-align: center;
  background: var(--surface-2);
  font: 800 18px var(--display);
  font-variant-numeric: tabular-nums;
}
.task-name:focus, .task-dur:focus { background: var(--surface-3); }
.task-dur.invalid { box-shadow: inset 0 0 0 2px var(--over); }

.add-task {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border-radius: 16px;
  border: 1.5px dashed var(--surface-3);
  background: transparent;
  color: var(--muted);
  font: 800 16px var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.add-task:hover { color: var(--text); border-color: var(--c); }
.add-task .icon { width: 18px; height: 18px; }
.editor-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }

/* ---------- player ---------- */

.dial { position: relative; width: min(88vw, 360px); aspect-ratio: 1; margin: 0 auto; }
.dial-gears, .dial-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dial-track { fill: none; stroke: var(--surface-2); stroke-width: 13; }
.dial-bar {
  fill: none;
  stroke: var(--c);
  stroke-width: 13;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--c) 55%, transparent));
  transition: stroke .3s;
}
.dial-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.dial-emoji { font-size: 28px; line-height: 1; }
.dial-time { font-size: clamp(58px, 18vw, 78px); font-weight: 800; line-height: .95; font-variant-numeric: tabular-nums; }
.dial-time.long { font-size: clamp(42px, 13vw, 56px); }
.dial-sub { font-size: 14px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

.player.over .dial-bar { stroke: var(--over); }
.player.over .g-accent { fill: var(--over); }
.player.over .dial-time { color: var(--over); }
.player.paused .dial-bar { stroke: var(--faint); filter: none; }
.player.paused .g-accent { fill: var(--faint); }
.player.paused .dial-time { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* calm dial: thin ring, breathing orb */
[data-mood="calm"] .dial-track { stroke: rgba(169, 180, 255, .12); stroke-width: 4; }
[data-mood="calm"] .dial-bar { stroke-width: 5; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--c) 70%, transparent)); }
[data-mood="calm"] .dial-time { font-weight: 500; letter-spacing: .02em; }
.breath { position: absolute; inset: 14%; }
.breath i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 30%, transparent) 0%, color-mix(in srgb, var(--c) 7%, transparent) 62%, transparent 72%);
  animation: breathe 10s ease-in-out infinite;
}
.breath i:nth-child(2) { inset: 14%; animation-delay: .3s; }
.breath i:nth-child(3) { inset: 30%; animation-delay: .6s; }
@keyframes breathe { 0%, 100% { transform: scale(.7); } 40%, 50% { transform: scale(1.06); } }
.player.paused .breath i { animation-play-state: paused; }

.breath-cue { position: relative; height: 22px; margin-top: 2px; text-align: center; font-size: 15px; font-weight: 500; letter-spacing: .32em; text-transform: uppercase; color: var(--accent); }
.breath-cue span { position: absolute; inset: 0; animation: 10s ease-in-out infinite; }
.breath-cue .cue-in { animation-name: cue-in; }
.breath-cue .cue-out { animation-name: cue-out; }
@keyframes cue-in { 0%, 40% { opacity: 1; } 47%, 95% { opacity: 0; } 100% { opacity: 1; } }
@keyframes cue-out { 0%, 43% { opacity: 0; } 50%, 92% { opacity: 1; } 99% { opacity: 0; } }

.task-title {
  margin-top: 8px;
  text-align: center;
  font-size: 44px;
  font-weight: 900;
  font-style: italic;
  line-height: .92;
  text-transform: uppercase;
}
[data-mood="calm"] .task-title { font-style: normal; font-weight: 500; font-size: 38px; letter-spacing: .04em; }
.task-hint { margin-top: 8px; min-height: 21px; text-align: center; color: var(--text); font-size: 14px; }
.task-hint .muted { font: 700 13px var(--display); letter-spacing: .14em; text-transform: uppercase; margin-right: 4px; }
.task-hint .when-over { display: none; color: var(--over); font-weight: 600; }
.player.over .task-hint .when-over { display: inline; }
.player.over .task-hint:has(.when-over) .when-normal { display: none; }

.controls { display: flex; align-items: center; justify-content: center; gap: 26px; margin-top: 20px; }
.ctrl {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--surface-2);
  transition: transform .1s, background .15s;
}
.ctrl:hover { background: var(--surface-3); }
.ctrl:active { transform: scale(.9); }
.ctrl-main {
  width: 90px;
  height: 90px;
  background: var(--c);
  color: var(--on-c);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--c) 14%, transparent);
}
.ctrl-main:hover { background: var(--c); filter: brightness(1.08); }
.ctrl-main .icon { width: 32px; height: 32px; }
.paused .ctrl-main .icon { margin-left: 4px; }
.ctrl-done { color: var(--c); }
.ctrl-done .icon { stroke-width: 3; }
.player.over .ctrl-done { background: var(--c); color: var(--on-c); animation: pulse 1.6s infinite; }

.chips { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--surface-3);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.chip:hover { background: var(--surface-2); }
.chip .icon { width: 14px; height: 14px; }

.statline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 24px 0 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.statline > div { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.statline > div + div { border-left: 1px solid var(--border); }
.statline strong { font-size: 28px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.statline small { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.statline .of { font-size: 18px; color: var(--muted); }

.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; color: var(--muted); }
.step-mark {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font: 800 14px var(--display);
}
.step-mark .icon { width: 14px; height: 14px; stroke-width: 3.5; }
.step-emoji { font-size: 18px; }
.step-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-time { font: 700 16px var(--display); font-variant-numeric: tabular-nums; }
.step.current { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--text); font-weight: 600; }
.step.current .step-mark { background: var(--c); color: var(--on-c); }
.step.done .step-mark { background: var(--c); color: var(--on-c); }
.step.done .step-name { text-decoration: line-through; text-decoration-color: var(--faint); }
.step.skipped { opacity: .5; }

/* ---------- finish ---------- */

.finish-hero {
  position: relative;
  overflow: hidden;
  margin-top: 4px;
  padding: 26px 22px 24px;
  border-radius: 26px;
  background: var(--c);
  color: var(--on-c);
}
.finish-kicker { position: relative; font-size: 14px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.finish-title { position: relative; margin-top: 10px; font-size: 64px; font-weight: 900; font-style: italic; line-height: .86; text-transform: uppercase; }
.finish-sub { position: relative; margin-top: 12px; font-size: 16px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .75; }
.finish .statline { margin-top: 18px; }
.finish-actions { display: flex; gap: 10px; margin-top: 22px; }
.finish-actions .pill { flex: 1; }

.confetti i {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 7px;
  height: 14px;
  border-radius: 2px;
  background: var(--on-c);
  animation: confetti 1.8s cubic-bezier(.15, .6, .35, 1) var(--d) both;
}
.confetti i:nth-child(3n) { background: #fff; }
.confetti i:nth-child(4n) { width: 10px; height: 10px; border-radius: 50%; }
@keyframes confetti {
  from { transform: translate(-50%, 0) rotate(0) scale(var(--s)); opacity: 1; }
  to { transform: translate(calc(-50% + var(--x)), 360px) rotate(var(--r)) scale(var(--s)); opacity: 0; }
}

[data-mood="calm"] .finish-hero { background: linear-gradient(170deg, #1c2056 0%, #0b0d26 80%); color: var(--text); padding-top: 70px; }
[data-mood="calm"] .finish-title { font-style: normal; font-weight: 500; font-size: 46px; line-height: 1; letter-spacing: .02em; }
[data-mood="calm"] .finish-kicker { color: var(--accent); opacity: 1; }
.finish-hero .moon { top: 18px; right: 22px; width: 46px; height: 46px; box-shadow: inset 10px -6px 0 0 #eef0ff; }

.quote-card { margin: 16px 0 10px; padding: 18px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.quote-card p { font-size: 18px; line-height: 1.38; font-weight: 500; }
.quote-card p::before { content: "“"; display: block; height: 26px; font: italic 900 56px/1 var(--display); color: var(--c); }
.quote-card cite { display: block; margin-top: 10px; font-size: 13px; font-weight: 700; font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
[data-mood="calm"] .quote-card p { font-style: italic; font-weight: 400; }

/* ---------- eye openers ---------- */

.eye-opener {
  margin-top: 28px;
  padding: 20px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.finish .eye-opener { margin-top: 12px; }
.eye-head { display: flex; align-items: center; justify-content: space-between; }
.eye-kicker { font: 800 14px var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--c); }
.eye-head .link { color: var(--c); }
.eye-title { margin: 10px 0 0; font: italic 900 34px/.92 var(--display); text-transform: uppercase; }
.eye-story { margin-top: 12px; font-size: 16px; line-height: 1.5; }
.eye-lesson {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  font-size: 15px;
  line-height: 1.45;
}
.eye-lesson strong { display: block; margin-bottom: 4px; font: 800 13px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--c); }
.eye-source { margin-top: 10px; font-size: 12px; color: var(--faint); }
[data-mood="calm"] .eye-title { font-style: normal; font-weight: 500; letter-spacing: .02em; }

/* ---------- history ---------- */

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); }
.routine-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.routine-text strong { font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.routine-text small { font-size: 13px; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.badge.ok { background: var(--accent); color: var(--on-accent); }
.badge.partial { background: var(--surface-2); color: var(--muted); }

/* ---------- sheets & toast ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  transition: background .2s;
}
.overlay.open { background: rgba(0, 0, 0, .7); }
.sheet {
  width: 100%;
  max-width: 520px;
  padding: 24px 18px calc(18px + var(--safe-b));
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  transform: translateY(100%);
  transition: transform .22s cubic-bezier(.2, .9, .3, 1);
}
.overlay.open .sheet { transform: none; }
.sheet-title { font-size: 28px; font-weight: 800; line-height: 1; text-transform: uppercase; }
.sheet-body { margin-top: 8px; color: var(--muted); }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { flex: 1; padding: 13px; font-size: 16px; }
@media (min-width: 560px) {
  .overlay { align-items: center; }
  .sheet { max-width: 400px; border-radius: 26px; border-bottom: 1px solid var(--border); transform: translateY(20px); opacity: 0; transition: transform .2s, opacity .2s; }
  .overlay.open .sheet { opacity: 1; }
}

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-top: 14px; }
.emoji-cell { aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent; font-size: 22px; }
.emoji-cell:hover { background: var(--surface-2); }
.emoji-cell.selected { background: var(--surface-3); box-shadow: inset 0 0 0 2px var(--accent); }
.emoji-custom { display: flex; gap: 8px; margin-top: 14px; }
.emoji-custom input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); outline: none; }
.emoji-custom input:focus { border-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-b));
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: 800 15px var(--display);
  letter-spacing: .06em;
  text-transform: uppercase;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s, opacity .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- moments ---------- */

.moment {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 28px calc(48px + var(--safe-b));
  overflow: hidden;
  cursor: pointer;
  background: var(--accent);
  color: var(--on-accent);
  opacity: 0;
  transform: translateX(40%) skewX(-10deg);
  transition: opacity .2s, transform .35s cubic-bezier(.2, .9, .3, 1);
}
.moment.in { opacity: 1; transform: none; }
.moment.out { opacity: 0; transform: translateX(-40%) skewX(-10deg); }
.speed-lines {
  position: absolute;
  inset: -40%;
  background: repeating-linear-gradient(-60deg, transparent 0 34px, rgba(0, 0, 0, .07) 34px 40px);
  animation: speed .5s linear infinite;
}
@keyframes speed { to { transform: translateX(92.38px); } }
.moment-gears { position: absolute; width: 340px; height: 340px; right: -110px; bottom: -90px; opacity: .13; overflow: visible; color: #000; }
.moment-body, .moment-quote { position: relative; width: 100%; max-width: 520px; margin: 0 auto; }
.moment-kicker { font-size: 34px; font-weight: 900; font-style: italic; line-height: 1; text-transform: uppercase; }
.moment-label { margin-top: 26px; font-size: 15px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; opacity: .6; }
.moment-title { margin-top: 4px; font-size: clamp(58px, 19vw, 104px); font-weight: 900; font-style: italic; line-height: .84; text-transform: uppercase; overflow-wrap: anywhere; }
.moment-sub { margin-top: 14px; font-size: 26px; font-weight: 800; letter-spacing: .06em; }
.moment-count { margin-top: 10px; height: 1em; font-size: clamp(120px, 40vw, 200px); font-weight: 900; font-style: italic; line-height: 1; text-transform: uppercase; }
.moment-count span { display: inline-block; animation: count-pop .9s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes count-pop { from { transform: scale(1.9); opacity: 0; } 25% { opacity: 1; } to { transform: scale(1); } }
.moment-quote { margin-top: 44px; padding-left: 14px; border-left: 4px solid currentColor; }
.moment-quote p { font-size: 19px; line-height: 1.35; font-weight: 600; }
.moment-quote cite { display: block; margin-top: 8px; font-size: 13px; font-weight: 800; font-style: normal; letter-spacing: .16em; text-transform: uppercase; opacity: .65; }
.moment-skip { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; opacity: .4; }

.moment[data-mood="calm"] {
  background: radial-gradient(80% 55% at 50% 35%, #1d2259 0%, #07081a 78%);
  color: var(--text);
  text-align: center;
  transform: none;
  transition: opacity .7s ease;
}
.moment[data-mood="calm"].out { transform: none; }
.moment[data-mood="calm"]::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: 70vmin;
  height: 70vmin;
  margin: -35vmin 0 0 -35vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(169, 180, 255, .18), transparent 65%);
  animation: breathe 8.8s ease-in-out infinite;
}
.moment[data-mood="calm"] .moment-kicker { font-size: 22px; font-weight: 500; font-style: normal; letter-spacing: .16em; color: var(--accent); }
.moment[data-mood="calm"] .moment-label { opacity: .5; }
.moment[data-mood="calm"] .moment-title { font-size: clamp(44px, 13vw, 76px); font-weight: 500; font-style: normal; line-height: 1; letter-spacing: .04em; }
.moment[data-mood="calm"] .moment-sub { font-weight: 500; font-size: 20px; color: var(--muted); }
.moment[data-mood="calm"] .moment-count { height: auto; margin-top: 34px; font-size: 30px; font-weight: 500; font-style: normal; letter-spacing: .3em; color: var(--accent); }
.moment[data-mood="calm"] .moment-count span { animation: calm-in 2.2s ease both; }
@keyframes calm-in { from { opacity: 0; letter-spacing: .1em; } 35% { opacity: 1; } to { letter-spacing: .3em; } }
.moment[data-mood="calm"] .moment-quote { border-left: 0; padding: 0; max-width: 420px; }
.moment[data-mood="calm"] .moment-quote p { font-style: italic; font-weight: 400; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
