/* Preppers — DESIGN.md v2 (2026-11-10). One stylesheet after tokens.css; no page-level overrides.
   Order: base → shell → page heading → file box → cards → stock card → products → pages → dialog → print.
   Breakpoints: 700 / 920 / 1100|1101 / 1199|1200 only (+ max-height:480 for the save bar,
   container queries inside components). */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  font-family: var(--font-family);
  color: var(--color-ink);
  background: var(--color-surface);
  letter-spacing: 0;
  scroll-padding-top: calc(var(--header-h, 0px) + 16px);
}
body {
  margin: 0;
  min-width: 320px;
  /* Entry animations may move beyond the viewport; clip without creating a scroll container. */
  overflow-x: clip;
  font-size: var(--font-body);
  line-height: var(--leading-body);
  background: var(--color-surface);
  isolation: isolate;
}
/* The coastal town and forest: a static background layer at opacity .6, never interactive. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .6;
  background: url("../assets/coastal-background.png") center / cover no-repeat;
}
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
h1, h2, h3, h4 { line-height: var(--leading-heading); }
p, li, dd, td { word-break: normal; line-break: strict; }
h1, h2, h3, h4, button, summary, label, legend, dt, th, caption, .phrase {
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--color-action); text-underline-offset: 4px; overflow-wrap: anywhere; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; letter-spacing: 0; color: inherit; }
button { cursor: pointer; line-height: var(--leading-control); }
button:disabled { cursor: not-allowed; }
button, a, summary, input, select, label { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* hidden="until-found" keeps its box (content-visibility: hidden) so find-in-page can reveal it. */
[hidden]:not([hidden="until-found"]) { display: none !important; }
.phrase { word-break: keep-all; overflow-wrap: anywhere; }
.qty { white-space: nowrap; }
.print-only { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* 6.1 Focus: dark ring; a white halo keeps it visible on green/yellow surfaces and primary buttons. */
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
:is(button, a, summary, input, select, textarea, label):focus-visible { box-shadow: 0 0 0 6px #fff; }
[tabindex="-1"]:focus { outline: none; box-shadow: none; }
.import-label:focus-within { outline: 3px solid var(--color-focus); outline-offset: 3px; box-shadow: 0 0 0 6px #fff; }

.skip-link {
  position: absolute; z-index: 100; top: -120px; left: 16px;
  min-height: 44px; padding: 10px 16px; border-radius: var(--radius-control);
  background: var(--color-surface); color: var(--color-action); font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- Buttons (4.4) ---------- */
.btn {
  display: inline-flex;
  flex: 0 0 auto;
  max-inline-size: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: var(--font-body);
  font-weight: 700;
  line-height: var(--leading-control);
  text-align: center;
  text-decoration: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
  transition: background-color var(--motion-fast), box-shadow var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast), scale var(--motion-press) var(--ease-bounce), rotate var(--motion-base) var(--ease-bounce);
}
.btn svg { flex: none; width: 18px; height: 18px; }
.btn-primary { background: var(--color-action); border-color: var(--color-action); color: var(--color-on-action); }
.btn-primary:hover:not(:disabled) { background: var(--color-action-hover); border-color: var(--color-action-hover); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-input-border); color: var(--color-action); }
.btn-secondary:hover:not(:disabled) { background: var(--color-action-tint); box-shadow: inset 0 0 0 1px var(--color-input-border); }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); border-color: var(--color-danger-hover); }
.btn-secondary.btn-danger-text { color: var(--color-danger); }
.btn-text {
  background: transparent; color: var(--color-action);
  padding-inline: 8px; text-decoration: underline; text-underline-offset: 4px;
}
.btn-text:hover:not(:disabled) { color: var(--color-action-hover); }
.btn[aria-pressed="true"] { background: var(--color-action); border-color: var(--color-action); color: var(--color-on-action); }
.btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--color-action-hover); box-shadow: none; }
/* Disabled: no opacity (2.1). */
.btn:disabled, .btn[aria-disabled="true"], .product-strip-arrow:disabled {
  background: var(--color-subtle); border-color: var(--color-line); color: var(--color-placeholder); box-shadow: none;
}

/* ---------- Form controls (4.4) ---------- */
/* :where() keeps this generic rule at element specificity, so states such as
   [aria-invalid] and :disabled below override its border (DESIGN.md 2.1). */
input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"])), select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: max(16px, var(--font-input));
  line-height: var(--leading-control);
}
input::placeholder { color: var(--color-placeholder); opacity: 1; }
:is(input, select, textarea)[aria-invalid="true"] { border: 2px solid var(--color-danger); padding: 7px 11px; }
input:disabled, select:disabled { background: var(--color-subtle); border-color: var(--color-line); color: var(--color-placeholder); }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="checkbox"] { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--color-action); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-field); }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.field-help { color: var(--color-muted); font-size: var(--font-body); line-height: var(--leading-control); }
.form-error { color: var(--color-danger); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.form-error:empty { display: none; }
.eyebrow { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
/* Stepper: −／input／＋／unit (4.4). */
.number-control { display: grid; grid-template-columns: 48px minmax(56px, 1fr) 48px auto; align-items: center; gap: 8px; max-width: 320px; }
.number-control .btn { width: 48px; min-height: 48px; padding: 0; font-size: var(--font-symbol); line-height: 1; }
.number-control input { text-align: center; font-weight: 700; appearance: textfield; -moz-appearance: textfield; }
.number-control input::-webkit-inner-spin-button, .number-control input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.number-control > span { font-size: var(--font-body); }
/* A short number with its unit beside it (e.g. トイレの目安 … 回). */
.input-with-unit { display: flex; align-items: center; gap: 8px; max-inline-size: 12em; }
.input-with-unit input { flex: 1 1 auto; font-weight: 700; }
.input-with-unit__unit { flex: none; font-size: var(--font-body); font-weight: 700; }

/* Small in-surface disclosure (4.5): white, R8, line border, 48px summary. */
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details) {
  min-width: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details) > summary {
  position: relative;
  display: block;
  min-height: 48px;
  padding: 11px calc(12px + 22px + 20px) 11px 12px;
  color: var(--color-ink);
  font-size: var(--font-body);
  font-weight: 700;
  line-height: var(--leading-control);
  list-style: none;
  cursor: pointer;
}
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details) > summary::-webkit-details-marker { display: none; }
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details) > summary::after {
  content: "";
  position: absolute;
  /* A filled triangle (▼ closed, ▲ open), centred on the summary text even when it wraps. */
  top: 50%;
  right: 12px;
  width: 22px;
  height: 22px;
  translate: 0 -50%;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 7.5h12l-6 9z' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px 22px no-repeat;
  transition: rotate var(--motion-reveal) var(--ease-smooth);
}
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details)[open] > summary::after { rotate: 180deg; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-surface);
}
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-right: auto;
  color: var(--color-ink);
  font-size: var(--font-file);
  font-weight: 800;
  line-height: var(--leading-number);
  text-decoration: none;
}
.brand > span { display: grid; }
.brand-caption { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.character-icon { display: block; flex: none; width: 48px; height: 48px; object-fit: contain; }
.text-size-control {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
}
.text-size-control > span { padding-inline: 8px 4px; color: var(--color-muted); font-size: var(--font-body); font-weight: 700; }
.text-size-control button {
  min-width: 44px; min-height: 44px; padding: 0 8px; border: 0; border-radius: var(--radius-control);
  background: transparent; color: var(--color-action); font-size: var(--font-body); font-weight: 700;
  transition: background-color .16s, color .16s;
}
.text-size-control button:hover { background: var(--color-action-tint); }
.text-size-control button[aria-pressed="true"] { background: var(--color-action); color: var(--color-on-action); }
.header-save-states { display: flex; flex: 0 1 auto; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.save-status { display: inline-flex; align-items: center; gap: 6px; color: var(--color-muted); font-size: var(--font-body); line-height: var(--leading-control); }
.save-status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.save-status[data-status="saved"] { color: var(--color-success); }
.save-status[data-status="error"] { color: var(--color-danger); font-weight: 700; }
/* 未保存 (household or stock): caution color with "！", never color alone (DESIGN.md 2.1). */
.save-status:is([data-status="unsaved"], [data-status="unsaved-stock"]) { color: var(--color-caution); font-weight: 700; }
.save-status:is([data-status="unsaved"], [data-status="unsaved-stock"])::before { content: "！"; width: auto; height: auto; border-radius: 0; background: none; }
/* In the header the 「未保存の在庫 N件」 button already states unsaved stock. */
.header-save-states .save-status[data-status="unsaved-stock"] { display: none; }
/* The header save state has a full and a short form; the short one is used at 701–920px. */
.save-status__short { display: none; }
.unsaved-stock-link {
  min-height: 44px; padding: 4px 10px; border: 1px solid currentColor; border-radius: var(--radius-badge);
  background: var(--color-surface); color: var(--color-caution); font-size: var(--font-body); font-weight: 700;
}
.unsaved-stock-link::before { content: "！"; }
.unsaved-stock-link:hover { background: var(--color-subtle); }
.cloud-header-status {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: start;
  min-height: 50px; padding: 4px 12px; border: 1px solid var(--color-action); border-radius: var(--radius-control);
  background: var(--color-surface); color: var(--color-action); font-size: var(--font-body); font-weight: 700;
  transition: background-color .16s, box-shadow .16s;
}
.cloud-header-status:hover { background: var(--color-action-tint); box-shadow: inset 0 0 0 1px var(--color-action); }
.cloud-header-icon { flex: 0 0 20px; }
.cloud-header-status [data-cloud-header-label] { min-width: 0; }
/* 保存状態と同期を1つのボタンにまとめる: 1行目に保存状態（小さい字）、2行目に同期のラベル。 */
.cloud-header-text { display: grid; min-width: 0; line-height: 1.4; }
.cloud-header-status .save-status { gap: 5px; font-size: var(--font-note); line-height: 1.4; }
.cloud-header-status .save-status:not([data-status="error"], [data-status="unsaved"], [data-status="unsaved-stock"]) { font-weight: 400; }

/* ---------- Shell: sidebar (≥921) and bottom nav (≤920) ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: auto 1fr; max-width: 1440px; margin-inline: auto; }
/* The side navigation spans main and the page tail (LEARN & PREPARE, footer). */
.sidebar { grid-row: 1 / span 2; min-width: 0; padding: 24px 0 24px var(--page-padding); }
.shell-tail { grid-column: 2; min-width: 0; }
.sidebar-sticky {
  position: sticky;
  top: calc(var(--header-h, 0px) + 16px);
  display: grid;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--radius-file);
  background: var(--color-surface);
}
.sidebar-title { padding-inline: 8px; color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.sidebar nav { display: grid; gap: 4px; }
.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 8px;
  border-radius: var(--radius-control);
  color: var(--color-ink);
  font-size: var(--font-body);
  font-weight: 700;
  line-height: var(--leading-control);
  text-decoration: none;
  transition: background-color .16s, color .16s;
}
.sidebar .nav-item .character-icon { width: 36px; height: 36px; }
.nav-item__label { min-width: 0; }
.sidebar .nav-item:hover { background: var(--color-action-tint); }
.sidebar .nav-item[aria-current="page"] { background: var(--color-action); color: var(--color-on-action); }
.bottom-nav { display: none; }

.main-content, .onboarding-content { min-width: 0; padding: 24px var(--page-padding) 32px; }
main.onboarding { max-width: 960px; margin-inline: auto; padding: 24px var(--page-padding) 32px; }
.loading-message { padding: 48px 16px; text-align: center; font-size: var(--font-card); font-weight: 700; }
/* Readable copy of the page in the published HTML (scripts/seo.mjs). It shows until the app starts and replaces it. */
.prerender { max-width: 1100px; margin: 0 auto; padding: 8px var(--page-padding, 16px) 48px; }
.prerender-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; margin-bottom: 16px; }
.prerender-brand { display: inline-flex; align-items: baseline; gap: 8px; min-height: 44px; padding-top: 6px; color: var(--color-action); font-size: 1.5rem; font-weight: 800; text-decoration: none; }
.prerender-brand small { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; }
.prerender-header ul { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 0; padding: 0; list-style: none; }
.prerender-header li a { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--font-body); font-weight: 700; }
.prerender-main .page-heading { margin-bottom: 16px; }
.prerender-body > p { margin-block: 8px; }
.prerender-table { display: block; overflow-x: auto; width: 100%; margin-block: 16px; border-collapse: collapse; font-size: var(--font-body); line-height: var(--leading-control); }
.prerender-table caption { padding-block: 4px; font-weight: 800; text-align: left; }
.prerender-table :is(th, td) { min-width: 6em; padding: 8px; border-top: 1px solid var(--color-line); text-align: left; vertical-align: top; }
.prerender-table td:nth-child(2) { white-space: nowrap; }
.prerender-table td:nth-child(3) { min-width: 16em; }
.prerender-table thead th { color: var(--color-muted); white-space: nowrap; }

/* Progress (4.5): only in the sidebar. Bottom-nav widths show the three cards in 「備蓄の目標量」. */
.nav-progress { display: grid; justify-items: center; padding: 4px 0 8px; }
.nav-progress__return { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; width: 104px; height: 104px; min-height: 44px; padding: 12px; border: 0; border-radius: 50%; background: var(--color-surface); color: var(--color-action); cursor: pointer; font: inherit; }
.nav-progress__return:hover { background: var(--color-action-tint); }
.nav-progress__ring { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.nav-progress__ring circle { fill: none; stroke-width: 6; }
.nav-progress__remainder { stroke: var(--color-line); }
.nav-progress__fill { stroke: var(--color-action); transform: rotate(-90deg); transform-origin: 52px 52px; }
.nav-progress__character { display: block; width: 56px; height: 56px; object-fit: contain; }
.nav-progress__caption { margin-top: 4px; color: var(--color-muted); font-size: var(--font-note); font-weight: 700; line-height: var(--leading-heading); text-align: center; }
.nav-progress [data-nav-progress-value] { font-size: var(--font-body); line-height: 1.2; font-variant-numeric: tabular-nums; }

/* ---------- 4.6 Page heading ---------- */
.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: var(--radius-file);
  background: var(--color-surface);
}
.page-heading > div:first-child { display: flex; flex: 1 1 14em; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; min-width: 0; }
.page-title { flex: 0 1 auto; max-inline-size: 100%; font-size: var(--font-page); font-weight: 800; line-height: var(--leading-heading); }
.page-lead { flex: 0 1 auto; max-inline-size: 100%; color: var(--color-muted); font-size: var(--font-body); line-height: var(--leading-control); }
.page-heading > .btn { margin-left: auto; }
.onboarding-catch { color: var(--color-action); font-weight: 700; }
.list-hint { margin: 0; color: var(--color-ink); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.onboarding-intro { margin: 0; color: var(--color-ink); font-size: var(--font-body); line-height: var(--leading-body); }
.onboarding-flow-steps { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 4px 0 0; padding: 0; list-style: none; }
.onboarding-flow-steps li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--color-action-tint); color: var(--color-action); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); word-break: keep-all; overflow-wrap: anywhere; }
.onboarding-flow-steps li > span { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--color-action); color: var(--color-on-action); font-size: var(--font-note); }
.onboarding-mascot {
  position: relative; display: grid; flex: 0 0 72px; place-items: center; aspect-ratio: 1;
  margin-left: auto; border-radius: 50%; background: var(--color-file-yellow);
}
.onboarding-mascot img { position: absolute; width: 112%; max-width: none; height: auto; }

/* Text links outside running text still get a 44px target (4.4). */
:is(.settings-panel > a, .backup-reminder a, .source-details a) { display: inline-flex; align-items: center; min-height: 44px; }

/* Notes and plain white blocks between the heading and the file boxes. */
.dashboard-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 16px; padding: 8px; border-radius: var(--radius-file); background: var(--color-surface);
}
/* 備蓄リスト: heading, action row and backup note on one white surface (4.6 / 4.6.1). */
.page-top {
  display: grid; gap: 12px; margin-bottom: 16px; padding: 16px;
  border-radius: var(--radius-file); background: var(--color-surface);
}
.page-top > .page-heading, .page-top > .dashboard-actions, .page-top > .backup-reminder {
  margin: 0; padding: 0; border: 0; border-radius: 0; background: none;
}
.page-top > .backup-reminder { padding-top: 12px; border-top: 1px solid var(--color-line); }
.next-step-note { flex: 1 1 100%; padding-inline: 4px; color: var(--color-action); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.backup-reminder {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-bottom: 16px; padding: 8px 8px 8px 16px; border: 1px solid var(--color-line); border-radius: var(--radius-card); background: var(--color-surface);
}
.backup-reminder p { flex: 1 1 260px; }
.offline-note {
  margin-bottom: 12px; padding: 8px 12px; border: 1px solid currentColor; border-radius: var(--radius-card);
  background: var(--color-surface); color: var(--color-caution); font-weight: 700; line-height: var(--leading-control);
}
.storage-banner {
  display: grid; gap: 8px; margin-bottom: 16px; padding: 12px 16px;
  border: 2px solid var(--color-danger); border-radius: var(--radius-card); background: var(--color-surface);
}
.storage-banner__actions, .settings-actions, .danger-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.empty-state {
  grid-column: 1 / -1; display: grid; justify-items: center; gap: 12px; padding: 24px 16px;
  border: 1px dashed var(--color-input-border); border-radius: var(--radius-card); background: var(--color-surface); text-align: center;
}
.empty-state__title { font-weight: 700; }
.info-note { display: grid; gap: 4px; margin-top: 16px; padding: 12px 16px; border-left: 4px solid var(--color-action); background: var(--color-surface); }
.info-note__title { font-weight: 700; }
.commerce-note { color: var(--color-muted); font-size: var(--font-note); line-height: var(--leading-control); }
.commerce-note:empty { display: none; }

/* ---------- 4.1 File box ---------- */
.band-stack { display: flex; flex-direction: column; }
.section-band {
  --band-color: var(--color-file-green);
  position: relative;
  isolation: isolate;
  flex: none;
  min-width: 0;
  padding-bottom: var(--file-reserve);
  color: var(--color-on-file);
}
.section-band--yellow { --band-color: var(--color-file-yellow); }
.band-stack > .section-band + .section-band { margin-top: calc(-1 * var(--file-overlap)); }
.band-stack > .section-band:last-child, .section-band:only-child { padding-bottom: var(--file-end-padding); }
/* The color body starts below the tab; the outline shadow sits on this background layer (6). */
.section-band::before {
  content: "";
  position: absolute;
  inset: var(--file-rise) 0 0;
  z-index: -1;
  pointer-events: none;
  border-radius: 0 var(--radius-file) var(--radius-file) var(--radius-file);
  background: var(--band-color);
  filter: var(--shadow-file);
}
header.section-band__heading { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 16px; padding-right: var(--file-tab-padding); }
header.section-band__heading > :not(.file-tab) { flex: 0 1 auto; margin-left: auto; padding: 0 0 12px var(--file-tab-padding); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
h2.file-tab.section-band__heading { display: block; margin: 0; }
/* The tab: content-width, 80px minimum, fixed 48×40 shoulder curve. */
header.section-band__heading > .file-tab, .file-tab__button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  width: fit-content;
  max-width: calc(100% - var(--file-shoulder-w));
  min-height: var(--file-heading-h);
  margin: 0;
  padding: 10px var(--file-tab-padding);
  border: 0;
  background: none;
  color: var(--color-on-file);
  font-size: var(--font-file);
  font-weight: 800;
  line-height: var(--leading-heading);
  text-align: left;
}
header.section-band__heading > .file-tab::before, .file-tab__button::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -2;
  height: var(--file-rise);
  pointer-events: none;
  border-radius: var(--radius-file) 0 0 0;
  background: var(--band-color);
  filter: var(--shadow-file);
}
header.section-band__heading > .file-tab::after, .file-tab__button::after {
  content: "";
  position: absolute;
  top: 0;
  left: 100%;
  z-index: -2;
  width: var(--file-shoulder-w);
  height: var(--file-rise);
  pointer-events: none;
  background: var(--band-color);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 40'%3E%3Cpath d='M0 0C20 0 20 40 48 40H0Z'/%3E%3C/svg%3E") center / 48px 40px no-repeat;
}
.file-tab__button { cursor: pointer; font-family: inherit; }
/* The item count sits on the tab's own line, next to the heading (never floating at the right). */
.file-tab__count { flex: 0 0 auto; font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); white-space: nowrap; }
.file-tab__label { min-width: 0; }
.file-tab__arrow { display: grid; flex: 0 0 22px; place-items: center; width: 22px; height: 22px; transition: rotate var(--motion-reveal) var(--ease-smooth); }
.file-tab__arrow svg { display: block; }
.file-tab__button[aria-expanded="true"] .file-tab__arrow { rotate: 180deg; }
.section-band > .section-band__surface, .file-tab__body { margin-inline: var(--file-inset); }
.section-band__surface {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: var(--file-surface-padding);
  border-radius: var(--radius-file);
  background: var(--color-surface);
  color: var(--color-ink);
}

/* ---------- 4.2 Shared card ---------- */
.stock-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap-card); align-items: start; }
@container (max-width: 360px) { .stock-list, .resource-grid, .coverage-grid { gap: 6px; } }
/* The card and its product disclosure are one grid item (.stock-entry), so opening 「商品を見る」
   in one column never leaves a blank area beside it in the other column. */
.stock-entry {
  display: flex; flex-direction: column; gap: 0; min-width: 0;
  border: 1px solid var(--color-line); border-radius: var(--radius-card);
  background: var(--color-surface); box-shadow: var(--shadow-card);
}
.stock-entry > .stock-card { border: 0; box-shadow: none; background: transparent; }
.stock-entry > .stock-card > .stock-card__heading {
  margin: -12px -12px 0; padding: 12px;
  border-bottom: 1px solid var(--color-line);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: var(--color-action-tint);
}
.stock-entry > .product-disclosure {
  margin: 0 12px; border: 0; border-top: 1px solid var(--color-line);
  border-radius: 0; background: transparent;
}
.stock-entry > .product-disclosure > summary { padding-inline-start: 0; }
.stock-entry > .product-disclosure > :not(summary) { margin-inline: 0; }
.stock-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--gap-stage);
  min-width: 0;
  min-height: 168px;
  padding: 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  scroll-margin-block: 120px calc(var(--bottom-nav-h) + 16px);
}
:root[data-text-size="large"] .stock-card { min-height: 184px; }
.stock-card__heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 48px; }
.stock-card__title { flex: 1 1 10em; min-width: 0; font-size: var(--font-card); font-weight: 700; }
.status-badge {
  display: inline-flex; flex: 0 0 auto; max-inline-size: 100%; align-items: center; gap: 4px;
  padding: 2px 8px; border: 1px solid currentColor; border-radius: var(--radius-badge);
  background: var(--color-surface); color: var(--color-muted);
  font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control);
}
.status-badge[data-status="shortage"] { color: var(--color-danger); }
.status-badge[data-status="target-needed"], .status-badge[data-status="review"] { color: var(--color-caution); }
.status-badge[data-status="target-needed"]::before, .status-badge[data-status="review"]::before { content: "！"; }
.status-badge[data-status="covered"] { color: var(--color-success); }
.stock-card__form { display: flex; flex: 1; flex-direction: column; gap: var(--gap-stage); min-width: 0; }
.stock-card__content {
  /* 1fr : 2fr with the same 8px gap as .stock-card__numbers gives 在庫・必要量・不足 three equal boxes. */
  display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  grid-template-areas: "input numbers" "help help" "status status"; gap: 8px; align-items: start;
}
.stock-card__input { grid-area: input; }
.stock-card__help { grid-area: help; margin-top: -4px; }
.stock-card__numbers { grid-area: numbers; }
/* 未保存・✓ 保存済み・エラー use the full width of the content stage, right under the input row. */
.stock-card__status { grid-area: status; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.stock-card__status:not(:has(.stock-card__undo)):has(> .stock-card__message:empty) { display: none; }
.stock-card--equipment .stock-card__content { grid-template-columns: minmax(0, 1fr); grid-template-areas: "input" "help" "status"; }
/* Three boxes side by side need about 110px each (24px digits + a 3-letter unit such as セット), so phones stack them. */
@container (max-width: 340px) {
  .stock-card__content { grid-template-columns: minmax(0, 1fr); grid-template-areas: "input" "help" "status" "numbers"; }
}
.stock-card__input { display: grid; gap: 4px; min-width: 0; }
.stock-card__label { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
/* 在庫・必要量・不足 share one box: 48px high, value on the left, unit inside on the right, same number size.
   Only 在庫 has a white field with a border; 必要量・不足 are grey read-only boxes. */
.stock-card__field, .stock-card__number dd {
  display: flex; align-items: center; gap: 4px; min-width: 0; min-height: 48px; padding: 0 10px;
  border-radius: var(--radius-control);
}
.stock-card__field { border: 1px solid var(--color-input-border); background: var(--color-surface); padding-left: 0; }
.stock-card__field:focus-within { outline: 3px solid var(--color-focus); outline-offset: 3px; box-shadow: 0 0 0 6px #fff; }
.stock-card__field:has(input[aria-invalid="true"]) { border-color: var(--color-danger); box-shadow: inset 0 0 0 1px var(--color-danger); }
.stock-card__field:has(input:disabled) { border-color: var(--color-line); background: var(--color-subtle); }
.stock-card__field input, .stock-card__field input[aria-invalid="true"] {
  flex: 1 1 auto; min-height: 46px; padding: 0 0 0 10px; border: 0; background: transparent;
  font-size: var(--font-number-compact); font-weight: 800;
}
.stock-card__field input:focus-visible { outline: none; box-shadow: none; }
/* 未登録 reads like 未設定 in the grey boxes: a note, not a big number. */
.stock-card__field input::placeholder { font-size: var(--font-body); font-weight: 700; }
.stock-card__unit, .stock-card__number small { flex: none; margin-left: 0; font-size: var(--font-body); font-weight: 400; line-height: var(--leading-control); }
.stock-card--equipment .stock-card__field { max-width: 240px; }
.stock-card__help { color: var(--color-muted); font-size: var(--font-body); line-height: var(--leading-control); }
.stock-card__message { font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.stock-card__message:empty { display: none; }
.stock-card__message { flex: 1 1 auto; min-width: 0; }
.stock-card__message[data-stock-message="draft"] {
  flex: 0 0 auto; padding: 0 6px; border: 1px solid currentColor; border-radius: var(--radius-badge); color: var(--color-caution);
}
.stock-card__message[data-stock-message="saved"] { color: var(--color-success); }
.stock-card__message[data-stock-message="error"] { color: var(--color-danger); }
.stock-card__numbers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.stock-card__number { min-width: 0; }
.stock-card__number dt { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.stock-card__number dd {
  margin: 4px 0 0; background: var(--color-subtle); font-size: var(--font-number-compact); font-weight: 800;
  line-height: var(--leading-number); font-variant-numeric: tabular-nums;
}
.stock-card__number .qty { display: flex; flex: 1; align-items: baseline; justify-content: space-between; gap: 4px; min-width: 0; }
.stock-card__number .value-note { font-size: var(--font-body); }
.coverage-stock small, .coverage-shortage small, .family-preview__amount small, .edit-required small {
  margin-left: 2px; font-size: var(--font-note); font-weight: 400;
}
.stock-card:has(.status-badge[data-status="shortage"]) .shortage-value dd { color: var(--color-danger); }
.value-note { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; }
.stock-card__hint { color: var(--color-muted); font-size: var(--font-body); line-height: var(--leading-control); }
.stock-card__note { color: var(--color-caution); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.stock-card__actions { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 8px; min-height: 44px; margin-top: auto; }

/* ---------- 4.3 Product candidates ---------- */
.product-disclosure { align-self: stretch; }
.product-disclosure > :not(summary) { margin: 0 12px 12px; }
.product-options { min-width: 0; }
.product-strip-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.product-strip-hint { color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.product-strip-buttons { display: flex; gap: 8px; }
.product-strip-arrow {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--color-input-border); border-radius: var(--radius-control);
  background: var(--color-surface); color: var(--color-action); transition: background-color .16s, box-shadow .16s;
}
.product-strip-arrow svg { fill: currentColor; pointer-events: none; }
.product-strip-arrow:hover:not(:disabled) { background: var(--color-action-tint); box-shadow: inset 0 0 0 1px var(--color-input-border); }
/* The only horizontal scroll on the site: the edge card peeks out. */
.product-strip {
  position: relative; /* contains the visually hidden "新しいタブ" labels inside the scroller */
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 2px 2px 8px;
  /* Unobtrusive: the 44px previous/next buttons are the visible control (4.3). */
  scrollbar-width: thin;
  scrollbar-color: var(--color-line) transparent;
}
.product-strip::-webkit-scrollbar { height: 6px; }
.product-strip::-webkit-scrollbar-track { background: transparent; }
.product-strip::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--color-line); }
/* Wide enough that 「Amazonで見る ↗」 fits on one line at both text sizes. */
.product-option { flex: 0 0 min(224px, 82%); min-width: 0; scroll-snap-align: start; }
.product-card {
  display: grid;
  grid-template-rows: 140px minmax(3lh, auto) minmax(2lh, 1fr) auto;
  font-size: var(--font-body);
  line-height: var(--leading-control);
  gap: 8px;
  height: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--color-line);
  border-radius: 0;
  background: var(--color-surface);
}
.product-visual {
  /* A definite height: the photo never grows past its frame onto the product name (4.3). */
  display: grid; place-items: center; width: 100%; block-size: 140px; overflow: hidden;
  background: var(--color-surface); color: var(--color-muted); text-align: center; text-decoration: none;
}
.product-visual img { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; }
.product-photo-note { padding: 4px; font-size: var(--font-body); line-height: var(--leading-control); }
.product-photo-pending { border: 1px dashed var(--color-line); }
.product-title { display: block; min-height: 44px; color: var(--color-ink); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); text-decoration: none; overflow-wrap: anywhere; }
.product-card > .product-title { grid-row: 2; }
.product-card > .product-purchase-count, .product-card > .product-purchase-hint { grid-row: 3; }
.product-card > .product-labels { grid-row: 4; }
.product-title:hover { text-decoration: underline; }
.product-purchase-count, .product-purchase-hint { font-size: var(--font-body); line-height: var(--leading-control); }
.product-labels { display: flex; flex-wrap: wrap; justify-content: flex-end; align-self: end; gap: 8px; }
.product-amazon-link { inline-size: 100%; padding-inline: 8px; background: var(--color-amazon); border-color: var(--color-amazon); color: var(--color-on-amazon); }
.product-amazon-link:hover { background: var(--color-amazon-hover); border-color: var(--color-amazon-hover); }
.product-options--single .product-row { width: min(224px, 82%); min-width: 0; }

/* ---------- Home: filters, plan, coverage, shelf ---------- */
.filter-bar { display: grid; gap: 8px; }
.inventory-groups, .status-filters, .shelf-toggle { display: flex; flex-wrap: wrap; gap: 8px; }
/* Five day buttons always share one row (7日 never drops to a second line). */
.day-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.day-options > .btn { min-width: 0; padding-inline: 4px; }
.inventory-groups > button {
  display: inline-flex; flex: 1 0 auto; max-inline-size: 100%; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-input-border); border-radius: var(--radius-control);
  background: var(--color-surface); color: var(--color-action); font-size: var(--font-body); font-weight: 700;
  transition: background-color .16s, box-shadow .16s;
}
.inventory-groups > button:hover { background: var(--color-action-tint); box-shadow: inset 0 0 0 1px var(--color-input-border); }
.inventory-groups > button[aria-pressed="true"] { background: var(--color-action); border-color: var(--color-action); color: var(--color-on-action); box-shadow: none; }
/* Label left, count badge at the right edge: the count lines up in every tab, even when a label wraps. */
.inventory-groups > button { justify-content: space-between; gap: 12px; text-align: left; }
.group-tab__label { flex: 1 1 auto; min-width: 0; }
.count-badge {
  display: inline-grid; flex: 0 0 auto; place-items: center; min-inline-size: 2em; padding: 0 6px;
  border: 1px solid currentColor; border-radius: var(--radius-badge);
  font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); font-variant-numeric: tabular-nums;
}
/* Status filter: a labelled row of chips, visibly different from the category tabs above. */
.status-filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.filter-label { flex: 0 0 auto; color: var(--color-muted); font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.filter-chip {
  display: inline-flex; flex: 0 0 auto; max-inline-size: 100%; align-items: center; gap: 4px;
  min-height: 44px; padding: 6px 14px; border: 1px solid var(--color-input-border); border-radius: var(--radius-chip);
  background: var(--color-surface); color: var(--color-ink); font-size: var(--font-body); font-weight: 700;
  transition: background-color .16s, box-shadow .16s, color .16s;
}
.filter-chip:hover { background: var(--color-action-tint); }
.filter-chip[aria-pressed="true"] { border-color: var(--color-action); background: var(--color-action-tint); color: var(--color-action); box-shadow: inset 0 0 0 1px var(--color-action); }
.filter-chip[aria-pressed="true"]::before { content: "✓"; }
.shopping-count { color: var(--color-muted); font-weight: 700; line-height: var(--leading-control); }

.plan-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px 24px; align-items: center; }
.plan-panel__household { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-width: 0; }
.plan-panel__household h3 { font-size: var(--font-card); font-weight: 700; }
.plan-panel__household p { color: var(--color-muted); }
.plan-panel__days { display: grid; gap: 8px; min-width: 0; }
.day-control__label { font-weight: 700; line-height: var(--leading-control); }

.coverage-summary { display: grid; gap: 12px; scroll-margin-top: calc(var(--header-h, 0px) + 12px); }
.coverage-heading h3 { font-size: var(--font-card); font-weight: 700; }
.coverage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap-card); }
/* Heading / ring / quantities share row tracks, so the three rings line up even when one
   heading (携帯トイレ) wraps to two lines. */
.coverage-card {
  position: relative;
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  justify-items: center;
  align-items: start;
  row-gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-align: center;
  transition: border-color .16s;
}
.coverage-card:has(.coverage-card-link:hover) { border-color: var(--color-action); }
.coverage-card h3 { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 4px; align-self: center; font-size: var(--font-card); font-weight: 700; }
.coverage-card h3 > .phrase { flex: 0 0 auto; max-inline-size: 100%; }
.coverage-card__body { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; max-inline-size: 100%; }
.coverage-chevron { color: var(--color-action); }
/* The ring is a square chart; the 目標達成 label sits below it, never over the percentage (4.5). */
.coverage-ring { position: relative; width: min(100%, 132px); text-align: center; }
.coverage-ring__chart { display: block; width: 100%; height: auto; aspect-ratio: 1; overflow: visible; }
.coverage-ring__chart circle { fill: none; stroke-width: 9; }
.coverage-ring__track { stroke: var(--color-line); }
.coverage-ring__value { stroke: var(--color-action); }
.coverage-ring__center { position: absolute; inset: 0 0 auto; box-sizing: border-box; aspect-ratio: 1; padding: 14%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.coverage-ring__center .stock-symbol { display: block; width: 62%; height: 54%; }
.coverage-ring__center > span { font-size: var(--font-body); line-height: var(--leading-number); white-space: nowrap; }
.coverage-ring__center b { font-size: var(--font-card); font-variant-numeric: tabular-nums; }
.coverage-achievement {
  display: inline-block; max-inline-size: 100%; margin-top: 4px; padding: 0 8px; border-radius: var(--radius-badge);
  background: var(--color-success); color: #fff; font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control);
  word-break: keep-all; overflow-wrap: anywhere;
}
.coverage-stock { display: grid; line-height: var(--leading-control); }
.coverage-stock > span { color: var(--color-muted); font-weight: 700; }
.coverage-stock strong { font-size: var(--font-number); font-weight: 800; line-height: var(--leading-number); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.coverage-prepper { display: block; width: 96px; height: 96px; object-fit: contain; pointer-events: none; }
.coverage-shortage { color: var(--color-danger); font-weight: 700; line-height: var(--leading-control); }
.coverage-shortage strong { font-size: var(--font-card); font-variant-numeric: tabular-nums; }
.coverage-review { color: var(--color-caution); font-weight: 700; line-height: var(--leading-control); }
.coverage-review::before { content: "！"; }
.coverage-card-link { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; padding: 0; border: 0; border-radius: inherit; background: transparent; }

.shelf-details > :not(summary) { margin: 0 12px 12px; }
.shelf-panel { display: grid; gap: 12px; min-width: 0; }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.section-heading h3 { font-size: var(--font-card); font-weight: 700; }

/* Shelf (onboarding target) and family preview share the approved stock artwork. */
.shelf-rows { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.shelf-row { display: grid; grid-row: span 6; grid-template-rows: subgrid; row-gap: 4px; min-width: 0; text-align: center; }
.shelf-row > .shelf-label { grid-row: 1; }
.shelf-row > .shelf-amount { grid-row: 2; }
.shelf-row > .shelf-art { grid-row: 3; align-self: start; }
.shelf-row > .shelf-breakdown { grid-row: 4; }
.shelf-row > .shelf-overflow { grid-row: 5; }
.shelf-row > .shelf-caption { grid-row: 6; }
svg.shelf-art { display: block; width: 100%; height: auto; overflow: visible; }
.shelf-caption, .shelf-overflow { color: var(--color-muted); line-height: var(--leading-control); }
.shelf-breakdown { font-weight: 700; line-height: var(--leading-control); }
/* 11.2: goods drop from above and settle with one bounce. */
.shelf-object { transform-box: fill-box; animation: shelf-arrive var(--motion-slow) var(--ease-spring) backwards; animation-delay: calc(min(var(--item-index), 14) * 30ms); }
@keyframes shelf-arrive { from { opacity: 0; translate: 0 calc(var(--motion-shift-l) * -1); } 30% { opacity: 1; } }

.family-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 0; min-width: 0; padding: 8px 0; }
.family-preview__category { padding-inline: 8px; position: relative; display: grid; grid-row: span 6; grid-template-rows: subgrid; row-gap: 4px; min-width: 0; text-align: center; }
.family-preview__category + .family-preview__category::before { content: ""; position: absolute; inset: 0 auto 0 0; border-left: 1px solid var(--color-line); }
.shelf-label, .family-preview__label { font-size: var(--font-body); font-weight: 700; line-height: var(--leading-control); }
.shelf-amount, .family-preview__amount { font-size: var(--font-number); font-weight: 800; line-height: var(--leading-number); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.family-preview__art {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); grid-template-rows: repeat(var(--preview-rows, 1), minmax(0, 1fr));
  align-self: start; width: min(100%, 270px); height: auto; aspect-ratio: 440 / calc(var(--preview-rows, 1) * 84); margin-inline: auto;
}
.family-preview__object { display: block; grid-column: var(--column) / span 2; grid-row: var(--row); width: 100%; height: 100%; min-height: 0; }
.family-preview__legend, .family-preview__overflow { padding-inline: 2px; color: var(--color-muted); line-height: var(--leading-control); overflow-wrap: anywhere; }
.family-preview__legend--water { display:flex; flex-wrap:wrap; justify-content:center; align-content:start; gap:0 6px; }
.family-preview__legend-part { white-space:nowrap; }
.family-preview__overflow { color: var(--color-ink); font-weight: 700; }
.family-preview__review { color: var(--color-caution); font-weight: 700; }
.family-preview-invalid { padding: 16px 0; color: var(--color-danger); font-weight: 700; }
.inline-family-preview { display: grid; gap: 4px; }
.inline-preview-title { font-weight: 700; line-height: var(--leading-control); }
.inline-preview-note { color: var(--color-muted); line-height: var(--leading-control); }
.onboarding-preview .inline-family-preview { display: none; }

/* ---------- Onboarding ---------- */
.onboarding-account-note { font-weight: 700; line-height: var(--leading-control); }
.wizard-steps { display: flex; gap: 12px; margin: 0; padding: 0; list-style: none; }
.wizard-steps > li {
  display: flex; flex: 1; align-items: center; gap: 8px; padding-top: 8px; border-top: 3px solid var(--color-line);
  color: var(--color-muted); font-weight: 700; line-height: var(--leading-control);
}
.wizard-steps > li.active { border-color: var(--color-action); color: var(--color-action); }
.wizard-steps > li > span { display: grid; flex: none; place-items: center; width: 28px; height: 28px; border: 1px solid currentColor; border-radius: 50%; }
.wizard-steps [aria-current="step"] > span { border-color: var(--color-file-yellow); background: var(--color-file-yellow); color: var(--color-on-file); }
#wizard-form { display: grid; gap: var(--gap-field); }
.onboarding-days { display: grid; gap: 8px; }
.onboarding-card { gap: var(--gap-field); }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.onboarding-support {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  margin-top: 16px; padding: 16px; border-radius: var(--radius-file); background: var(--color-surface);
}
.scope-note { flex: 1 1 260px; }
.import-control { display: grid; gap: 4px; }
.import-label { cursor: pointer; }
.wizard-quantity-note { color: var(--color-on-file); }

/* ---------- Settings ---------- */
.settings-panel { display: grid; gap: 12px; min-width: 0; }
.section-band__surface > .settings-panel + .settings-panel { padding-top: 8px; border-top: 1px solid var(--color-line); }
.settings-panel h3 { font-size: var(--font-card); font-weight: 700; }
#household-form { display: grid; gap: var(--gap-field); }
/* 5章: the wrappers only form columns at ≥1101. Below that they disappear and order keeps
   人数 → 目標量 → トイレ → 区分 → 保存 (the preview has no controls, so tab order is unchanged). */
.household-form__main, .household-form__rest, .household-form__aside { display: contents; }
.household-form__aside > .inline-family-preview { order: 1; }
.household-form__rest > * { order: 2; }
.household-form__aside > .household-save-bar { order: 3; }
.household-members { align-items: start; }
.optional-groups { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 12px 16px 16px; border: 1px solid var(--color-line); border-radius: var(--radius-card); }
.optional-groups legend { padding-inline: 4px; font-size: var(--font-card); font-weight: 700; }
.optional-groups__choices { display: flex; flex-wrap: wrap; gap: 8px; }
.optional-groups__choice {
  display: inline-flex; flex: 1 0 auto; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 8px 12px; border: 1px solid var(--color-input-border); border-radius: var(--radius-control);
  font-weight: 700; cursor: pointer;
}
.optional-groups__choice:has(input:checked) { border-color: var(--color-action); background: var(--color-action-tint); color: var(--color-action); box-shadow: inset 0 0 0 1px var(--color-action); }
.optional-groups__choice:has(input:focus-visible) { outline: 3px solid var(--color-focus); outline-offset: 3px; }
.optional-group-panel { display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--color-line); }
.care-count-summary { color: var(--color-action); font-weight: 700; line-height: var(--leading-control); }
.daily-usage-fields > summary { display: grid; gap: 2px; }
.daily-summary-title { font-size: var(--font-card); }
.daily-summary-meta { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--color-muted); font-weight: 400; }
.daily-toggle-hint { color: var(--color-action); }
.daily-usage-fields[open] .daily-toggle-hint { display: none; }
.daily-usage-fields > :not(summary) { margin: 0 12px 12px; }
.daily-usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-field); }
.household-save-bar {
  position: sticky;
  bottom: 12px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-sticky);
}
#household-form:not([data-dirty="true"]) .household-save-bar { position: static; box-shadow: none; }
#household-form[data-dirty="true"] .household-save-state { color: var(--color-caution); }
.household-save-state { flex: 1 1 12em; font-weight: 700; line-height: var(--leading-control); }
.last-backup { font-weight: 700; }
.danger-panel h3 { color: var(--color-danger); }
.edit-required { font-size: var(--font-number); font-weight: 800; line-height: var(--leading-number); font-variant-numeric: tabular-nums; }
.equipment-note { font-weight: 700; }
.equipment-help { color: var(--color-muted); }

/* Optional cloud storage */
.cloud-optional { margin-left: 4px; color: var(--color-muted); font-size: var(--font-body); font-weight: 400; }
.cloud-controls { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 0; border: 0; }
.cloud-identity { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 12px; border: 1px solid var(--color-line); border-radius: var(--radius-card); }
.cloud-identity > span { color: var(--color-muted); }
.cloud-benefits { display: grid; gap: 6px; margin: 8px 0 12px; padding-left: 1.4em; }
.cloud-benefits li::marker { color: var(--color-action); }
.cloud-state { color: var(--color-action); font-weight: 700; }
.cloud-comparisons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-card); }
.cloud-comparison { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 12px; border: 1px solid var(--color-line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.cloud-comparison h3, .cloud-comparison h4 { font-size: var(--font-card); }
.cloud-comparison dl { margin: 0 12px 12px; }
.cloud-comparison dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 4px 0; border-bottom: 1px solid var(--color-line); }
.cloud-comparison dd { font-variant-numeric: tabular-nums; }
.cloud-gate { max-width: 960px; }

/* ---------- Links page (based on the link card, 4.2) ---------- */
.resource-section-description { line-height: var(--leading-control); }
.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--gap-card); align-items: stretch; }
.resource-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(48px, auto) 1fr minmax(44px, auto);
  gap: var(--gap-stage);
  min-width: 0;
  min-height: 168px;
  padding: 12px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-ink);
  text-decoration: none;
  transition: border-color .16s;
}
:root[data-text-size="large"] .resource-card { min-height: 184px; }
.resource-card:hover { border-color: var(--color-action); }
.resource-card-heading { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 12px; min-width: 0; }
.resource-card-heading h3 { font-size: var(--font-card); font-weight: 700; }
.resource-card > p { line-height: var(--leading-control); }
.resource-brand { display: grid; place-items: center; width: 40px; height: 40px; }
.resource-brand img { display: block; width: 40px; height: 40px; object-fit: contain; }
.resource-brand > span { display: none; }
.resource-brand-symbol { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-control); background: var(--color-action); color: #fff; }
.resource-card-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; justify-self: end; align-self: end;
  min-width: 96px; min-height: 44px; padding: 8px 16px; border-radius: var(--radius-control);
  background: var(--color-action); color: var(--color-on-action); font-weight: 700; line-height: var(--leading-control);
  transition: background-color .16s;
}
.resource-card-action > svg { flex: none; }
.resource-card-action.resource-call { background: var(--color-danger); }
.resource-card:hover .resource-card-action { background: var(--color-action-hover); }
.resource-card:hover .resource-call { background: var(--color-danger-hover); }

/* "防災を、もっと知る。" (home page) */
.resource-links {
  display: grid; gap: 12px; max-width: 1392px; margin: 0 auto 24px; padding: 20px 24px;
  width: calc(100% - 2 * var(--page-padding)); border-radius: var(--radius-file); background: var(--color-surface);
}
.resource-links__heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.resource-links__heading > div:first-child { display: grid; gap: 4px; flex: 1 1 260px; min-width: 0; }
.resource-links__heading .eyebrow { color: var(--color-action); }
.resource-links__heading h2 { font-size: var(--font-file); font-weight: 800; }
.resource-links__intro { color: var(--color-muted); line-height: var(--leading-control); }
.resource-links__track {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--gap-card);
  margin: 0; padding: 0; list-style: none;
}
.resource-links__item { min-width: 0; }
.resource-banner {
  position: relative; display: grid; grid-template-rows: 72px 1fr; gap: 8px; height: 100%; min-height: 168px; padding: 12px;
  border: 1px solid var(--color-line); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card);
  color: var(--color-ink); text-decoration: none; transition: border-color .16s;
}
.resource-banner:hover { border-color: var(--color-action); }
.resource-banner__visual { display: grid; place-items: center; min-width: 0; }
.resource-banner__visual img { display: block; max-width: 100%; max-height: 64px; object-fit: contain; }
.resource-banner__wordmark { color: var(--color-action); font-size: var(--font-card); font-weight: 800; line-height: var(--leading-control); text-align: center; }
.resource-banner__body { display: grid; align-content: start; gap: 4px; padding-right: 28px; }
.resource-banner__name { font-size: var(--font-body); font-weight: 700; line-height: var(--leading-heading); }
.resource-banner__description { color: var(--color-muted); font-size: var(--font-body); line-height: var(--leading-control); }
.resource-banner__arrow { position: absolute; right: 10px; bottom: 12px; display: grid; place-items: center; width: 22px; height: 22px; color: var(--color-action); }

/* ---------- Footer with the four Preppers ---------- */
.community-footer { position: relative; margin-top: 8px; color: var(--color-ink); }
.community-footer__intro {
  width: fit-content; max-width: calc(100% - 32px); margin: 0 auto; padding: 20px 24px;
  border-radius: var(--radius-file); background: var(--color-surface); text-align: center;
}
.community-footer__eyebrow { margin-bottom: 4px; color: var(--color-action); font-size: var(--font-body); font-weight: 800; line-height: var(--leading-control); }
.community-footer__intro h2 { margin-bottom: 8px; font-size: var(--font-file); font-weight: 800; }
.community-footer__intro h2 span { display: inline-block; }
.community-footer__scene { position: relative; max-width: 960px; margin: 0 auto; padding: 24px 16px 0; }
.community-footer__landscape { display: none; }
.community-footer__friends { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 24px; max-width: 720px; margin: 0 auto; }
.community-footer__friends img { display: block; justify-self: center; width: 120px; height: 120px; max-width: 100%; object-fit: contain; }
.community-footer__base {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
  padding: 16px max(24px, calc((100% - 1360px) / 2)); background: var(--color-action); color: var(--color-on-action);
}
.community-footer__base strong { font-size: var(--font-file-sp); font-weight: 800; line-height: var(--leading-heading); }
.community-footer__base strong span { margin-left: 12px; font-size: var(--font-body); font-weight: 400; }

/* ---------- Toast and live region ---------- */
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: max-content; max-width: min(620px, calc(100% - 32px)); padding: 10px 16px;
  border-radius: var(--radius-control); background: var(--color-ink); color: #fff;
  font-size: var(--font-body); line-height: var(--leading-control); box-shadow: var(--shadow-dialog);
  word-break: keep-all; overflow-wrap: anywhere;
}
.toast:empty { display: none; }

/* ---------- 4.7 Dialog ---------- */
dialog {
  width: min(640px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 24px; border: 0; border-radius: var(--radius-file);
  background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-dialog);
}
dialog::backdrop { background: var(--color-backdrop); }
dialog h2 { margin-bottom: 12px; font-size: var(--font-file-sp); font-weight: 800; }
dialog form, dialog [data-cloud-panel] { display: grid; gap: var(--gap-field); }
dialog > p { margin-bottom: 12px; }
dialog > .dialog-actions, dialog form .dialog-actions { margin-top: 8px; }
.source-details > :not(summary) { margin: 0 12px 12px; }
.dialog-actions--split { justify-content: space-between; }
.dialog-actions__destructive { margin-right: 16px; }
.dialog-actions__main { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; }

/* ---------- 6.2 Glass layers and 11. Motion ---------- */
/* Only the fixed bars are glass; cards, inputs and the dialog body stay opaque. */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-header, .bottom-nav, .household-save-bar {
    background: var(--glass-surface);
    -webkit-backdrop-filter: var(--glass-filter); backdrop-filter: var(--glass-filter);
  }
  .app-header { border-bottom-color: rgb(17 24 39 / 10%); }
  .household-save-bar { border-color: var(--glass-edge); }
  /* Green and red status text never sits directly on glass. */
  .app-header .header-save-states > :not([hidden]):not(.cloud-header-status):not(.text-size-control):not(.intro-story-link) { padding: 2px 10px; border-radius: 999px; background: rgb(255 255 255 / 92%); }
  .toast { background: var(--glass-dark); -webkit-backdrop-filter: var(--glass-filter); backdrop-filter: var(--glass-filter); }
  dialog::backdrop { background: var(--glass-backdrop); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
}

/* Press and release */
.btn:active:not(:disabled, [aria-disabled="true"]), .filter-chip:active, .resource-card:active, .product-card:active {
  scale: .94; transition-duration: var(--motion-fast); transition-timing-function: var(--ease-out);
}
.number-control .btn:active:not(:disabled) { scale: .88; }
.nav-item .character-icon { transition: scale var(--motion-base) var(--ease-bounce); }
.nav-item:active .character-icon { scale: .84; transition: scale var(--motion-fast) var(--ease-out); }
.motion-pop { animation: motion-pop var(--motion-pop) var(--ease-pop) backwards; }
@keyframes motion-pop { from { scale: .6; opacity: 0; } 60% { scale: 1.08; opacity: 1; } }
.motion-bump { animation: motion-bump var(--motion-pop) var(--ease-pop); }
@keyframes motion-bump { 25% { scale: .9; translate: 0 4px; } 60% { scale: 1.18; translate: 0 -3px; } }

/* Keep selected controls aligned; color and border indicate selection. */
.filter-chip { transition: background-color var(--motion-fast), scale var(--motion-base) var(--ease-bounce), rotate var(--motion-base) var(--ease-bounce); }
:is(.filter-chip, .day-options > .btn)[aria-pressed="true"] { scale: 1; rotate: none; }

/* 11.5: the only two motions that repeat. Both are slow, and both stop with reduced motion. */
.dashboard-actions:has(.next-step-note) #show-inventory { position: relative; }
.dashboard-actions:has(.next-step-note) #show-inventory::after {
  content: ""; position: absolute; inset: -1px; border: 2px solid var(--color-action); border-radius: inherit;
  pointer-events: none; animation: motion-beacon 1.8s ease-out infinite;
}
@keyframes motion-beacon { from { opacity: .8; scale: 1; } to { opacity: 0; scale: 1.14 1.5; } }
.coverage-prepper { animation: motion-nod 1.8s ease-in-out infinite; }
@keyframes motion-nod { 0%, 100% { translate: 0 0; rotate: -4deg; } 50% { translate: 0 -6px; rotate: -4deg; } }
:is(input, select, textarea)[aria-invalid="true"] { animation: motion-shake var(--motion-base) linear; }
@keyframes motion-shake {
  0%, 100% { translate: 0; }
  17%, 50%, 83% { translate: calc(var(--motion-shift-s) / -2); }
  33%, 67% { translate: calc(var(--motion-shift-s) / 2); }
}

/* Cards that are one whole link lift on hover (mouse only); cards with inputs never move. */
.resource-card, .product-card { transition: translate var(--motion-base) var(--ease-out), box-shadow var(--motion-base) var(--ease-out), scale var(--motion-base) var(--ease-spring); }
@media (hover: hover) and (pointer: fine) {
  :is(.resource-card, .product-card):hover { translate: 0 -4px; box-shadow: var(--shadow-dialog); }
}

/* Bottom navigation: the current-place pill is inserted by motion.js and slides to the next item. */
.nav-pill { position: absolute; z-index: -1; inset: 0; border-radius: 26px; background: rgb(0 123 48 / 16%); pointer-events: none; }

/* Cards waiting to rise into view (motion.js reveals them once). */
.motion-await { opacity: 0; }

/* Goal reached: one ring spreads from the card; confetti pieces are placed by motion.js. */
.motion-celebrate { position: relative; }
.motion-celebrate::after {
  content: ""; position: absolute; inset: -1px; border: 3px solid var(--color-success); border-radius: inherit;
  pointer-events: none; opacity: 0; animation: motion-ring-out var(--motion-slow) var(--ease-out);
}
@keyframes motion-ring-out { from { opacity: .9; scale: 1; } to { opacity: 0; scale: 1.06 1.24; } }
.motion-confetti { position: fixed; z-index: 90; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; }

/* In-surface disclosures grow and shrink where the browser can animate to auto. */
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details) { interpolate-size: allow-keywords; }
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details)::details-content {
  block-size: 0; overflow: clip;
  transition: block-size var(--motion-reveal) var(--ease-smooth), opacity var(--motion-reveal) var(--ease-smooth), content-visibility var(--motion-reveal) allow-discrete;
  opacity: 0;
}
:is(.product-disclosure, .shelf-details, .daily-usage-fields, .source-details, .cloud-comparison details)[open]::details-content { block-size: auto; opacity: 1; }

/* Dialog: rises from below on phones, scales in on wider screens. Closing takes half the time. */
dialog {
  opacity: 0; scale: .92; translate: 0 var(--motion-shift-m);
  transition: opacity calc(var(--motion-slow) / 2) var(--ease-in), scale calc(var(--motion-slow) / 2) var(--ease-in),
    translate calc(var(--motion-slow) / 2) var(--ease-in),
    overlay calc(var(--motion-slow) / 2) allow-discrete, display calc(var(--motion-slow) / 2) allow-discrete;
}
dialog[open] {
  opacity: 1; scale: 1; translate: 0 0;
  transition: opacity var(--motion-base) ease-out, scale var(--motion-slow) var(--ease-spring), translate var(--motion-slow) var(--ease-spring),
    overlay var(--motion-slow) allow-discrete, display var(--motion-slow) allow-discrete;
}
@starting-style { dialog[open] { opacity: 0; scale: .92; translate: 0 var(--motion-shift-m); } }
dialog::backdrop { opacity: 0; transition: opacity var(--motion-base) ease-out, overlay var(--motion-base) allow-discrete, display var(--motion-base) allow-discrete; }
dialog[open]::backdrop { opacity: 1; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }

/* Toast: springs up from below, leaves downwards. */
.toast { transition: opacity var(--motion-base) ease-out, translate var(--motion-base) var(--ease-spring), display var(--motion-base) allow-discrete; }
.toast[hidden] { opacity: 0; translate: 0 var(--motion-shift-m); transition-timing-function: var(--ease-in); }
@starting-style { .toast:not([hidden]) { opacity: 0; translate: 0 var(--motion-shift-m); } }

/* ---------- Responsive ---------- */
@media (min-width: 1101px) {
  :is(#inventory-list, #shopping-list, .equipment-list) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  /* 5章: 家族・設定 = inputs on the left, target preview and save on a sticky right column. */
  /* Starts at 1200, not 1101: beside the side nav the form is only ~745px wide at 1101. */
  #household-form.household-form--split { grid-template-columns: minmax(400px, 1fr) minmax(320px, 440px); gap: 0 40px; align-items: start; }
  .household-form--split .household-form__main, .household-form--split .household-form__rest { display: grid; gap: 24px; min-width: 0; }
  .household-form--split .household-form__aside {
    display: grid; gap: 16px; padding: 20px;
    border-radius: var(--radius-card); background: var(--color-action-tint); box-shadow: inset 0 0 0 1px var(--color-line);
  }
  .household-form--split .household-form__aside .family-preview { padding: 12px 0 4px; }
  .household-form--split .household-form__aside .inline-preview-note { padding-top: 12px; border-top: 1px solid var(--color-line); }
  /* The column itself is sticky, so the save bar sits at its foot without floating or glass. */
  #household-form.household-form--split .household-save-bar {
    position: static; display: grid; gap: 12px; padding: 16px 0 0;
    border: 0; border-top: 1px solid var(--color-line); border-radius: 0;
    background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .household-form--split .household-save-bar .btn { width: 100%; }
  .household-form--split .household-members { grid-template-columns: repeat(auto-fill, minmax(216px, max-content)); gap: 16px 32px; }
  .household-form--split .number-control { grid-template-columns: 48px 80px 48px auto; max-width: none; }
  .household-form--split .input-with-unit { max-width: 176px; }
  .household-form--split .optional-groups { padding: 16px 20px 20px; }
  .household-form--split .optional-groups__choice { flex: 1 1 0; }
  .household-form--split .daily-usage-fields { max-width: 560px; }
}
/* Sticky only when the whole right column fits under the header; otherwise 保存 could stay out of reach. */
@media (min-width: 1200px) and (min-height: 720px) {
  .household-form--split .household-form__aside { position: sticky; top: calc(var(--header-h, 0px) + 16px); }
}
@media (min-width: 1200px) {
  .resource-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  /* With the bottom nav, the header scrolls away instead of staying fixed (one fixed bar only). */
  html { scroll-padding-top: 16px; scroll-padding-bottom: calc(var(--bottom-nav-h) + 16px); }
  .app-header { position: relative; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-content, .onboarding-content { padding-bottom: calc(var(--bottom-nav-h) + 16px); }
  .main-content:has(+ .shell-tail) { padding-bottom: 16px; }
  .bottom-nav {
    /* 4.5: a floating glass pill, 16px from the sides and 12px above the bottom edge. */
    position: fixed;
    inset: auto 16px calc(var(--bottom-nav-gap) + env(safe-area-inset-bottom));
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    max-width: 520px;
    margin-inline: auto;
    padding: 6px;
    border: 1px solid var(--glass-edge);
    border-radius: 34px;
    background: var(--color-surface);
    box-shadow: var(--shadow-float);
  }
  .bottom-nav .nav-item {
    position: relative; border-radius: 26px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 0; min-height: 48px; padding: 4px 0; color: var(--color-muted);
    /* 5項目を1行ずつで収める: 画面幅に合わせて 10〜12px。折り返さない。 */
    font-size: clamp(.625rem, 2.9vw, .75rem); font-weight: 700; line-height: var(--leading-nav); text-align: center; text-decoration: none; white-space: nowrap;
    transition: color var(--motion-base);
  }
  .bottom-nav .nav-item .character-icon { width: 28px; height: 28px; }
  /* 文字「大」でも1行のまま: 10〜14px。 */
  :root[data-text-size="large"] .bottom-nav .nav-item { font-size: clamp(.625rem, 3.3vw, .875rem); }
  .bottom-nav .nav-item__label { max-inline-size: 100%; }
  .bottom-nav .nav-item:hover { color: var(--color-action-on-glass); }
  /* Without motion.js the current item carries the tint itself; with it, the sliding pill does. */
  .bottom-nav .nav-item[aria-current="page"] { color: var(--color-action-on-glass); background: rgb(0 123 48 / 16%); }
  .bottom-nav .nav-item[aria-current="page"]:has(.nav-pill) { background: none; }
  .toast { bottom: calc(var(--bottom-nav-h) + 12px); }
  .household-save-bar { bottom: calc(var(--bottom-nav-h) + 8px); }
  .community-footer__base { padding-bottom: calc(var(--bottom-nav-h) + 16px); }
}
/* 701–920: the header stays on one line (DESIGN.md 7.1): no caption, short save state. */
@media (min-width: 701px) and (max-width: 920px) {
  .app-header { flex-wrap: nowrap; padding: 8px 16px; gap: 12px; }
  .brand-caption { display: none; }
  .header-save-states { flex-wrap: wrap; }
  .header-save-states > * { max-width: 100%; overflow-wrap: anywhere; }
  .save-status__full { display: none; }
  .save-status__short { display: inline; }
}
@media (max-width: 700px) {
  .app-header { padding: 8px 10px; gap: 8px; }
  .brand { font-size: var(--font-file-sp); }
  .brand .character-icon { width: 40px; height: 40px; }
  .brand-caption { display: none; }
  /* Two rows on phones: logo + save state, then text size + Google sync (no third row). */
  .app-header { row-gap: 4px; }
  .header-save-states { display: contents; }
  .app-header::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
  .header-save-states > .text-size-control, .header-save-states > .cloud-header-status { order: 2; }
  /* The sync button shares row 2 with the text size switch; at 320px its label wraps to two lines inside it. */
  .header-save-states > .cloud-header-status { flex: 1 1 0; }
  .cloud-header-status [data-cloud-header-label] { line-height: 1.3; }
  /* 359px 以下は同期の絵を出さず、「ほかの端末でも使う」を1行に収める（保存状態と合わせて2行、高さ50px）。 */
  @media (max-width: 359px) {
    .cloud-header-icon { display: none; }
    .header-save-states > .cloud-header-status { padding-inline: 8px; }
  }
  .main-content, .onboarding-content, main.onboarding { padding-top: 12px; }
  .page-heading { gap: 8px; padding: 12px; }
  .page-heading > div:first-child { gap: 4px 8px; }
  .page-title { font-size: var(--font-page-sp); }
  .onboarding-mascot { flex-basis: 56px; }
  header.section-band__heading > .file-tab, .file-tab__button { font-size: var(--font-file-sp); }
  .form-grid, .daily-usage-grid, .cloud-comparisons { grid-template-columns: minmax(0, 1fr); }
  /* Category tabs: equal-width columns on phones (3 categories). */
  .inventory-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inventory-groups > button { min-width: 0; padding-inline: 6px; flex-direction: column; justify-content: center; gap: 4px; text-align: center; }
  .inventory-groups .group-tab__label { flex: 0 0 auto; }
  .plan-panel { grid-template-columns: minmax(0, 1fr); }
  .coverage-card { padding: 8px 6px; }
  .coverage-ring { width: min(100%, 82px); }
  .coverage-stock > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .coverage-stock strong { font-size: var(--font-number-compact); }
  .coverage-prepper { width: 64px; height: 64px; }
  .coverage-chevron { display: none; }
  .shelf-rows { grid-template-columns: minmax(0, 1fr); }
  .shelf-row { grid-row: auto; grid-template-rows: none; align-content: start; }
  .shelf-row > :is(.shelf-label, .shelf-amount, .shelf-art, .shelf-breakdown, .shelf-overflow, .shelf-caption) { grid-row: auto; }
  .onboarding-preview .onboarding-illustration { display: none; }
  .onboarding-preview .inline-family-preview { display: grid; }
  .family-preview__category { padding-inline: 6px; }
  .family-preview__legend--water { flex-direction:column; justify-content:flex-start; }
  .shelf-amount, .family-preview__amount { font-size: var(--font-number-compact); }
  .family-preview__art {
    grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: repeat(var(--preview-mobile-rows, 1), minmax(0, 1fr));
    height: auto; aspect-ratio: 264 / calc(var(--preview-mobile-rows, 1) * 84);
  }
  .family-preview__object { grid-column: var(--mobile-column) / span 2; grid-row: var(--mobile-row); }
  .stock-illustration-label { display: none; }
  [data-stock-art] > image { transform: translateY(6px); }
  .household-save-bar .btn { flex: 1 1 100%; }
  /* 11.2: on phones the dialog is a sheet that springs up from the bottom edge. */
  dialog {
    width: 100%; max-width: 100%; max-height: calc(100dvh - 24px); margin: auto 0 0;
    padding: 20px; border-radius: 20px 20px 0 0;
    scale: 1; translate: 0 100%;
  }
  dialog[open] { scale: 1; }
  @starting-style { dialog[open] { opacity: 1; scale: 1; translate: 0 100%; } }
  dialog form > .dialog-actions {
    position: sticky;
    bottom: -20px;
    z-index: 1;
    margin: 8px -20px -20px;
    padding: 12px 20px max(12px, env(safe-area-inset-bottom));
    background: var(--color-surface);
    box-shadow: var(--shadow-sticky);
  }
  .resource-grid { grid-template-columns: minmax(0, 1fr); }
  .resource-links { padding: 16px 12px; }
  .resource-links__heading h2, .community-footer__intro h2 { font-size: var(--font-file-sp); }
  .community-footer__intro { padding: 16px; }
  .community-footer__friends { gap: 12px; }
  .community-footer__friends img { height: 76px; }
  .community-footer__base { padding-inline: 10px; }
}
@media (max-height: 480px) {
  .household-save-bar, #household-form[data-dirty="true"] .household-save-bar { position: static; box-shadow: none; }
  dialog form > .dialog-actions { position: static; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- 8.1 Print ---------- */
@media print {
  .motion-await { opacity: 1 !important; }
  .nav-pill, .motion-confetti { display: none !important; }
  @page { margin: 12mm; }
  html, body { background: #fff; color: #000; }
  body { font-size: 10.5pt; line-height: 1.6; }
  body::before, .skip-link, .app-header, .sidebar, .bottom-nav, .nav-progress, .toast, #live-status,
  .community-footer, .resource-links, .dashboard-actions, .backup-reminder, .offline-note, #save-banner,
  .btn, button, .product-disclosure, .commerce-note, .file-tab__arrow, .resource-card-action,
  .household-save-bar, .onboarding-mascot, .resource-brand { display: none !important; }
  .print-only { display: block; }
  .app-shell { display: block; max-width: none; }
  .main-content, .onboarding-content { padding: 0; }
  .page-heading, .section-band__surface, .onboarding-support { padding: 0; border-radius: 0; background: none; }
  .page-title { font-size: 16pt; }
  .band-stack > .section-band + .section-band { margin-top: 12pt; }
  .section-band, .band-stack > .section-band:last-child { padding: 0; color: #000; }
  .section-band::before, header.section-band__heading > .file-tab::before, header.section-band__heading > .file-tab::after,
  .file-tab__button::before, .file-tab__button::after { display: none; }
  header.section-band__heading > .file-tab, .file-tab__button { min-height: 0; padding: 4pt 0; font-size: 13pt; color: #000; }
  .section-band > .section-band__surface, .file-tab__body { margin: 0; }
  .file-tab__body[hidden] { display: block !important; content-visibility: visible !important; }
  .file-tab__button { display: flex !important; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { border: 0; padding: 0; min-height: 0; }
  .resource-card, .stock-card, .coverage-card, .settings-panel { break-inside: avoid; box-shadow: none; }
  .resource-card { min-height: 0; border-color: #000; }
  /* Pages with a print sheet print only the sheet (saved values), not the interactive cards. */
  main:has(.print-sheet) > :not(.print-sheet) { display: none !important; }
  .print-header { display: grid; gap: 2pt; margin-bottom: 8pt; }
  .print-header__title { font-size: 14pt; font-weight: 800; }
  .print-table { width: 100%; margin-block: 8pt; border-collapse: collapse; font-size: 10.5pt; line-height: 1.6; }
  .print-table caption { font-weight: 700; text-align: start; }
  .print-table th, .print-table td { padding: 2pt 4pt; border: 1px solid #000; text-align: start; }
  .print-table tr { break-inside: avoid; }
}

/* Store checklist is separate from the saved-inventory print sheet. */
.print-actions { display:flex; flex-wrap:wrap; gap:8px; }
@media print {
  @page store-checklist {
    size:A4; margin:12mm 12mm 30mm;
    @bottom-left { font-family:var(--font-family); font-size:8pt; color:#4b5563; vertical-align:middle; }
    @bottom-right { content:url("../assets/watrix-print-footer.svg"); vertical-align:middle; }
    @bottom-center { content:counter(page) " / " counter(pages); font-family:var(--font-family); font-size:9pt; color:#4b5563; vertical-align:middle; }
  }
  .print-store-footer { display:none; }
  .print-watrix-logo { width:32mm; height:auto; }
  .print-watrix-qr { width:22mm; height:22mm; }
  body[data-print-kind="store-checklist"] > :not(.store-checklist) { display:none !important; }
  .store-checklist { page:store-checklist; font-size:9pt; }
  .store-checklist .print-header { display:block; margin-bottom:0; flex:1; min-width:0; text-align:left; }
  .store-checklist .print-header p { margin:0; }
  .store-checklist .print-header__title { font-size:11pt; font-weight:700; line-height:1.4; }
  .print-title-divider { font-weight:400; color:#6b7280; margin-inline:1mm; }
  .store-checklist .print-header .print-header__days { margin-top:3mm; font-size:23pt; font-weight:800; line-height:1.25; letter-spacing:-.02em; }
  .print-header__days span { font-size:18pt; font-weight:400; color:#6b7280; }
  .store-checklist .print-header .print-header__household { margin-top:1.5mm; font-size:11pt; font-weight:400; line-height:1.5; }
  .store-checklist .print-header .print-header__family { margin-top:1mm; font-size:9pt; line-height:1.5; }
  .print-store-heading { display:flex; justify-content:space-between; align-items:center; gap:8mm; break-inside:avoid; padding-bottom:5mm; margin-bottom:3mm; border-bottom:0.5pt solid #d2d6d9; }
  .print-store-brand { display:flex; align-items:center; gap:3mm; flex:none; }
  .print-store-brand img { width:22mm; height:22mm; object-fit:contain; }
  .print-store-brand img:last-child { width:24mm; height:24mm; }
  .print-folder-stack { margin-top:2mm; }
  .print-folder-page { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:5mm; align-items:start; }
  .print-folder-page + .print-folder-page { break-before:page; }
  .print-folder-column { min-width:0; }
  .print-folder { --print-folder-color:#e5f3e9; position:relative; isolation:isolate; padding-bottom:3mm; break-inside:avoid; page-break-inside:avoid; print-color-adjust:exact; -webkit-print-color-adjust:exact; }
  .print-folder--yellow { --print-folder-color:#fff4cc; }
  .print-folder + .print-folder { margin-top:4mm; }
  .print-folder:last-child { padding-bottom:3mm; }
  .print-folder::before { content:""; position:absolute; inset:5mm 0 0; z-index:-1; background:var(--print-folder-color); border-radius:0 3mm 3mm 3mm; }
  .print-folder-tab { position:relative; width:fit-content; max-width:calc(100% - 8mm); min-height:10mm; display:flex; align-items:center; margin:0; padding:2mm 4mm; color:var(--color-on-file); font-size:12pt; font-weight:800; line-height:1.25; }
  .print-folder-tab::before { content:""; position:absolute; inset:0 0 auto; height:5mm; z-index:-1; border-radius:3mm 0 0 0; background:var(--print-folder-color); }
  .print-folder-tab::after { content:""; position:absolute; left:100%; top:0; width:6mm; height:5mm; z-index:-1; background:var(--print-folder-color); mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 40'%3E%3Cpath d='M0 0C20 0 20 40 48 40H0Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat; }
  .print-folder-surface { margin:0 2mm; padding:1mm; border-radius:2.5mm; background:white; }
  .print-folder .print-store-table { margin:0; border-collapse:collapse; font-size:9pt; }
  .print-folder .print-store-table th, .print-folder .print-store-table td { height:8mm; border-color:#9ca3af; }
  .print-folder .print-store-table thead th { height:7mm; color:#4b5563; font-size:8.5pt; }

  .print-store-table thead { break-inside:avoid; break-after:avoid; }
  .print-store-table { table-layout:fixed; width:calc(100% - 2px); }
  .print-store-table thead { display:table-header-group; }
  .print-store-table tr { break-inside:avoid; page-break-inside:avoid; }
  .print-store-table th, .print-store-table td { height:12mm; overflow-wrap:anywhere; }
  .print-store-table col:nth-child(1) { width:12%; }
  .print-store-table col:nth-child(2) { width:58%; }
  .print-store-table col:nth-child(3) { width:30%; }
  .print-store-table .print-check { text-align:center; font-size:16pt; }
  .print-write-in { display:block; height:6mm; }
}
.product-purchase-hint { color: var(--color-muted); }
.product-purchase-extra { display: block; color: var(--color-muted); }
/* Text links and plain summaries keep a 44px touch target (DESIGN.md 4.5). */
.tap-link { display: inline-flex; align-items: center; min-height: 44px; }
.settings-panel > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }

/* ---------- 使い方 (/guide) ---------- */
.page-guide-link { align-self: flex-start; color: var(--color-action); font-size: var(--font-body); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
/* 目次はスクロールしても残す。PC は固定ヘッダーの直下、ヘッダーが流れる幅は画面の上端に付く。
   項目は1行に並べ、入りきらない幅では横にスクロールする（折り返して縦に場所を取らない）。
   いま読んでいる節は layout.js が aria-current を付けて塗る。 */
.guide-toc {
  position: sticky; top: var(--header-h, 0px); z-index: 15;
  margin: 0 0 16px; padding: 10px 0; border-radius: var(--radius-card); background: var(--color-surface);
  transition: box-shadow var(--motion-reveal) var(--ease-smooth), border-radius var(--motion-reveal) var(--ease-smooth);
}
.guide-toc.is-stuck { border-radius: 0 0 var(--radius-card) var(--radius-card); box-shadow: 0 4px 12px rgb(12 48 32 / 12%); }
.guide-toc ul {
  display: flex; gap: 8px; margin: 0; padding: 0 16px; list-style: none;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-padding-inline: 16px; scroll-snap-type: x proximity; scrollbar-width: none;
}
.guide-toc ul::-webkit-scrollbar { display: none; }
/* 横に続きがあるときだけ端をぼかし、まだ項目があると分かるようにする。 */
.guide-toc[data-more~="start"] ul { mask-image: linear-gradient(to right, transparent, #000 32px); }
.guide-toc[data-more~="end"] ul { mask-image: linear-gradient(to left, transparent, #000 32px); }
.guide-toc[data-more~="start"][data-more~="end"] ul { mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
.guide-toc li { flex: none; scroll-snap-align: start; }
.guide-toc a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 4px 14px; border: 1px solid var(--color-input-border);
  border-radius: 999px; background: var(--color-surface); color: var(--color-action); font-size: var(--font-body); font-weight: 700;
  text-decoration: none; white-space: nowrap;
  transition: background-color var(--motion-reveal) var(--ease-smooth), color var(--motion-reveal) var(--ease-smooth);
}
.guide-toc a:hover { background: var(--color-action-tint); }
.guide-toc a[aria-current="location"] { border-color: var(--color-action); background: var(--color-action); color: var(--color-on-action); }
/* html の scroll-padding-top（ヘッダー＋16px）に目次の高さを足す。 */
.guide-section { scroll-margin-top: var(--guide-toc-h, 0px); }
.guide-body { display: grid; gap: 12px; font-size: var(--font-body); line-height: var(--leading-body); word-break: normal; line-break: strict; }
.guide-body p { margin: 0; }
.guide-body a { color: var(--color-action); font-weight: 700; }
.guide-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: guide-step; }
.guide-steps li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 2px 10px; counter-increment: guide-step; }
.guide-steps li::before {
  content: counter(guide-step); grid-row: span 2; display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 50%; background: var(--color-action); color: var(--color-on-action); font-weight: 800;
}
.guide-steps strong { font-size: var(--font-card); line-height: var(--leading-heading); word-break: keep-all; overflow-wrap: anywhere; }
.guide-list { display: grid; gap: 8px; margin: 0; padding-left: 1.25em; }
.guide-terms { display: grid; gap: 10px; margin: 0; }
.guide-terms > div { display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr); gap: 8px 12px; align-items: start; }
.guide-terms dt .status-badge { display: inline-flex; }
.guide-terms dd { margin: 0; }
/* 節の冒頭: いちばん伝えたい1文とリスの挿絵。そのあとに短い要点、細かい説明は折りたたむ。 */
.guide-intro { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 12px; align-items: center; }
.guide-lead { font-size: var(--font-card); font-weight: 700; line-height: 1.6; }
.guide-art { display: block; width: 104px; height: 104px; object-fit: contain; }
.guide-points { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.guide-points li { position: relative; padding-left: 26px; }
.guide-points li::before {
  content: ""; position: absolute; left: 0; top: .28em; width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-action) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.2 8.3l2.5 2.5 5-5.4'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.guide-more, .guide-faq details { border-top: 1px solid var(--color-line); }
.guide-more > summary, .guide-faq summary {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding-block: 6px;
  color: var(--color-action); font-weight: 700; line-height: var(--leading-heading); cursor: pointer; list-style: none;
}
.guide-more > summary::-webkit-details-marker, .guide-faq summary::-webkit-details-marker { display: none; }
.guide-more > summary::before, .guide-faq summary::before {
  content: ""; flex: none; width: 8px; height: 8px; margin-inline: 2px 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  rotate: -45deg; transition: rotate var(--motion-fast);
}
.guide-more[open] > summary::before, .guide-faq details[open] > summary::before { rotate: 45deg; }
.guide-more > .guide-list { padding-bottom: 4px; }
.guide-faq { display: grid; }
.guide-faq summary { color: var(--color-ink); }
.guide-faq details > p { padding: 0 0 12px 26px; }
.guide-faq details:last-child { border-bottom: 1px solid var(--color-line); }
/* ページの見出しの下: 漫画のポップアップを開く。 */
.guide-story-link { min-height: 44px; padding: 0; border: 0; background: none; font: inherit; font-size: var(--font-body); font-weight: 700; cursor: pointer; }
@media (min-width: 701px) {
  .guide-intro { grid-template-columns: minmax(0, 1fr) 152px; gap: 20px; }
  .guide-art { width: 152px; height: 152px; }
}
.community-footer__guide { color: inherit; font-weight: 700; }
.community-footer__links { display: flex; flex-wrap: wrap; gap: 0 20px; }
@media (max-width: 700px) {
  .guide-terms > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  /* 画面の端から端まで使い、上端に付いたら角を落とす。指で送れる幅を広く取る。 */
  .guide-toc { margin-inline: calc(var(--page-padding) * -1); padding: 8px 0; border-radius: 0; }
  .guide-toc.is-stuck { border-radius: 0; }
  .guide-toc ul { gap: 6px; padding-inline: var(--page-padding); scroll-padding-inline: var(--page-padding); }
  .guide-toc a { padding-inline: 12px; }
}
