/* Palettes and rules are explained in DESIGN.md. */
:root,
:root[data-theme="sky"] {
  --bg: linear-gradient(135deg, #cbd7f4 0%, #e6e4f3 50%, #f3d3e0 100%);
  --bg-solid: #e6e4f3;
  --surface: #ffffffb8;
  --ink: #1f233b;
  --muted: #4a5272;
  --line: #1f233b24;
  --focus: #fc3b75;
  --break: #6b8ccb;
  --track: #1f233b14;
  --btn: #1f233b;
  --btn-ink: #ffffff;
  --selected: #ffffff;
  --error: #b3124c;
  color-scheme: light;
}

:root[data-theme="blush"] {
  --bg: linear-gradient(135deg, #f7dbe6 0%, #f3e4ec 55%, #d9e3f6 100%);
  --bg-solid: #f3e4ec;
  --surface: #ffffffbf;
  --ink: #2b2038;
  --muted: #5d4c69;
  --line: #2b203824;
  --focus: #e0245f;
  --break: #5a7cbd;
  --track: #2b203814;
  --btn: #2b2038;
  --btn-ink: #ffffff;
  --selected: #ffffff;
  --error: #a80f45;
  color-scheme: light;
}

:root[data-theme="midnight"] {
  --bg: linear-gradient(135deg, #1f233b 0%, #1c1e35 55%, #2c2341 100%);
  --bg-solid: #1f233b;
  --surface: #ffffff0f;
  --ink: #f1f2f3;
  --muted: #b6caea;
  --line: #ffffff24;
  --focus: #fc3b75;
  --break: #b6caea;
  --track: #ffffff14;
  --btn: #e1acc3;
  --btn-ink: #1f233b;
  --selected: #ffffff1f;
  --error: #ecc0d2;
  color-scheme: dark;
}

:root[data-theme="ousadia"] {
  --bg: #ede8e0;
  --bg-solid: #ede8e0;
  --surface: #f7f4ef;
  --ink: #211d1a;
  --muted: #5c5148;
  --line: #211d1a24;
  --focus: #c1440e;
  --break: #6b3226;
  --track: #211d1a14;
  --btn: #211d1a;
  --btn-ink: #ede8e0;
  --selected: #ffffff;
  --error: #a33a0c;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { background: var(--bg-solid); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 15px/1.45 Inter, system-ui, sans-serif;
}

h1, h2, .clock, .tab, .btn { font-family: "Space Grotesk", Inter, system-ui, sans-serif; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.app { max-width: 1040px; margin: 0 auto; padding: 24px 16px 40px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.brand { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }

.themes { display: flex; gap: 8px; }
.swatch {
  width: 34px; height: 34px; padding: 0;
  border: 2px solid var(--line); border-radius: 50%;
}
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--selected); }

.views { display: flex; gap: 4px; width: fit-content; max-width: 100%; margin-bottom: 16px; padding: 4px; border-radius: 999px; background: var(--track); }
.view-tab { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font: 500 14px "Space Grotesk", Inter, system-ui, sans-serif; white-space: nowrap; }
.view-tab[aria-current="page"] { background: var(--selected); font-weight: 700; }
.nav-clock { margin-left: 6px; font-variant-numeric: tabular-nums; color: var(--muted); }
.nav-clock:empty { display: none; }

.plan { max-width: 720px; }
.plan-list { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.plan-list:empty { display: none; }
.plan-empty { margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
.plan-empty:empty { display: none; }
.plan-task { padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; }
.plan-row { display: flex; align-items: flex-start; gap: 10px; }
.plan-row input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--focus); }
.plan-text { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: pointer; }
.plan-task.done .plan-name { color: var(--muted); text-decoration: line-through; }
.plan-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-task details { margin: 6px 0 0 28px; }
.plan-task summary { width: fit-content; min-height: 28px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.plan-fields { display: grid; gap: 12px; margin-top: 8px; }
.plan-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.plan-fields input[type="text"], .plan-fields textarea, .plan-fields select {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--selected); color: var(--ink); font: inherit; font-size: 16px;
}
.plan-fields textarea { min-height: 88px; resize: vertical; }
.steps-title { font-size: 13px; color: var(--muted); }
.step-list { display: grid; gap: 2px; margin: 4px 0 8px; padding: 0; list-style: none; }
.step-item { display: flex; align-items: flex-start; gap: 4px; }
.step-item label { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; cursor: pointer; }
.step-item input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--focus); }
.step-item.done span { color: var(--muted); text-decoration: line-through; }
.plan-actions { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.plan-actions label { flex: 1; min-width: 160px; }

.layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 20px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }

.timer { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 24px 20px; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--track); max-width: 100%; }
.tab {
  padding: 8px 14px; border: 0; border-radius: 999px;
  background: transparent; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.tab[aria-pressed="true"] { background: var(--selected); font-weight: 700; }

.dial { position: relative; width: min(100%, 320px); aspect-ratio: 1; }
.dial svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.dial circle { fill: none; stroke-width: 9; }
.track { stroke: var(--track); }
.progress {
  stroke: var(--focus); stroke-linecap: round;
  stroke-dasharray: 1000; transition: stroke-dashoffset .4s linear;
}
.is-break .progress { stroke: var(--break); }

.readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.kind { font-size: 14px; font-weight: 500; color: var(--muted); }
.clock {
  font-size: clamp(52px, 16vw, 72px); font-weight: 500; line-height: 1.05;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}

.controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; font-size: 15px; }
.btn.primary { min-width: 132px; min-height: 52px; background: var(--btn); color: var(--btn-ink); font-size: 18px; }
.btn.ghost { background: transparent; border-color: var(--line); font-weight: 500; }
.btn.small { min-height: 40px; background: var(--btn); color: var(--btn-ink); font-size: 14px; }

.steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.steps:empty { display: none; }
.step {
  min-width: 34px; padding: 2px 8px; border-radius: 999px; text-align: center;
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--track);
}
.step.done { opacity: .5; text-decoration: line-through; }
.step.current { background: var(--focus); color: #fff; font-weight: 600; }
.step.current.rest { background: var(--break); }
:root[data-theme="midnight"] .step.current { color: #1f233b; }

.status { min-height: 21px; margin: 0; text-align: center; font-size: 14px; color: var(--muted); }

.seq-list { display: grid; gap: 8px; }
.seq, .chip {
  position: relative; display: flex; align-items: center;
  border: 1px solid var(--line); background: transparent;
}
.seq { border-radius: 16px; }
.seq.active, .chip.active { background: var(--selected); border-color: var(--ink); }
.seq-pick { flex: 1; min-width: 0; padding: 10px 14px; border: 0; background: transparent; text-align: left; border-radius: 16px; }
.seq-name { display: block; font-weight: 600; }
.seq-meta { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border-radius: 999px; }
.chip-pick { min-height: 40px; padding: 0 14px; border: 0; background: transparent; border-radius: 999px; font-weight: 500; }

.del { flex: none; width: 32px; height: 32px; margin-right: 4px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; }
.del:hover:not(:disabled) { background: var(--track); color: var(--ink); }

.add { margin-top: 12px; }
.add summary { width: fit-content; min-height: 28px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.add form { display: grid; gap: 10px; margin-top: 10px; justify-items: start; }
.add label { display: grid; gap: 4px; width: 100%; font-size: 13px; color: var(--muted); }
.add input { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--selected); color: var(--ink); font-size: 16px; }
.form-error { margin: 0; font-size: 13px; color: var(--error); }
.form-error:empty { display: none; }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.task-form { display: flex; gap: 8px; }
.task-form input, #login-form input {
  width: 100%; min-width: 0; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--selected); color: var(--ink); font-size: 16px;
}
.tasks { display: grid; gap: 2px; margin: 10px 0 0; padding: 0; list-style: none; }
.tasks:empty { display: none; }
.task { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.task label { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; cursor: pointer; overflow-wrap: anywhere; }
.task input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--focus); }
.task.done span { color: var(--muted); text-decoration: line-through; }

#login-form { display: grid; gap: 10px; justify-items: start; }
#login-form label { display: grid; gap: 4px; width: 100%; font-size: 13px; color: var(--muted); }
.btn.compact { min-height: 40px; font-size: 14px; }
.sync-status { margin: 10px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.sync-status:empty { display: none; }
.sync-status.error { color: var(--error); }
[hidden] { display: none !important; }

.options { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--focus); }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .views { width: 100%; }
  .view-tab { flex: 1; padding: 0 8px; }
  .plan-task details { margin-left: 0; }
  .app { padding-top: 16px; }
  .timer { padding: 20px 12px; }
  .tab { padding: 8px 10px; font-size: 13px; }
  .dial { width: min(100%, 280px); }
}

@media (prefers-reduced-motion: reduce) {
  .progress { transition: none; }
}
