/* Atkinson Hyperlegible Next (OFL-1.1, see fonts/OFL-LICENSE.txt). Self-hosted:
   the app must work offline and makes no third-party requests. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;
  /* Calm, high-contrast palette */
  --color-bg: #f6f4ef;
  --color-surface: #ffffff;
  --color-text: #1c1c1e;
  --color-text-muted: #5b5b61;
  --color-accent: #2f6fbd;
  --color-accent-text: #ffffff;
  --color-done: #2e8b57;
  --color-muted: #c9c6bf;
  --color-frame: #e9e6df;
  --color-done-soft: #e2f1e8;
  --color-accent-soft: #d3e2f4;
  --color-danger: #b3362a;

  /* Type */
  --font: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --text-base: 1.25rem;
  --text-title: clamp(2rem, 6vw, 3.5rem);
  --text-heading: 1.5rem;

  /* Touch targets: well above the 48px minimum */
  --tap-min: 4rem;
  --tap-primary: 5.5rem;

  /* Spacing and shape */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --radius: 1rem;

  /* Progress bar. Wide slots give the indicator room to travel; capped so
     a full bar (requirements + 12 steps) still fits a phone. */
  --dot: clamp(0.9rem, 3.2vw, 1.4rem);
  --slot: min(calc(var(--dot) * 2.2), calc((100vw - 2rem) / 13));
  --bar-height: calc(var(--dot) * 2.4);

  /* Motion */
  --enter-duration: 280ms;
}

/* Dark: dim, warm-neutral surfaces; accents lightened to keep contrast. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #17181b;
  --color-surface: #212328;
  --color-text: #e8e6e1;
  --color-text-muted: #a8a7a2;
  --color-accent: #4a7fbf;
  --color-accent-text: #f4f6fa;
  --color-done: #5cb987;
  --color-muted: #4b4d53;
  --color-frame: #30333a;
  --color-done-soft: #1e3328;
  --color-accent-soft: #1d2b3d;
  --color-danger: #e0776b;
}

/* Fallback before a theme is chosen: follow the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --color-bg: #17181b;
    --color-surface: #212328;
    --color-text: #e8e6e1;
    --color-text-muted: #a8a7a2;
    --color-accent: #4a7fbf;
    --color-accent-text: #f4f6fa;
    --color-done: #5cb987;
    --color-muted: #4b4d53;
    --color-frame: #30333a;
    --color-done-soft: #1e3328;
    --color-accent-soft: #1d2b3d;
  --color-danger: #e0776b;
  }
}

html,
body,
#app {
  height: 100dvh;
}

/* Banner (parent mode only) above the current screen. */
.app {
  display: grid;
  /* minmax(0, …): content can never widen the page past the viewport. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

/* Always the filling row, whether or not the banner is there. (Without
   this, with no banner the screen would land in the content-sized row.) */
.screen {
  grid-row: 2;
  min-height: 0;
}

.loading,
.home,
.walkthrough {
  height: 100%;
}

.home {
  overflow-y: auto;
}

body {
  /* Backstop for long unbroken words (e.g. a pasted URL). */
  overflow-wrap: break-word;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: var(--text-base);
}

/* ------------------------------------------------------------------------
   Controls */

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation; /* no double-tap zoom delay */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

:focus-visible {
  outline: 4px solid var(--color-accent);
  outline-offset: 3px;
}

/* Low-emphasis controls */
.wt-exit,
.wt-back,
.wt-next,
.toggle {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 var(--space-2);
  border: 2px solid var(--color-muted);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text-muted);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--tap-primary);
  min-width: 10rem;
  padding: 0 var(--space-4);
  border: 3px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-size: 1.75rem;
  font-weight: 700;
  transition: background-color 300ms, color 300ms, border-color 300ms;
}

.primary .icon {
  width: 1.75rem;
  height: 1.75rem;
}

/* "Not yet", not "broken": clearly unavailable at a glance. Hatched
   instead of a solid surface (so it can't be mistaken for a checklist
   row), dashed edge, and the word struck through: it isn't true yet. */
.primary:disabled {
  cursor: default;
  border-style: dashed;
  border-color: var(--color-muted);
  background: repeating-linear-gradient(
    135deg,
    transparent 0 0.6rem,
    color-mix(in srgb, var(--color-muted) 30%, transparent) 0.6rem 0.8rem);
  color: var(--color-text-muted);
}

.primary:disabled .primary-label {
  text-decoration: line-through;
  text-decoration-thickness: 3px;
}

/* Comes to life when a gate (checklist, choice) is satisfied. */
.primary.is-gated:not(:disabled) {
  animation: wake 450ms ease-out;
}

@keyframes wake {
  50% { transform: scale(1.06); }
}

/* ------------------------------------------------------------------------
   Home */

.home {
  /* Extra bottom room so the last item can scroll clear of the undo toast. */
  padding: var(--space-3) var(--space-3) 6rem;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.home-title {
  font-size: 2rem;
}

/* The hidden parent-mode gesture: no selection or callout while held. */
.long-press {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Two-option toggles (theme, one step / all steps): both options shown,
   the active one highlighted. */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.toggle-option {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  color: var(--color-muted);
  transition: color 300ms, background-color 300ms;
}

.toggle-option.is-active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.toggle-option .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.toggle-slash {
  color: var(--color-muted);
  font-size: 1.5rem;
}

.group + .group {
  margin-top: var(--space-4);
}

.group-name {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: var(--space-2);
  font-size: var(--text-heading);
}

/* Same color and size as the heading text. */
.checkmark {
  flex: none;
  width: 1em;
  height: 1em;
}

.sequence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-1);
  padding: 0;
  list-style: none;
}

/* Compact row: title, and a dot per step underneath. */
.sequence-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.75rem var(--space-2);
  border: 1px solid var(--color-frame);
  border-radius: 0.75rem;
  background: var(--color-surface);
  text-align: start;
}

.sequence-card-text {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

/* Done today: a green edge and check; the dots are all filled. */
.sequence-card.is-done {
  border-color: var(--color-done);
  background: var(--color-done-soft);
}

.sequence-card-check {
  flex: none;
  color: var(--color-done);
}

.sequence-card-check .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.sequence-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.mini-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.mini-dots i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-muted);
}

.mini-dots i.is-done {
  background: var(--color-done);
}

/* Link steps: a longer pill, echoing the progress-bar marker. */
.mini-dots i.is-link {
  width: 1rem;
  border-radius: 0.25rem;
}

.card .mini-dots {
  justify-content: center;
  gap: 0.5rem;
}

.card .mini-dots i {
  width: 0.9rem;
  height: 0.9rem;
}

.card .mini-dots i.is-link {
  width: 1.8rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------------
   Parent mode */

/* Progress dots as jump buttons (parent preview). */
.marker.is-selectable {
  padding: 0;
  border: none;
  border-radius: 0.5rem;
  background: none;
}

/* ------------------------------------------------------------------------
   Sequence list in parent mode */

.group-header {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.group-name-input {
  flex: 1;
  min-width: 0;
  font-size: var(--text-heading);
  font-weight: 700;
}

.group-actions {
  display: flex;
  flex: none;
}

.sequence-card.is-not-today {
  opacity: 0.55;
}

.sequence-card-days {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.new-sequence,
.new-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: 100%;
  min-height: var(--tap-min);
  border: 2px dashed var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text-muted);
  font-weight: 700;
}

.new-group {
  margin-top: var(--space-4);
}

.new-sequence .icon,
.new-group .icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Settings popover (gear in the parent banner). The same pattern as
   brainboard's settings panel. */

/* Anchored to the banner (not the gear, which isn't at the edge), so the
   popover always opens fully on screen, under the banner's right side. */
.settings-panel {
  position: static;
}

.select-row {
  display: flex;
  justify-content: flex-end;
  margin: calc(var(--space-1) * -1) 0 var(--space-3);
}

/* Icon buttons in the parent banner (Pictures, …), beside Settings. */
.banner-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-text);
}

.banner-button[aria-pressed="true"],
.banner-button:hover {
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
}

.banner-button .icon {
  width: 1.6rem;
  height: 1.6rem;
}

.settings-body > .settings-section:first-child {
  padding-top: 0;
  border-top: none;
}

.settings-toggle {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-text);
}

.settings-toggle[aria-expanded="true"],
.settings-toggle:hover {
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
}

.settings-toggle .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.settings-body {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: var(--space-1);
  z-index: 15;
  display: grid;
  gap: var(--space-2);
  width: min(20rem, calc(100vw - 2rem));
  padding: var(--space-2);
  border: 2px solid var(--color-frame);
  border-radius: 0.75rem;
  background: var(--color-surface);
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.25);
  font-size: 1rem;
}

.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
}

.settings-section {
  display: grid;
  gap: 0.4rem;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-frame);
}

.settings-label {
  font-weight: 700;
}

.backup-status {
  color: var(--color-text-muted);
}

.backup-status.is-stale {
  color: var(--color-text);
  font-weight: 700;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.settings-button {
  min-height: 2.75rem;
  padding: 0 var(--space-2);
  border: 2px solid var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text);
  font-weight: 700;
}

.settings-hint {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.settings-version {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: end;
}

/* Selecting sequences to share */

.select-toggle {
  min-height: 2.75rem;
  padding: 0 var(--space-2);
  border: 2px solid var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 700;
}

.sequence-card.is-selected {
  border: 2px solid var(--color-accent);
  background: var(--color-accent-soft);
}

.select-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--color-muted);
  border-radius: 50%;
}

.select-mark.is-on {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-size: 1rem;
}

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: max(var(--space-2), env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(calc(100% - 2rem), 36rem);
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--color-text);
  color: var(--color-bg);
  transform: translateX(-50%);
  animation: fade-in 200ms ease-out;
}

.selection-summary {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.25rem;
  font-size: 1rem;
}

.selection-count {
  font-weight: 700;
}

.selection-extras {
  font-size: 0.9rem;
  opacity: 0.85;
}

.selection-actions {
  display: flex;
  gap: var(--space-1);
}

.selection-move,
.selection-action {
  min-height: 2.75rem;
  border-radius: 0.75rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
}

.selection-move {
  flex: 1;
  min-width: 0;
  padding: 0 0.5rem;
  border: 2px solid color-mix(in srgb, var(--color-bg) 45%, transparent);
  background: transparent;
  color: var(--color-bg);
}

.selection-move option {
  color: var(--color-text);
  background: var(--color-surface);
}

.selection-action {
  padding: 0 var(--space-2);
  border: 2px solid color-mix(in srgb, var(--color-bg) 45%, transparent);
  background: none;
  color: var(--color-bg);
}

.selection-action.is-primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
}

.selection-move:disabled,
.selection-action:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Room for the taller bar under the last card while selecting. */
.home:has(.selection-bar) {
  padding-bottom: 12rem;
}

/* Merge dialog */

.merge-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 50dvh;
  overflow-y: auto;
  padding: 0;
  list-style: none;
}

.merge-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-frame);
  border-radius: 0.75rem;
}

.merge-title {
  font-weight: 700;
}

.merge-status {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Pictures */

.picture {
  display: block;
  overflow: hidden;
  background: var(--color-frame);
}

.picture img {
  display: block;
  width: 100%;
  height: 100%;
}

/* The picture takes all the card's height the text doesn't need (the text
   keeps its natural height), but never less than half of the content area,
   so a long description can't shrink it to a stamp. The area is a size
   container; the 4:3 frame fits inside it, bottom-aligned (next to its
   title), and never wider than the card or 36rem. */
.card-picture-area {
  container-type: size;
  display: flex;
  flex: 1 1 0;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  min-height: 50cqh;
}

.step-picture {
  width: min(100%, 36rem, calc(100cqh * 4 / 3));
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
}

.overview-thumb {
  flex: none;
  width: 3.5rem;
  aspect-ratio: 4 / 3;
  margin-left: auto;
  border-radius: 0.5rem;
}

.overview-row-inner .overview-thumb + .overview-go {
  margin-left: 0;
}

.picture-slot {
  align-self: flex-start;
  padding: 0;
  border: none;
  border-radius: 0.5rem;
  background: none;
}

.picture-slot-thumb {
  width: 5rem;
  aspect-ratio: 4 / 3;
  border-radius: 0.5rem;
}

.picture-dialog {
  width: min(100%, 30rem);
  max-height: 92dvh;
  overflow-y: auto;
}

.picture-preview {
  position: relative;
}

.picture-preview .step-picture {
  width: 100%;
}

.picture-preview.is-focusable {
  cursor: crosshair;
}

.focus-mark {
  position: absolute;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgb(0 0 0 / 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.picture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.picture-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr));
  gap: var(--space-1);
  max-height: 40dvh;
  overflow-y: auto;
  padding: 0;
  list-style: none;
}

.picture-choice {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-text);
  text-align: start;
}

.picture-choice-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 0.5rem;
}

.picture-choice-name {
  overflow: hidden;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sequence card picture: a thumbnail at the card's left. */
.card-thumb {
  flex: none;
  width: 4.5rem;
  aspect-ratio: 4 / 3;
  border-radius: 0.5rem;
}

.sequence-card-text {
  flex: 1;
}

/* The Pictures screen */

.library-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.library-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 var(--space-2) 0 var(--space-1);
  border: 2px solid var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 700;
}

.library-back .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.library-add {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.library-grid {
  display: grid;
  /* Two across on a phone. */
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: var(--space-2);
  padding: 0;
  list-style: none;
}

.library-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  font-size: 1rem;
  padding: var(--space-1);
  border: 1px solid var(--color-frame);
  border-radius: 0.75rem;
  background: var(--color-surface);
}

.library-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 0.5rem;
}

.library-name-input {
  font-weight: 700;
}

.library-usage {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.library-confirm,
.library-replace {
  display: grid;
  gap: var(--space-1);
  font-size: 1rem;
}

/* Things: pictures beside checklist items and choice options (step view),
   and the list editor's rows. */
.thing-thumb {
  flex: none;
  width: 4rem;
  aspect-ratio: 4 / 3;
  margin-left: auto;
  border-radius: 0.5rem;
}

.list-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-thumb {
  flex: none;
  width: 3.5rem;
  aspect-ratio: 4 / 3;
  border-radius: 0.4rem;
}

.list-add-picture {
  display: grid;
  flex: none;
  place-items: center;
  width: 3.5rem;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 2px dashed var(--color-muted);
  border-radius: 0.4rem;
  background: none;
  color: var(--color-text-muted);
}

.list-add-picture .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.list-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
}

.list-actions {
  display: flex;
  flex: none;
}

.list-actions .row-action {
  width: 2.25rem;
  height: 2.5rem;
}

.list-name-input {
  font-weight: 700;
}

.list-existing-choice {
  flex-direction: row;
  align-items: center;
  gap: var(--space-1);
}

/* The Things & lists screen */

.things-section {
  display: grid;
  gap: var(--space-2);
}

.things-section + .things-section {
  margin-top: var(--space-4);
}

.things-section .group-name {
  margin-bottom: 0;
}

/* Lists are mostly text: wider cards than the picture grid's. */
.things-section .library-grid {
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}

.thing-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.thing-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.5rem;
  border: 1px solid var(--color-frame);
  border-radius: 0.75rem;
  background: var(--color-surface);
}

.thing-text {
  display: grid;
  flex: 1;
  gap: 0.2rem;
  min-width: 0;
  font-size: 1rem;
}

/* Step timer: a ring that empties; green with a check at zero. */
.step-timer {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  /* Balances the reset button's width, so the ring stays centered. */
  padding-left: 2.75rem;
}

.timer-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(4.5rem, 12dvh, 6rem);
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-text);
}

.timer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* empties from the top, clockwise */
}

.timer-track {
  fill: none;
  stroke: var(--color-frame);
  stroke-width: 8;
}

.timer-fill {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 250ms linear, stroke 300ms;
}

.is-idle .timer-fill { stroke: var(--color-muted); }
.is-paused .timer-fill { stroke: var(--color-text-muted); }
.is-done .timer-fill { stroke: var(--color-done); }

.timer-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.timer-center .icon {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--color-accent);
}

.timer-time {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.timer-paused {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.is-done .timer-center {
  color: var(--color-done);
  font-size: 2rem;
}

/* One gentle pulse at zero (none with reduced motion, see below). */
.is-done .timer-ring {
  animation: timer-done 900ms ease-out;
}

@keyframes timer-done {
  40% { transform: scale(1.08); }
}

.timer-reset {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 2px solid var(--color-muted);
  border-radius: 50%;
  background: none;
  color: var(--color-text-muted);
}

.timer-reset .icon {
  width: 1.3rem;
  height: 1.3rem;
}

/* Editor: a step's timer length */
.timer-select {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.timer-select {
  flex-wrap: wrap;
}

.timer-required {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.timer-select select {
  min-height: 2.25rem;
  padding: 0 0.4rem;
  border: 1px solid var(--color-muted);
  border-radius: 0.5rem;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

/* Confirmation dialogs */

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: var(--space-2);
  background: rgb(0 0 0 / 0.45);
  animation: fade-in 150ms ease-out;
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(100%, 26rem);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 1.05rem;
}

.dialog-title {
  font-size: var(--text-heading);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

.dialog-button {
  min-height: 3rem;
  padding: 0 var(--space-2);
  border: 2px solid var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text);
  font-weight: 700;
}

.dialog-button.is-primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
}

.dialog-button.is-danger {
  border-color: var(--color-danger);
  background: var(--color-danger);
  color: var(--color-surface);
}

/* The editor's "Sequence" section, below the steps */

.sequence-settings {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-1) var(--space-4);
  border-top: 1px solid var(--color-frame);
}

.settings-heading {
  font-size: var(--text-heading);
}

.setting {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.setting-label {
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 700;
}

.setting-select {
  min-height: 3rem;
  min-width: 12rem;
  padding: 0 var(--space-1);
  border: 2px solid var(--color-muted);
  border-radius: 0.75rem;
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.setting-note {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  min-height: 2.75rem;
  padding: 0 var(--space-2);
  border: 2px solid var(--color-muted);
  border-radius: 999px;
  background: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 700;
}

.chip.day {
  min-width: 3.25rem;
  padding: 0 0.5rem;
}

.chip[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 3rem;
  padding: 0 var(--space-2);
  border: 2px solid var(--color-danger);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-danger);
  font-weight: 700;
}

.danger-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.danger-button .icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* ------------------------------------------------------------------------
   Editor (the overview in parent mode) */

.text-field {
  width: 100%;
  padding: 0.1rem 0;
  border: none;
  border-bottom: 2px dashed var(--color-frame);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.text-field:focus {
  outline: none;
  border-bottom: 2px solid var(--color-accent);
}

.overview-title-input {
  font-weight: 700;
  line-height: 1.2;
  resize: none;
  field-sizing: content;
}

.overview-description-input {
  min-height: 1.5em;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.35;
  resize: none;
  field-sizing: content;
}

/* Sized to its text where supported, so it still reads as a heading. */
.sequence-title-input {
  min-width: 6ch;
  text-align: center;
  font-weight: 700;
  field-sizing: content;
}

.overview.is-editing .overview-row-inner {
  gap: var(--space-1);
  padding-left: 0;
  padding-right: 0.25rem;
}

.overview.is-editing .overview-text {
  flex: 1;
  gap: 0.2rem;
}

.add-description {
  align-self: flex-start;
  padding: 0.2rem 0;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.drag-handle,
.drag-spacer {
  flex: none;
  width: 2.5rem;
  height: 3rem;
}

.drag-handle {
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 0.5rem;
  background: none;
  color: var(--color-text-muted);
  cursor: grab;
  touch-action: none; /* the handle drags; it must not scroll the list */
}

.drag-handle .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.overview.is-sorting {
  user-select: none;
}

.overview.is-sorting .drag-handle {
  cursor: grabbing;
}

/* Rows make way smoothly while another is dragged (only while sorting, so
   the drop itself snaps into place). */
.overview.is-sorting .overview-row:not(.is-dragging) {
  transition: transform 180ms ease;
}

.overview-row.is-dragging {
  position: relative;
  z-index: 2;
  background: var(--color-surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}

.row-actions {
  display: flex;
  flex: none;
  margin-left: auto;
}

.row-action {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-text-muted);
}

.row-action.is-go {
  color: var(--color-accent);
}

.row-action:disabled {
  opacity: 0.35;
  cursor: default;
}

.row-action .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.overview-add {
  margin-top: var(--space-1);
}

.add-row {
  display: flex;
  gap: var(--space-1);
}

.add-row > .add-step {
  flex: 1;
}

/* Smaller, icon-only: linking is the less common way to add a step. */
.add-link {
  display: grid;
  flex: none;
  place-items: center;
  width: 3.5rem;
  min-height: 3.5rem;
  border: 2px dashed var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text-muted);
}

.add-link[aria-expanded="true"] {
  border-style: solid;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.add-link .icon {
  width: 1.4rem;
  height: 1.4rem;
}

.link-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-1);
  padding: var(--space-2);
  border: 2px solid var(--color-frame);
  border-radius: 0.75rem;
  background: var(--color-surface);
}

.link-picker-title {
  font-weight: 700;
}

.link-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.link-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.5rem var(--space-2);
  border: 1px solid var(--color-frame);
  border-radius: 0.75rem;
  background: var(--color-bg);
  text-align: start;
}

.link-choice-title {
  font-weight: 700;
}

.link-picker-cancel {
  align-self: flex-end;
  min-height: 2.75rem;
  padding: 0 var(--space-2);
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-weight: 700;
}

.undo-count {
  color: color-mix(in srgb, var(--color-bg) 70%, transparent);
}

.add-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: 100%;
  min-height: 3.5rem;
  border: 2px dashed var(--color-muted);
  border-radius: 0.75rem;
  background: none;
  color: var(--color-text-muted);
  font-weight: 700;
}

.add-step .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.add-step-full {
  padding: var(--space-1);
  color: var(--color-text-muted);
  font-size: 1rem;
  text-align: center;
}

.undo-toast {
  position: fixed;
  left: 50%;
  bottom: max(var(--space-2), env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.4rem 0.4rem 1.25rem;
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-bg);
  transform: translateX(-50%);
  animation: fade-in 200ms ease-out;
}

.undo-toast > span {
  white-space: nowrap;
}

.undo-button {
  min-height: 2.75rem;
  padding: 0 var(--space-2);
  border: none;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-weight: 700;
}

.parent-banner {
  grid-row: 1;
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.4rem var(--space-2);
  font-size: 1rem;
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.parent-banner-label {
  margin-right: auto;
  font-weight: 700;
  white-space: nowrap;
}

.parent-banner .toggle {
  min-height: 3rem;
  padding: 0 0.6rem;
}

.parent-lock {
  min-height: 3rem;
  padding: 0 var(--space-2);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-weight: 700;
}

/* PIN pad: opaque, so the screen behind stays calm and unreadable. */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: var(--space-2);
  background: var(--color-bg);
  animation: fade-in 200ms ease-out;
}

.pin-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  width: min(100%, 20rem);
}

.pin-title {
  font-size: var(--text-heading);
}

.pin-prompt {
  color: var(--color-text-muted);
  text-align: center;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  height: 1rem;
  margin-top: var(--space-1);
}

.pin-dots i {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--color-text);
}

.pin-message {
  min-height: 1.5em;
  color: var(--color-text-muted);
  font-size: 1rem;
  text-align: center;
}

.pin-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
  width: 100%;
}

.pin-key {
  display: grid;
  place-items: center;
  height: 4rem;
  border: 2px solid var(--color-frame);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 1.5rem;
  font-weight: 700;
}

.pin-key.is-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1rem;
}

.pin-key .icon {
  width: 1.75rem;
  height: 1.75rem;
}

.pin-ok {
  width: 100%;
  margin-top: var(--space-1);
}

/* Dev builds only */
.dev-tools {
  margin-top: var(--space-4);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-muted);
}

.dev-button {
  padding: var(--space-1) var(--space-2);
  border: 1px dashed var(--color-muted);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------------------
   Walkthrough

     Exit
           card (title, description, options)
           Done
     Back      3 of 7 / dots      Next: …

   Only the card content changes between steps. */

.walkthrough {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-2);
  padding: max(var(--space-2), env(safe-area-inset-top))
           max(var(--space-2), env(safe-area-inset-right))
           max(var(--space-2), env(safe-area-inset-bottom))
           max(var(--space-2), env(safe-area-inset-left));
  overflow: hidden;
}

/* Exit | sequence title | view toggle. Equal side columns center the
   title in the viewport; a side column only grows past that (min
   max-content) when a long title needs the room, so nothing collides.
   On phones the title takes its own full-width row, still centered. */
.wt-header {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  grid-template-areas: "exit title toggle";
  align-items: center;
  gap: var(--space-2);
}

@media (max-width: 40rem) {
  .wt-header {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "exit  toggle"
      "title title";
    row-gap: var(--space-1);
  }
}

.wt-exit {
  grid-area: exit;
  justify-self: start;
}

.wt-header-title {
  grid-area: title;
  min-width: 0;
}

.sequence-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  text-align: center;
}

/* max-content: the view-transition snapshot hugs the text, so the small
   (header) and large (overview) versions keep the same shape and scale
   cleanly into each other. */
.sequence-heading-title {
  width: max-content;
  max-width: 100%;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text-muted);
}

.sequence-heading-context {
  width: max-content;
  max-width: 100%;
  font-size: 0.875rem;
  line-height: 1.2;
  color: var(--color-text-muted);
}

/* As the overview's heading */
.wt-overview > .sequence-heading {
  flex: none;
  margin-bottom: var(--space-3);
}

.wt-overview .sequence-heading-title {
  font-size: 1.75rem;
  color: var(--color-text);
}

.wt-overview .sequence-heading-context {
  font-size: 1rem;
}

.view-toggle {
  grid-area: toggle;
  justify-self: end;
}

/* ------------------------------------------------------------------------
   Overview */

.walkthrough.is-overview {
  grid-template-rows: auto minmax(0, 1fr);
}

/* Heading and list are centered together while the list fits; when it
   doesn't, the list shrinks to the space left and scrolls on its own, and
   the heading stays put. */
.wt-overview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  min-height: 0;
}

.overview-scroll {
  flex: 0 1 auto;
  width: min(100%, 34rem);
  min-height: 0;
  overflow-y: auto;
}

.overview {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0;
  list-style: none;
}

.overview-row {
  border-radius: 0.75rem;
}

.overview-row-inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 3.5rem;
  padding: 0.25rem var(--space-2) 0.25rem var(--space-1);
  border: none;
  border-radius: inherit;
  background: none;
  text-align: start;
}

/* The current row's "go to this step" hint. */
.overview-go {
  display: grid;
  margin-left: auto;
  color: var(--color-accent);
}

.overview-go .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.overview-row.is-current {
  background: var(--color-accent-soft);
}

.overview-marker {
  position: relative;
  flex: none;
}

.overview-indicator {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.35rem;
  display: grid;
  place-items: center;
}

.overview-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.overview-title {
  font-weight: 700;
  line-height: 1.2;
}

.overview-description {
  margin-top: 0.15rem;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.35;
}

.overview-detail {
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* Shared elements (markers, indicator, title) glide between bar and
   list: unhurried, easing in and out. The rest of the page (root) just
   cross-fades, and more quickly, so the moving pieces lead. */
::view-transition-group(*) {
  animation-duration: 950ms;
  animation-timing-function: cubic-bezier(0.45, 0, 0.25, 1);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 450ms;
}

/* Content grows upward from the primary button, which sits at a fixed
   distance above the footer and so never moves. */
/* The primary button sits at the bottom of this area, which has the same
   height on every step, so the button never moves; everything above it is
   the card's. */
.wt-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: var(--space-2);
  min-height: 0;
}

.wt-content {
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* margin-top:auto (not justify-content:flex-end) keeps overflowing
   content scrollable from its top. */
/* The card fills the content area, its content bottom-aligned (just above
   the button). min-height, not height: if content ever overflows, the card
   grows and the area scrolls from its top. */
.wt-content > .card {
  flex: none; /* never squeezed: overflow must scroll from the top, not spill off it */
  min-height: 100%;
  justify-content: flex-end;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.75rem, 2.5dvh, 1.5rem);
  width: min(100%, 48rem);
  /* Vertical padding contains large glyphs that overflow their line box,
     which would otherwise make the content area scrollable. */
  padding: var(--space-1) var(--space-2);
  text-align: center;
}

.card.enter-forward { animation: enter-from-right var(--enter-duration) ease-out; }
.card.enter-back    { animation: enter-from-left var(--enter-duration) ease-out; }

@keyframes enter-from-right {
  from { opacity: 0; transform: translateX(3rem); }
}

@keyframes enter-from-left {
  from { opacity: 0; transform: translateX(-3rem); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

.card-title {
  font-size: var(--text-title);
  line-height: 1.15;
  text-wrap: balance;
}

.card-description {
  max-width: 32ch;
  /* Smaller on phones, so the picture keeps its presence. */
  font-size: clamp(1.05rem, 4.2vw, 1.5rem);
  line-height: 1.35;
  color: var(--color-text-muted);
  text-wrap: pretty;
}

.finished-title {
  font-size: clamp(3rem, 10vw, 5.5rem);
  color: var(--color-done);
}

/* Which sequence was finished, above "All done!" */
.finished-sequence {
  margin-bottom: calc(var(--space-3) * -1);
  color: var(--color-text-muted);
  font-size: 1.5rem;
  font-weight: 700;
}

/* A check-circle that draws itself in: circle, then check. */
/* The sequence's picture on the finished screen, with the check as a
   stamp on its corner. */
.finished-picture {
  position: relative;
  /* Exactly the step picture frame's size, so the stamp sits on its corner. */
  width: min(100%, 36rem, calc(100cqh * 4 / 3));
  aspect-ratio: 4 / 3;
}

.finished-picture .step-picture {
  width: 100%;
}

.finished-stamp {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-bg);
  transform: translate(25%, 25%);
}

.finished-stamp .finished-mark {
  width: clamp(3.5rem, 10vw, 5rem);
  height: clamp(3.5rem, 10vw, 5rem);
}

/* Pictures in the step view answer a tap (see picture/soft-bounce!). */
.picture.is-bouncy {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.finished-mark {
  width: clamp(4rem, 12vw, 6rem);
  height: clamp(4rem, 12vw, 6rem);
  fill: none;
  stroke: var(--color-done);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.finished-mark-circle {
  stroke-width: 4;
  stroke-dasharray: 176;
  animation: draw-circle 700ms ease-out both;
  transform: rotate(-90deg);
  transform-origin: center;
}

.finished-mark-check {
  stroke-width: 5;
  stroke-dasharray: 36;
  animation: draw-check 450ms ease-out 600ms both;
}

@keyframes draw-circle {
  from { stroke-dashoffset: 176; }
  to   { stroke-dashoffset: 0; }
}

@keyframes draw-check {
  from { stroke-dashoffset: 36; }
  to   { stroke-dashoffset: 0; }
}

/* Footer: Back | position | Next. On narrow screens the dots get their
   own row so all 12 fit. */
.wt-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "back progress next";
  align-items: end;
  gap: var(--space-2);
}

@media (max-width: 40rem) {
  .wt-footer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "progress progress"
      "back     next";
  }
}

.wt-back     { grid-area: back; justify-self: start; }
.wt-progress { grid-area: progress; }
.up-next,
.wt-next     { grid-area: next; justify-self: end; }

/* Back and Next are a matching pair of neutral page turns. */
.wt-back,
.wt-next {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.wt-back .icon,
.wt-next .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.wt-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.wt-position {
  color: var(--color-text-muted);
  font-weight: 700;
}

/* Exactly the height of the Back button, whether the title takes one line
   or two, so the footer (and everything above it) never shifts. */
.up-next {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  max-width: 14rem;
  height: var(--tap-min);
  overflow: hidden;
  color: var(--color-text-muted);
  text-align: end;
}

.up-next-label {
  font-size: 0.875rem;
  line-height: 1.1;
}

.up-next-title {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.up-next.is-finish .up-next-title {
  color: var(--color-done);
}

/* ------------------------------------------------------------------------
   Progress dots: filled = done, hollow = future. The current position is
   a line underneath that slides between equal-width slots. */

.progress {
  position: relative;
  width: max-content;
  padding-bottom: 0.75rem; /* room for the indicator */
}

.progress-markers {
  display: flex;
  padding: 0;
  list-style: none;
}

.marker {
  display: grid;
  place-items: center;
  width: var(--slot);
  height: var(--bar-height);
}

.dot {
  display: block;
  width: var(--dot);
  height: var(--dot);
  border: 3px solid var(--color-muted);
  border-radius: 50%;
  background: transparent;
  transition: background-color 300ms, border-color 300ms;
}

.marker.is-done > .dot {
  border-color: var(--color-done);
  background: var(--color-done);
}

/* Requirements: a box that gets a checkmark drawn in when passed. */
.req-marker {
  width: calc(var(--dot) * 1.1);
  height: calc(var(--dot) * 1.1);
  overflow: visible;
}

.req-marker rect {
  fill: transparent;
  stroke: var(--color-muted);
  stroke-width: 2.5;
  transition: fill 300ms, stroke 300ms;
}

.req-check {
  fill: none;
  stroke: var(--color-bg);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 14;
  stroke-dashoffset: 14;
  transition: stroke-dashoffset 450ms ease-out 200ms;
}

.marker.is-done .req-marker rect {
  fill: var(--color-done);
  stroke: var(--color-done);
}

.marker.is-done .req-check {
  stroke-dashoffset: 0;
}

/* Link: a pill holding a little sequence. */
.dot-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: calc(var(--dot) * 1.7);
  height: var(--dot);
  border: 3px solid var(--color-muted);
  border-radius: var(--dot);
  transition: background-color 300ms, border-color 300ms;
}

.dot-link i {
  width: calc(var(--dot) * 0.2);
  height: calc(var(--dot) * 0.2);
  border-radius: 50%;
  background: var(--color-muted);
}

.marker.is-done > .dot-link {
  border-color: var(--color-done);
  background: var(--color-done);
}

.marker.is-done > .dot-link i {
  background: var(--color-bg);
}

/* Choice: a stack of small dots, one per option, in list order. */
.dot-stack {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 2px;
  max-height: var(--bar-height);
}

.dot-option {
  width: calc(var(--dot) * 0.55);
  height: calc(var(--dot) * 0.55);
  border-width: 2px;
}

.dot-option.is-chosen {
  border-color: var(--color-done);
  background: var(--color-done);
}

.dot-option.is-muted {
  border-color: var(--color-muted);
  background: var(--color-muted);
}

/* The current-position line. */
.progress-indicator {
  --travel: 800ms;
  position: absolute;
  left: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: var(--slot);
  height: 0.75rem;
  transform: translateX(calc(var(--i) * var(--slot)));
  transition: transform var(--travel) cubic-bezier(0.4, 0, 0.2, 1),
              width var(--travel) cubic-bezier(0.4, 0, 0.2, 1),
              opacity 300ms;
}

.progress-indicator.is-hidden {
  opacity: 0;
}

.indicator-shape {
  position: relative;
  width: var(--dot);
  height: 4px;
  border-radius: 2px;
  background: var(--color-accent);
}

/* Arrowheads at the leading end: right when moving forward, left when
   moving back. */
.indicator-shape::before,
.indicator-shape::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  border: solid var(--color-accent);
  border-width: 4px 4px 0 0;
  border-radius: 1px;
  opacity: 0;
  transform: translateY(-50%) rotate(45deg);
}

.indicator-shape::before {
  right: auto;
  left: 0;
  border-width: 0 0 4px 4px;
}

.indicator-shape.go-forward,
.indicator-shape.go-back {
  animation: indicator-stretch 1000ms ease-in-out;
}

.indicator-shape.go-forward::after,
.indicator-shape.go-back::before {
  animation: indicator-arrow 1000ms ease-in-out;
}

@keyframes indicator-stretch {
  15%, 70% { width: calc(var(--dot) * 1.6); }
}

@keyframes indicator-arrow {
  15%, 70% { opacity: 1; }
}

/* Complete: the line grows to underline the whole bar, like the rule
   under a finished sum, and turns done-green. */
.progress-indicator.is-complete {
  width: calc(var(--n) * var(--slot));
  transform: translateX(0);
}

.indicator-shape.go-complete {
  width: calc(100% - var(--slot) + var(--dot));
  background: var(--color-done);
  animation: indicator-complete 900ms ease-out;
}

@keyframes indicator-complete {
  from { background: var(--color-accent); }
}

/* ------------------------------------------------------------------------
   Requirements checklist */

.checklist {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: min(100%, 28rem);
  padding: 0;
  list-style: none;
}

.check-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--color-frame);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 1.5rem;
  text-align: start;
  transition: background-color 200ms, border-color 200ms;
}

.check-box {
  position: relative;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid var(--color-muted);
  border-radius: 0.5rem;
  transition: background-color 200ms, border-color 200ms;
}

.check-item[aria-checked="true"] {
  border-color: var(--color-done);
  background: var(--color-done-soft);
}

.check-item[aria-checked="true"] .check-box {
  border-color: var(--color-done);
  background: var(--color-done);
}

/* Checkmark */
.check-item[aria-checked="true"] .check-box::after {
  content: "";
  position: absolute;
  left: 30%;
  top: 10%;
  width: 30%;
  height: 60%;
  border: solid var(--color-surface);
  border-width: 0 4px 4px 0;
  transform: rotate(45deg);
}

/* ------------------------------------------------------------------------
   Choice step */

.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: min(100%, 28rem);
  padding: 0;
  list-style: none;
}

/* Echoes the checklist rows, with a dot (as in the progress bar's choice
   stack) where the checklist has a box. */
.choice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--color-frame);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 1.5rem;
  text-align: start;
  transition: background-color 200ms, border-color 200ms;
}

.choice-dot {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--color-muted);
  border-radius: 50%;
  transition: background-color 200ms, border-color 200ms;
}

.choice[aria-pressed="true"] {
  border-color: var(--color-done);
  background: var(--color-done-soft);
}

.choice[aria-pressed="true"] .choice-dot {
  border-color: var(--color-done);
  background: var(--color-done);
}

/* ------------------------------------------------------------------------
   Reduced motion: no sliding or bouncing, just fades. */

@media (prefers-reduced-motion: reduce) {
  .card.enter-forward,
  .card.enter-back {
    animation-name: fade-in;
  }

  .primary.is-gated:not(:disabled),
  .indicator-shape.go-forward,
  .indicator-shape.go-forward::after,
  .indicator-shape.go-back,
  .indicator-shape.go-back::before,
  .finished-mark-circle,
  .finished-mark-check,
  .is-done .timer-ring,
  .indicator-shape.go-complete {
    animation: none;
  }

  .progress-indicator {
    transition: opacity 300ms;
  }

  .req-check {
    transition: none;
  }
}
