:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --border: #dcd9d2;
  --accent: #d9481e;
  --accent-text: #ffffff;
  --work: #d9481e;
  --rest: #1f8a7d;
  --prepare: #b8860b;
  --note: #4a5bbd;
  --danger: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1e1c;
    --surface-2: #282826;
    --text: #f1efe9;
    --muted: #a3a19b;
    --border: #3a3936;
    --accent: #f0643a;
    --work: #f0643a;
    --rest: #3bb3a3;
    --prepare: #e0b23f;
    --note: #8291e6;
    --danger: #f07167;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 700; text-decoration: none; color: var(--text); }
.brand-mark { width: 2rem; height: 2rem; flex: none; fill: none; stroke: currentColor; stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .pulse { stroke: var(--accent); stroke-width: 4; }
@media (max-width: 520px) { .brand-name { display: none; } }
.site-header nav { display: flex; gap: 1rem; margin-left: auto; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.2rem; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, .button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
button:hover, .button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary:hover { background: var(--accent); filter: brightness(1.08); }
.icon { padding: 0.35rem 0.55rem; line-height: 1; }
.danger { color: var(--danger); }

.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.row > select, .row > input { width: auto; }
.stack > * + * { margin-top: 0.75rem; }

.notice {
  border-left: 4px solid var(--prepare);
  background: var(--surface-2);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}
.notice.error { border-color: var(--danger); }

/* Landing */
.hero { max-width: 640px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.choices a { text-decoration: none; color: inherit; }
.choices .card:hover { border-color: var(--accent); }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.summary { position: sticky; top: 1rem; }
.summary .total { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary pre {
  max-height: 320px;
  overflow: auto;
  background: var(--surface-2);
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
}
.section-head { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto; gap: 0.6rem; align-items: end; }
.section-head .checkbox { display: flex; gap: 0.35rem; align-items: center; white-space: nowrap; padding-bottom: 0.5rem; }
.section-head .checkbox input { width: auto; }
.steps { margin: 0.9rem 0 0.6rem; padding: 0; list-style: none; }
.step {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 0.9fr) auto;
  gap: 0.5rem;
  align-items: end;
  padding: 0.6rem 0;
  border-top: 1px dashed var(--border);
}
.step.rest { grid-template-columns: minmax(0, 2.2fr) minmax(0, 0.9fr) auto; }
.step .tag { font-weight: 600; padding-bottom: 0.5rem; }
.step .tag.rest-tag { color: var(--rest); }
.step-actions { display: flex; gap: 0.25rem; padding-bottom: 0.1rem; }
.section-actions { display: flex; gap: 0.25rem; }

@media (max-width: 860px) {
  .builder { grid-template-columns: 1fr; }
  .summary { position: static; }
}
@media (max-width: 560px) {
  .section-head { grid-template-columns: 1fr 1fr; }
  .section-head > :first-child { grid-column: 1 / -1; }
  .step { grid-template-columns: 1fr 1fr; }
  .step > :first-child { grid-column: 1 / -1; }
  .step.rest { grid-template-columns: 1fr 1fr; }
}

/* Player */
.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
}
.drop.over { border-color: var(--accent); background: var(--surface-2); }
.examples { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.overview-list { margin: 0; padding-left: 1.2rem; }

.run {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  --tone: var(--work);
}
.run[data-tone="rest"] { --tone: var(--rest); }
.run[data-tone="prepare"] { --tone: var(--prepare); }
.run[data-tone="note"] { --tone: var(--note); }
.run-top { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; }
.run-top .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-top .clock { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.progress { height: 6px; background: var(--surface-2); }
.progress > div { height: 100%; width: 0; background: var(--tone); transition: width 0.3s linear; }
.run-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  gap: 0.6rem;
  border-top: 8px solid var(--tone);
}
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; color: var(--tone); font-weight: 700; }
.step-name { font-size: clamp(2rem, 7vw, 4.5rem); font-weight: 800; line-height: 1.05; }
.timer {
  font-size: clamp(4.5rem, 24vw, 13rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--tone);
}
.timer.small-timer { font-size: clamp(2rem, 8vw, 4rem); }
.goal { font-size: clamp(1.6rem, 6vw, 3.2rem); font-weight: 700; }
.details { color: var(--muted); max-width: 40rem; white-space: pre-line; }
.task-list { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: clamp(1.1rem, 3.5vw, 1.6rem); }
.task-list li { padding: 0.2rem 0; }
.done-button { font-size: 1.3rem; padding: 0.8rem 2.4rem; }
.next { padding: 0.75rem 1rem; border-top: 1px solid var(--border); color: var(--muted); text-align: center; }
.next strong { color: var(--text); }
.controls { display: flex; justify-content: center; gap: 0.5rem; padding: 0 1rem 1rem; flex-wrap: wrap; }
.controls button { min-width: 6rem; }
.finished { text-align: center; }
.finished .total { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.drop.small { padding: 1rem; }
.problems { margin: 0.5rem 0; padding-left: 1.2rem; }
.problems li + li { margin-top: 0.3rem; }
.problems code { font-size: 0.85em; }
#copy-problems { margin-top: 0.25rem; }
.ai-box { border-top: 1px solid var(--border); padding-top: 1rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  max-width: min(90vw, 32rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 10;
}
