:root {
  color-scheme: light;
  --ink: #111111;
  --paper: #ffffff;
  --paper-soft: #f6f4ee;
  --line: #cbc7bc;
  --muted: #69655d;
  --accent: #c41e24;
  --success: #315d43;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

.app-shell { min-height: 100dvh; }
.home-view {
  --home-ink: #f7fbff;
  --home-muted: #b9cfde;
  --home-line: rgba(220, 244, 255, .2);
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 74% 4%, rgba(101, 215, 232, .2), transparent 34rem),
    linear-gradient(160deg, #071426 0%, #0b2440 58%, #0e4765 135%);
  color: var(--home-ink);
  padding: 30px max(16px, calc((100% - 980px) / 2)) 150px;
}
.home-masthead { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.home-kicker, .home-date { margin: 0 0 8px; color: #bfeef6; font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
.home-view h1.home-brand { color: white; font: 750 1.25rem/1 Inter, "PingFang SC", sans-serif; letter-spacing: .04em; }
.home-intro { max-width: 620px; margin: 14px 0 0; color: var(--home-muted); }
.home-date { margin-top: 30px; }
.home-edit-button, .home-add-actions button, .home-card-control, .home-card-select {
  min-height: 42px; border: 1px solid var(--home-line); border-radius: 999px;
  background: rgba(7, 24, 43, .62); color: white; padding: 8px 14px; font-weight: 750;
}
.home-edit-button[aria-pressed="true"] { background: #f7fbff; color: #071426; }
.home-view button:focus-visible, .home-view select:focus-visible, .home-card:focus-visible {
  outline: 3px solid #65d7e8; outline-offset: 3px;
}
.home-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.home-card {
  min-width: 0; overflow: hidden; border: 1px solid var(--home-line); border-radius: 26px;
  background: transparent; color: white; padding: 18px;
  box-shadow: none;
}
.home-card[data-borderless="true"] { border-color: transparent; }
.home-health-card {
  cursor: pointer; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: max-content; align-content: start; row-gap: 3px; column-gap: 12px;
}
.home-health-card .home-card-component { grid-column: 1 / -1; }
.home-card-small { grid-column: auto; min-height: 190px; }
.home-card-medium { grid-column: 1 / -1; min-height: 280px; }
.home-card-large { grid-column: 1 / -1; min-height: 390px; }
.home-health-card.home-card-medium,
.home-health-card.home-card-large,
.home-todo-card.home-card-medium,
.home-todo-card.home-card-large { min-height: 0; }
.home-health-card.home-card-small { grid-template-columns: minmax(0, 1fr); }
.home-health-card.home-card-medium { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-health-card.home-card-large { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.home-card-component { margin: 0; color: #bfeef6; font-size: .76rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.home-card-question { margin-top: 18px; color: var(--home-muted); font: 650 .86rem/1.4 Inter, "PingFang SC", sans-serif; }
.home-card-value { display: inline-block; max-width: 100%; margin-top: 5px; font-size: clamp(2rem, 8vw, 4.2rem); line-height: 1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.home-card-unit { margin-left: 7px; color: var(--home-muted); font-size: .78rem; }
.home-card-status, .home-card-progress, .home-card-trend, .home-card-evidence-line { color: var(--home-muted); }
.home-card-status { min-height: 2.8em; margin: 12px 0 0; }
.home-card-progress, .home-card-trend { margin: 16px 0 0; border-top: 1px solid var(--home-line); padding-top: 12px; }
.home-card-progress::before { content: "进度 · "; color: white; font-weight: 750; }
.home-card-trend::before { content: "趋势 · "; color: white; font-weight: 750; }
.home-card-evidence { margin-top: 18px; border-top: 1px solid var(--home-line); padding-top: 8px; }
.home-card-evidence-line { margin: 9px 0 0; }
.home-card-small .health-module { grid-column: 1 / -1; }
.home-card-medium .health-module { grid-column: span 1; }
.home-card-large .health-module { grid-column: span 1; }
.home-memory-card { min-height: 190px; }
.home-memory-value { display: block; margin-top: 24px; font-size: 1.6rem; }
.home-memory-status { color: var(--home-muted); }
.home-memory-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.home-memory-actions button {
  min-height: 40px; border: 1px solid var(--home-line); border-radius: 999px;
  background: rgba(255, 255, 255, .08); color: white; padding: 7px 12px; font-weight: 750;
}
.home-card-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 18px; border-top: 1px dashed var(--home-line); padding-top: 14px; }
.home-health-card .home-card-controls { grid-column: 1 / -1; }
.home-module-control { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.home-card-select { min-width: 0; width: 100%; border-radius: 12px; background: #0d2a46; }
.home-card-control { border-radius: 12px; padding-inline: 8px; }
.home-card-remove { color: #ffd2ce; }
.home-editor { grid-column: 1 / -1; margin-top: 16px; border: 1px solid var(--home-line); border-radius: 24px; background: rgba(4, 17, 31, .82); padding: 18px; }
.home-editor h2 { color: white; font: 750 1.3rem/1.2 Inter, "PingFang SC", sans-serif; }
.home-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.home-editor-heading button { min-height: 42px; border: 1px solid var(--home-line); border-radius: 999px; padding: 8px 16px; background: white; color: #071426; font-weight: 800; }
.home-editor p, .home-status, .home-meaning { color: var(--home-muted); }
.home-add-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.home-status { min-height: 1.5em; }
.home-meaning { margin: 20px 0 0; font-size: .78rem; }
.home-empty { grid-column: 1 / -1; border: 1px dashed var(--home-line); border-radius: 24px; padding: 34px 18px; color: var(--home-muted); text-align: center; }
.home-todo-card { position: relative; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.home-todo-card-link {
  position: relative;
  z-index: 2;
  display: inline-flex;
  justify-self: end;
  align-items: center;
  min-height: 44px;
  color: var(--home-muted);
  font-size: .82rem;
  font-weight: 720;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.home-todo-card-link:focus-visible { outline: 3px solid #65d7e8; outline-offset: 2px; }
.home-todo-card[data-editing="true"] { cursor: default; }
.home-todo-card[data-editing="true"] .home-todo-card-link { display: none; }
.home-todo-card > .todo-information-group { grid-column: 1 / -1; position: relative; z-index: 1; }
.home-todo-card .home-card-controls { grid-column: 1 / -1; position: relative; z-index: 1; }
.home-todo-card > .todo-information-group,
.home-todo-card .home-card-controls { cursor: default; }
.journal-view { min-height: 100dvh; background: var(--paper); color: var(--ink); }
.health-back { align-self: center; white-space: nowrap; }
.app-shell[data-view="home"] .ben-bar {
  color: white;
}
.app-shell[data-view="home"] .ben-composer-sheet { border-color: rgba(220, 244, 255, .25); background: rgba(5, 18, 33, .96); box-shadow: 0 12px 34px rgba(0, 7, 17, .34); backdrop-filter: blur(22px); }
.app-shell[data-view="home"] .ben-bar input,
.app-shell[data-view="home"] .ben-bar textarea,
.app-shell[data-view="home"] .ben-action { border-color: rgba(220, 244, 255, .2); background: rgba(255, 255, 255, .08); color: white; }
.app-shell[data-view="home"] .ben-send { background: #65d7e8; color: #071426; }
.app-shell[data-view="home"] .ben-state,
.app-shell[data-view="home"] .ben-media-preview label,
.app-shell[data-view="home"] .ben-media-preview span { color: #b9cfde; }

.page-shell { width: min(100% - 32px, 980px); margin: 0 auto; padding: 30px 0 130px; }
.masthead, .today-heading, .dialog-heading, .items-heading, .split-actions {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
}
.masthead { border-bottom: 2px solid var(--ink); padding-bottom: 18px; }
h1, h2, h3, .metric-value, .meal-title, .meal-total {
  margin: 0; font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
}
h1 { font-size: clamp(2rem, 8vw, 4.5rem); line-height: .95; }
h2 { font-size: clamp(2rem, 6vw, 3.5rem); }
h3 { font-size: 1.35rem; }
.kicker, .section-number {
  margin: 0 0 8px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .18em;
}
.today-heading { padding: 32px 0 18px; }
.date-field { display: grid; gap: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; }
input, select {
  min-height: 44px; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); padding: 9px 11px; color: var(--ink);
}
.button { min-height: 44px; border: 1px solid var(--ink); border-radius: 2px; padding: 10px 16px; font-weight: 800; }
.button-primary { border-color: var(--accent); background: var(--accent); color: white; }
.button-secondary { background: white; color: var(--ink); }
.text-button { border: 0; background: transparent; padding: 8px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--ink); }
.metric { min-width: 0; padding: 18px 14px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: block; color: var(--muted); font-size: .76rem; }
.metric-value { display: block; margin-top: 6px; font-size: clamp(1.45rem, 4vw, 2.4rem); }
.metric-unit { font-family: inherit; font-size: .72rem; color: var(--muted); }
.status-line { min-height: 1.4em; color: var(--muted); }
.meal-list { display: grid; gap: 16px; }
.meal-card { border: 1px solid var(--line); padding: 18px; }
.meal-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 13px; }
.meal-title { font-size: 1.55rem; }
.meal-total { font-size: 1.4rem; white-space: nowrap; }
.tag-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.tag { border: 1px solid var(--ink); padding: 3px 7px; font-size: .72rem; }
.memory-complete { color: var(--success); border-color: var(--success); }
.memory-waiting_ben { color: var(--accent); border-color: var(--accent); }
.meal-items { list-style: none; margin: 14px 0; padding: 0; }
.meal-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.meal-item-meta { color: var(--muted); }
.meal-macros { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: .85rem; }
.empty-state { border-block: 1px solid var(--line); padding: 35px 4px; color: var(--muted); font-family: Georgia, "Songti SC", serif; font-style: italic; }

.meal-dialog { width: min(920px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 2px solid var(--ink); border-radius: 3px; padding: 0; background: var(--paper); }
.meal-dialog::backdrop { background: rgba(17,17,17,.55); }
.meal-dialog form { padding: 22px; }
.meal-edit-dialog {
  width: min(920px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  border: 2px solid var(--ink); border-radius: 3px; padding: 0; background: var(--paper);
  overflow-x: hidden;
}
.meal-edit-dialog::backdrop { background: rgba(17,17,17,.55); }
.meal-edit-dialog form { padding: 22px; }
.meal-edit-course { display: grid; gap: 6px; font-weight: 700; }
.meal-edit-course input { width: 100%; }
.meal-delete-boundary { border-left: 4px solid var(--accent); padding: 10px 12px; color: var(--muted); }
.meal-provenance { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.meal-original-input { margin-top: 10px; color: var(--muted); font-size: .82rem; }
.meal-original-input summary { cursor: pointer; font-weight: 700; }
.meal-original-input pre { margin: 9px 0 0; padding: 10px; background: var(--paper-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.meal-edit-comparison { border-top: 1px solid var(--line); padding-top: 14px; }
.meal-maintenance-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.meal-maintenance-actions span { color: var(--muted); font-size: .78rem; }
.recently-deleted-panel { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 10px; }
.recently-deleted-card { background: var(--paper-soft); }
.exercise-heading { margin-top: 34px; }
.exercise-list { display: grid; gap: 12px; }
.exercise-card { border: 1px solid var(--ink); background: var(--paper); padding: 16px; overflow-wrap: anywhere; }
.exercise-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.exercise-card-head strong { color: var(--accent); white-space: nowrap; }
.exercise-facts, .exercise-formula, .exercise-provenance, .exercise-deduction { margin: 8px 0; color: var(--muted); font-size: .85rem; }
.exercise-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 2px solid var(--ink); background: var(--paper); overflow-x: hidden; }
.exercise-dialog::backdrop, .exercise-remove-dialog::backdrop { background: rgba(17,17,17,.55); }
.exercise-dialog form, .exercise-remove-dialog section { padding: 22px; }
.exercise-mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; border: 1px solid var(--line); }
.exercise-mode-switch label, .exercise-check { display: flex; align-items: center; gap: 8px; }
.exercise-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.exercise-fields label, .exercise-field { display: grid; gap: 6px; }
.exercise-check { grid-column: 1 / -1; }
.exercise-volume-formula { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.exercise-remove-dialog { width: min(520px, calc(100% - 24px)); padding: 0; border: 2px solid var(--ink); background: var(--paper); }
.metric-heading { margin-top: 34px; }
.metric-entry-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.metric-current-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.weight-day-row { min-width: 0; border: 1px solid var(--ink); padding: 14px; overflow-wrap: anywhere; }
.weight-day-row p { margin: 6px 0 0; color: var(--muted); }
.metric-dialog { width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 2px solid var(--ink); overflow-x: hidden; }
.metric-dialog::backdrop, #weight-remove-dialog::backdrop { background: rgba(17,17,17,.55); }
.metric-dialog form { padding: 22px; }
.metric-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric-form-grid label { display: grid; gap: 6px; }
.metric-source-note { grid-column: 1 / -1; color: var(--muted); }
.metric-step-actions { grid-column: 1 / -1; gap: 8px; }
.weight-day-list { display: grid; gap: 8px; }
.weight-day-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.dialog-heading { border-bottom: 1px solid var(--ink); padding-bottom: 14px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label, .food-row label { display: grid; gap: 6px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.wide-field { grid-column: 1 / -1; }
.items-heading { margin: 28px 0 12px; }
.food-items { display: grid; gap: 12px; }
.food-row { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); gap: 10px; border: 1px solid var(--line); padding: 14px; }
.food-row legend { padding: 0 6px; font-family: Georgia, "Songti SC", serif; font-weight: 700; }
.food-row .remove-item { grid-column: 1 / -1; justify-self: end; color: var(--accent); }
.memory-switch { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; border-left: 3px solid var(--ink); background: var(--paper-soft); padding: 13px; }
.memory-switch input { min-height: auto; margin-top: 3px; }
.memory-switch span { display: grid; gap: 4px; }
.memory-switch small { color: var(--muted); }
.memory-component-library { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-top: 16px; border: 1px solid var(--ink); padding: 14px; }
.memory-component-library h3, .memory-component-library p { margin: 4px 0; }
.memory-first-notice { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; }
.memory-first-notice[hidden] { display: none; }
.memory-component-manage { grid-column: 1 / -1; justify-self: start; min-height: 42px; }

.memory-record-dialog {
  width: min(940px, calc(100% - 24px)); max-height: calc(100dvh - 24px); margin: auto;
  overflow: hidden; border: 1.5px solid var(--ink); border-radius: 8px; padding: 0;
  background: var(--paper); color: var(--ink); box-shadow: 0 22px 70px rgba(7, 20, 38, .28);
}
.memory-record-dialog::backdrop { background: rgba(7, 20, 38, .7); }
.memory-record-shell { display: flex; min-height: min(680px, calc(100dvh - 26px)); flex-direction: column; }
.memory-record-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  border-bottom: 1px solid var(--ink); padding: 18px 20px 15px;
}
.memory-record-heading h2 { font-size: clamp(1.65rem, 4vw, 2.5rem); line-height: 1; }
.memory-record-heading p { max-width: 66ch; margin: 8px 0 0; color: var(--muted); font-size: .82rem; }
.memory-record-toolbar {
  display: flex; align-items: stretch; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line); padding: 12px 20px;
}
.memory-record-toolbar form { min-width: 0; display: flex; flex: 1; gap: 8px; }
.memory-record-toolbar input { min-width: 0; flex: 1; }
.memory-record-status { min-height: 0; margin: 0; padding: 7px 20px; border-bottom: 1px solid var(--line); font-size: .78rem; }
.memory-record-status:empty { display: none; }
.memory-record-workspace { min-height: 0; display: grid; grid-template-columns: minmax(230px, 31%) minmax(0, 1fr); flex: 1; }
.memory-record-index { min-width: 0; overflow-y: auto; border-inline-end: 1px solid var(--line); background: var(--paper-soft); padding: 8px; }
.memory-record-list { display: grid; gap: 2px; }
.memory-record-list-item {
  min-width: 0; width: 100%; display: grid; gap: 4px; border: 0; border-radius: 4px;
  background: transparent; color: var(--ink); padding: 11px 10px; text-align: start;
}
.memory-record-list-item:hover { background: #ebe8df; }
.memory-record-list-item[aria-current="true"] { background: #071426; color: white; }
.memory-record-list-item strong { overflow-wrap: anywhere; }
.memory-record-list-item span { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.memory-record-list-item[aria-current="true"] span { color: #c9dce8; }
.memory-record-empty { margin: 14px 10px; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.memory-record-stage { min-width: 0; overflow-y: auto; padding: 22px; }
.memory-record-welcome { max-width: 62ch; padding-block: 36px; }
.memory-record-welcome h3 { font-size: 1.55rem; }
.memory-record-welcome p { color: var(--muted); line-height: 1.65; }
.memory-record-detail > header, .memory-record-editor > header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  border-bottom: 1px solid var(--line); padding-bottom: 13px;
}
.memory-record-detail h3, .memory-record-editor h3, .memory-record-confirmation h3 {
  min-width: 0; overflow-wrap: anywhere; font-size: clamp(1.45rem, 4vw, 2.15rem); line-height: 1.12;
}
.memory-record-meta { margin: 7px 0 0; color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }
.memory-record-body { max-width: 72ch; margin: 22px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.memory-record-detail h4 { margin: 22px 0 9px; font-size: .78rem; letter-spacing: .08em; }
.memory-record-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.memory-record-tag { max-width: 100%; border: 1px solid var(--line); padding: 5px 8px; font-size: .76rem; overflow-wrap: anywhere; }
.memory-record-links { display: grid; gap: 1px; border-block: 1px solid var(--line); }
.memory-record-link-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 7px; padding: 9px 0; }
.memory-record-link-open { min-width: 0; border: 0; background: transparent; color: var(--ink); padding: 5px; text-align: start; overflow-wrap: anywhere; }
.memory-record-link-type { color: var(--muted); font-size: .72rem; }
.memory-record-link-remove { border: 0; background: transparent; color: var(--accent); padding: 7px; text-decoration: underline; text-underline-offset: 3px; }
.memory-record-link-form {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, .42fr) auto;
  align-items: end; gap: 8px; margin-top: 12px;
}
.memory-record-link-form label, .memory-record-editor label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.memory-record-link-form select { min-width: 0; width: 100%; }
.memory-record-delete { margin-top: 28px; border: 0; background: transparent; color: var(--accent); padding: 8px 0; text-decoration: underline; text-underline-offset: 4px; }
.memory-record-editor { display: grid; gap: 14px; }
.memory-record-editor[hidden] { display: none; }
.memory-record-editor input, .memory-record-editor textarea { min-width: 0; width: 100%; }
.memory-record-editor textarea { resize: vertical; border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); padding: 10px 11px; color: var(--ink); line-height: 1.55; }
.memory-record-editor small { color: var(--muted); line-height: 1.5; }
.memory-record-confirmation { max-width: 68ch; }
.memory-record-confirmation > p { color: var(--muted); line-height: 1.6; }
.memory-record-confirm-summary { border-block: 1px solid var(--line); padding: 13px 0; }
.memory-record-confirm-summary p { margin: 5px 0; overflow-wrap: anywhere; }
.memory-record-confirm-summary .memory-record-preview-body { max-height: 12em; overflow-y: auto; white-space: pre-wrap; }
.memory-record-confirmation .dialog-actions { gap: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.review-notice { border-left: 3px solid var(--accent); background: var(--paper-soft); padding: 12px; }
.review-course { border: 1px solid var(--line); padding: 15px; }
.review-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.review-macros { color: var(--muted); font-size: .82rem; }
.error-line { min-height: 1.4em; color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.intake-review-dialog {
  width: min(402px, calc(100% - 24px)); max-width: 402px; max-height: calc(100dvh - 24px);
  overflow-x: hidden; overflow-y: auto; border: 1px solid var(--ink); border-radius: 16px;
  padding: 14px 14px 0; background: var(--paper);
}
.intake-review-dialog::backdrop { background: rgba(17,17,17,.55); }
.intake-review-dialog .dialog-heading { align-items: flex-start; gap: 8px; }
.intake-review-dialog h2 { font-size: 1.55rem; line-height: 1.1; }
.intake-review-summary { display: grid; gap: 4px; margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--paper-soft); }
.intake-review-summary p { margin: 0; overflow-wrap: anywhere; }
.intake-review-dialog > .review-notice { margin: 0 0 8px; padding: 9px 10px; font-size: .78rem; }
.intake-review-dialog > .status-line { min-height: 1.3em; margin: 7px 0; font-size: .78rem; overflow-wrap: anywhere; }
.intake-source { color: var(--muted); font-size: .8rem; }
.intake-action-list { min-width: 0; display: grid; gap: 10px; }
.intake-action-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; padding: 11px; }
.intake-action-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 9px; }
.intake-action-head h3 { font-size: 1.05rem; line-height: 1.2; }
.intake-action-head p { margin: 0; color: var(--muted); font-size: .76rem; }
.intake-action-grid { min-width: 0; display: grid; grid-template-columns: 1fr; gap: 9px; }
.intake-action-grid label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.intake-action-grid input, .intake-action-grid select { min-width: 0; width: 100%; }
.food-review-context { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(92px, .65fr); gap: 8px; }
.food-review-context label:last-child { grid-column: 1 / -1; }
.ordinary-food-editor { grid-column: 1 / -1; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; border-top: 1px dashed var(--line); padding-top: 10px; }
.intake-food-editor { grid-column: 1 / -1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; border-top: 1px dashed var(--line); padding-top: 10px; }
.intake-food-editor label { min-width: 0; }
.compact-food-name { grid-column: 1 / 2; }
.compact-food-name input { min-height: 38px; }
.compact-food-calories { grid-column: 2 / 3; white-space: nowrap; font-size: .9rem; }
.food-weight-controls { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.food-weight-controls input { min-height: 38px; text-align: center; }
.food-weight-step { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-soft); padding: 6px 10px; font-weight: 800; }
.compact-food-macros { grid-column: 1 / -1; color: var(--muted); line-height: 1.45; }
.remove-food-analysis-item { grid-column: 2 / 3; grid-row: 3; justify-self: end; color: var(--accent); }
.food-review-subtotal { grid-column: 1 / -1; margin: 0; border-top: 1px solid var(--ink); padding-top: 9px; font-weight: 800; line-height: 1.45; }
.food-analysis-audit { grid-column: 1 / -1; min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 9px; }
.food-analysis-audit > summary { cursor: pointer; font-size: .8rem; font-weight: 800; }
.food-analysis-details { grid-column: 1 / -1; min-width: 0; margin-top: 9px; border: 0; border-top: 1px solid var(--line); padding: 10px 0 0; background: transparent; }
.food-analysis-details h4, .food-analysis-details h5 { margin: 0 0 8px; }
.food-analysis-boundary { margin: 0 0 10px; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.food-analysis-judgment { display: grid; grid-template-columns: minmax(0, 92px) minmax(0, 1fr); gap: 5px 10px; margin: 0 0 14px; padding: 10px 0; border-block: 1px solid var(--line); }
.food-analysis-judgment dt { color: var(--muted); font-size: .76rem; font-weight: 800; }
.food-analysis-judgment dd { min-width: 0; margin: 0; font-size: .82rem; line-height: 1.5; overflow-wrap: anywhere; }
.food-analysis-item { min-width: 0; border-top: 1px dashed var(--line); padding: 12px 0; overflow-wrap: anywhere; }
.food-analysis-item p { margin: 5px 0; }
.food-analysis-weight, .food-analysis-totals { font-weight: 800; }
.food-analysis-confidence, .food-analysis-cross-check { color: var(--muted); }
.food-analysis-sources, .food-analysis-conflicts, .food-analysis-notes { margin: 8px 0; padding-left: 20px; }
.food-analysis-conflicts, .food-analysis-missing { color: var(--accent); }
.food-analysis-missing { border-top: 1px solid currentColor; margin-top: 10px; padding-top: 10px; }
.food-analysis-candidate-selection { min-width: 0; margin: 12px 0; border: 1px solid var(--accent); padding: 10px; }
.food-analysis-candidate-selection legend { padding: 0 4px; font-weight: 800; }
.food-analysis-candidate-option { display: flex; min-width: 0; align-items: flex-start; gap: 8px; margin-top: 8px; overflow-wrap: anywhere; }
.food-analysis-candidate-option input { flex: 0 0 auto; margin-top: 3px; }
.food-confidence-details { grid-column: 1 / -1; min-width: 0; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.food-confidence-details h4 { margin: 0 0 6px; }
.food-confidence-list { margin: 0; padding: 0; list-style: none; }
.food-confidence-item { display: flex; min-width: 0; justify-content: space-between; gap: 14px; padding: 7px 0; border-top: 1px dashed var(--line); overflow-wrap: anywhere; }
.food-confidence-item:first-child { border-top: 0; }
.food-confidence-level { flex: 0 0 auto; text-align: right; }
.food-confidence-label { margin: 9px 0 4px; color: var(--muted); font-size: .76rem; font-weight: 800; }
.food-confidence-notes, .food-confidence-confirmations { margin: 0; padding-left: 20px; font-size: .82rem; line-height: 1.5; }
.food-confidence-confirmations { color: var(--accent); }
.food-confidence-empty { margin: 7px 0 0; color: var(--muted); font-size: .82rem; }
.food-analysis-reanalysis { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr; align-items: end; gap: 8px; border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.food-analysis-reanalysis[hidden] { display: none; }
.food-analysis-reanalysis label { min-width: 0; display: grid; gap: 6px; font-weight: 700; }
.food-analysis-reanalysis input { min-width: 0; width: 100%; }
.food-analysis-reanalysis-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.food-analysis-reanalysis-actions .button { white-space: nowrap; }
.remove-intake-action {
  flex: 0 0 auto; max-width: 100%; color: var(--accent); white-space: nowrap;
}
.intake-empty { border: 1px dashed var(--line); padding: 20px; color: var(--muted); }
.ben-quota { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.intake-review-actions {
  position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: 8px; margin: 12px -14px 0; border-top: 1px solid var(--line); background: rgba(255,255,255,.97);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.intake-review-actions .button { min-width: 0; padding-inline: 12px; }
.intake-review-actions .button-secondary {
  border-color: transparent; background: transparent; padding-inline: 8px;
}
.intake-review-actions .button-primary { width: 100%; }

.food-profile-choice-grid {
  min-width: 0; grid-column: 1 / -1; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.food-profile-choice-notice { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.food-profile-choice-card, .food-profile-library-card {
  min-width: 0; border: 1px solid var(--line); background: #fff; padding: 14px; overflow-wrap: anywhere;
}
.food-profile-choice-card h4, .food-profile-library-card h4 { margin: 0 0 9px; font-size: 1.08rem; }
.food-profile-choice-card p, .food-profile-library-card p { margin: 6px 0; }
.food-profile-aliases, .food-profile-source, .food-profile-meta { color: var(--muted); font-size: .82rem; }
.food-profile-nutrients { font-weight: 750; }
.food-profile-choice-button { width: 100%; margin-top: 10px; white-space: nowrap; }
.historical-origin {
  grid-column: 1 / -1; min-width: 0; border: 1px solid var(--ink);
  border-left: 5px solid var(--accent); padding: 12px; background: #fff; overflow-wrap: anywhere;
}
.historical-origin p { margin: 6px 0 0; }
.historical-choice-grid {
  min-width: 0; grid-column: 1 / -1; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.historical-choice-notice { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.historical-choice-card {
  min-width: 0; border: 1px solid var(--line); padding: 14px; background: #fff; overflow-wrap: anywhere;
}
.historical-choice-card p { margin: 0; }
.historical-choice-button { width: 100%; margin-top: 10px; }
.food-profile-library-dialog {
  width: min(860px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  border: 2px solid var(--ink); border-radius: 3px; padding: 22px; background: var(--paper);
}
.food-profile-library-dialog::backdrop { background: rgba(17,17,17,.55); }
.food-profile-library-list {
  min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.food-profile-delete-preview { color: var(--accent); }
.food-profile-delete-confirmation { margin-top: 18px; border: 2px solid var(--accent); padding: 14px; }
.food-profile-delete-confirmation[hidden] { display: none; }
.food-profile-delete-confirmation p { overflow-wrap: anywhere; }

.ben-bar {
  position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 5;
  width: 172px; height: 60px;
}
.ben-launcher {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); isolation: isolate; overflow: visible;
  display: grid; place-items: center;
  width: 172px; height: 60px; border: 0; border-radius: 999px; padding: 0;
  background: transparent; color: white; font: 700 1.05rem/1 system-ui, sans-serif; letter-spacing: -.01em;
  box-shadow: none; touch-action: none;
  transition: transform 160ms cubic-bezier(.16, 1, .3, 1), filter 180ms ease-out;
}
.ben-launcher::after { display: none;
}
.ben-launcher:active { transform: translateX(-50%) scale(.98); }
.ben-launcher.pressing { transform: translateX(-50%) scale(.97); filter: saturate(1.03) brightness(1.02); }
.ben-launcher:focus-visible { outline: 2px solid rgba(128, 229, 255, .9); outline-offset: 3px; }
.ben-launcher-label {
  position: relative; z-index: 4; pointer-events: none;
  text-shadow: 0 1px 8px rgba(1, 9, 24, .92), 0 0 10px rgba(84, 186, 255, .25);
}
.ben-liquid-core {
  position: absolute; inset: 0; z-index: 1; overflow: visible; border-radius: inherit;
  background: transparent;
  transition: opacity 180ms cubic-bezier(.16, 1, .3, 1), filter 180ms ease-out;
  pointer-events: none;
}
.ben-liquid-surface {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  opacity: 1; filter: none;
  transition: filter 180ms ease-out;
}
.ben-thinking-nodes {
  display: none;
}
.ben-launcher[data-ben-state="idle"] { filter: saturate(.9) brightness(.94); }
.ben-launcher[data-ben-state="listening"] { filter: saturate(1.08) brightness(1.03); }
.ben-launcher[data-ben-state="transcribing"] { filter: saturate(1.04) brightness(1.01); }
.ben-launcher[data-ben-state="thinking"] { filter: saturate(1.08) brightness(1.04); }
.ben-launcher[data-ben-state="success"] { filter: saturate(1.06) brightness(1.04); }
.ben-launcher[data-ben-state="success"] .ben-liquid-core {
  animation: ben-liquid-success 180ms cubic-bezier(.16, 1, .3, 1) both;
}
.ben-launcher[data-ben-state="error"] { filter: saturate(1.08) brightness(.98); }
.ben-launcher[data-ben-state="error"] .ben-liquid-surface {
  filter: sepia(.32) saturate(1.75) hue-rotate(298deg) brightness(.92);
}
.ben-launcher[data-ben-state="error"] .ben-launcher-label { color: #ffd7d3; }
@keyframes ben-liquid-success {
  0% { transform: scale(1.018); opacity: .86; }
  100% { transform: scale(1); opacity: 1; }
}
.ben-launcher[aria-pressed="true"] { filter: saturate(1.1) brightness(1.04); }
.ben-composer-sheet {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px 8px;
  width: min(calc(100vw - 28px), 402px); max-width: 402px;
  border: 1px solid rgba(160, 204, 235, .35); border-radius: 24px; background: rgba(7, 20, 36, .97);
  color: #eef9ff; padding: 10px; box-shadow: 0 14px 36px rgba(0, 7, 17, .42); backdrop-filter: blur(24px);
}
.ben-composer-sheet[hidden] { display: none; }
.ben-composer-close {
  justify-self: end;
  min-height: 44px;
  border-radius: 999px;
  color: #eef9ff;
  padding: 5px 10px;
}
.ben-composer-close:focus-visible { outline: 2px solid #68dded; outline-offset: 2px; }
.ben-entry-row { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; }
.ben-attachment-control { position: relative; }
.ben-attachment-toggle {
  display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(177, 218, 244, .3);
  border-radius: 50%; background: #10243b; box-shadow: inset 0 0 10px rgba(93, 170, 226, .12);
}
.ben-attachment-toggle img { display: block; width: 22px; height: 22px; }
.ben-attachment-menu {
  position: absolute; left: 0; bottom: 52px; z-index: 2; display: grid; gap: 6px; min-width: 112px;
  padding: 7px; border: 1px solid rgba(177, 218, 244, .3); border-radius: 16px;
  background: rgba(7, 20, 36, .98); box-shadow: 0 12px 30px rgba(0, 5, 14, .42);
}
.ben-attachment-menu[hidden] { display: none; }
.ben-attachment-menu .ben-action { width: 100%; color: #eef9ff; background: #132940; }
.ben-compose { min-width: 0; display: grid; gap: 7px; }
.ben-bar input, .ben-bar textarea { min-width: 0; width: 100%; border: 1px solid rgba(177, 218, 244, .3); border-radius: 12px; background: #13243a; color: #f4fbff; padding: 8px 10px; }
#ben-text-input { min-height: 44px; border-radius: 22px; font-size: 1rem; }
#ben-text-input::placeholder, .ben-bar textarea::placeholder { color: rgba(223, 237, 247, .48); }
.ben-bar textarea { resize: vertical; line-height: 1.4; }
.ben-action { min-height: 40px; border: 1px solid rgba(177, 218, 244, .3); border-radius: 12px; background: #13243a; color: #eef9ff; padding: 7px 10px; font-weight: 700; }
.ben-action[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: white; }
.ben-mode { font-size: .72rem; }
.ben-hold-voice { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.ben-hold-voice.holding { color: white; filter: brightness(1.08); }
.ben-send { grid-column: 1 / -1; width: 100%; border-color: rgba(126, 222, 255, .62); border-radius: 18px; background: #183b5a; color: white; }
.ben-state { min-height: 1em; margin: -2px 2px 0; color: rgba(222, 237, 247, .68); font-size: .7rem; }
.ben-media-preview { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; border-top: 1px solid var(--line); padding-top: 7px; }
.ben-media-preview[hidden] { display: none; }
.ben-media-visual { grid-column: 1 / -1; }
.ben-media-visual img { display: block; max-width: min(100%, 180px); max-height: 120px; border-radius: 8px; }
.ben-media-visual audio { width: 100%; }
.ben-media-visual img[hidden] { display: none !important; }
.ben-media-visual audio[hidden] { display: none !important; }
.ben-media-preview label { grid-column: 1 / -1; color: rgba(222, 237, 247, .68); font-size: .7rem; }
.ben-media-preview textarea { grid-column: 1 / -1; }
.ben-media-preview span { color: rgba(222, 237, 247, .68); font-size: .72rem; }
.ben-rec-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #c94335; animation: ben-rec-pulse 1s ease-in-out infinite; }
@keyframes ben-rec-pulse { 50% { opacity: .35; transform: scale(.8); } }

@media (max-width: 719px) {
  .home-view { padding-inline: 12px; }
  .home-card-grid { grid-template-columns: 1fr; }
  .home-card-small, .home-card-medium, .home-card-large { grid-column: auto; }
  .home-health-card.home-card-medium, .home-health-card.home-card-large { grid-template-columns: 1fr; }
  .home-masthead { display: flex; }
  .home-edit-button { justify-self: auto; }
  .page-shell { width: min(100% - 22px, 980px); padding-top: 18px; }
  .masthead { align-items: flex-start; }
  .date-field { max-width: 145px; }
  .today-heading { align-items: center; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .food-row { grid-template-columns: 1fr 1fr; }
  .food-row .food-name { grid-column: 1 / -1; }
  .meal-item { grid-template-columns: 1fr auto; }
  .meal-item-meta { grid-column: 1 / -1; }
  .ben-compose { min-width: 0; }
  .ben-action { min-width: 0; padding-inline: 5px; }
  .ben-state { margin-top: 1px; }
  .memory-record-dialog {
    width: calc(100% - 12px); max-height: calc(100dvh - 12px); margin-block: 6px;
    border-radius: 7px;
  }
  .memory-record-shell { min-height: calc(100dvh - 14px); }
  .memory-record-heading { padding: 14px; }
  .memory-record-toolbar { flex-wrap: wrap; padding: 10px 14px; }
  .memory-record-toolbar form { flex-basis: 100%; }
  .memory-record-toolbar > .button { width: 100%; }
  .memory-record-status { padding-inline: 14px; }
  .memory-record-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(112px, 28dvh) minmax(0, 1fr); }
  .memory-record-index { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .memory-record-stage { padding: 16px 14px calc(22px + env(safe-area-inset-bottom)); }
  .memory-record-link-form { grid-template-columns: 1fr 1fr; }
  .memory-record-link-form .button { grid-column: 1 / -1; }
}

@media (max-width: 460px) {
  .home-card-controls { grid-template-columns: 1fr; }
  .home-memory-actions { display: grid; }
  .home-add-actions { display: grid; }
  .masthead { display: grid; }
  .date-field { max-width: none; }
  .today-heading { display: grid; }
  .today-heading .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .food-row { grid-template-columns: 1fr; }
  .food-row .food-name { grid-column: auto; }
  .split-actions { align-items: stretch; flex-direction: column-reverse; }
  .split-actions .button { width: 100%; }
  .intake-review-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 8px); border-radius: 12px; padding-inline: 12px; }
  .intake-action-grid { grid-template-columns: 1fr; }
  .intake-food-editor { grid-column: auto; grid-template-columns: minmax(0, 1fr) auto; }
  .food-analysis-reanalysis { grid-template-columns: 1fr; }
  .food-analysis-reanalysis-actions { display: grid; }
  .food-profile-choice-grid, .food-profile-library-list, .historical-choice-grid { grid-template-columns: 1fr; }
  .food-profile-library-dialog { width: calc(100% - 16px); padding: 14px; overflow-x: hidden; }
  .meal-edit-dialog { width: calc(100% - 16px); }
  .meal-edit-dialog form { padding: 14px; }
  .meal-maintenance-actions { display: grid; grid-template-columns: 1fr; }
  .exercise-dialog, .exercise-remove-dialog { width: calc(100% - 16px); }
  .exercise-dialog form, .exercise-remove-dialog section { padding: 14px; }
  .exercise-mode-switch, .exercise-fields, .exercise-volume-formula { grid-template-columns: 1fr; }
  .exercise-check { grid-column: auto; }
  #open-food-profile-library { width: 100%; }
  .ben-bar { bottom: calc(8px + env(safe-area-inset-bottom)); width: 82px; height: 56px; }
  .ben-entry-row { grid-template-columns: auto minmax(0, 1fr); }
  .ben-action { font-size: .78rem; }
  #calculation-detail.health-toolbar-menu { position: static; }
  #calculation-detail .health-toolbar-sheet { left: 0; right: 0; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .ben-launcher {
    animation: none !important; transition: none !important; transform: translateX(-50%) !important;
  }
  .ben-launcher.ben-launcher-in-review { transform: none !important; }
  .ben-launcher .ben-liquid-core {
    animation: none !important; transition: none !important; transform: none !important;
  }
  .ben-liquid-surface { transition: none !important; }
}

@media (max-width: 390px) {
  .food-analysis-judgment { grid-template-columns: 1fr; gap: 2px; }
  body { overflow-x: hidden; }
  .health-profile-panel, .profile-first-prompt, .calculation-detail { min-width: 0; overflow-x: hidden; }
  .profile-form-grid, .profile-settings, .calculation-items { grid-template-columns: 1fr; }
  .metric-current-summary, .metric-form-grid, .weight-day-row { grid-template-columns: 1fr; }
  .metric-dialog, #weight-remove-dialog { width: calc(100% - 16px); }
  .metric-dialog form, #weight-remove-dialog section { padding: 14px; }
  .metric-source-note, .metric-step-actions { grid-column: auto; }
  .metric-entry-actions { width: 100%; }
  .metric-entry-actions .button { flex: 1; }
}

.profile-first-prompt, .health-profile-panel, .calculation-detail {
  margin: 20px 0; border: 1px solid var(--line); padding: 18px; background: #fff;
}
.profile-first-prompt { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.profile-first-prompt[hidden], .health-profile-panel[hidden] { display: none; }
.profile-first-prompt p { margin: 5px 0 0; color: var(--muted); }
.profile-prompt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-form-grid, .profile-settings, .calculation-items {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.profile-form-grid label, .profile-settings label { min-width: 0; display: grid; gap: 6px; font-weight: 700; }
.profile-form-grid input, .profile-form-grid select, .profile-settings input, .profile-settings select { min-width: 0; width: 100%; }
.profile-setting-hint { color: var(--muted); font-size: .72rem; font-weight: 600; line-height: 1.4; }
.profile-settings { margin: 14px 0; }
.profile-advanced { margin: 18px 0; }
.profile-advanced > summary, .calculation-detail > summary { cursor: pointer; font-weight: 850; }
.profile-toggle { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.profile-toggle input { width: auto; }
.calculation-items { margin-top: 14px; }
.calculation-item { min-width: 0; border-top: 1px solid var(--line); padding: 10px 0; overflow-wrap: anywhere; }
.calculation-item strong, .calculation-item span { display: block; }
.calculation-item small, .calculation-warning { color: var(--muted); }
.health-trends-view { min-width: 0; margin: 20px 0; }
.health-trends-view[hidden], .day-report-drawer[hidden] { display: none; }
.trend-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.trend-stat { min-width: 0; border: 1px solid var(--line); padding: 14px; overflow-wrap: anywhere; }
.trend-stat strong, .trend-stat span { display: block; }
.trend-stat span { color: var(--muted); font-size: .78rem; }
.trend-chart-panel, .monthly-placeholder, .day-report-drawer { margin-top: 18px; border: 1px solid var(--line); padding: 16px; background: #fff; }
.trend-svg { display: block; width: 100%; max-width: 100%; height: auto; overflow: visible; }
.trend-svg text { fill: var(--ink); font-size: 12px; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 3; }
.trend-point { fill: #fff; stroke: var(--ink); stroke-width: 2; }
.trend-bar { fill: #738ca8; }
.trend-bar-over { fill: var(--accent); }
.trend-bar-none { fill: none; stroke: var(--line); stroke-width: 2; }
.trend-target-line { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 7 6; }
.trend-target-label { font-weight: 800; }
.trend-day-list { display: grid; gap: 8px; }
.trend-day-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 12px; align-items: center; border-top: 1px solid var(--line); padding: 10px 0; }
.trend-day-row p { margin: 0; }
.day-report-drawer { overflow-wrap: anywhere; }
.day-report-item { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 12px; border-top: 1px solid var(--line); padding: 9px 0; }
.monthly-placeholder { color: var(--muted); }

@media (max-width: 390px) {
  .profile-form-grid, .profile-settings, .calculation-items { grid-template-columns: 1fr; }
  .profile-first-prompt { align-items: stretch; flex-direction: column; }
  .profile-prompt-actions .button { flex: 1; }
  .trend-stat-grid { grid-template-columns: 1fr 1fr; }
  .trend-day-row, .day-report-item { grid-template-columns: 1fr; }
  .trend-chart-panel, .day-report-drawer { min-width: 0; overflow-x: hidden; padding: 12px; }
}

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

@media (prefers-reduced-transparency: reduce) {
  .home-editor, .app-shell[data-view="home"] .ben-composer-sheet {
    backdrop-filter: none;
    background: #0b223b;
  }
  .home-card, .health-module { backdrop-filter: none; background: transparent; }
}
/* The account gate is the only visible surface until the server session is resolved. */
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #071426;
  color: #f5f8ff;
}
.auth-view[hidden], .app-shell[hidden] { display: none; }

.auth-card {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 28px;
  background: rgba(15, 35, 57, .92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.auth-card form, .auth-card label { display: grid; gap: 8px; }
.auth-card form { gap: 18px; margin-top: 24px; }
.auth-card input { min-height: 48px; border-radius: 12px; padding: 0 14px; }
.auth-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.recovery-panel {
  margin-top: 24px; padding: 20px; border: 1px solid var(--line);
  border-radius: 20px; background: rgba(255, 255, 255, .82);
}
.recovery-panel[hidden] { display: none; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.recovery-grid form { display: grid; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--line); }
.recovery-grid label { display: grid; gap: 6px; }
.recovery-grid input { min-width: 0; width: 100%; }
.recovery-code { display: block; min-height: 3em; overflow-wrap: anywhere; font-family: monospace; }
#recovery-preview-summary { padding: 12px; background: #f4f7fb; overflow-wrap: anywhere; }
@media (max-width: 390px) {
  .recovery-panel { padding: 14px; }
  .recovery-grid { grid-template-columns: 1fr; }
}
 .connection-strip {
  position: fixed; inset: 0 0 auto; z-index: 30; display: flex; gap: .7rem;
  align-items: center; justify-content: flex-end; padding: .35rem .8rem;
  color: #c8fff2; background: rgba(4, 15, 28, .92); font-size: .76rem;
}
.connection-strip button { font: inherit; }
.release-version { color: #ffffff; letter-spacing: .08em; }

/* Health today: the frozen DingBot Three Meals journal structure on Ben's data/contracts. */
#health-view.page-shell {
  width: 100%; max-width: 402px; padding: 48px 16px 150px;
}
.health-journal-header { display: grid; gap: 10px; margin-bottom: 12px; }
.health-journal-brand {
  display: flex; align-items: center; gap: 8px; min-height: 30px;
  color: var(--muted); font-size: 12px; font-weight: 750;
}
.health-back {
  border: 0; background: transparent; padding: 5px 0; color: var(--ink);
  font-weight: 800; text-decoration: none;
}
.health-journal-brand > span { flex: 1; }
.health-release-version {
  border: 1px solid var(--ink); border-radius: 999px; padding: 3px 8px;
  color: var(--ink); font-size: 11px; letter-spacing: .06em;
}
.health-dayhead { display: flex; align-items: center; gap: 7px; position: relative; }
.health-daybtn {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--ink); border-radius: 999px; background: var(--paper);
  color: var(--ink); font-size: 19px; line-height: 1;
}
.health-daybtn:disabled { opacity: .3; cursor: not-allowed; }
.health-date-picker { flex: 1; min-width: 104px; }
.health-date-picker input {
  width: 100%; min-height: 34px; border: 0; background: transparent; padding: 0 2px;
  color: var(--ink); font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 14px; font-weight: 700; text-align: center;
}
.health-toolbar-menu { flex: none; position: relative; margin: 0; border: 0; padding: 0; overflow: visible; background: transparent; }
.health-toolbar-menu > summary {
  min-height: 34px; display: grid; place-items: center; list-style: none; cursor: pointer;
  border: 1px solid var(--ink); border-radius: 999px; background: var(--paper);
  padding: 5px 9px; color: var(--ink); font-size: 11px; font-weight: 800; white-space: nowrap;
}
.health-toolbar-menu > summary::-webkit-details-marker { display: none; }
.health-toolbar-sheet {
  position: absolute; z-index: 20; top: calc(100% + 8px); right: 0;
  width: min(370px, calc(100vw - 32px)); max-height: 70dvh; overflow-y: auto;
  border: 1.5px solid var(--ink); border-radius: 6px; background: var(--paper);
  padding: 14px; box-shadow: 0 14px 34px rgba(17,17,17,.2);
}
.health-toolbar-sheet .calculation-items { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.health-me-sheet { width: min(210px, calc(100vw - 32px)); display: grid; gap: 8px; }
.health-me-sheet .button { width: 100%; min-height: 40px; padding: 8px 10px; text-align: center; }

.health-journal-dashboard { display: flex; flex-direction: column; gap: 12px; }
#health-view .summary-grid {
  display: flex; flex-direction: column; gap: 3px; border: 0;
}
.today-exercise,
.meal-card, .meal-collapsed {
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); box-shadow: none;
}
.health-page-status { min-height: 0; margin: -4px 2px 0; font-size: 11px; }

#health-view .today-heading { padding: 4px 0 0; }
#health-view .today-sec-row { display: flex; align-items: center; justify-content: space-between; }
#health-view .today-sec {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font: 800 11px/1 Inter, "PingFang SC", sans-serif; letter-spacing: .18em;
}
#health-view .today-sec::before { content: ""; width: 12px; height: 1.5px; background: var(--ink); }
.meal-add {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--ink); border-radius: 999px; background: var(--paper);
  color: var(--ink); padding: 0; font-size: 15px;
}
#health-view .meal-list { display: flex; flex-direction: column; gap: 8px; }
.today-empty-add {
  width: 100%; border: 1px dashed var(--line); border-radius: 6px; background: var(--paper);
  padding: 13px; color: var(--muted); text-align: left;
}
#health-view .meal-card { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.meal-head-main {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; padding: 10px 13px; color: var(--ink); text-align: left;
}
.meal-head-name {
  flex: none; font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 16px; font-weight: 700;
}
.meal-collapsed-dish { flex: 1; min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.meal-head-kcal { flex: none; font-size: 12px; white-space: nowrap; }
.meal-head-main::after { content: "⌄"; flex: none; color: var(--muted); font-size: 12px; }
.meal-head-main[aria-expanded="true"]::after { content: "⌃"; }
.meal-card-body { display: flex; flex-direction: column; gap: 9px; border-top: 1px solid var(--line); padding: 10px 13px 12px; }
.meal-card-body[hidden] { display: none; }
.meal-course-head { display: flex; align-items: center; gap: 7px; }
.meal-course-name { flex: 1; min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.meal-course-kcal { flex: none; color: var(--muted); font-size: 12px; }
.meal-course-src { flex: none; }
.meal-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.meal-chip {
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper);
  padding: 4px 9px; color: var(--ink); font-size: 11px;
}
.meal-chip.is-on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.meal-ingredient-list { display: flex; flex-direction: column; border-block: 1px solid var(--line); }
.meal-ingredient-row {
  min-width: 0; min-height: 48px; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 8px 0;
}
.meal-ingredient-row:first-child { border-top: 0; }
.meal-ingredient-description { min-width: 0; display: grid; gap: 3px; }
.meal-ingredient-description strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.meal-ingredient-description span { color: var(--muted); font-size: 10px; line-height: 1.35; }
.meal-ingredient-edit {
  min-height: 38px; border: 0; border-bottom: 1px solid var(--ink); background: transparent;
  padding: 7px 2px; color: var(--ink); font-size: 11px; font-weight: 800;
}
.meal-ingredient-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#health-view .meal-macros { border-top: 1px solid var(--line); padding-top: 8px; font-size: 11px; }
#health-view .meal-provenance, #health-view .meal-original-input { margin: 0; font-size: 11px; }
#health-view .tag-row { margin: 0; gap: 5px; }
#health-view .tag { padding: 2px 6px; font-size: 10px; }
#health-view .meal-maintenance-actions { display: flex; align-items: center; gap: 8px; margin: 0; }
#health-view .meal-maintenance-actions .edit-saved-meal { min-height: 32px; padding: 5px 9px; font-size: 11px; }
#health-view .meal-maintenance-actions > span { display: none; }
.meal-del { margin-left: auto; border: 0; background: transparent; color: var(--accent); padding: 5px; font-size: 11px; }

#health-view .exercise-heading, #health-view .metric-heading { margin-top: 2px; }
#health-view #exercise-summary { margin: -5px 2px 0; min-height: 0; font-size: 11px; }
#health-view .today-exercise { padding: 12px 13px; }
#health-view .exercise-list:empty { min-height: 44px; }
#health-view .exercise-card { border: 0; border-top: 1px solid var(--line); padding: 10px 0; }
#health-view .exercise-card:first-child { border-top: 0; padding-top: 0; }
#health-view .exercise-card:last-child { padding-bottom: 0; }
#health-view .exercise-card h3 { font: 700 13px/1.3 Inter, "PingFang SC", sans-serif; }
#health-view .exercise-card-head strong { font-size: 12px; }
#health-view .exercise-facts, #health-view .exercise-formula,
#health-view .exercise-provenance, #health-view .exercise-deduction { font-size: 11px; }
#health-view .exercise-remove { min-height: 32px; padding: 5px 9px; font-size: 11px; }

#health-view .metric-heading { justify-content: flex-start; }
#health-view .metric-current-summary.today-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.health-secondary-tools { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); }
.health-secondary-tools > summary { cursor: pointer; font-size: 11px; font-weight: 750; }
.health-secondary-tools .items-heading { align-items: center; margin: 12px 0; }
.health-secondary-tools h3 { font-size: 16px; }
.health-secondary-tools .button { min-height: 36px; padding: 6px 9px; font-size: 11px; }

@media (max-width: 390px) {
  #health-view.page-shell { padding-inline: 12px; }
  .health-dayhead { gap: 5px; }
  .health-daybtn { width: 32px; height: 32px; }
  .health-date-picker { min-width: 96px; }
  .health-toolbar-menu > summary { padding-inline: 7px; }
  #health-view .metric-current-summary.today-tiles { grid-template-columns: 1fr 1fr; }
}

/* Health inner routes: Today, My and Trends are separate Journal screens. */
#health-view .health-route-view[hidden] { display: none !important; }
#health-view .health-today-view { display: flex; flex-direction: column; gap: 12px; }
#health-view .health-route-heading {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  border-bottom: 1.5px solid var(--ink); padding: 2px 0 12px;
}
#health-view .health-route-heading h2 {
  font-size: 28px; line-height: 1.05; letter-spacing: -.02em;
}
#health-view .health-route-back {
  flex: none; color: var(--ink); font-size: 12px; font-weight: 800;
  text-decoration: underline; text-underline-offset: 4px;
}

/* "My health" follows the frozen Three Meals profile-card rhythm. */
#health-view .health-profile-panel.me {
  min-width: 0; margin: 0; border: 0; padding: 0;
  display: flex; flex-direction: column; gap: 12px; background: var(--paper);
}
#health-view .me-sec {
  margin: 6px 0 -4px; color: var(--muted); font-size: 11px; font-weight: 800;
  letter-spacing: .18em; text-transform: uppercase;
}
#health-view .me-card {
  min-width: 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); padding: 13px 14px; color: var(--ink);
}
#health-view .me-card-title { margin: 0; font: 800 14px/1.3 Inter, "PingFang SC", sans-serif; }
#health-view .me-entry {
  display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
}
#health-view .me-entry-text { flex: 1; font-size: 15px; font-weight: 700; }
#health-view .me-entry-hint { flex: none; color: var(--accent); font-size: 12px; font-weight: 800; }
#health-view .profile-form-grid,
#health-view .profile-settings {
  display: flex; flex-direction: column; gap: 9px; margin: 0;
}
#health-view .profile-form-grid label,
#health-view .profile-settings label {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(112px, 45%);
  align-items: center; gap: 10px; color: var(--ink); font-size: 12px;
}
#health-view .profile-form-grid input,
#health-view .profile-form-grid select,
#health-view .profile-settings input,
#health-view .profile-settings select {
  min-width: 0; width: 100%; min-height: 38px; border-color: var(--line); border-radius: 2px;
}
#health-view .profile-form-grid .button { width: 100%; margin-top: 2px; }
#health-view .profile-advanced { margin: 0; }
#health-view .profile-advanced > summary {
  display: flex; align-items: baseline; gap: 8px; list-style: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
  padding: 12px 14px; color: var(--ink);
}
#health-view .profile-advanced > summary::-webkit-details-marker { display: none; }
#health-view .profile-advanced > summary span { font-size: 14px; font-weight: 800; }
#health-view .profile-advanced > summary small { flex: 1; color: var(--muted); font-size: 11px; }
#health-view .profile-advanced > summary b { color: var(--accent); font-size: 11px; }
#health-view .profile-advanced[open] > summary b { font-size: 0; }
#health-view .profile-advanced[open] > summary b::after { content: "收起 ⌃"; font-size: 11px; }
#health-view .profile-advanced .profile-settings { margin-top: 8px; }
#health-view #reset-health-profile { width: 100%; }
#health-view #health-profile-status { margin: 0; font-size: 11px; }

/* Trends uses the same 402px magazine cards as the frozen Three Meals screen. */
#health-view .health-trends-view.trends {
  min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 12px;
}
#health-view .trends-sec {
  margin: 6px 0 2px; color: var(--muted); font-size: 11px; font-weight: 800;
  letter-spacing: .18em; text-transform: uppercase;
}
#health-view #trend-window { min-height: 0; margin: 0; font-size: 11px; line-height: 1.55; }
#health-view .trend-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#health-view .trend-stat {
  min-width: 0; display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); padding: 12px 13px;
}
#health-view .trend-stat:last-child { grid-column: 1 / -1; }
#health-view .trend-stat span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
#health-view .trend-stat strong {
  color: var(--ink); font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 22px; line-height: 1.2;
}
#health-view .trend-chart-panel {
  display: flex; flex-direction: column; gap: 7px; margin: 0;
  border: 1px solid var(--line); border-radius: 6px; padding: 12px 13px; background: var(--paper);
}
#health-view .trend-chart-panel h3,
#health-view #trend-day-list-title {
  margin: 0; color: var(--muted); font: 800 11px/1.3 Inter, "PingFang SC", sans-serif;
  letter-spacing: .16em;
}
#health-view .trend-target-label { margin: 0; font-size: 11px; }
#health-view .trend-svg text { font-size: 20px; }
#health-view .trend-day-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
#health-view .trend-day-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 6px; padding: 11px 12px;
}
#health-view .trend-day-row .button { min-height: 32px; padding: 5px 8px; font-size: 11px; }
#health-view .monthly-placeholder {
  margin: 0; border: 1px dashed var(--line); border-radius: 6px; padding: 12px;
  background: var(--paper); color: var(--muted); text-align: center; font-size: 11px;
}
#health-view .monthly-placeholder h3,
#health-view .monthly-placeholder p { margin: 2px 0; font: inherit; }
#health-view .day-report-drawer {
  position: fixed; z-index: 45; left: 50%; right: auto; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%); width: min(370px, calc(100% - 24px)); max-height: 78dvh;
  overflow-y: auto; margin: 0; border: 1.5px solid var(--ink); border-radius: 6px;
  background: var(--paper); padding: 18px; box-shadow: 0 12px 32px rgba(17,17,17,.18);
}
#health-view .day-report-item { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; }
#health-view .day-report-item strong { flex: 1; color: var(--muted); font-size: 12px; }
#health-view .day-report-item span { text-align: right; font-size: 12px; font-weight: 800; }

/* All health forms and reviews share one narrow bottom-sheet family. */
.health-journal-dialog-family {
  position: fixed; left: 50%; right: auto; top: auto; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%); width: min(370px, calc(100% - 24px)); max-width: 370px;
  max-height: 78dvh; margin: 0; overflow-x: hidden; overflow-y: auto;
  border: 1.5px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink);
  padding: 18px; box-shadow: 0 12px 32px rgba(17,17,17,.18);
}
.health-journal-dialog-family::backdrop { background: rgba(17,17,17,.52); }
.health-journal-dialog-family.health-confirm-dialog {
  top: 50%; bottom: auto; max-width: 320px; transform: translate(-50%, -50%);
}
.health-journal-dialog-family form,
.health-journal-dialog-family > section { padding: 0 !important; }
.health-journal-dialog-family .dialog-heading {
  align-items: center; gap: 10px; margin: 0 0 14px; border-bottom: 1px solid var(--line); padding: 0 0 12px;
}
.health-journal-dialog-family .dialog-heading h2,
.health-journal-dialog-family .dialog-heading h3 { font-size: 17px; line-height: 1.25; }
.health-journal-dialog-family .kicker,
.health-journal-dialog-family .section-number { margin-bottom: 4px; font-size: 10px; }
.health-journal-dialog-family .form-grid,
.health-journal-dialog-family .food-row,
.health-journal-dialog-family .exercise-fields,
.health-journal-dialog-family .exercise-volume-formula,
.health-journal-dialog-family .metric-form-grid,
.health-journal-dialog-family .exercise-mode-switch {
  display: grid; grid-template-columns: 1fr; gap: 9px;
}
.health-journal-dialog-family .wide-field,
.health-journal-dialog-family .exercise-check,
.health-journal-dialog-family .metric-source-note,
.health-journal-dialog-family .metric-step-actions { grid-column: auto; }
.health-journal-dialog-family input,
.health-journal-dialog-family select,
.health-journal-dialog-family textarea { min-width: 0; width: 100%; border-color: var(--line); }
.health-journal-dialog-family .food-row { border-radius: 4px; padding: 11px; }
.health-journal-dialog-family .items-heading { align-items: center; margin: 18px 0 10px; }
.health-journal-dialog-family .items-heading h3 { font-size: 15px; }
.health-journal-dialog-family .items-heading .button { min-height: 34px; padding: 5px 8px; font-size: 11px; }
.health-journal-dialog-family .memory-switch,
.health-journal-dialog-family .review-notice,
.health-journal-dialog-family .metric-source-note {
  margin: 10px 0 0; border-left: 3px solid var(--ink); background: var(--paper-soft);
  padding: 10px; color: var(--muted); font-size: 11px;
}
.health-journal-dialog-family .dialog-actions { gap: 8px; margin-top: 14px; }
.health-journal-dialog-family .dialog-actions .button { flex: 1; min-height: 42px; padding: 8px; }
.health-journal-dialog-family .split-actions { align-items: stretch; flex-direction: row; }
.health-journal-dialog-family .intake-action-card,
.health-journal-dialog-family .food-profile-library-card,
.health-journal-dialog-family .food-profile-card { border-radius: 6px; }
.health-journal-dialog-family .weight-day-row { grid-template-columns: minmax(0, 1fr) auto; padding: 9px 0; border: 0; border-top: 1px solid var(--line); }
.health-journal-dialog-family .weight-day-row .button { min-height: 32px; padding: 5px 8px; font-size: 11px; }
.health-journal-dialog-family .health-metric-stepper {
  display: grid; grid-template-columns: minmax(0, 1fr) 42px minmax(92px, auto) auto 42px;
  align-items: center; gap: 7px; margin: 6px 0;
}
.health-journal-dialog-family .health-metric-stepper-label { font-size: 12px; color: var(--muted); }
.health-journal-dialog-family .health-step-button {
  width: 42px; height: 42px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); font-size: 20px;
}
.health-journal-dialog-family .health-metric-stepper label { min-width: 0; }
.health-journal-dialog-family .health-metric-stepper input {
  min-height: 42px; border: 0; border-bottom: 1.5px solid var(--ink); border-radius: 0;
  padding: 4px; font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 24px; font-weight: 700; text-align: center;
}
.health-journal-dialog-family .health-metric-unit { color: var(--muted); font-size: 11px; }
.health-sheet-heading { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.health-sheet-heading span { color: var(--muted); font-size: 11px; }

@media (max-width: 390px) {
  #health-view .profile-form-grid label,
  #health-view .profile-settings label { grid-template-columns: minmax(0, 1fr) minmax(104px, 44%); }
  #health-view .trend-day-row { grid-template-columns: 54px minmax(0, 1fr) auto; }
  .health-journal-dialog-family { width: calc(100% - 16px); bottom: calc(8px + env(safe-area-inset-bottom)); padding: 14px; }
  #ben-record-review-dialog.health-journal-dialog-family {
    top: calc(8px + env(safe-area-inset-top)); bottom: calc(8px + env(safe-area-inset-bottom));
    height: auto; max-height: none; padding-bottom: 0;
  }
  .health-journal-dialog-family .split-actions { flex-direction: row; }
  .health-journal-dialog-family .health-metric-stepper {
    grid-template-columns: 42px minmax(92px, 1fr) auto 42px;
  }
  .health-journal-dialog-family .health-metric-stepper-label { grid-column: 1 / -1; }
}
.ben-record-confirmation-card {
  display: grid;
  gap: 12px;
}

.ben-record-confirmation-body {
  margin: 0;
  line-height: 1.6;
  white-space: pre-wrap;
}

.ben-record-confirmation-facts {
  display: grid;
  grid-template-columns: minmax(86px, auto) minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
}

.ben-record-confirmation-facts dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.ben-record-confirmation-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.ben-record-confirmation-structured pre {
  max-height: 280px;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-strong, #fff) 82%, transparent);
  font: 0.78rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.health-meal-review { gap: 10px; }
.health-meal-review-heading {
  min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: start; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 9px;
}
.health-meal-review-heading h3 { margin: 0; font-size: 16px; line-height: 1.25; }
.health-meal-review-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.health-meal-review-heading > strong { font-size: 12px; white-space: nowrap; }
.health-meal-review-intro { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.health-meal-review-items { display: flex; flex-direction: column; border-block: 1px solid var(--line); }
.health-meal-review-item { min-width: 0; margin: 0; border: 0; border-top: 1px solid var(--line); padding: 10px 0; }
.health-meal-review-item:first-child { border-top: 0; }
.health-meal-review-item legend { width: 100%; padding: 0; font-size: 13px; font-weight: 800; }
.health-meal-review-nutrition { margin: 4px 0 8px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.health-meal-review-estimate { margin: -3px 0 8px; color: var(--muted); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.health-review-weight-controls { grid-template-columns: 42px minmax(0, 1fr) 42px; }
.health-review-weight-controls label { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px; }
.health-review-weight-controls input { min-height: 42px; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.health-review-weight-controls label span { color: var(--muted); font-size: 10px; }
.health-meal-review-evidence { font-size: 11px; }
.health-meal-review-evidence summary { cursor: pointer; font-weight: 800; }
.health-meal-review-evidence p { margin: 7px 0 0; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }

.ben-query-health-result { display: grid; min-width: 0; }
.ben-query-health-result[hidden] { display: none; }
.ben-query-health-result .health-nutrition-result-card { border-radius: 6px; }
.ben-health-query-dialog > section { display: grid; gap: 10px; }
.health-meal-review-static-weight {
  margin: 2px 0 0; color: var(--ink); font-size: 11px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ben-query-secondary-panel {
  min-width: 0; border-top: 1px solid var(--line); padding-top: 10px;
}
.ben-query-secondary-panel > summary {
  min-height: 38px; display: flex; align-items: center; cursor: pointer;
  font-size: 11px; font-weight: 800;
}
.ben-query-note-fields { display: grid; gap: 10px; padding-top: 10px; }
.ben-query-note-fields label { min-width: 0; display: grid; gap: 5px; }
.ben-query-note-fields .button { width: 100%; min-height: 42px; }
.ben-query-primary-actions { margin-top: 4px !important; }
.todo-edit-dialog .ben-query-secondary-panel { border-color: var(--todo-line); }
.todo-edit-dialog .ben-query-secondary-panel > summary { color: var(--todo-text); }
.ben-health-query-dialog .ben-query-primary-actions {
  position: sticky; bottom: -18px; z-index: 2; border-top: 1px solid var(--line);
  background: var(--paper); padding-top: 10px;
}
.ben-health-query-dialog .ben-query-primary-actions .button { width: 100%; }

.health-journal-dialog-family .saved-meal-food-row {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
  border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 0;
}
.health-journal-dialog-family .saved-meal-food-row:first-child { border-top: 0; }
.saved-meal-food-row legend { width: 100%; padding: 0; font-size: 13px; font-weight: 800; }
.saved-meal-food-summary { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.saved-meal-weight-controls { grid-template-columns: 42px minmax(0, 1fr) 42px; }
.saved-meal-weight-controls label { min-width: 0; }
.saved-meal-weight-controls input { min-height: 42px; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.saved-meal-food-row .remove-item { justify-self: end; min-height: 36px; }
