:root {
  --bg:        oklch(0.985 0.006 150);
  --surface:   #ffffff;
  --surface-2: oklch(0.975 0.006 155);
  --ink:       oklch(0.28 0.013 175);
  --muted:     oklch(0.55 0.012 175);
  --faint:     oklch(0.70 0.010 175);
  --line:      oklch(0.918 0.006 160);
  --line-soft: oklch(0.95 0.005 160);
  --sage:      oklch(0.60 0.050 158);
  --sage-deep: oklch(0.46 0.055 160);
  --sage-soft: oklch(0.955 0.022 158);
  --sage-line: oklch(0.86 0.035 158);
  --warn:      oklch(0.55 0.135 42);
  --warn-ink:  oklch(0.42 0.115 40);
  --warn-soft: oklch(0.965 0.028 55);
  --warn-line: oklch(0.85 0.075 48);
  --shadow:    0 1px 2px oklch(0.5 0.02 160 / 0.04), 0 8px 24px oklch(0.5 0.02 160 / 0.06);
  --shadow-sm: 0 1px 2px oklch(0.5 0.02 160 / 0.05);
  --r:   18px;
  --r-sm: 12px;
  --maxw: 600px;
  --font: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "Space Mono", ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
#root { min-height: 100%; }

/* ====== App shell ====== */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}
@media (min-width: 640px) {
  body { padding: 0; }
  .shell {
    border-left: 1px solid var(--line-soft);
    border-right: 1px solid var(--line-soft);
    box-shadow: 0 0 80px oklch(0.5 0.02 160 / 0.05);
  }
}

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 130px;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .scroll { padding: 0 32px 130px; } }

/* ====== Header ====== */
.topbar {
  padding: calc(34px + env(safe-area-inset-top)) 0 6px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sage-deep);
  font-weight: 600;
}
.greeting {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(30px, 8vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin-top: 6px;
}
.greeting .day {
  font-style: italic;
}
.subdate {
  color: var(--muted);
  font-size: 14.5px;
  margin-top: 7px;
}

/* ====== Segmented AM/PM ====== */
.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-top: 22px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: color .2s, background .2s, box-shadow .2s;
}
.seg button .glyph { font-size: 13px; opacity: .8; display: flex; }
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.seg button[aria-pressed="true"] .glyph { opacity: 1; }

/* ====== Progress summary ====== */
.summary {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-top: 18px;
  box-shadow: var(--shadow-sm);
}
.ring { flex: 0 0 auto; }
.summary .meta { flex: 1; min-width: 0; }
.summary .meta h3 {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.summary .meta p {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 2px;
}
.summary .reset {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.summary .reset:hover { background: var(--surface-2); color: var(--ink); }
.summary .reset[hidden] { display: none; }

/* ====== Warning banner ====== */
.warn {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  margin-top: 14px;
}
.warn .bang {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.warn p { font-size: 13.5px; color: var(--warn-ink); line-height: 1.4; }
.warn p strong { font-weight: 700; }
.warn.info { background: var(--sage-soft); border-color: var(--sage-line); }
.warn.info .bang { background: var(--sage-deep); }
.warn.info p { color: var(--sage-deep); }

/* ====== Group section ====== */
.group { margin-top: 26px; }
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 11px;
  padding: 0 2px;
}
.group-head h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink);
}
.group-head .count {
  font-size: 12.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.steps {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ====== Step row ====== */
.step {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
  position: relative;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
  /* rendered as a <button> for keyboard + VoiceOver support */
  width: 100%;
  text-align: left;
  font-family: var(--font);
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  border-left: 0; border-right: 0; border-bottom: 0;
}
/* the row's spans must be blocks for the ellipsis truncation to apply */
.step .body > .name, .step .body > .sub { display: block; }
.step:first-child { border-top: 0; }
.step:hover { background: var(--surface-2); }

.check {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: border-color .2s, background .2s, transform .2s;
}
.check svg { width: 13px; height: 13px; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .25s cubic-bezier(.34,1.56,.64,1); }
.step.done .check { background: var(--sage); border-color: var(--sage); }
.step.done .check svg { opacity: 1; transform: scale(1); stroke: #fff; }

.chip {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 7px;
  min-width: 38px;
  text-align: center;
  transition: opacity .2s;
}
.chip.gl { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }

.step .body { flex: 1; min-width: 0; }
.step .name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .2s;
}
.step .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step .sub .tag {
  color: var(--faint);
}
.step.done .name { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line); }
.step.done .chip { opacity: .55; }
.step.done { background: var(--surface-2); }

.step .ord {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  width: 16px;
  text-align: right;
}

/* note pill inside step */
.notepill {
  font-size: 11px;
  color: var(--sage-deep);
  background: var(--sage-soft);
  border: 1px solid var(--sage-line);
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
  white-space: nowrap;
}

/* reapply info card */
.infocard {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  border: 1px dashed var(--sage-line);
  background: var(--sage-soft);
  border-radius: var(--r-sm);
  padding: 13px 15px;
}
.infocard .ic {
  flex: 0 0 auto; width: 34px; height: 34px;
  border-radius: 9px; background: var(--surface);
  border: 1px solid var(--sage-line);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--sage-deep);
  text-align: center; line-height: 1.1;
}
.infocard .txt h4 { font-size: 13.5px; font-weight: 700; color: var(--sage-deep); }
.infocard .txt p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

/* ====== Done celebration ====== */
.alldone {
  margin-top: 14px;
  text-align: center;
  padding: 18px;
  border-radius: var(--r-sm);
  background: var(--sage-soft);
  border: 1px solid var(--sage-line);
  color: var(--sage-deep);
  font-size: 14px;
  font-weight: 600;
}
.alldone[hidden] { display: none; }

/* ====== Section heading for reference pages ====== */
.pagehead { padding: calc(34px + env(safe-area-inset-top)) 0 4px; }
.pagehead.tight { padding-top: 30px; }
.pagehead h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(28px, 7vw, 34px);
  letter-spacing: -0.01em;
}
.pagehead p { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ====== Week list ====== */
.weekrow {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}
.weekrow.today { border-color: var(--sage-line); box-shadow: 0 0 0 1px var(--sage-line), var(--shadow-sm); }
.weekrow .dname {
  flex: 0 0 auto;
  width: 44px;
}
.weekrow .dname .d { font-size: 14px; font-weight: 700; }
.weekrow .dname .t { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--sage-deep); font-weight: 700; margin-top: 1px; }
.weekrow .seq { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; }
.weekrow .seq .miniarrow { color: var(--faint); font-size: 11px; align-self: center; }
.weekrow .badge {
  flex: 0 0 auto;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--warn-ink); background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: 6px; padding: 3px 7px;
}
.weekrow .badge.std { color: var(--muted); background: var(--surface-2); border-color: var(--line); }

.minichip {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 5px;
  padding: 2px 5px;
}
.minichip.gl { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }

/* ====== Shelf ====== */
.shelfgroup { margin-top: 22px; }
.shelfgroup > h2 {
  font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink); margin-bottom: 10px; padding: 0 2px;
}
.product {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 13px 15px; margin-top: 9px;
  box-shadow: var(--shadow-sm);
}
.product .pchip {
  flex: 0 0 auto; min-width: 46px; text-align: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 6px;
}
.product .pbody { flex: 1; min-width: 0; }
.product .pname { font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; }
.product .pbrand { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.product .ptype {
  flex: 0 0 auto;
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  color: var(--faint);
}

/* milestones */
.miles { margin-top: 12px; display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); }
.mile { display: flex; gap: 14px; align-items: baseline; padding: 14px 16px; border-top: 1px solid var(--line-soft); }
.mile:first-child { border-top: 0; }
.mile .when { flex: 0 0 auto; width: 88px; font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--sage-deep); }
.mile .what { font-size: 14px; color: var(--ink); }

.footnote { margin-top: 22px; text-align: center; color: var(--faint); font-size: 12px; line-height: 1.5; padding: 0 10px; }

/* ====== Body map ====== */
.bodywrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px 16px 18px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}
.bodysvg { width: 100%; max-width: 260px; height: auto; display: block; }
.bz {
  fill: var(--surface-2);
  stroke: var(--line);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill .2s, stroke .2s;
}
.bz:hover { fill: var(--sage-soft); stroke: var(--sage-line); }
.bz.sel { fill: var(--sage); stroke: var(--sage-deep); }
.bz.dot { stroke-dasharray: 0; }
.bzlabel {
  font-family: var(--mono);
  font-size: 8.5px;
  fill: var(--faint);
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.zonehint {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}
.zonehint strong { color: var(--sage-deep); font-weight: 700; }

/* zone detail panel */
.zonecard {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.zonecard .zhead {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--line-soft);
}
.zonecard .zhead .pin {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sage); display: grid; place-items: center; flex: 0 0 auto;
}
.zonecard .zhead .pin span { width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.zonecard .zhead h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.zoneblock { padding: 13px 16px; border-top: 1px solid var(--line-soft); }
.zoneblock:first-of-type { border-top: 0; }
.zoneblock .zlab {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.zoneblock .zlab svg { color: var(--sage-deep); }
.zchips { display: flex; flex-wrap: wrap; gap: 7px; }
.zchip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 10px 6px 7px;
}
.zchip .c {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px;
  padding: 2px 5px; min-width: 30px; text-align: center;
}
.zchip .c.gl { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.zchip .n { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.zonenote {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px 16px; background: var(--sage-soft); border-top: 1px solid var(--sage-line);
}
.zonenote .bang { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; background: var(--sage-deep); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.zonenote p { font-size: 12.5px; color: var(--sage-deep); line-height: 1.4; }

/* ====== Reminders (not in the original design — push settings) ====== */
.remind {
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.remind .rhead {
  display: flex; align-items: center; gap: 11px;
  padding: 15px 16px 13px;
}
.remind .rhead .ri {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  background: var(--sage-soft); border: 1px solid var(--sage-line);
  display: grid; place-items: center; color: var(--sage-deep);
}
.remind .rhead .rt { flex: 1; min-width: 0; }
.remind .rhead h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }
.remind .rhead p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.remind .rbody { padding: 0 16px 15px; }

.rstatus {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  padding: 11px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.rstatus .dot {
  flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
}
.rstatus.on .dot { background: var(--sage); }
.rstatus.warn-state .dot { background: var(--warn); }
.rstatus.on { color: var(--sage-deep); }

.rtimes {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}
.rtime {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px;
}
.rtime .lbl { color: var(--faint); font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  border-radius: 999px; padding: 11px 18px;
  border: 1px solid var(--sage-deep);
  background: var(--sage-deep); color: #fff;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  width: 100%;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost {
  background: var(--surface); color: var(--muted); border-color: var(--line);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btnrow { display: flex; gap: 8px; margin-top: 12px; }
.btnrow .btn { flex: 1; }

.installsteps {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}
.installsteps li { margin-left: 17px; margin-top: 3px; }
.installsteps strong { color: var(--ink); font-weight: 600; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 40;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ====== Bottom nav ====== */
.nav {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: oklch(0.99 0.005 150 / 0.85);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 9px 12px calc(10px + env(safe-area-inset-bottom));
  gap: 4px;
  z-index: 20;
}
.nav button {
  flex: 1;
  border: 0; background: transparent;
  font-family: var(--font);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0;
  cursor: pointer;
  color: var(--faint);
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav button .ni { width: 22px; height: 22px; display: grid; place-items: center; }
.nav button .nl { font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.nav button[aria-current="true"] { color: var(--sage-deep); }
.nav button:hover { color: var(--ink); }
.nav button[aria-current="true"]:hover { color: var(--sage-deep); }

/* view entrance — transform only, so a paused/backgrounded tab never strands content invisible */
.view { animation: viewin .3s cubic-bezier(.4,0,.2,1); }
@keyframes viewin { from { transform: translateY(8px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
