:root {
  --fondo: #ffffff;
  --carta: #fdfcfa;
  --inchiostro: #15161a;
  --grigio: #6f7178;
  --tenue: #a6a8ae;
  --linea: #ebeae6;
  --campo: #f4f3f0;
  --accento: #e2542b;
  --accento-tenue: #fdeee8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 2vh 4vw;
  font-size: clamp(10px, min(3.6vw, 3vh), 17px);
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

.panel {
  width: min(92vw, 25em);
  background: var(--carta);
  border: 1px solid var(--linea);
  border-radius: 1.25em;
  padding: 1.15em 1.2em 1.2em;
  box-shadow:
    0 1px 1px rgba(20, 20, 26, 0.04),
    0 6px 14px rgba(20, 20, 26, 0.05),
    0 22px 44px rgba(20, 20, 26, 0.07);
  display: grid;
  gap: 0.95em;
}

/* ---- head ---- */
.head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.7em; }
.glyph {
  width: 2.3em; height: 2.3em; border-radius: 0.7em;
  display: grid; place-items: center;
  background: var(--accento-tenue); color: var(--accento);
}
.glyph svg { width: 1.25em; height: 1.25em; display: block; }
.head__txt { display: grid; min-width: 0; }
.head__title { font-weight: 640; font-size: 1.02em; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head__sub { color: var(--grigio); font-size: 0.78em; margin-top: 0.1em; }
.state {
  position: relative; overflow: hidden;
  height: 1.7em; padding: 0 0.7em; border-radius: 999px;
  border: 1px solid var(--linea); background: #fff;
  font-size: 0.74em; font-weight: 560; color: var(--grigio);
  display: grid; place-items: center;
}
.state.is-on { color: var(--accento); border-color: #f6cfc1; background: var(--accento-tenue); }
.state__in { display: block; line-height: 1; white-space: nowrap; }

/* ---- rows ---- */
.row { display: grid; grid-template-columns: 4.4em minmax(0, 1fr); align-items: center; gap: 0.6em; }
.label { font-size: 0.78em; color: var(--grigio); font-weight: 520; }

/* segmented control */
.seg {
  position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--campo); border-radius: 0.75em; padding: 0.2em;
}
.seg__pill {
  position: absolute; top: 0.2em; bottom: 0.2em; left: 0; width: 0;
  background: #fff; border-radius: 0.58em;
  box-shadow: 0 1px 1px rgba(20,20,26,0.06), 0 2px 6px rgba(20,20,26,0.08);
  pointer-events: none;
}
.seg__opt {
  position: relative; z-index: 1; height: 2.1em; border-radius: 0.58em;
  font-size: 0.82em; font-weight: 540; color: var(--grigio);
  display: grid; place-items: center;
  transition: color 0.25s ease;
}
.seg__opt[aria-checked="true"] { color: var(--inchiostro); }
.seg__opt span { display: block; line-height: 1; }

/* detail: days or a note, same height, crossfaded */
.row--detail { min-height: 2.4em; }
.detail { position: relative; height: 2.4em; }
.days {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.32em; align-items: center;
}
.day {
  width: 100%; max-width: 2.25em; aspect-ratio: 1; justify-self: center;
  border-radius: 50%; border: 1px solid var(--linea); background: #fff;
  display: grid; place-items: center; color: var(--grigio);
  font-size: 0.8em; font-weight: 600;
  transition: border-color 0.25s ease;
}
.day span { display: block; line-height: 1; }
.day[aria-pressed="true"] { background: var(--accento); border-color: var(--accento); color: #fff; }
.days.is-all .day { background: var(--campo); border-color: var(--campo); color: var(--inchiostro); }
.note {
  position: absolute; inset: 0; display: flex; align-items: center;
  font-size: 0.86em; color: var(--inchiostro); opacity: 0; pointer-events: none;
}

/* time */
.time { display: flex; align-items: center; gap: 0.45em; min-width: 0; }
.step {
  width: 2em; height: 2em; border-radius: 50%;
  border: 1px solid var(--linea); background: #fff; color: var(--inchiostro);
  display: grid; place-items: center; flex: none;
}
.step svg { width: 0.8em; height: 0.8em; display: block; }
.clock {
  display: inline-flex; font-size: 1.32em; font-weight: 620; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; height: 1.2em; line-height: 1.2em;
  min-width: 3.2em; justify-content: center;
}
.ch { position: relative; display: inline-block; height: 1.2em; overflow: hidden; }
.ch > span { display: block; }
.ch > span + span { position: absolute; left: 0; top: 0; }
.tz { margin-left: auto; font-size: 0.74em; color: var(--tenue); white-space: nowrap; }

/* next runs */
.runs { display: grid; gap: 0.45em; padding-top: 0.15em; border-top: 1px solid var(--linea); padding-top: 0.85em; }
.runs__list { list-style: none; display: grid; gap: 0.3em; }
.run {
  display: grid; grid-template-columns: minmax(0, 1fr); align-items: center;
  font-size: 0.88em;
}
.run__mask { position: relative; display: block; height: 1.45em; overflow: hidden; }
.run__in { display: block; line-height: 1.45em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.run__in + .run__in { position: absolute; left: 0; top: 0; }
.run__in b { font-weight: 600; }
.run__in i { font-style: normal; color: var(--grigio); }

/* save */
.save {
  position: relative; overflow: hidden;
  height: 2.9em; border-radius: 0.85em;
  background: var(--inchiostro); color: #fff;
  font-weight: 600; font-size: 0.92em;
  box-shadow: 0 1px 1px rgba(20,20,26,0.12), 0 6px 14px rgba(20,20,26,0.14);
}
.save.is-done { background: var(--accento); }
.save__face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 0.45em;
  line-height: 1; opacity: 0; white-space: nowrap;
}
.save__face--a { opacity: 1; }
.save__face svg { width: 1em; height: 1em; display: block; flex: none; }
.save__bar {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: rgba(255,255,255,0.75); transform-origin: 0 50%; transform: scaleX(0);
}

@media (hover: hover) {
  .seg__opt:hover { color: var(--inchiostro); }
  .day:hover { border-color: #d8d6d1; }
  .step:hover { border-color: #d8d6d1; }
}
