/* ───────────────────────── Tokens ───────────────────────── */
:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #fdfdfc;
  --surface-2: #f0f1ed;
  --surface-3: #e6e8e3;
  --ink: #0d0f0e;
  --ink-2: #4f5451;
  --muted: #858a86;
  --line: rgba(13, 15, 14, 0.08);
  --line-strong: rgba(13, 15, 14, 0.14);
  --accent: #13866f;
  --accent-ink: #0d6b58;
  --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
  --morning: #e59a1a;
  --morning-soft: #fdf3df;
  --night: #5b63d3;
  --night-soft: #ecedfb;
  --good: #13866f;
  --warning: #c98a00;
  --warning-soft: #fdf4dc;
  --critical: #cf3e3a;
  --critical-soft: #fbe9e8;
  --shadow-sm: 0 1px 2px rgba(15, 20, 18, 0.05);
  --shadow: 0 1px 2px rgba(15, 20, 18, 0.04), 0 6px 24px -8px rgba(15, 20, 18, 0.1);
  --shadow-lg: 0 24px 60px -12px rgba(15, 20, 18, 0.28), 0 2px 6px rgba(15, 20, 18, 0.06);
  --hero-a: #18a383;
  --hero-b: #0b5d55;
  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.36, 0.5, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0e0e;
    --surface: #18191a;
    --surface-2: #212324;
    --surface-3: #2b2d2e;
    --ink: #eff1ef;
    --ink-2: #c0c5c1;
    --muted: #868b88;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --accent: #23a88c;
    --accent-ink: #6fd3bb;
    --morning: #f0b04a;
    --morning-soft: #2c2416;
    --night: #8c93f0;
    --night-soft: #1f2136;
    --warning-soft: #2c2412;
    --critical-soft: #2f1716;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 80px -10px rgba(0, 0, 0, 0.75);
    --hero-a: #148e74;
    --hero-b: #0a3f3a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e0e;
  --surface: #18191a;
  --surface-2: #212324;
  --surface-3: #2b2d2e;
  --ink: #eff1ef;
  --ink-2: #c0c5c1;
  --muted: #868b88;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #23a88c;
  --accent-ink: #6fd3bb;
  --morning: #f0b04a;
  --morning-soft: #2c2416;
  --night: #8c93f0;
  --night-soft: #1f2136;
  --warning-soft: #2c2412;
  --critical-soft: #2f1716;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 80px -10px rgba(0, 0, 0, 0.75);
  --hero-a: #148e74;
  --hero-b: #0a3f3a;
}

/* ───────────────────────── Base ───────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  letter-spacing: -0.015em;
}
p {
  margin: 0;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
}
.hidden {
  display: none;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.fine {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.warn-text {
  color: var(--warning);
  font-size: 13px;
}

/* Boot screen while WebAssembly loads */
#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
}
.boot-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  animation: breathe 1.2s var(--ease) infinite alternate;
}
@keyframes breathe {
  from {
    transform: scale(0.88);
    opacity: 0.6;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ───────────────────────── Shell ───────────────────────── */
.shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px 64px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
}
.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 4px 12px -4px color-mix(in oklab, var(--accent) 60%, transparent);
  flex: none;
}
.topbar-actions {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.tabs {
  --n: 4;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tab-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--n));
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  transform: translateX(calc(var(--tab) * 100%));
  transition: transform 0.42s var(--spring);
  will-change: transform;
}
.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
  transition: color 0.2s;
  white-space: nowrap;
}
.tab .icon {
  width: 16px;
  height: 16px;
}
.tab:hover,
.tab.active {
  color: var(--ink);
}
.tab-icon {
  position: relative;
  display: grid;
}
.badge {
  position: absolute;
  top: -7px;
  right: -10px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--critical);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface-2);
  animation: pop 0.4s var(--spring) both;
}
@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

.content {
  padding-top: 8px;
}
.page {
  animation: page-in 0.4s var(--ease) both;
}
@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.reveal {
  animation: rise 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
}

/* ───────────────────────── Buttons ───────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  border-radius: 12px;
  font-weight: 580;
  font-size: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-sm);
  transition: transform 0.15s var(--ease), background 0.2s, box-shadow 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -6px color-mix(in oklab, var(--accent) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn.primary:hover {
  background: color-mix(in oklab, var(--accent) 88%, #000);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.danger {
  color: var(--critical);
}
.btn.small {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
}
.btn.big {
  height: 52px;
  font-size: 16px;
  border-radius: 15px;
  width: 100%;
}
.btn .icon {
  width: 17px;
  height: 17px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: var(--ink-2);
  transition: background 0.2s, color 0.2s, transform 0.15s var(--ease);
  flex: none;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn:active {
  transform: scale(0.92);
}
.link {
  display: inline;
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ───────────────────────── Cards & layout ───────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
  padding: 18px;
}
.card + .card,
.card + .action-row,
.settings > * + * {
  margin-top: 14px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.card-head h3 {
  font-size: 15px;
  font-weight: 640;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13.5px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 18px;
}
.page-head h1 {
  font-size: 28px;
  font-weight: 720;
  letter-spacing: -0.03em;
}
.page-head .sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}
.head-actions {
  display: flex;
  gap: 8px;
}
.section-label {
  margin: 22px 4px 10px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty > .icon {
  width: 30px;
  height: 30px;
  color: var(--accent);
}
.tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13.5px;
}
.tip .icon {
  margin-top: 1px;
  color: var(--accent);
}

/* ───────────────────────── Pill swatch ───────────────────────── */
.pill-dot {
  position: relative;
  width: 26px;
  height: 14px;
  border-radius: 99px;
  background: var(--pill);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), inset 0 -3px 4px rgba(0, 0, 0, 0.1), inset 0 2px 2px rgba(255, 255, 255, 0.5);
  transform: rotate(-30deg);
  flex: none;
}
.pill-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 1px;
  background: rgba(0, 0, 0, 0.12);
}

/* ───────────────────────── Welcome ───────────────────────── */
.welcome {
  margin-top: 18px;
  padding: 34px 26px 26px;
  text-align: center;
}
.welcome h1 {
  font-size: 26px;
  font-weight: 740;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}
.welcome > p.muted {
  max-width: 460px;
  margin: 0 auto;
}
.welcome-art {
  position: relative;
  height: 84px;
  margin-bottom: 14px;
}
.cap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 26px;
  border-radius: 99px;
  box-shadow: inset 0 -5px 8px rgba(0, 0, 0, 0.12), 0 8px 18px -8px rgba(0, 0, 0, 0.35);
  animation: float 3.6s ease-in-out infinite alternate;
}
.cap.a {
  background: linear-gradient(90deg, #fff 50%, #ffd27a 50%);
  transform: translate(-90%, -60%) rotate(-35deg);
}
.cap.b {
  background: linear-gradient(90deg, #f6f6f2 50%, var(--accent) 50%);
  transform: translate(-30%, -20%) rotate(20deg);
  animation-delay: -1.2s;
}
.cap.c {
  width: 34px;
  height: 34px;
  background: #f2a3bf;
  transform: translate(40%, -80%);
  animation-delay: -2.4s;
}
@keyframes float {
  to {
    margin-top: -6px;
  }
}
.welcome-actions {
  display: grid;
  gap: 10px;
  max-width: 360px;
  margin: 24px auto 0;
}

/* ───────────────────────── Start week (hero) ───────────────────────── */
.hero {
  margin-top: 6px;
  padding: 22px;
  border-radius: 24px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(140deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 18px 40px -18px color-mix(in oklab, var(--hero-b) 80%, transparent);
}
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.8;
}
.week-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.14);
}
.icon-btn.on-hero {
  width: 32px;
  height: 32px;
  color: #fff;
}
.icon-btn.on-hero:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.week-label {
  min-width: 112px;
  text-align: center;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0;
}
.hero-stats div {
  display: flex;
  flex-direction: column;
}
.hero-stats strong {
  font-size: 34px;
  font-weight: 740;
  letter-spacing: -0.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.hero-stats span {
  font-size: 13px;
  opacity: 0.82;
}
.btn.hero-btn {
  width: 100%;
  height: 54px;
  border-radius: 16px;
  font-size: 16.5px;
  font-weight: 680;
  color: var(--hero-b);
  background: #fff;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.45);
}
.btn.hero-btn:hover {
  background: #f1fbf8;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  text-align: left;
  font-size: 14px;
}
.notice.warn {
  background: var(--warning-soft);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--warning) 30%, transparent);
}
.notice.warn > .icon {
  color: var(--warning);
  margin-top: 1px;
}
.notice ul {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 13.5px;
}
.link-notice {
  align-items: center;
  font-weight: 600;
  transition: background 0.2s, transform 0.15s var(--ease);
}
.link-notice span {
  flex: 1;
}
.link-notice > .icon:first-child {
  color: var(--critical);
}
.link-notice:hover {
  background: var(--surface-2);
}
.link-notice:active {
  transform: scale(0.99);
}
.paused-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 4px 0;
  color: var(--muted);
  font-size: 13.5px;
}
.recent {
  margin-top: 18px;
}
.rows .row {
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.rows .row:first-child {
  border-top: 0;
  padding-top: 2px;
}
.row-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 14px;
}
.row-main .muted {
  font-size: 13px;
}

/* ───────────────────────── Packing ───────────────────────── */
.pack-head {
  position: sticky;
  top: 64px;
  z-index: 10;
  margin: 0 -20px 6px;
  padding: 6px 20px 14px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.pack-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.pack-title .eyebrow {
  color: var(--accent-ink);
  opacity: 1;
}
.pack-title h1 {
  font-size: 24px;
  font-weight: 720;
  letter-spacing: -0.03em;
}

/* Row tabs: morning, night, check, each with its own progress. */
.row-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}
.row-tab {
  --tint: var(--morning);
  --tint-soft: var(--morning-soft);
  display: grid;
  gap: 7px;
  padding: 9px 12px 10px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: left;
  color: var(--ink-2);
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}
.row-tab.night {
  --tint: var(--night);
  --tint-soft: var(--night-soft);
}
.row-tab.active {
  color: var(--ink);
  background: var(--tint-soft);
  box-shadow: inset 0 0 0 2px var(--tint);
}
.row-tab.check {
  --tint: var(--accent);
  --tint-soft: var(--accent-soft);
  align-content: center;
}
.rt-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
}
.rt-top .icon {
  width: 17px;
  height: 17px;
  color: var(--tint);
  flex: none;
}
.rt-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rt-count {
  flex: none;
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.row-tab.complete .rt-count {
  color: var(--good);
}
.rt-bar {
  display: block;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.rt-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tint);
  transform-origin: left;
  transform: scaleX(var(--p));
  transition: transform 0.5s var(--spring);
}

.step-focus {
  scroll-margin-top: 210px;
}
.step-focus:empty {
  display: none;
}
.pack-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
  animation: rise 0.45s var(--ease) both;
  transition: transform 0.26s var(--ease), opacity 0.26s var(--ease);
}
.pack-card.leaving {
  transform: translateX(28px) scale(0.97);
  opacity: 0;
}
.step-focus .pack-card {
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 55%, transparent), var(--shadow);
}
.step-dose {
  display: grid;
  gap: 2px;
  padding: 12px 14px 13px;
  border-radius: 15px;
  background: var(--morning-soft);
}
.step-dose.night {
  background: var(--night-soft);
}
.sd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.sd-row .icon {
  width: 16px;
  height: 16px;
  color: var(--morning);
}
.step-dose.night .sd-row .icon {
  color: var(--night);
}
.sd-amount {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.sd-amount strong {
  font-size: 44px;
  line-height: 1.05;
  font-weight: 760;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.sd-amount span {
  font-size: 15px;
  font-weight: 560;
  color: var(--ink-2);
}
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.ds-cell {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 6px 0 7px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.ds-cell.on {
  color: var(--ink);
  background: var(--morning-soft);
  box-shadow: inset 0 0 0 1.5px var(--morning);
}
.day-strip.night .ds-cell.on {
  background: var(--night-soft);
  box-shadow: inset 0 0 0 1.5px var(--night);
}
.ds-day {
  font-size: 11px;
  font-weight: 650;
}
.ds-n {
  font-size: 15px;
  font-weight: 720;
}

/* Short on stock: choose the days this row gets. */
.day-pick {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 15px;
  background: var(--surface-2);
}
.day-pick.short {
  background: var(--critical-soft);
}
.dp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.day-pick.short .dp-status {
  color: var(--critical);
}
.dp-status .icon {
  width: 16px;
  height: 16px;
  flex: none;
}
.day-strip.pick {
  gap: 4px;
}
.day-strip.pick .ds-cell {
  min-height: 48px;
  align-content: center;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s var(--ease);
}
.day-strip.pick .ds-cell.on {
  background: var(--morning-soft);
  box-shadow: inset 0 0 0 2px var(--morning);
}
.day-strip.pick.night .ds-cell.on {
  background: var(--night-soft);
  box-shadow: inset 0 0 0 2px var(--night);
}
.day-strip.pick .ds-cell:active:not(:disabled) {
  transform: scale(0.94);
}
.day-strip.pick .ds-cell:disabled {
  opacity: 0.35;
  background: transparent;
  box-shadow: none;
}
.dp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 620;
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.dp-btn.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: none;
}
.dp-btn .icon {
  width: 15px;
  height: 15px;
  flex: none;
}

/* The rest of the row: open one, or tick it straight off. */
.step-rows {
  display: grid;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), var(--shadow-sm);
  overflow: hidden;
}
.step-row {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
  transition: transform 0.24s var(--ease), opacity 0.24s var(--ease);
}
.step-row:first-child {
  border-top: none;
}
.step-row.leaving {
  transform: translateX(24px);
  opacity: 0;
}
.sr-main {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: 8px 4px 8px 14px;
  text-align: left;
}
.sr-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15.5px;
  font-weight: 620;
}
.sr-strength {
  margin-left: 6px;
  font-size: 13.5px;
  font-weight: 520;
  color: var(--muted);
}
.sr-dose {
  display: grid;
  justify-items: end;
  flex: none;
  font-size: 18px;
  font-weight: 740;
  color: var(--morning);
  font-variant-numeric: tabular-nums;
}
.sr-dose.night {
  color: var(--night);
}
.sr-dose small {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.sr-tick {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0 8px 0 6px;
  border-radius: 50%;
  color: var(--muted);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.sr-tick .icon {
  width: 20px;
  height: 20px;
}
.sr-tick:hover,
.sr-tick:active {
  color: #fff;
  background: var(--accent);
  box-shadow: none;
}
.pc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pc-name {
  flex: 1;
  min-width: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.pc-strength {
  margin-left: 7px;
  font-size: 15px;
  font-weight: 550;
  color: var(--muted);
}
.flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  flex: none;
}
.flag-chip .icon {
  width: 14px;
  height: 14px;
}
.flag-chip.on {
  color: var(--critical);
  background: var(--critical-soft);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--critical) 30%, transparent);
}
.flag-chip.static {
  cursor: default;
}
.pc-cut,
.pc-stock,
.pc-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.pc-cut .icon,
.pc-stock .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.pc-cut {
  color: var(--ink);
  font-weight: 560;
}
.pc-cut .icon {
  color: var(--accent);
}
.pc-stock.bad {
  color: var(--critical);
  font-weight: 600;
}
.pc-stock.bad .icon {
  color: var(--critical);
}
.pc-note {
  font-style: italic;
}
.pack-btn {
  margin-top: 4px;
}


.all-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 16px 14px;
  text-align: center;
}
.all-done h2 {
  font-size: 21px;
}
.done-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 14px 30px -12px var(--accent);
  animation: pop 0.6s var(--spring) both;
}
.done-mark .icon {
  width: 34px;
  height: 34px;
  stroke-width: 2.4;
}

.packed-list {
  margin-top: 6px;
}
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.packed-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13.5px;
  color: var(--ink-2);
  animation: pop 0.35s var(--spring) both;
  transition: background 0.2s;
}
.packed-chip:hover {
  background: var(--surface-2);
}
.packed-chip .pill-dot {
  width: 18px;
  height: 10px;
}
.packed-chip > .icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

/* Stays out of the way while packing, then sticks in reach once everything is in. */
.finish-bar {
  margin-top: 26px;
}
.finish-bar.ready {
  position: sticky;
  bottom: 16px;
  z-index: 5;
}

/* Organiser check */
.org-grid {
  display: grid;
  grid-template-columns: 28px repeat(7, 1fr);
  gap: 6px;
  align-items: center;
}
.org-head {
  text-align: center;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.org-row-label {
  display: grid;
  place-items: center;
  color: var(--morning);
}
.org-row-label.night {
  color: var(--night);
}
.org-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1.1;
  border-radius: 12px;
  background: var(--morning-soft);
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
}
.org-cell.night {
  background: var(--night-soft);
}
.org-cell.empty {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
}
.org-cell.sel {
  box-shadow: inset 0 0 0 2.5px var(--morning);
  transform: scale(1.04);
}
.org-cell.night.sel {
  box-shadow: inset 0 0 0 2.5px var(--night);
}
.org-cell:active {
  transform: scale(0.95);
}
.org-detail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  animation: rise 0.35s var(--ease) both;
}
.org-detail h4 {
  margin-bottom: 8px;
  font-size: 14px;
}
.org-detail li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
}
.org-detail li span:not(.pill-dot) {
  flex: 1;
}

/* ───────────────────────── Medicine list ───────────────────────── */
.card.list {
  padding: 6px;
}
.med-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: 13px;
  text-align: left;
  transition: background 0.15s;
}
button.med-row:hover {
  background: var(--surface-2);
}
.med-row + .med-row {
  box-shadow: 0 -1px 0 var(--line);
}
.med-row > .icon {
  color: var(--muted);
  width: 16px;
  height: 16px;
}
.med-row.wrap {
  flex-wrap: wrap;
}
.med-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.med-name {
  font-weight: 640;
  font-size: 15.5px;
}
.med-strength {
  margin-left: 5px;
  font-weight: 500;
  color: var(--muted);
}
.med-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
}
.tag {
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.tag.accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.stock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  font-size: 12px;
  color: var(--muted);
  flex: none;
}
.stock strong {
  font-size: 16px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stock.low strong,
.stock.low span {
  color: var(--critical);
}
.card.list.paused {
  opacity: 0.7;
}
.receive {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  padding: 4px 0 2px 38px;
  animation: rise 0.3s var(--ease) both;
}
.receive .field {
  flex: 1;
}
.notice .btn.small {
  margin-top: 10px;
}

/* Add a delivery: one row per medicine with a stock count. */
.topup-list {
  display: grid;
  margin: 0 -6px;
}
.topup-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 8px;
  padding: 12px 6px;
}
.topup-row + .topup-row {
  box-shadow: 0 -1px 0 var(--line);
}
.tu-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15.5px;
  font-weight: 620;
}
.tu-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tu-sub.up {
  color: var(--good);
  font-weight: 600;
}
.tu-tag {
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
}
.tu-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.tu-box {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 0 13px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 620;
  color: var(--accent);
  background: var(--accent-soft);
}
.tu-box .icon {
  width: 15px;
  height: 15px;
}
.tu-count {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.tu-count input {
  width: 68px;
  height: 44px;
  padding: 0 6px;
  border: 0;
  border-radius: 12px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  appearance: textfield;
  -moz-appearance: textfield;
}
.tu-count input::-webkit-outer-spin-button,
.tu-count input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tu-count input:focus {
  outline: none;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ───────────────────────── Forms ───────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-row.two {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > span,
.field-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.field-head {
  display: flex;
  justify-content: space-between;
}
.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: 12px;
  border: 0;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px;
  transition: box-shadow 0.2s, background 0.2s;
}
.field input::placeholder {
  color: var(--muted);
}
.field input:focus {
  outline: none;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.field.inline > span {
  font-size: 12px;
}
.hint {
  font-size: 12.5px;
  color: var(--muted);
}
.form-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--critical-soft);
  color: var(--critical);
  font-size: 14px;
  font-weight: 600;
}

.dose-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dose-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 15px;
  background: var(--morning-soft);
}
.dose-box.night {
  background: var(--night-soft);
}
.dose-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.dose-label .icon {
  width: 16px;
  height: 16px;
  color: var(--morning);
}
.dose-box.night .dose-label .icon {
  color: var(--night);
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.step-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-sm);
  transition: transform 0.12s var(--ease);
}
.step-btn:active {
  transform: scale(0.92);
}
.step-btn:disabled {
  opacity: 0.4;
}
.step-val {
  flex: 1;
  text-align: center;
  font-size: 24px;
  font-weight: 740;
  font-variant-numeric: tabular-nums;
}
.step-val.zero {
  color: var(--muted);
  font-weight: 500;
}

.day-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.day-chip {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-weight: 650;
  color: var(--muted);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.2s, color 0.2s, transform 0.12s var(--ease);
}
.day-chip.on {
  color: #fff;
  background: var(--accent);
  box-shadow: none;
}
.day-chip:active {
  transform: scale(0.92);
}
.colour-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.colour-chip {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--pill);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), inset 0 -4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.colour-chip.on {
  transform: scale(1.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), 0 0 0 3px var(--surface), 0 0 0 5px var(--accent);
}
.group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 0;
  border-radius: 15px;
  background: var(--surface-2);
}
.group legend {
  float: left;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  font-weight: 650;
  font-size: 14px;
}
.group legend .icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.group .field input {
  background: var(--surface);
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.toggle-row > div:first-child {
  display: flex;
  flex-direction: column;
  font-size: 14.5px;
}
.toggle-row .muted {
  font-size: 13px;
}
.card .toggle-row {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

/* Segmented */
.segmented {
  --n: 2;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  flex: none;
}
.seg-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--n));
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.4s var(--spring);
}
.seg {
  position: relative;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 580;
  color: var(--ink-2);
  border-radius: 8px;
  transition: color 0.2s;
  white-space: nowrap;
}
.seg.active {
  color: var(--ink);
}

/* Switch */
.switch {
  position: relative;
  width: 48px;
  height: 29px;
  border-radius: 99px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.25s var(--ease);
  flex: none;
}
.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.35s var(--spring);
}
.switch.on {
  background: var(--accent);
}
.switch.on .knob {
  transform: translateX(19px);
}

/* ───────────────────────── Sheet ───────────────────────── */
.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 10, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.25s var(--ease) both;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
  animation: sheet-in 0.42s var(--spring) both;
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.965);
  }
}
.sheet-grip {
  display: none;
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 8px 22px;
  background: var(--surface);
}
.sheet-head h2 {
  font-size: 20px;
  font-weight: 700;
}
.sheet-body {
  padding: 6px 22px 22px;
}
.sheet-actions {
  position: sticky;
  bottom: -22px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px -22px -22px;
  padding: 14px 22px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line);
}
.spacer {
  flex: 1;
}

/* ───────────────────────── Toast ───────────────────────── */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px 11px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 540;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.45s var(--spring) both;
  white-space: nowrap;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
}
.toast-action {
  padding: 5px 11px;
  border-radius: 9px;
  font-weight: 650;
  color: #6fd3bb;
  background: color-mix(in oklab, var(--bg) 12%, transparent);
}
:root[data-theme="dark"] .toast-action {
  color: var(--accent);
}

.crash {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 14px;
  background: var(--critical);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
}
.crash button {
  padding: 6px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 650;
}

/* ───────────────────────── Phone layout ───────────────────────── */
@media (max-width: 720px) {
  .shell {
    /* Height of the top bar below, so the packing head can pin under it. */
    --topbar-h: calc(46px + max(10px, env(safe-area-inset-top)));
    padding: 0 16px calc(100px + env(safe-area-inset-bottom));
  }
  .topbar {
    padding: 10px 0;
    padding-top: max(10px, env(safe-area-inset-top));
    /* backdrop-filter would trap the fixed bottom nav inside the header */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }
  .tabs {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 30;
    padding: 5px;
    border-radius: 22px;
    background: color-mix(in oklab, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(16px);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    box-shadow: 0 0 0 1px var(--line), var(--shadow-lg);
  }
  .tab-pill {
    top: 5px;
    bottom: 5px;
    left: 5px;
    width: calc((100% - 10px) / var(--n));
    border-radius: 17px;
    background: var(--accent-soft);
    box-shadow: none;
  }
  .tab {
    flex-direction: column;
    gap: 3px;
    padding: 8px 0 7px;
    font-size: 11px;
  }
  .tab .icon {
    width: 22px;
    height: 22px;
  }
  .tab.active {
    color: var(--accent-ink);
  }
  .badge {
    box-shadow: 0 0 0 2px var(--surface);
  }
  .pack-head {
    top: var(--topbar-h);
    margin: 0 -16px 6px;
    padding: 2px 16px 12px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
    box-shadow: 0 1px 0 var(--line);
  }
  .pack-title h1 {
    font-size: 19px;
  }
  .pack-title .btn.small {
    margin-top: 2px;
  }
  .row-tabs {
    margin-top: 10px;
    gap: 6px;
  }
  .row-tab {
    padding: 8px 10px 9px;
  }
  .step-focus {
    scroll-margin-top: calc(var(--topbar-h) + 150px);
  }
  .finish-bar.ready {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
  .toast-host {
    bottom: calc(96px + env(safe-area-inset-bottom));
    width: calc(100% - 32px);
    display: flex;
    justify-content: center;
  }
  .toast {
    white-space: normal;
  }
  .page-head h1 {
    font-size: 25px;
  }
  .hide-sm {
    display: none;
  }
  .hero-stats strong {
    font-size: 30px;
  }
  .sheet-root {
    place-items: end stretch;
    padding: 0;
  }
  .sheet {
    width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: 24px 24px 0 0;
    animation: sheet-up 0.42s var(--ease) both;
  }
  @keyframes sheet-up {
    from {
      transform: translateY(100%);
    }
  }
  .sheet-grip {
    display: block;
    width: 38px;
    height: 5px;
    margin: 8px auto 0;
    border-radius: 99px;
    background: var(--surface-3);
  }
  .sheet-head {
    padding-top: 10px;
  }
  .org-grid {
    gap: 4px;
    grid-template-columns: 22px repeat(7, 1fr);
  }
  .org-cell {
    font-size: 17px;
    border-radius: 10px;
  }
  .card .toggle-row {
    flex-wrap: wrap;
  }
}
@media (max-width: 420px) {
  /* The Check tab shrinks to its icon so both rows keep room for their counts. */
  .row-tab {
    padding-inline: 9px;
  }
  .rt-top {
    gap: 5px;
    font-size: 13.5px;
  }
  .row-tab.check .rt-label {
    display: none;
  }
  .row-tab.check .rt-top {
    justify-content: center;
  }
  .row-tab.check .rt-top .icon {
    width: 20px;
    height: 20px;
  }
  .row-tab.check {
    min-width: 46px;
  }
  .pc-name {
    font-size: 17.5px;
  }
  .form-row.two {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 380px) {
  /* Narrow phones: the tab colour already says morning or night. */
  .row-tab:not(.check) .rt-top .icon {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ───────────────────────── Print ───────────────────────── */
.print-sheet {
  display: none;
}
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  body {
    background: #fff;
    color: #000;
    font-size: 11px;
  }
  .shell,
  .toast-host,
  .sheet-root,
  #boot {
    display: none !important;
  }
  .print-sheet {
    display: block;
  }
  .print-sheet header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
  }
  .print-sheet h1 {
    font-size: 20px;
  }
  .print-sheet header span {
    color: #555;
  }
  .print-sheet table {
    width: 100%;
    margin-bottom: 14px;
    border-collapse: collapse;
    break-inside: avoid;
  }
  .print-sheet th,
  .print-sheet td {
    padding: 3px 6px;
    border: 1px solid #333;
    text-align: center;
  }
  .print-sheet .l {
    text-align: left;
  }
  .print-sheet .band th {
    background: #d6ecc9;
    font-size: 13px;
    text-align: left;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-sheet table.night .band th {
    background: #cfe2f3;
  }
  .print-sheet tbody tr:nth-child(even) td {
    background: #f1f1f1;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-sheet .day {
    width: 22px;
    color: #999;
  }
  .print-sheet td.day.off {
    background: #ccc !important;
  }
  .print-sheet .box {
    width: 48px;
    font-size: 14px;
  }
}
