:root {
  --teal: #14746f;
  --teal-dark: #0f3d3a;
  --teal-soft: #e3f1ef;
  --ink: #14201f;
  --muted: #5d6b6a;
  --line: #d8e2e0;
  --bg: #f3f7f6;
  --bubble-bot: #ffffff;
  --bubble-user: #14746f;
  --urgent: #d64545;
  --monitor: #e0a100;
  --routine: #2e9e6b;
  --radius: 16px;
  --tap: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Lock the page itself — the app pins to the viewport, only inner areas scroll.
   Relying on a height:100% chain let the whole page scroll on iOS standalone
   (so nothing stayed fixed); position:fixed pins to the viewport reliably. */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 17px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: 17px;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
  /* Stop iOS treating rapid taps as a double-tap-to-zoom (breaks the water
     +/- counters). Pinch-to-zoom on content still works. */
  touch-action: manipulation;
}

/* ---------- App bar ---------- */
.appbar {
  flex: 0 0 auto;
  background: var(--teal);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  z-index: 5;
}
.appbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}
.appbar .who {
  font-size: 13px;
  opacity: 0.92;
  margin-top: 2px;
}
.appbar .who-change {
  background: none;
  color: #fff;
  text-decoration: underline;
  font-size: 13px;
  padding: 2px 2px;
  min-height: 0;
  opacity: 0.95;
}
.appbar .restart {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  min-height: 40px;
  white-space: nowrap;
}
.appbar .restart:active { background: rgba(255, 255, 255, 0.28); }

/* ---------- Generic content ---------- */
.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}
/* Pushes the summary + question panel to the bottom when content is short,
   and collapses to zero once the content overflows. */
.scroll-spacer {
  flex: 1 1 auto;
  min-height: 0;
}

.center-pad {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------- Identity screen ---------- */
.identity h2 {
  font-size: 24px;
  margin: 0 0 6px;
}
.identity p {
  color: var(--muted);
  margin: 0 0 24px;
}
.identity .names {
  display: grid;
  gap: 14px;
}
.name-btn {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.12s, background 0.12s;
}
.name-btn:active {
  border-color: var(--teal);
  background: var(--teal-soft);
}
.name-btn .avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}

/* ---------- Home / start ---------- */
.home h2 {
  font-size: 22px;
  margin: 0 0 8px;
}
.home p {
  color: var(--muted);
  margin: 0 0 28px;
}

/* ---------- Chat ---------- */
.chat-progress {
  flex: 0 0 auto;
  height: 4px;
  background: var(--line);
}
.chat-progress > span {
  display: block;
  height: 100%;
  background: var(--teal);
  width: 0;
  transition: width 0.25s ease;
}

.divider {
  text-align: center;
  margin: 14px 0 6px;
}
.divider span {
  display: inline-block;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
}

.bubble {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 18px;
  margin: 6px 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop 0.18s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble.bot {
  background: var(--bubble-bot);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
}
.bubble.user {
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}
.turns {
  display: flex;
  flex-direction: column;
}

/* ---------- Input dock ---------- */
.dock {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 12px 14px calc(12px + var(--safe-bottom));
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}
.dock .hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  max-height: 46vh;
  overflow-y: auto;
}
.chip {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 14px;
  color: var(--ink);
  min-height: 36px;
}
.chip[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.chip.other[aria-pressed="true"] {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.concerns {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.concern-btn {
  text-align: left;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: #fff;
  min-height: var(--tap);
}
.concern-btn .lvl { font-weight: 700; display: block; }
.concern-btn .desc { font-size: 13px; color: var(--muted); margin-top: 2px; display: block; }
.concern-btn[aria-pressed="true"] { background: var(--teal-soft); }
.concern-btn.urgent[aria-pressed="true"] { border-color: var(--urgent); }
.concern-btn.monitor[aria-pressed="true"] { border-color: var(--monitor); }
.concern-btn.routine[aria-pressed="true"] { border-color: var(--routine); }

textarea, input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
  margin-bottom: 12px;
  background: #fff;
}
textarea:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--teal);
}
.field-extra { margin-bottom: 12px; }
.field-extra label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.dock-actions {
  display: flex;
  gap: 10px;
}
.btn {
  flex: 1 1 auto;
  min-height: var(--tap);
  border-radius: 12px;
  font-weight: 600;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:disabled {
  background: #a9c5c2;
  color: #eef5f4;
}
.btn-primary:active:not(:disabled) { background: var(--teal-dark); }
.btn-ghost {
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--ink);
  flex: 0 0 auto;
  padding: 0 18px;
}
.btn-ghost:active { background: var(--teal-soft); }
.btn-block { width: 100%; }
.error {
  color: var(--urgent);
  font-size: 14px;
  margin: 0 0 10px;
  min-height: 0;
}

/* ---------- Review ---------- */
.review h2 { font-size: 22px; margin: 4px 0 4px; }
.review .sub { color: var(--muted); margin: 0 0 18px; }
.review-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.review-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}
.review-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.review-row:first-of-type { border-top: none; }
.review-row .rl { color: var(--muted); font-size: 14px; flex: 0 0 38%; }
.review-row .rv { font-size: 15px; flex: 1 1 auto; }
.review-row .edit {
  background: none;
  color: var(--teal);
  font-size: 14px;
  font-weight: 600;
  padding: 0 0 0 8px;
  flex: 0 0 auto;
}
.preview {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--ink);
}
.preview-label {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 6px;
  font-weight: 600;
}

/* ---------- Sent ---------- */
.sent { text-align: center; }
.sent .big {
  width: 84px; height: 84px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 44px;
  display: grid; place-items: center;
  margin: 0 auto 18px;
}
.sent h2 { font-size: 24px; margin: 0 0 8px; }
.sent p { color: var(--muted); margin: 0 auto 24px; max-width: 320px; }

.note {
  background: #fff8e6;
  border: 1px solid #f0deaa;
  color: #6b551c;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}
.stack { display: grid; gap: 10px; }

/* ---------- Install gate ---------- */
.install-gate h2 {
  font-size: 24px;
  margin: 0 0 8px;
}
.gate-lead {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 16px;
}

/* ---------- Install card ---------- */
.install {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.install-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.install-ico {
  font-size: 26px;
  line-height: 1;
  flex: 0 0 auto;
}
.install-head strong {
  font-size: 17px;
  color: var(--ink);
}
.install-sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.install-steps {
  margin: 12px 0 4px;
  padding-left: 22px;
  font-size: 14px;
  color: var(--ink);
}
.install-steps li { margin: 6px 0; }
.install-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.install-actions .btn { flex: 1 1 auto; }

/* ---------- Build-the-summary screen ---------- */
.summary {
  flex: 0 0 auto;
  padding: 16px 16px 0;
}
.sum-head {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}
.sum-empty {
  color: var(--muted);
  text-align: center;
  font-size: 15px;
  margin: 24px 0;
}
.sum-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 14px 8px;
  margin-bottom: 12px;
}
.sum-resident {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--teal-dark);
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--line);
}
.sum-avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--teal-soft);
  display: grid; place-items: center;
  font-size: 18px;
  flex: 0 0 auto;
}
.sum-name { min-width: 0; }
.sum-badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.sum-badge.routine { background: #e4f4ec; color: var(--routine); }
.sum-badge.monitor { background: #fbf0d2; color: #9a7400; }
.sum-badge.urgent  { background: #fbe3e3; color: var(--urgent); }
.sum-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.sum-row:first-of-type { border-top: none; }
.sum-row.editing {
  background: var(--teal-soft);
  border-top-color: transparent;
  border-radius: 10px;
  margin: 2px -8px;
  padding: 9px 8px;
}
.sum-row.editing + .sum-row { border-top-color: transparent; }
.sum-editing {
  flex: 0 0 auto;
  color: var(--teal);
  font-weight: 600;
  font-size: 13px;
  font-style: italic;
}
.sum-l { flex: 0 0 32%; color: var(--muted); font-size: 13px; }
.sum-v { flex: 1 1 auto; font-size: 15px; }
.sum-v.sum-skipped { color: var(--muted); font-style: italic; }
.sum-edit {
  flex: 0 0 auto;
  background: none;
  color: var(--teal);
  font-weight: 600;
  font-size: 14px;
  padding: 4px 4px 4px 8px;
  min-height: 32px;
}

/* Pinned question on top of the options */
.askdock {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.07);
}
.ask {
  padding: 14px 16px 2px;
}
.ask-resident {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--teal);
}
.ask-avatar {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--teal-soft);
  display: grid; place-items: center;
  font-size: 20px;
}
.ask-q {
  font-size: 23px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
  margin-top: 10px;
}
.askdock > .dock {
  border-top: none;
  box-shadow: none;
  padding-top: 10px;
}

/* ---------- Confirmation modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 61, 58, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  animation: fade 0.15s ease;
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}
.modal-title {
  margin: 0 0 8px;
  font-size: 19px;
}
.modal-body {
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--muted);
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn {
  flex: 1 1 auto;
  min-height: 50px;
}
.btn-danger {
  background: var(--urgent);
  color: #fff;
}
.btn-danger:active { background: #b83a3a; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- App bar: menu button ---------- */
.appbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.menu-btn {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
.menu-btn:active { background: rgba(255, 255, 255, 0.28); }
.menu-icon {
  display: grid;
  gap: 4px;
  width: 20px;
}
.menu-icon > span {
  display: block;
  height: 2.5px;
  border-radius: 2px;
  background: #fff;
}

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 61, 58, 0);
  transition: background 0.2s ease;
  z-index: 90;
}
.drawer-overlay.open { background: rgba(15, 61, 58, 0.45); }
.drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: #fff;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}
.drawer-overlay.open .drawer { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--teal-soft);
  border-bottom: 1px solid var(--line);
}
.drawer-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--teal-dark);
}
.drawer-close {
  background: none;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
  width: 40px;
  height: 40px;
}
.drawer-items {
  flex: 1 1 auto;
  padding: 10px 10px 8px;
  overflow-y: auto;
}
.drawer-version {
  flex: 0 0 auto;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border-radius: 12px;
  padding: 14px 12px;
  font-size: 17px;
  color: var(--ink);
  min-height: 50px;
}
.drawer-item:active { background: var(--teal-soft); }
.drawer-item.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 700;
}
.drawer-ico { font-size: 20px; flex: 0 0 auto; }
.drawer-sub {
  font-size: 15px;
  padding: 11px 12px 11px 20px;
  color: var(--muted);
  min-height: 44px;
}
.drawer-sub.active { color: var(--teal-dark); }
.drawer-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 16px 12px 6px;
}

/* ---------- Plain scroll (guides) ---------- */
.scroll-plain {
  flex: 1 1 auto;
  /* min-height:0 lets this shrink and scroll in iOS Safari instead of growing
     to its content height and pushing the sticky bar (e.g. read-aloud) off. */
  min-height: 0;
  overflow-y: auto;
  /* NOTE: do not add -webkit-overflow-scrolling: touch here — it breaks
     position: sticky on iOS (the read-aloud controls stop sticking). Modern
     iOS has momentum scrolling by default. */
}
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 18px calc(28px + env(safe-area-inset-bottom, 0px));
}
.content-title { font-size: 24px; margin: 4px 0 4px; }
.content-lead { color: var(--muted); margin: 0 0 18px; }

/* ---------- Guides landing ---------- */
.guide-cat {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal);
  margin: 18px 2px 8px;
}
.guide-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.guide-card:active { background: var(--teal-soft); }
.guide-card-main { flex: 1 1 auto; min-width: 0; }
.guide-card-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.guide-card-summary { font-size: 14px; color: var(--muted); margin-top: 2px; }
.guide-card-chevron { font-size: 26px; color: var(--muted); flex: 0 0 auto; }

/* ---------- Guide document ---------- */
.doc-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
/* Explicit columns so the contents icon stays on the right even when the
   centre Listen button is hidden (display:none) during playback. */
.doc-topbar .back-link { grid-column: 1; justify-self: start; }
.doc-topbar .tts-listen { grid-column: 2; justify-self: center; }
.doc-topbar .toc-btn { grid-column: 3; justify-self: end; }
.back-link {
  background: none;
  color: var(--teal);
  font-weight: 600;
  font-size: 15px;
  padding: 4px 0;
}
.toc-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: none;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.toc-btn:active { background: var(--teal-soft); }
.doc-body h1, .doc-body h2, .doc-body h3 { scroll-margin-top: 12px; }

/* Contents panel (right drawer) */
.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 61, 58, 0);
  transition: background 0.2s ease;
  z-index: 90;
}
.toc-overlay.open { background: rgba(15, 61, 58, 0.45); }
.toc-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  padding-top: env(safe-area-inset-top, 0px);
}
.toc-overlay.open .toc-panel { transform: translateX(0); }
.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.toc-title { font-size: 18px; font-weight: 800; color: var(--teal-dark); }
.toc-close {
  background: none;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
  width: 40px;
  height: 40px;
}
.toc-items {
  overflow-y: auto;
  padding: 8px 10px calc(16px + env(safe-area-inset-bottom, 0px));
}
.toc-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border-radius: 10px;
  padding: 15px 12px;
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  min-height: 54px;
}
.toc-item:active { background: var(--teal-soft); }
.toc-l1 { font-weight: 700; }
.toc-l1 + .toc-l1, .toc-l2 + .toc-l1 { border-top: 1px solid var(--line); }
.toc-l2 {
  padding-left: 26px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  min-height: 48px;
}
.toc-empty { color: var(--muted); padding: 16px 12px; }
.doc-body { color: var(--ink); font-size: 16px; line-height: 1.55; }
.doc-body h1, .doc-body h2, .doc-body h3 { color: var(--teal); }
.doc-body h1 {
  font-size: 23px;
  margin: 26px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--teal);
}
.doc-body h2 {
  font-size: 19px;
  margin: 24px 0 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid #bcd9d4;
}
.doc-body h3 { font-size: 17px; margin: 18px 0 6px; }
.doc-body h4 { font-size: 15px; margin: 16px 0 6px; color: var(--muted); }
.doc-body p { margin: 0 0 12px; }
.doc-body ul, .doc-body ol { margin: 0 0 14px; padding-left: 22px; }
.doc-body li { margin: 6px 0; }
.doc-body a { color: var(--teal); }
.doc-body em { font-style: italic; }
.doc-body code {
  background: var(--teal-soft);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 90%;
}
.doc-body hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.doc-loading, .doc-error { color: var(--muted); }

/* Hero title block */
.doc-hero {
  text-align: center;
  padding: 4px 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.doc-hero-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--teal);
}
.doc-hero-sub { color: var(--muted); margin: 7px 0 0; font-size: 16px; }

/* ---------- Callouts ---------- */
.callout {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 16px;
}
.callout p { margin: 0 0 8px; }
.callout p:last-child { margin-bottom: 0; }
.callout-lead { font-weight: 700; }
.callout-source { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* info (teal) */
.callout-info {
  background: var(--teal-soft);
  border-left: 4px solid var(--teal);
}
.callout-info p { color: var(--teal-dark); }

/* caution (yellow) */
.callout-caution {
  background: #fbf3d3;
  border-left: 4px solid #d8be4e;
}
.callout-caution p { color: #7a6312; }

/* danger (red) */
.callout-danger {
  background: #fbe9e4;
  border-left: 4px solid #b0432f;
}
.callout-danger p { color: var(--ink); }
.callout-danger.has-bar { padding: 0; overflow: hidden; }
.callout-danger .callout-bar {
  background: #b0432f;
  color: #fff;
  font-weight: 700;
  padding: 11px 14px;
}
.callout-danger.has-bar p {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid #f1d2c9;
}

/* research claim + source card */
.callout-research {
  background: #fff;
  border: 1.5px solid var(--teal);
}
.callout-claim { font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.callout-research .callout-source { color: var(--teal); }

/* do / don't / numbered badges */
.callout-badge {
  display: flex;
  gap: 0;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  border-left: none;
}
.badge-mark {
  flex: 0 0 auto;
  width: 48px;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.badge-body { flex: 1 1 auto; min-width: 0; padding: 12px 14px; }
.callout-badge.tick { background: #e4f1ee; }
.callout-badge.tick .badge-mark { background: var(--teal); }
.callout-badge.tick .badge-body { color: var(--teal-dark); }
.callout-badge.cross { background: #f7e6e2; }
.callout-badge.cross .badge-mark { background: #a8432f; }
.callout-badge.cross .badge-body { color: #a8432f; }
.callout-badge.warn { background: #fbf3d3; }
.callout-badge.warn .badge-mark { background: #d8be4e; }
.callout-badge.num { background: var(--teal-soft); }
.callout-badge.num .badge-mark { background: var(--teal); }

/* ---------- Tables ---------- */
/* Two-column tables → definition list */
.md-deflist { margin: 0 0 16px; }
.md-def {
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.md-def:first-child { border-top: none; }
.md-def dt { font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.md-def dd { margin: 0; color: var(--ink); }

/* Three+ column tables → stacked cards */
.md-cards { margin: 0 0 16px; }
.md-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.md-cell { padding: 5px 0; }
.md-cell + .md-cell { border-top: 1px solid var(--line); }
.md-key {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal);
  margin-bottom: 2px;
}
.md-val { display: block; font-size: 15px; color: var(--ink); }

/* ---------- Tab bar ---------- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1 1 0;
  background: none;
  padding: 13px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  min-height: 48px;
}
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ---------- Shift checklist ---------- */
.checklist .doc-hero { padding-top: 0; }
.cl-progress {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 4px 0 10px;
}
.cl-cat {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal);
  margin: 20px 2px 6px;
}
.cl-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  text-align: left;
  background: none;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  min-height: 50px;
}
.cl-item:active { background: var(--teal-soft); }
.cl-box {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 2px solid var(--teal);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  margin-top: 1px;
}
.cl-item.done .cl-box { background: var(--teal); }
.cl-text { flex: 1 1 auto; font-size: 16px; line-height: 1.4; color: var(--ink); }
.cl-item.done .cl-text { color: var(--muted); text-decoration: line-through; }
.cl-item.done .cl-text strong { color: var(--muted); }

.cl-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--teal-soft);
  border-radius: 12px;
  padding: 14px;
  margin: 2px 0 10px;
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 16px;
  min-height: 52px;
}
.cl-action:active { background: #d3e7e3; }
.cl-action-arrow { font-size: 26px; color: var(--teal); flex: 0 0 auto; }
.cl-cat-note { font-size: 14px; color: var(--muted); margin: 0 2px 8px; }

.cl-text .app-link {
  color: var(--teal);
  text-decoration: underline;
  font-weight: 700;
}
.cl-item.done .cl-text .app-link { color: var(--muted); }
.cl-footer {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin: 26px 2px 8px;
}

/* ---------- Read-aloud ---------- */
.tts-ico { display: inline-flex; }

/* Light "Listen" trigger on the top bar */
.tts-listen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid #c3ddd8;
  border-radius: 999px;
  padding: 7px 15px 7px 12px;
  font-size: 15px;
  font-weight: 600;
  min-height: 40px;
}
.tts-listen:active { background: #d3e7e3; }

/* Playback controls: a fixed bar directly below the app bar (shown while
   playing). A flex item outside the scroll — stays put with no position:sticky
   (unreliable in iOS PWA scroll containers). */
.tts-controls {
  flex: 0 0 auto;
  display: none; /* JS shows it (flex) while playing */
  align-items: center;
  gap: 6px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 8px 12px;
  z-index: 6;
}
.tts-c {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: none;
  color: var(--teal-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tts-c:active { background: var(--teal-soft); }
.tts-c-main {
  background: var(--teal);
  color: #fff;
}
.tts-c-main:active { background: var(--teal-dark); }
.tts-c-speed {
  margin-left: auto;
  width: auto;
  min-width: 48px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--teal-dark);
  background: var(--teal-soft);
}
.tts-c-stop { color: var(--muted); }

.tts-w.tts-on {
  background: #ffdf8a;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #ffdf8a;
}

/* ---------- Guide search ---------- */
.guide-search-wrap { margin: 0 0 16px; }
.guide-search {
  width: 100%;
  margin: 0;
  padding: 13px 14px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  -webkit-appearance: none;
}
.guide-search:focus { outline: none; border-color: var(--teal); }
.guide-results { margin-bottom: 8px; }
.guide-results-status {
  font-size: 13px;
  color: var(--muted);
  margin: 0 2px 10px;
}
.guide-result {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.guide-result:active { background: var(--teal-soft); }
.guide-result-guide {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--teal);
  margin-bottom: 3px;
}
.guide-result-heading { font-size: 16px; font-weight: 700; color: var(--ink); }
.guide-result-snippet { font-size: 14px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.guide-result mark, .guide-result-heading mark {
  background: #ffdf8a;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.anchor-flash { animation: anchorFlash 1.6s ease; }
@keyframes anchorFlash {
  0%, 30% { background: #fff3cf; }
  100% { background: transparent; }
}

/* ---------------------------- Shopping list ---------------------------- */
.shop-file { display: none; }

.shop-empty {
  text-align: center;
  padding: 28px 8px;
}
.shop-empty-ico { font-size: 46px; display: block; }
.shop-empty h2 { margin: 10px 0 6px; font-size: 22px; }
.shop-empty-sub { color: var(--muted); margin: 0 auto 22px; max-width: 22em; }

.shop-scan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--teal);
  background: #fff;
  color: var(--teal);
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 18px;
  min-height: var(--tap);
  cursor: pointer;
}
.shop-scan.primary {
  background: var(--teal);
  color: #fff;
  width: 100%;
  max-width: 340px;
}
.shop-scan-ico { font-size: 18px; }

.shop-toolbar { margin-bottom: 12px; text-align: center; }
.shop-toolbar .shop-scan { width: 100%; }

/* Secondary "choose a photo" text link under the scan button. */
.shop-pick-link {
  display: inline-block;
  margin-top: 12px;
  background: none;
  border: none;
  padding: 8px 6px;
  color: var(--teal);
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.shop-clear-link {
  display: inline-block;
  margin-top: 4px;
  background: none;
  border: none;
  padding: 6px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

/* Tips panel on the empty shopping page. */
.shop-tips {
  margin: 30px auto 0;
  max-width: 440px;
  background: var(--teal-soft);
  border-radius: 14px;
  padding: 16px 18px;
  text-align: left;
}
.shop-tips-head {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin-bottom: 10px;
}
.shop-tips-list { list-style: none; margin: 0; padding: 0; }
.shop-tips-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 7px 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
}
.shop-tip-ico { flex: 0 0 auto; font-size: 18px; }

.shop-busy {
  text-align: center;
  padding: 48px 8px;
  color: var(--muted);
}
.shop-busy-main { font-size: 17px; color: var(--ink); font-weight: 600; margin: 14px 0 4px; }
.shop-hint { font-size: 14px; color: var(--muted); margin: 0; }
.shop-spinner {
  width: 34px; height: 34px;
  margin: 0 auto;
  border: 3px solid var(--teal-soft);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: shop-spin 0.8s linear infinite;
}
@keyframes shop-spin { to { transform: rotate(360deg); } }

.shop-error {
  background: #fdecec;
  border: 1px solid #f3c6c6;
  color: #a12a2a;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 15px;
}

.shop-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--teal-dark);
}
.shop-cat-ico { font-size: 16px; }
.shop-cat-name { flex: 1 1 auto; }
.shop-cat-count {
  flex: 0 0 auto;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}

.shop-item {
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
}
.shop-item-name { color: var(--ink); }

.shop-foot {
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* --- Shopping list: editing (Phase 3) --- */

/* Toolbar: two side-by-side actions + a links row. */
.shop-actions { display: flex; gap: 10px; }
.shop-actions .shop-scan,
.shop-add { flex: 1 1 0; width: auto; }
.shop-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px;
  min-height: var(--tap);
  cursor: pointer;
}
.shop-add-ico { font-size: 20px; color: var(--teal); font-weight: 700; }
.shop-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}
.shop-links .shop-pick-link,
.shop-links .shop-clear-link { margin-top: 0; }
.shop-link-sep { color: var(--line); }

/* Editable rows: name button (tap to edit) + delete. */
.shop-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-bottom: 1px solid var(--line);
}
.shop-item-name {
  flex: 1 1 auto;
  text-align: left;
  background: none;
  border: none;
  padding: 13px 4px;
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
}
.shop-item-name:active { background: var(--teal-soft); }
.shop-item-del {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}
.shop-item-del:active { color: var(--urgent); }

/* Edit / add sheet. */
.shop-edit-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 16px;
}
.shop-edit-input:focus { outline: none; border-color: var(--teal); }
.shop-edit-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.shop-cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.shop-cat-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.shop-cat-chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.shop-delete-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--urgent);
  font-size: 15px;
  font-weight: 600;
  padding: 10px;
  cursor: pointer;
}

/* Undo toast. */
.toast-undo {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
  max-width: 90vw;
  border-radius: 16px;
  text-align: left;
}
.toast-undo-btn { flex: 0 0 auto; }
.toast-undo-btn {
  background: none;
  border: none;
  color: #7fd8cf;
  font-weight: 800;
  font-size: 15px;
  padding: 2px 4px;
  cursor: pointer;
}

/* --- Shopping list: shared (Phase 4) --- */
.shop-topbar { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.shop-link {
  background: none; border: none; color: var(--teal);
  font-size: 14px; font-weight: 700; padding: 6px 4px; cursor: pointer;
}

/* Deadline banner */
.shop-deadline {
  background: var(--teal-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.shop-deadline.soon { background: #fdf2d8; }
.shop-deadline.urgent { background: #fdecec; }
.shop-deadline-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.shop-deadline-label { font-size: 14px; font-weight: 700; color: var(--teal-dark); }
.shop-deadline.soon .shop-deadline-label { color: #8a6d1a; }
.shop-deadline.urgent .shop-deadline-label { color: #a12a2a; }
.shop-deadline-count { font-size: 15px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.shop-deadline-sub { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* Mark as sent */
.shop-send {
  display: block; width: 100%; margin-top: 22px;
  background: var(--teal); color: #fff;
  border: none; border-radius: 12px;
  padding: 14px; min-height: var(--tap);
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.shop-send:active { background: var(--teal-dark); }
.shop-send-note { margin: 8px 2px 0; font-size: 12px; color: var(--muted); text-align: center; }

/* Archive list */
.shop-archive-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.shop-archive-row:active { background: var(--teal-soft); }
.shop-archive-main { flex: 1 1 auto; }
.shop-archive-date { font-size: 16px; font-weight: 700; color: var(--ink); }
.shop-archive-count { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Archive item view (read-only + select) */
.shop-arch-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
  font-size: 17px; cursor: pointer;
}
.shop-check { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--teal); }
.shop-arch-name { flex: 1 1 auto; color: var(--ink); }
.shop-arch-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.shop-arch-actions .btn { flex: 1 1 auto; }
.btn-primary:disabled { cursor: default; }

/* Deadline is tappable to edit; new-list deadline field. */
.shop-deadline { cursor: pointer; }
.shop-newdl {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--teal-soft); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 16px;
}
.shop-newdl-text { font-size: 14px; font-weight: 700; color: var(--teal-dark); }
.shop-newdl .shop-link { padding: 4px; }

/* Deadline banner: stacked copy layout (Phase 5 copy) */
.shop-deadline-label { display: block; font-size: 15px; line-height: 1.3; }
.shop-deadline-count { display: block; font-size: 20px; margin: 3px 0; white-space: normal; }

/* Bottom Add-item button + archive select-all */
.shop-add-bottom { width: 100%; margin-top: 14px; }
.shop-selectall { font-weight: 700; border-bottom: 2px solid var(--line); }

/* --- Shopping list: Phase 5 additions --- */
/* Top bar: item count/last-edit (left) + Past lists (right) */
.shop-topbar { justify-content: space-between; }
.shop-meta { font-size: 13px; color: var(--muted); }

/* Toolbar row 2: Add item + Clear list on the right */
.shop-actions2 { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.shop-actions2 .shop-add { flex: 1 1 auto; }
.shop-actions2 .shop-clear-link { flex: 0 0 auto; margin: 0; white-space: nowrap; }

/* Accuracy reminder on the processing screen */
.shop-verify-tip {
  display: flex; gap: 10px; text-align: left;
  background: #fdf2d8; border-radius: 12px;
  padding: 12px 14px; margin: 22px auto 0; max-width: 380px;
  font-size: 14px; line-height: 1.4; color: #6b551a;
}
.shop-verify-ico { flex: 0 0 auto; font-size: 18px; }

/* New-item flash */
@keyframes shop-flash {
  0% { background: var(--teal-soft); }
  100% { background: transparent; }
}
.shop-flash { animation: shop-flash 1.8s ease; }

/* Copy for WhatsApp (primary CTA); Mark as sent becomes secondary */
.shop-copy {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 24px;
  background: var(--teal); color: #fff;
  border: none; border-radius: 12px;
  padding: 15px; min-height: var(--tap);
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.shop-copy:active { background: var(--teal-dark); }
.shop-copy-ico { font-size: 18px; }
.shop-send {
  margin-top: 10px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line);
}
.shop-send:active { background: var(--teal-soft); }

/* White list block so the list itself pops against the tinted page. */
.shop-list {
  background: #fff;
  margin: 16px -18px 0;
  padding: 2px 18px 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.shop-list .shop-item:last-child { border-bottom: none; }
.shop-list .shop-cat:first-child { margin-top: 12px; }

.shop-deadline-note { font-size: 13px; color: var(--muted); margin-bottom: 6px; line-height: 1.35; }
.shop-deadline.soon .shop-deadline-note { color: #8a6d1a; }
.shop-deadline.urgent .shop-deadline-note { color: #a12a2a; }

/* Toolbar: one line — Add photo (button) left, Choose photo · Clear list right */
.shop-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 0; text-align: left; }
.shop-toolbar .shop-scan { flex: 0 0 auto; width: auto; padding: 10px 16px; }
.shop-toolbar .shop-links { margin-top: 0; }

/* Add item inside the white list (top & bottom) */
.shop-add-inlist {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--teal);
  font-size: 15px; font-weight: 700;
  padding: 10px; margin: 10px 0;
  cursor: pointer;
}
.shop-add-inlist:active { background: var(--teal-soft); }

/* iOS date inputs ignore width:100% and overflow the modal — constrain them. */
.shop-edit-input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Toolbar (revised): two equal outline buttons fill the row; Clear list below-right */
.shop-toolbar { display: block; margin-bottom: 0; text-align: left; }
.shop-toolbar .shop-actions .shop-scan { flex: 1 1 0; width: auto; padding: 13px 12px; }
.shop-clearrow { text-align: right; margin-top: 8px; }
.shop-clearrow .shop-clear-link { margin: 0; }

/* Offline / connection gating */
.shop-dim { opacity: 0.5; pointer-events: none; }
.shop-offline-banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fdecec; border: 1px solid #f3c6c6; color: #a12a2a;
  border-radius: 12px; padding: 12px 14px;
  margin: 14px 18px 4px; font-size: 14px; line-height: 1.4;
}
.shop-checking {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 14px; margin: 14px 18px 4px;
}
.shop-spinner-sm { width: 18px; height: 18px; border-width: 2px; margin: 0; }

/* Offline banner: retry button */
.shop-offline-body { flex: 1 1 auto; }
.shop-retry {
  margin-top: 10px;
  background: #a12a2a; color: #fff;
  border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.shop-retry:active { background: #872020; }

/* Top meta line: baseline-align with Past lists + more gap above the countdown */
.shop-topbar { align-items: baseline; margin-bottom: 16px; }
.shop-toplinks { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 16px; }

/* ---------- Family sign-in ---------- */
.family-link {
  display: block;
  margin: 22px auto 0;
  background: none;
  border: none;
  color: var(--teal);
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  padding: 10px;
}
.family-link:active { color: var(--teal-dark); }

.pin-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 20px 26px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  position: relative;
  text-align: center;
}
.pin-cancel {
  position: absolute;
  top: 12px;
  left: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  padding: 6px 8px;
}
.pin-title {
  font-size: 19px;
  font-weight: 700;
  margin: 4px 0 6px;
}
.pin-msg {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 18px;
  min-height: 20px;
}
.pin-msg-err { color: var(--urgent); }
.pin-field { position: relative; display: inline-block; }
.pin-boxes { display: flex; gap: 8px; justify-content: center; }
.pin-box {
  width: 38px;
  height: 48px;
  border: 2px solid var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.pin-box.filled { border-color: var(--teal); background: #fff; }
.pin-box.active { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.pin-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--ink); }
/* Real input laid transparently over the boxes so typing shows the numeric keypad. */
.pin-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  margin: 0;
  padding: 0;
  font-size: 16px; /* avoids iOS zoom-on-focus */
  background: transparent;
  color: transparent;
  caret-color: transparent;
}
.pin-shake { animation: pin-shake 0.35s ease; }
@keyframes pin-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* ---------- Family carer pager (review checklists) ---------- */
.carer-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--teal-soft);
  border-radius: 12px;
  padding: 8px 8px;
  margin-bottom: 16px;
}
.carer-pager-arrow {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}
.carer-pager-arrow:active { background: var(--teal); color: #fff; }
.carer-pager-mid { flex: 1 1 auto; text-align: center; }
.carer-pager-name { font-weight: 700; font-size: 16px; color: var(--teal-dark); }
.carer-pager-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Read-only checklist rows (family view) */
.cl-item-ro { cursor: default; }
.cl-item-ro:active { background: transparent; }
.cl-item-ro .cl-box { border-style: dashed; }

/* ============================ Shopping data (family) ============================ */
/* Family-only warning strip above the dashboard. */
.shopdata-warn {
  flex: 0 0 auto;
  background: #fdf6d8;
  color: #7a5c00;
  border-bottom: 1px solid #efe3a8;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  padding: 7px 12px;
}

.shopdata {
  --sd-pad: 12px;
  --sd-mono: ui-monospace, SFMono-Regular, Menlo, "Roboto Mono", monospace;
  --sd-rule-soft: #e7efed;
  padding: 16px var(--sd-pad) calc(40px + var(--safe-bottom));
  color: var(--ink);
  font-size: 15px;
}
.sd-loading { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.sd-err { color: var(--ink); }
.sd-retry {
  display: inline-block; margin-top: 12px; background: var(--teal); color: #fff;
  border: none; border-radius: 999px; padding: 10px 20px; font-size: 14px; font-weight: 600;
}

/* full-bleed helper: data containers run edge-to-edge to maximise width */
.sd-card, .sd-stats, .sd-rows, .sd-strip {
  margin-left: calc(-1 * var(--sd-pad));
  margin-right: calc(-1 * var(--sd-pad));
}

.sd-h1 {
  font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05;
  margin: 0 0 14px; padding-bottom: 12px; border-bottom: 2px solid var(--ink);
}
.sd-h2 {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em;
  margin: 0 0 4px; color: var(--ink);
}
.sd-note { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.sd-sec { margin-bottom: 30px; }

/* Time filter sticks to the top of the scroller. Full-bleed so full-width
   content scrolling underneath is covered on both edges. */
.sd-filterbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  margin-left: calc(-1 * var(--sd-pad));
  margin-right: calc(-1 * var(--sd-pad));
  padding: 8px var(--sd-pad);
  box-shadow: 0 4px 8px -6px rgba(20, 32, 31, 0.35);
}
.sd-switch { display: flex; width: 100%; border: 1px solid var(--ink); background: #fff; }
.sd-switch button {
  flex: 1; min-width: 0; font-family: var(--sd-mono); font-size: 12px; letter-spacing: 0.02em;
  padding: 9px 2px; border: 0; border-right: 1px solid var(--line);
  background: transparent; color: var(--muted); min-height: 38px;
}
.sd-switch button:last-child { border-right: 0; }
.sd-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.sd-range {
  font-family: var(--sd-mono); font-size: 11px; color: var(--muted); margin: 10px 0 20px;
  letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* stats */
.sd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-left: 0; border-right: 0; }
.sd-stat { background: #fff; padding: 12px 11px; min-width: 0; }
.sd-stat .k { font-family: var(--sd-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); line-height: 1.3; }
.sd-stat .v { font-family: var(--sd-mono); font-weight: 600; font-size: 20px; letter-spacing: -0.03em; margin-top: 5px; line-height: 1.1; }
.sd-stat .d { font-family: var(--sd-mono); font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.35; overflow-wrap: anywhere; }

/* charts */
.sd-card { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sd-chart { position: relative; padding: 12px 4px 6px; touch-action: pan-y; }
.sd-chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.sd-ax { font-family: var(--sd-mono); font-size: 9.5px; fill: var(--muted); }
.sd-gl { stroke: var(--sd-rule-soft); stroke-width: 1; }
.sd-gl-base { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }

.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  font-family: var(--sd-mono); font-size: 10.5px; line-height: 1.5; padding: 8px 9px; border-radius: 4px;
  box-shadow: 0 5px 16px rgba(20, 24, 27, 0.32); z-index: 5; max-width: 200px;
}
.tip b { display: block; font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase; opacity: 0.65; margin-bottom: 5px; font-weight: 500; }
.tip span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip i { width: 8px; height: 8px; flex: none; border-radius: 1px; }
.tip em { margin-left: auto; font-style: normal; font-weight: 600; padding-left: 12px; }

.sd-legend { display: flex; gap: 10px 14px; flex-wrap: wrap; font-family: var(--sd-mono); font-size: 10px; color: var(--muted); padding: 10px 12px 12px; border-top: 1px solid var(--sd-rule-soft); }
.sd-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 5px; vertical-align: -1px; border-radius: 1px; }
.sd-legend i.ln { height: 3px; width: 12px; border-radius: 0; vertical-align: 3px; }
.sd-hint { font-family: var(--sd-mono); font-size: 9.5px; color: var(--muted); padding: 0 12px 11px; letter-spacing: 0.03em; }

.sd-toggle { display: flex; border: 1px solid var(--line); margin-bottom: 10px; width: 100%; }
.sd-toggle button { flex: 1; font-family: var(--sd-mono); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; padding: 10px 4px; border: 0; background: #fff; color: var(--muted); border-right: 1px solid var(--line); min-height: 40px; }
.sd-toggle button:last-child { border-right: 0; }
.sd-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Claude's read panels */
.sd-ai { background: var(--teal-soft); border: 1px solid #cfe4e0; border-left: 3px solid var(--teal); margin-top: 14px; }
.sd-ai .hd { display: flex; align-items: center; gap: 7px; width: 100%; background: transparent; border: 0; font-family: var(--sd-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.11em; color: var(--teal-dark); padding: 13px 12px; text-align: left; min-height: 44px; }
.sd-ai .hd > span { flex: 1; min-width: 0; }
.sd-ai .hd svg { width: 13px; height: 13px; flex: none; }
.sd-ai .hd .chev { width: 16px; height: 16px; opacity: 0.75; transition: transform 0.18s ease; }
.sd-ai .hd[aria-expanded="true"] .chev { transform: rotate(180deg); }
.sd-ai .bd { padding: 0 12px 14px; }
.sd-ai p { margin: 0; font-size: 14px; line-height: 1.6; }
@media (prefers-reduced-motion: reduce) { .sd-ai .hd .chev { transition: none; } }

/* list rows */
.sd-rows { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.sd-r { padding: 11px 12px; border-bottom: 1px solid var(--sd-rule-soft); }
.sd-r:last-child { border-bottom: 0; }
.sd-r-top { display: flex; align-items: flex-start; gap: 8px; }
.sd-r-nm { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.sd-r-raw { font-family: var(--sd-mono); font-size: 10px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.sd-r-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; font-family: var(--sd-mono); font-size: 11px; color: var(--muted); }
.sd-r-meta b { color: var(--ink); font-weight: 600; }
.sd-bar { height: 4px; background: var(--sd-rule-soft); margin-top: 8px; }
.sd-bar i { display: block; height: 100%; background: #b45309; opacity: 0.8; }
.sd-tag { font-family: var(--sd-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 5px; border: 1px solid currentColor; white-space: nowrap; flex: none; margin-top: 1px; }
.t-high { color: #b45309; } .t-medium { color: #8a6a2b; } .t-medical { color: #5b4b8a; }
.t-low, .t-none, .t-na { color: var(--muted); }
.up { color: #9a2b26; } .down { color: var(--teal); } .flat { color: var(--muted); }

/* price watch strip */
.sd-strip { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 16px 13px 18px; font-family: var(--sd-mono); font-size: 12px; }
.sd-strip-head { text-align: center; border-bottom: 1px dashed var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.sd-strip-head b { font-size: 11px; letter-spacing: 0.1em; }
.sd-strip-head span { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.sd-pw { padding: 6px 0; border-bottom: 1px dotted var(--sd-rule-soft); }
.sd-pw:last-of-type { border-bottom: 0; }
.sd-pw-a { display: flex; align-items: baseline; gap: 8px; }
.sd-pw-a span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.sd-pw-a b { font-weight: 600; white-space: nowrap; font-size: 12px; }
.sd-pw-a b.swing { color: #b45309; }
.sd-pw-b { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.sd-strip-foot { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; text-align: center; font-size: 10px; color: var(--muted); line-height: 1.5; }

/* filters */
.sd-tbar { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.shopdata input[type="search"], .shopdata select {
  width: 100%; font-family: var(--sd-mono); font-size: 14px; padding: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); border-radius: 8px; min-height: 44px; -webkit-appearance: none; appearance: none;
}
.shopdata select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 20px, calc(100% - 10px) 20px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.shopdata input:focus, .shopdata select:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.sd-sortbar { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.sd-sortbar button { font-family: var(--sd-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 9px 11px; border: 1px solid var(--line); background: #fff; color: var(--muted); white-space: nowrap; min-height: 36px; border-radius: 6px; }
.sd-sortbar button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.sd-more { width: 100%; font-family: var(--sd-mono); font-size: 12px; padding: 13px; border: 1px solid var(--ink); background: #fff; color: var(--ink); margin-top: 10px; min-height: 46px; border-radius: 8px; }

.sd-foot { border-top: 1px solid var(--line); padding-top: 18px; font-size: 12.5px; color: var(--muted); }
.sd-foot p { margin: 0 0 10px; }
.sd-foot-upd { font-size: 11.5px; }

@media (max-width: 359px) {
  .shopdata { --sd-pad: 10px; }
  .sd-h1 { font-size: 22px; }
  .sd-stat .v { font-size: 18px; }
  .sd-ai p { font-size: 13.5px; }
}

/* ---------- Water tracker (first step of the care log) ---------- */
.water-ask { padding-bottom: 4px; }
.water-sub { color: var(--muted); font-size: 14px; margin: 2px 0 16px; line-height: 1.4; }
.water-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  margin-bottom: 14px;
  text-align: center;
}
.water-person {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 17px; color: var(--teal-dark); margin-bottom: 12px;
}
.water-emoji { font-size: 22px; }
.water-counter { display: flex; align-items: center; justify-content: center; gap: 12px; }
.water-btn {
  width: 66px; height: 66px; flex: 0 0 auto;
  border-radius: 999px; border: 2px solid var(--teal);
  background: var(--teal-soft); color: var(--teal-dark);
  font-size: 32px; line-height: 1; display: grid; place-items: center;
  transition: background 0.1s, color 0.1s, transform 0.08s;
}
.water-btn:active { background: var(--teal); color: #fff; transform: scale(0.94); }
.water-count {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.water-count-top { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.water-count-top.lead-one { gap: 0; }
.water-count-top.lead-one .water-num { margin-left: -6px; }
.water-drop { font-size: 49px; line-height: 1; }
.water-num {
  font-size: 54px; font-weight: 800; color: var(--ink);
  line-height: 1; font-variant-numeric: tabular-nums;
}
.water-unit { font-size: 14px; color: var(--muted); letter-spacing: 0.02em; }

/* Water card Edit link sits at the right of the summary card header. */
.sum-edit.water-edit { margin-left: auto; }

/* Guides placeholder (shown while there's no guide content) */
.guide-empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 24px;
}
.guide-empty-ico { font-size: 40px; opacity: 0.7; margin-bottom: 12px; }
.guide-empty p { font-size: 15px; margin: 0; }
