:root {
  color-scheme: light dark;
  --paper: light-dark(#f4f0e7, #1e2822);
  --ink: light-dark(#26382e, #f0eee3);
  --muted: light-dark(#4f6455, #c2d0c3);
  --line: light-dark(#cfD4c7, #506358);
  --field: light-dark(#e0e8db, #304337);
  --ring: light-dark(#bccdb9, #557360);
  --rest: light-dark(#eee1d3, #473a31);
  --rest-ring: light-dark(#d0b69e, #785e4b);
  --rest-muted: light-dark(#694d3c, #edc9ad);
  --plant-ink: light-dark(#527353, #c2d6a9);
  --button: light-dark(#35533f, #d6e5cc);
  --button-ink: light-dark(#fffaf0, #1e3427);
  --danger: light-dark(#8b3f35, #f3b6a5);
  font: 16px/1.4 "DM Sans", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

.desk {
  width: min(100%, 32rem);
  min-height: 100svh;
  margin-inline: auto;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

.masthead, .brand, .next-row, .desk-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.masthead { padding: .15rem .1rem 1rem; }
.brand { font-size: 1.12rem; font-weight: 690; letter-spacing: -.04em; }
.brand img { border-radius: .58rem; }
time { font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.desk-tools { gap: .65rem; }
.masthead .text-button { margin-right: -.5rem; }

.activity {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(.55rem, 1.8vh, 1.2rem);
  min-height: 20rem;
  padding: 1.35rem 1rem;
  text-align: center;
  border-radius: 1.5rem;
  background: var(--field);
}

.activity[data-tone="rest"] {
  background: var(--rest);
  --ring: var(--rest-ring);
  --muted: var(--rest-muted);
  --plant-ink: light-dark(#846248, #ecd0ab);
}

.phase {
  margin: 0 0 .45rem;
  font-weight: 650;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.phase:empty { display: none; }
.activity h1, .editor h1, .dialog-heading h2 {
  margin: 0;
  text-wrap: balance;
  font: 400 clamp(2.15rem, 9vw, 3.3rem)/1.02 "Instrument Serif", Georgia, serif;
  letter-spacing: -.05em;
  overflow-wrap: anywhere;
}

.dial {
  width: clamp(8.5rem, 24vh, 12rem);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.dial::before, .dial::after {
  position: absolute;
  inset: 0;
  border: 1px solid var(--ring);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}
.dial::after { inset: .42rem; border-bottom-color: transparent; transform: rotate(-32deg); }
#countdown { font-size: clamp(3rem, 9vh, 4.6rem); line-height: .92; font-weight: 500; letter-spacing: -.08em; font-variant-numeric: tabular-nums; }
#countdown.long-countdown { font-size: clamp(1.8rem, 6vw, 2.65rem); letter-spacing: -.06em; }
#unit { font-size: .8rem; margin-top: .45rem; color: var(--muted); }
.growth { color: var(--plant-ink); width: min(100%, 15rem); }
.growth canvas { display: block; width: 100%; height: auto; }
.cue { margin: 0; max-width: 30ch; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.cue:empty { display: none; }

.next { padding: 1rem .15rem .15rem; }
.next-row span, .anchor { font-size: .87rem; color: var(--muted); }
.next-row strong { max-width: 72%; text-align: right; font-size: .95rem; font-weight: 650; overflow-wrap: anywhere; }
.next-row span { flex-shrink: 0; }
.anchor { text-align: right; margin: .5rem 0 0; }

.text-button, .filled-button, .days button {
  min-height: 44px;
  padding: .45rem .65rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font: inherit;
  font-size: .83rem;
  font-weight: 650;
  cursor: pointer;
}
.text-button { background: transparent; color: var(--ink); }
.filled-button, .days button[aria-pressed="true"] { background: var(--button); color: var(--button-ink); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--plant-ink);
  outline-offset: 2px;
}

.editor {
  width: min(100%, 40rem);
  margin-inline: auto;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.editor-top, .day-tools, .dialog-heading, .dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .45rem;
}
.editor h1 { font-size: clamp(1.85rem, 7vw, 2.65rem); }
.editor-caption, .field-hint { margin: .3rem 0 .85rem; color: var(--muted); font-size: .83rem; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-bottom: 1rem; }
.days button { padding-inline: 0; background: var(--field); color: var(--ink); font-size: .76rem; }
.day-tools { flex-wrap: wrap; }
.day-tools h2 { flex: 1; font-size: 1.08rem; margin: 0; }
.day-tools button { white-space: nowrap; }
.editor-status { margin: .25rem 0; color: var(--muted); font-size: .84rem; }
.editor-status:empty { display: none; }
.timeline { list-style: none; margin: .65rem 0 0; padding: 0; border-top: 1px solid var(--line); }
.timeline li {
  display: grid;
  grid-template-columns: minmax(5.7rem, 28%) minmax(0, 1fr) auto;
  align-items: center;
  gap: .45rem;
  min-height: 45px;
  border-bottom: 1px solid var(--line);
  font-size: .87rem;
}
.timeline .gap { color: var(--muted); }
.slot-time { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.timeline strong { overflow-wrap: anywhere; font-weight: 620; }
.timeline small { display: block; color: var(--muted); font-size: .72rem; font-weight: 500; }

dialog {
  width: min(29rem, calc(100% - 1.5rem));
  max-height: 88svh;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: #18251ca0; }
dialog form { display: grid; gap: .75rem; }
.dialog-heading h2 { font-size: 1.8rem; }
.dialog-actions { justify-content: flex-end; margin-top: .25rem; }
dialog label { display: grid; gap: .25rem; font-size: .83rem; font-weight: 600; }
dialog input, dialog select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: .45rem .55rem;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
}
.time-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.form-error, .danger { color: var(--danger); }
.form-error, dialog .field-hint { margin: 0; font-size: .82rem; }
dialog summary { padding-block: .45rem; font-size: .83rem; color: var(--muted); cursor: pointer; }
dialog details label { margin-top: .65rem; }

@media (max-height: 620px) {
  .desk { padding-block: max(.8rem, env(safe-area-inset-top)) max(.8rem, env(safe-area-inset-bottom)); }
  .masthead { padding-bottom: .65rem; }
  .activity { gap: .55rem; padding: .95rem .85rem; min-height: 17rem; }
  .dial { width: clamp(7.1rem, 23vh, 9.25rem); }
  .growth { width: min(100%, 13rem); }
}

@media (min-width: 42rem) and (min-height: 40rem) {
  .desk { min-height: min(100svh, 52rem); padding-top: 2rem; }
}
