/* Haversack: a calm canvas-and-olive utility. Mobile first (390px),
   a centered 560px column on wider screens. */

:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --surface: #fdfcf8;
  --surface-2: #ebe7dc;
  --field: #f8f6f0;
  --ink: #26261f;
  --ink-2: #636257;
  --ink-3: #6f6d62; /* small secondary text: still 4.5:1 on --bg */
  --line: #e3ded1;
  --line-strong: #cdc7b7;
  --ring: #878474; /* the check-off ring is a control: 3:1 against cards */
  --olive: #5b6634;
  --olive-press: #4b552a;
  --olive-ink: #fbfaf4;
  --olive-soft: #e7e9d5;
  --olive-soft-ink: #434b23;
  --olive-ring: rgba(91, 102, 52, 0.22);
  --amber: #96591b;
  --amber-soft: #f5e8d4;
  --danger: #a3392a;
  --seg-on: var(--surface);
  --banner-bg: var(--olive);
  --banner-ink: var(--olive-ink);
  --toast-bg: #2a2a22;
  --toast-ink: #f3f0e8;
  --toast-action: #cdd8a2;
  --backdrop: rgba(30, 28, 18, 0.38);
  --shadow: 0 1px 2px rgba(60, 52, 24, 0.05), 0 2px 10px rgba(60, 52, 24, 0.05);
  --shadow-lift: 0 10px 40px rgba(40, 34, 14, 0.18);
  --radius: 16px;
  --radius-sm: 12px;
  --tabbar-h: 60px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23636257' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #191a15;
    --surface: #23241e;
    --surface-2: #2e2f28;
    --field: #1c1d18;
    --ink: #ecebe2;
    --ink-2: #aeac9e;
    --ink-3: #9a998c;
    --line: #34352d;
    --line-strong: #4a4b41;
    --ring: #7c7b70;
    --olive: #aab879;
    --olive-press: #bcc98f;
    --olive-ink: #191b10;
    --olive-soft: #30351f;
    --olive-soft-ink: #cfdaa6;
    --olive-ring: rgba(170, 184, 121, 0.28);
    --amber: #e3ad6c;
    --amber-soft: #3a2f1f;
    --danger: #ec8d7a;
    --seg-on: #45463c;
    --banner-bg: #3f4828;
    --banner-ink: #e6edcf;
    --toast-bg: #ecebe2;
    --toast-ink: #1f2019;
    --toast-action: #4f5a28;
    --backdrop: rgba(0, 0, 0, 0.55);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 10px 40px rgba(0, 0, 0, 0.5);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aeac9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body.sheet-open { overflow: hidden; }

h1, h2, h3, p { margin: 0; }

a { color: var(--olive); }

button, input, select, textarea { font: inherit; color: inherit; }

button { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 2px;
}

/* Headings take focus only as a place to land when the focused thing went
   away (a checked-off row, a closed sheet); no ring for that. */
h1[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }

.wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.34em;
  margin-right: -0.34em;
  color: var(--olive);
  text-transform: uppercase;
}

.boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.noscript { padding: 24px; text-align: center; }

/* ---------- shell ---------- */

.shell {
  max-width: 560px;
  margin: 0 auto;
  padding:
    env(safe-area-inset-top)
    max(var(--gutter), env(safe-area-inset-right))
    calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 40px)
    max(var(--gutter), env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding-top: 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  min-height: 44px;
  color: var(--olive);
}

.brand-icon { width: 20px; height: 20px; stroke-width: 1.9; }

.topbar-household {
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

.title {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 10px 0 16px;
}

.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 16px;
}

.screen-head .title { margin: 0; }

.lede {
  color: var(--ink-2);
  font-size: 16px;
  margin: -8px 0 18px;
}

.section { margin-top: 28px; }

.section-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 28px 4px 10px;
}

.section .section-title { margin-top: 0; }

.section-note {
  font-size: 14px;
  color: var(--ink-2);
  margin: -2px 4px 12px;
}

.sub-title {
  font-size: 15px;
  font-weight: 650;
  margin: 20px 0 8px;
}

.section-actions { margin-top: 12px; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.tabbar-inner {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabbar-h);
  color: var(--ink-3);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tab.is-active { color: var(--olive); }

.tab-icon { position: relative; display: inline-flex; }
.tab-icon .icon { width: 24px; height: 24px; }

.tab-dot {
  position: absolute;
  top: -1px;
  right: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 2px var(--surface);
  display: none;
}

.tab.has-dot .tab-dot { display: block; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.15s, color 0.15s, opacity 0.15s, transform 0.08s;
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn .icon { width: 18px; height: 18px; stroke-width: 2; }

.btn-primary { background: var(--olive); color: var(--olive-ink); }
.btn-primary:hover:not(:disabled) { background: var(--olive-press); }

.btn-secondary { background: var(--surface-2); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--surface-2) 80%, var(--ink) 6%); }

.btn-ghost { background: transparent; color: var(--olive); }
.btn-ghost:hover:not(:disabled) { background: var(--olive-soft); }

.btn-danger { color: var(--danger); }
.btn-danger.is-armed { background: var(--danger); color: var(--surface); }

.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-block { display: flex; width: 100%; min-height: 50px; font-size: 16px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.link-btn {
  background: none;
  border: 0;
  padding: 10px 4px;
  color: var(--olive);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.muted-link { color: var(--ink-3); font-weight: 500; font-size: 14px; }
.muted-link.is-armed { color: var(--danger); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; min-width: 0; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 2px 6px;
}

.hint {
  font-size: 13px;
  color: var(--ink-3);
  margin: 6px 2px 0;
}

.hint-strong { color: var(--ink-2); }

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
  line-height: 1.3;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder { color: var(--ink-3); opacity: 1; }

.input:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px var(--olive-ring);
}

.textarea { padding: 12px 14px; min-height: 76px; resize: vertical; }

.select {
  padding-right: 40px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

.mono { font-family: var(--mono); font-size: 14px; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.affix { position: relative; }

.affix-text {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
  font-size: 16px;
}

.affix-pre { left: 14px; }
.affix-suf { right: 14px; }
.affix.has-prefix .input { padding-left: 28px; }
.affix.has-suffix .input { padding-right: 34px; }

/* minmax(0, …) so an input's intrinsic width can't push a column past a
   320px screen. */
.row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.inline-row {
  display: flex;
  gap: 8px;
}

.inline-row .input { flex: 1; min-width: 0; }
.inline-row .btn { min-height: 48px; }

.retailer-picker { display: grid; gap: 8px; }

.form-error {
  color: var(--danger);
  font-size: 14px;
  margin: 8px 2px 12px;
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.switch:checked { background: var(--olive); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.6; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  min-height: 56px;
  cursor: pointer;
}

.toggle-plain { padding: 6px 2px 14px; }
.toggle-text { display: grid; gap: 2px; }
.toggle-title { font-weight: 550; }
.toggle-sub { font-size: 13px; color: var(--ink-2); }

/* segmented controls */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.seg-btn, .seg-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 4px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.seg-btn[aria-pressed="true"],
.seg-input:checked + .seg-label {
  background: var(--seg-on);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--line);
}

.seg-input { position: absolute; opacity: 0; pointer-events: none; }
.seg-input:focus-visible + .seg-label { outline: 2px solid var(--olive); outline-offset: 1px; }

.seg-autonomy .seg-label { min-height: 48px; }

/* ---------- cards & lists ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 18px;
  font-weight: 650;
  margin-bottom: 4px;
}

.card > .muted,
.card > .card-text { margin-bottom: 16px; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list > li + li { border-top: 1px solid var(--line); }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-style: normal;
  white-space: nowrap;
}

.chip-olive { background: var(--olive-soft); color: var(--olive-soft-ink); }
.chip-warn { background: var(--amber-soft); color: var(--amber); }
.chip-muted { margin-left: 8px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.notice {
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 550;
  margin: 0 0 14px;
}

.notice-info {
  background: var(--olive-soft);
  color: var(--olive-soft-ink);
}

.notice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  margin-top: 14px;
}

.notice-row .btn { color: var(--amber); }
.notice-row .btn:hover:not(:disabled) { background: transparent; text-decoration: underline; }

.empty {
  text-align: center;
  padding: 44px 24px 32px;
  color: var(--ink-2);
}

.empty-card { text-align: center; padding: 32px 20px 24px; }
.empty-card .btn { margin-top: 16px; }

.empty-mark {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--olive-soft);
  color: var(--olive);
  margin-bottom: 14px;
}

.empty-mark .icon { width: 28px; height: 28px; stroke-width: 1.6; }
.empty-title { font-size: 17px; font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.empty-text { font-size: 15px; max-width: 300px; margin: 0 auto; }

.loading-row,
.loading-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-2);
  padding: 28px 0;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0.75;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- List screen ---------- */

.add {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.add-field { position: relative; flex: 1; min-width: 0; }

.add-input {
  min-height: 54px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 17px;
  box-shadow: var(--shadow);
}

.add-field.has-mic .add-input { padding-right: 52px; }

.add-btn { min-height: 54px; border-radius: 14px; padding: 0 20px; font-size: 16px; }

.mic {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.mic:hover { background: var(--surface-2); }

.mic.is-listening {
  background: var(--olive);
  color: var(--olive-ink);
  animation: listen 1.4s ease-in-out infinite;
}

@keyframes listen {
  0%, 100% { box-shadow: 0 0 0 0 var(--olive-ring); }
  50% { box-shadow: 0 0 0 7px var(--olive-ring); }
}

.add-error { margin: 10px 4px 0; }

.ai-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 4px 0;
  font-size: 13px;
  color: var(--ink-2);
}

.screen-head + .js-ai-note .ai-note { margin: -6px 4px 14px; }

.ai-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.questions { display: grid; gap: 12px; margin-top: 16px; }
.questions:empty { display: none; }

#region-banner:not(:empty) { margin-top: 16px; }
#region-needs { margin-top: 16px; }

.qcard { padding: 14px 16px 16px; }

.qcard-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.qcard-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 14px;
  font-weight: 750;
  flex: none;
}

.qcard-title { font-weight: 650; font-size: 17px; flex: 1; min-width: 0; }
.qcard-title .badge { margin-left: 8px; vertical-align: 1px; }
.qcard-who { font-size: 13px; color: var(--ink-3); white-space: nowrap; }

.qcard-text { color: var(--ink-2); font-size: 16px; }
.qcard-text strong { color: var(--ink); font-weight: 600; }
.qcard-detail { font-size: 14px; color: var(--ink-3); margin-top: 4px; }

.qcard-body:not(:empty) { margin-top: 14px; }

.qactions { display: flex; flex-wrap: wrap; gap: 8px; }
.qactions .btn-primary { min-width: 76px; }
.qcard > .qactions { margin-top: 14px; }

.qform { padding-top: 14px; border-top: 1px solid var(--line); }
.qform .qactions { margin-top: 4px; }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-radius: var(--radius);
  background: var(--banner-bg);
  color: var(--banner-ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.banner-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.banner-head { font-weight: 650; }
.banner-detail { font-size: 14px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.banner-chevron { width: 20px; height: 20px; opacity: 0.85; }

.need { display: flex; align-items: stretch; }

.check {
  flex: none;
  width: 54px;
  display: flex;
  justify-content: center;
  padding-top: 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ink-2);
}

span.check { cursor: default; }

.ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--ring);
  transition: background-color 0.18s, border-color 0.18s;
}

.ring-check {
  width: 14px;
  height: 14px;
  stroke-width: 3;
  color: var(--olive-ink);
  opacity: 0;
  transition: opacity 0.18s;
}

button.check:hover .ring { border-color: var(--olive); }

.need.is-done .ring,
.ring-done { background: var(--olive); border-color: var(--olive); }
.need.is-done .ring-check,
.ring-done .ring-check { opacity: 1; }
.need.is-done .need-title { color: var(--ink-3); text-decoration: line-through; }

.ring-ordering { border-color: var(--olive); border-style: dashed; }
.ring-ordering::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--olive);
}

.need-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 15px 16px 15px 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.need-top {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.need-title {
  font-size: 17px;
  font-weight: 550;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.need-sub {
  font-size: 14px;
  color: var(--ink-2);
}

/* The product is the useful part ("Dawn Free & Clear Dish Soap, 24 oz"), so
   it wraps to a second line rather than being cut; the store never splits. */
.subline {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  max-width: 100%;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.subline-tail { white-space: nowrap; }

.need-note { font-size: 14px; font-style: italic; color: var(--ink-2); overflow-wrap: anywhere; }
.need-main .chip { margin-top: 3px; }

.need.is-ordering .need-title { color: var(--ink-2); }

.need.is-pending { color: var(--ink-3); }
.need.is-pending .check { cursor: default; color: var(--olive); padding-top: 19px; }
.need.is-pending .need-main { cursor: default; }
.need.is-pending .need-title { color: var(--ink-2); }

.recent-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.recent-toggle .count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  text-align: center;
}

.recent-toggle .chevron { width: 18px; height: 18px; margin-left: auto; transition: transform 0.2s; }
.recent-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.recent-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px 10px 15px;
  min-height: 56px;
}

.recent-row .ring { width: 22px; height: 22px; flex: none; }
.recent-text { flex: 1; min-width: 0; display: grid; }
.recent-title { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.recent-sub { font-size: 13px; color: var(--ink-3); }

/* ---------- sheet ---------- */

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.sheet-root.is-open { pointer-events: auto; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  opacity: 0;
  transition: opacity 0.22s;
}

.sheet-root.is-open .sheet-backdrop { opacity: 1; }

.sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lift);
  padding: 8px max(20px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  transform: translate(-50%, 100%);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet:focus { outline: none; }

.sheet-root.is-open .sheet { transform: translate(-50%, 0); }

.sheet-grab {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: var(--line-strong);
  margin: 0 auto 10px;
}

.sheet-close { position: absolute; top: 10px; right: 10px; }

.sheet-head { padding: 4px 44px 16px 0; }
.sheet-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.sheet-sub { color: var(--ink-2); margin-top: 4px; }
.sheet-meta { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.sheet-quote { color: var(--ink-2); font-style: italic; font-size: 14px; margin-top: 6px; }

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.sheet-actions .btn { min-height: 50px; font-size: 16px; }

.sheet-form { border-top: 1px solid var(--line); padding-top: 18px; }

.sheet-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-top: 16px;
  padding: 0 4px;
  border-top: 1px solid var(--line);
  color: var(--olive);
  font-weight: 600;
  text-decoration: none;
}

.sheet-link .icon { width: 18px; height: 18px; }

.sheet-danger { margin-top: 12px; }

@media (min-width: 640px) {
  .sheet {
    bottom: 50%;
    border-radius: 22px;
    max-height: 86vh;
    transform: translate(-50%, 60%);
    opacity: 0;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
  }
  .sheet-root.is-open .sheet { transform: translate(-50%, 50%); opacity: 1; }
  .sheet-grab { visibility: hidden; }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: min(528px, calc(100% - 32px));
  padding: 12px 8px 12px 16px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 15px;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast:not(:has(.toast-action)) { padding-right: 16px; }

body.has-tabbar .toast { bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 14px); }

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-text { flex: 1; min-width: 0; }

.toast-action {
  border: 0;
  background: transparent;
  color: var(--toast-action);
  font-weight: 700;
  padding: 8px 10px;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- Plan screen ---------- */

#region-plan { transition: opacity 0.2s; }
#region-plan.is-dimmed { opacity: 0.5; pointer-events: none; }

.working { margin-bottom: 16px; }
.working-row { display: flex; align-items: center; gap: 10px; color: var(--olive); margin-bottom: 6px; }
.working-row strong { color: var(--ink); }
.working .muted { font-size: 14px; }

.progress {
  position: relative;
  height: 3px;
  margin-top: 14px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--olive-soft);
}

.progress::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--olive);
  animation: slide 1.5s ease-in-out infinite;
}

@keyframes slide { to { left: 100%; } }

.plan-summary { font-size: 17px; line-height: 1.45; }
.plan-meta { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

.order { padding: 0; overflow: hidden; }

.order-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}

.order-name { font-size: 18px; font-weight: 700; }
.order-total { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.order-est { font-size: 13px; font-weight: 500; color: var(--ink-3); }

.lines { list-style: none; margin: 0; padding: 0 16px; }

.line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 4px 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.line-text { display: grid; min-width: 0; }
.line-product { overflow-wrap: anywhere; }
.line-title { font-size: 13px; color: var(--ink-3); }
.line-qty { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.line-price { font-variant-numeric: tabular-nums; text-align: right; min-width: 56px; }

.order-note,
.order-reason {
  font-size: 14px;
  color: var(--ink-2);
  padding: 0 16px;
}

.order-note { padding-top: 10px; border-top: 1px solid var(--line); }
.order-reason { padding-top: 4px; }
.lines + .order-reason { padding-top: 10px; border-top: 1px solid var(--line); }

.order-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 16px;
}

.order > .order-reason:last-child,
.order > .order-note:last-child { padding-bottom: 16px; }

/* An approved (or otherwise settled) order folds to a summary. */
.order.is-decided { padding-bottom: 14px; }
.order.is-decided .order-head { padding-bottom: 4px; }
.order-items { font-size: 14px; color: var(--ink-2); padding: 0 16px; }

.order-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.order-status.is-ok { color: var(--olive); }
.order-status .icon { width: 16px; height: 16px; stroke-width: 2.4; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  min-width: 0;
  padding: 7px 10px 7px 12px;
  border: 0;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
}

.pill-text { min-width: 0; }
.pill .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.pill .chevron { flex: none; stroke-width: 2.2; transition: transform 0.2s; }
.pill[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.pill-ok { background: var(--olive-soft); color: var(--olive-soft-ink); }
.pill-off { background: var(--surface-2); color: var(--ink-2); }

.checks {
  list-style: none;
  margin: 0;
  padding: 4px 16px 16px;
  display: grid;
  gap: 10px;
}

.check-item { display: flex; gap: 10px; font-size: 14px; }
.check-mark { flex: none; padding-top: 1px; }
.check-mark .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.check-item.is-ok .check-mark { color: var(--olive); }
.check-item.is-fail .check-mark { color: var(--danger); }
.check-text { display: grid; }
.check-label { font-weight: 600; }
.check-detail { color: var(--ink-2); }

.approve-all { margin-top: 16px; }
.approve-all .hint { margin-top: 10px; }

.plain-row { display: grid; gap: 3px; padding: 14px 16px; }
.plain-title { font-weight: 600; }
.plain-sub { font-size: 14px; color: var(--ink-2); }

.row-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  min-height: 44px;
  padding: 0;
  color: var(--olive);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.row-link .icon { width: 16px; height: 16px; stroke-width: 2.2; }

.row-answered { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.row-answered .btn { padding: 0 10px; }

.dismiss { margin-top: 18px; }

.checkout .stack { gap: 14px; }

.co .order-head { padding: 0 0 2px; }
.co-meta { font-size: 13px; color: var(--ink-3); }

.co-lines { list-style: none; margin: 12px 0 0; padding: 0; }

/* The store link sits beside the details when there's room and drops to its
   own line on narrow phones instead of pushing the card wider. */
.co-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.co-product { flex: 1 0 100%; overflow-wrap: anywhere; }
.co-sub { flex: 1 1 8em; min-width: 0; font-size: 13px; color: var(--ink-2); }
.co-sub > span { white-space: nowrap; }
.co-link { flex: none; margin: 6px 0 0 auto; }

.placed {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.placed-title { font-weight: 600; margin-bottom: 12px; }
.placed .field { margin-bottom: 12px; }

.co-diff { margin: 0 0 12px; }
.co-diff .hint { margin: 0 2px 4px; }
.co-diff-line { padding-top: 10px; }
.co-diff-line + .co-diff-line { border-top: 1px solid var(--line); }
.co-diff-title { font-size: 14px; font-weight: 600; margin: 0 2px 8px; }

.co-diff-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 7.5em);
  gap: 10px;
}

.placed-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-row { display: grid; gap: 2px; padding: 12px 16px; }
.history-main { font-size: 15px; }
.history-meta { font-size: 13px; color: var(--ink-3); }
.history-row.is-cancelled .history-main { color: var(--ink-3); }

/* ---------- Items screen ---------- */

#region-suggestions:not(:empty) { margin-bottom: 16px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 14px 16px;
  min-height: 64px;
  color: inherit;
  text-decoration: none;
}

.item-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.item-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-name { font-size: 17px; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.item-sub { font-size: 14px; color: var(--ink-2); }
.item-meta { font-size: 13px; color: var(--ink-3); }

.aut {
  flex: none;
  margin-left: auto;
  font-size: 12px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.aut-full, .aut-exact { background: var(--olive-soft); color: var(--olive-soft-ink); }
.aut-never { color: var(--ink-3); }

.row-chevron { width: 18px; height: 18px; color: var(--ink-3); }

/* ---------- Household screen ---------- */

.member,
.invite-row,
.token-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 10px 16px;
  min-height: 64px;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--olive-soft);
  color: var(--olive-soft-ink);
  font-size: 14px;
  font-weight: 700;
}

.member-text,
.invite-text,
.token-text { flex: 1; min-width: 0; display: grid; gap: 1px; }

.member-name { font-weight: 600; overflow-wrap: break-word; }

.member-sub {
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invites, .tokens { margin-top: 12px; }

.ship-list { margin-bottom: 12px; }

/* Store and its minimum on one line; the explanation and the shortcut
   under them at full width, so nothing gets squeezed on a 320px phone. */
.ship-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  align-items: center;
  column-gap: 12px;
  padding: 12px 12px 4px 16px;
}

.ship-name { font-weight: 600; overflow-wrap: break-word; }
.ship-sub { grid-column: 1 / -1; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.ship-free { grid-column: 1 / -1; justify-self: start; padding: 6px 0; min-height: 40px; font-size: 14px; }
.token-label { font-weight: 600; }

.once {
  border: 1px solid var(--olive);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--olive-soft) 55%, var(--surface));
  padding: 16px;
}

.card .once { margin-top: 14px; }
.section > .once { margin-top: 12px; }
.once-title { font-weight: 650; margin-bottom: 6px; }
.once .hint { margin: 0 0 12px; color: var(--ink-2); }
.once .btn-row + .hint { margin: 10px 0 0; }
.copy-input { background: var(--surface); }

.prose p + p { margin-top: 10px; }
.prose > p { color: var(--ink-2); }

.token-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.token-form .input { margin-bottom: 12px; }

.steps {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 10px;
  font-size: 15px;
}

.steps > li { padding-left: 2px; }
.steps > li::marker { color: var(--olive); font-weight: 700; }

.kv {
  list-style: none;
  margin: 8px 0 0;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
}

.kv li { display: grid; gap: 1px; }
.kv-key { font-size: 12px; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.kv-val { overflow-wrap: anywhere; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  word-break: break-all;
}

.code {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--field);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  color: var(--ink);
}

.siri {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 16px 0 4px;
  font-size: 15px;
  font-weight: 550;
}

.siri .arrow { color: var(--olive); }

.details { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }

.details summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--olive);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.details summary::-webkit-details-marker { display: none; }
.details summary::after { content: "+"; margin-left: auto; font-size: 20px; font-weight: 400; }
.details[open] summary::after { content: "–"; }
.details .steps { margin-top: 6px; }
.details .code { margin-top: 12px; }

.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.account { padding-top: 8px; }
.account .muted { margin-bottom: 10px; }

/* ---------- solo screens (auth, onboarding, invite) ---------- */

.solo {
  max-width: 440px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 48px)
    max(20px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom) + 40px)
    max(20px, env(safe-area-inset-left));
  display: grid;
  gap: 16px;
}

.solo-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.solo-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--olive);
  color: var(--olive-ink);
}

.solo-mark .icon { width: 26px; height: 26px; stroke-width: 1.7; }

.solo-title {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.solo .lede { margin: -6px 0 8px; font-size: 17px; }

.solo-foot {
  text-align: center;
  font-size: 14px;
  color: var(--ink-3);
}

.solo-foot .link-btn { font-size: 14px; padding: 10px 2px; }

.auth-form .btn-block { margin-top: 6px; }
.card > .btn-block + .btn-block { margin-top: 10px; }
.auth-form > .hint { margin-top: 12px; }
.solo .email-address { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }

/* The emailed code: big, spaced digits that line up. */
.code-input {
  min-height: 56px;
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.32em;
  text-align: center;
  padding: 0 10px 0 calc(10px + 0.32em);
}

.code-input::selection { background: var(--olive-soft); color: var(--olive-soft-ink); }
.solo .join-note { margin-top: -10px; }

.auth-note {
  background: var(--amber-soft);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 15px;
}

/* Stacked, so the countdown changing length never reflows the row. */
.auth-links { display: grid; justify-items: center; }

.auth-links .link-btn { font-size: 15px; min-height: 44px; }
.link-btn:disabled { color: var(--ink-3); cursor: default; }
.countdown { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
