:root {
  color-scheme: light;
  --bg: #efece3;
  --bg-2: #e7f0e4;
  --surface: #fffdf8;
  --surface-2: #f3efe4;
  --line: rgba(23, 33, 27, 0.12);
  --text: #17211b;
  --muted: #5c675f;
  --accent: #1b7a43;
  --accent-2: #d7f26a;
  --on-accent: #f3ffe8;
  --rest: #1d5cbf;
  --rest-soft: #e4efff;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(48, 42, 24, 0.08);
  --radius: 26px;
  --font: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101410;
  --bg-2: #172117;
  --surface: #1a211c;
  --surface-2: #242c27;
  --line: rgba(236, 244, 226, 0.12);
  --text: #f3f6ef;
  --muted: #a7b2a6;
  --accent: #d6ff4a;
  --accent-2: #d6ff4a;
  --on-accent: #142000;
  --rest: #9ec4ff;
  --rest-soft: #18283a;
  --danger: #ff8d82;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 420px at 100% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
    radial-gradient(700px 380px at -15% 8%, color-mix(in srgb, var(--rest) 16%, transparent), transparent 50%),
    var(--bg);
  transition: background-color 0.25s ease, color 0.25s ease;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }

.screen {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) 0 calc(40px + var(--safe-bot));
}
.screen-editor { width: min(820px, calc(100% - 28px)); }

.eyebrow, .tile-kicker, .label, .resume-kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero { margin-bottom: 28px; }
.hero h1, .page-head h1, .empty h1, .empty h2, .done-card h2, .hero-name {
  font-family: var(--display);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.hero h1 { font-size: clamp(3.2rem, 12vw, 5.4rem); }
.lede, .muted, .hint, .tile-text, .resume-meta { color: var(--muted); }
.lede { margin-top: 12px; max-width: 38rem; font-size: 1.05rem; line-height: 1.45; }
.hint { font-size: 0.92rem; line-height: 1.4; }

.menu { display: grid; gap: 14px; }
.tile, .resume, .session-card, .panel, .series-card, .hero-card, .overview, .done-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 118px;
  padding: 22px;
  text-decoration: none;
}
.tile-title, .session-card h2, .panel h2 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.tile.primary {
  min-height: 180px;
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}
.tile.primary .tile-kicker,
.tile.primary .tile-text { color: color-mix(in srgb, var(--on-accent) 78%, transparent); }
.tile-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--on-accent) 16%, transparent);
  margin-bottom: 8px;
}
.tile-icon svg { width: 22px; height: 22px; }

.resume {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin-bottom: 16px;
  padding: 18px 18px 16px;
  text-decoration: none;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface) 55%);
}
.resume strong { font-size: 1.25rem; letter-spacing: -0.03em; }
.resume-meta { grid-column: 1; font-size: 0.95rem; }
.resume-go {
  grid-row: 1 / span 3;
  align-self: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.page-head h1 { font-size: clamp(2.4rem, 8vw, 3.6rem); flex: 1; }
.back {
  width: 100%;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  color: var(--muted);
}
.back::before { content: "← "; }

.btn, .icon-btn {
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  background: var(--surface-2);
  font-weight: 650;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-block { width: 100%; }
.icon-btn {
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: var(--surface-2);
}
.icon-btn svg, .sheet-head svg { width: 18px; height: 18px; }
.btn:active, .tile:active, .icon-btn:active { transform: scale(0.98); }

.session-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.session-card { padding: 18px; display: grid; gap: 14px; }
.session-card p { margin-top: 4px; }
.session-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty {
  padding: 28px 8px 8px;
  display: grid;
  gap: 12px;
  justify-items: start;
}
.empty h1, .empty h2 { font-size: clamp(2rem, 6vw, 2.8rem); }
.empty p { max-width: 38rem; line-height: 1.45; color: var(--muted); }

.panel { padding: 18px; margin-bottom: 14px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
input[type="text"], input[type="number"], input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 16px;
}
.session-name {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 560;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding-left: 0;
}
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.seg button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
html[data-theme="dark"] .seg button[aria-pressed="true"] { background: #121714; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper input { text-align: center; }
.stepper .icon-btn { flex: 0 0 auto; }

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-weight: 600;
}
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.editor-top, .series-head, .ex-top, .hero-actions, .player-bar, .sheet-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.editor-top { justify-content: space-between; margin-bottom: 18px; }
.editor-top-actions, .series-tools, .ex-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.warn {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--text);
}
.series-card { padding: 14px; margin-bottom: 14px; display: grid; gap: 12px; }
.series-index {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 750;
  flex: 0 0 auto;
}
.series-head { align-items: stretch; }
.series-head .session-name, .series-head input[type="text"] { flex: 1; font-size: 1.15rem; }
.ex-list { display: grid; gap: 8px; }
.ex-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface-2);
}
.ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkline { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.92rem; }
.sticky-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 calc(12px + var(--safe-bot));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
}

.player {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 0 calc(28px + var(--safe-bot));
}
.player[data-phase="rest"] {
  background: radial-gradient(800px 280px at 50% 0%, color-mix(in srgb, var(--rest) 20%, transparent), transparent 60%);
}
.player-bar { justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.player-title { min-width: 0; display: grid; gap: 2px; }
.player-title strong {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 16px;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}
.player[data-phase="rest"] .progress > span { background: var(--rest); }
.player-layout { display: grid; gap: 16px; }
.hero-card { padding: 22px 18px 18px; display: grid; gap: 8px; position: relative; }
.where {
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-card h2 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
}
.clock-wrap { display: grid; justify-items: start; gap: 4px; margin: 8px 0; }
.clock {
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  font-size: clamp(4.2rem, 18vw, 6.4rem);
  line-height: 0.85;
  letter-spacing: -0.04em;
}
.player[data-phase="rest"] .clock,
.player[data-phase="rest"] .where { color: var(--rest); }
.unit { font-size: 1.05rem; color: var(--muted); font-weight: 650; }
.next-line { min-height: 1.3em; }
.hero-actions { margin-top: 8px; }
.hero-actions .btn { flex: 1; min-height: 56px; font-size: 1.05rem; }
.pause-note {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  font-weight: 700;
}

.overview { padding: 16px; display: grid; gap: 14px; align-content: start; }
.overview h3 { font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.rail { display: grid; gap: 16px; }
.rail-series { display: grid; gap: 8px; }
.rail-series header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; }
.rail-series header p { color: var(--muted); font-size: 0.85rem; }
.rail-series header strong { font-size: 1.05rem; }
.pips { display: flex; gap: 6px; }
.pip {
  width: 22px;
  height: 22px;
  border-radius: 99px;
  border: 0;
  padding: 0;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.pip.done { background: var(--accent); box-shadow: none; }
.pip.now { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent); }
.rail-item {
  width: 100%;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 14px;
}
.rail-jump {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 8px 0;
  min-height: 44px;
  display: grid;
}
.rail-item.current { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.player[data-phase="rest"] .rail-item.current { background: var(--rest-soft); }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  box-shadow: inset 0 0 0 2px var(--line);
}
.rail-item.done .dot { background: var(--accent); box-shadow: none; }
.rail-item.current .dot { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.rail-item small { color: var(--muted); }
.adjust { display: flex; flex-wrap: wrap; gap: 8px; }

.done-card { padding: 28px 20px; display: grid; gap: 10px; }
.done-card h2 { font-size: clamp(2.6rem, 8vw, 4rem); }
.done-card .clock { font-size: clamp(3rem, 10vw, 4.4rem); }

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  justify-items: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 12, 9, 0.46);
}
.sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: min(88dvh, 820px);
  overflow: auto;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 8px 16px calc(18px + var(--safe-bot));
  box-shadow: var(--shadow);
}
.sheet-head { position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 10px 0; z-index: 1; }
.sheet-head h2 { font-size: 1.25rem; }
.sheet-body { display: grid; gap: 12px; }
.sheet-actions { margin-top: 4px; }
.suggest { display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.suggest button, .lib-row {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 16px;
  padding: 12px;
}
.suggest button { display: grid; gap: 2px; }
.suggest button small, .lib-row small { display: block; color: var(--muted); margin-top: 2px; }
.library-list { display: grid; gap: 8px; }
.lib-row { display: grid; gap: 8px; }
.lib-row-top { display: flex; gap: 8px; align-items: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bot));
  transform: translateX(-50%) translateY(16px);
  max-width: min(440px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 40;
  font-weight: 650;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 800px) {
  .menu { grid-template-columns: 1.3fr 1fr; }
  .tile.primary { grid-row: span 2; min-height: 280px; }
  .page-head .back { width: auto; }
  .sheet-root { align-items: center; }
  .sheet { border-radius: 28px; padding: 8px 18px 18px; }
}
@media (min-width: 980px) {
  .player-layout { grid-template-columns: minmax(320px, 460px) minmax(0, 1fr); align-items: start; }
  .overview { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
