/* Palette values copied from Android Theme.kt; no reinterpretation. */
:root, :root[data-palette="graphite"] {
  color-scheme: dark;
  --primary: #D8FF78;
  --on-primary: #1B2811;
  --primary-container: #2C3D24;
  --on-primary-container: #E4FFB4;
  --secondary: #BCCBB9;
  --on-secondary: #243126;
  --secondary-container: #28352E;
  --on-secondary-container: #DBE9D8;
  --tertiary: #9ED8C3;
  --on-tertiary: #10372D;
  --tertiary-container: #23483D;
  --on-tertiary-container: #BBF1DB;
  --background: #0F1517;
  --on-background: #F4F6EF;
  --surface: #192225;
  --on-surface: #F4F6EF;
  --surface-variant: #263236;
  --on-surface-variant: #B4C1BE;
  --surface-tint: #D8FF78;
  --surface-container-lowest: #0B1012;
  --surface-container-low: #151D20;
  --surface-container: #1B2528;
  --surface-container-high: #263236;
  --surface-container-highest: #303D40;
  --outline: #85948D;
  --outline-variant: #354344;
  --error: #FFB4AC;
  --on-error: #5E1714;
  --error-container: #572C2A;
  --on-error-container: #FFDAD5;
  --bg-rgb: 15,21,23;
  --bar-rgb: 38,50,54;
  --ambient-one: 152,217,76; --ambient-two: 54,157,165; --ambient-opacity: .18;
}
:root[data-palette="porcelain"] {
  color-scheme: light;
  --primary: #174FFF;
  --on-primary: #FFFFFF;
  --primary-container: #E0E7FF;
  --on-primary-container: #102C85;
  --secondary: #526482;
  --on-secondary: #FFFFFF;
  --secondary-container: #E9EDF4;
  --on-secondary-container: #253752;
  --tertiary: #81603B;
  --on-tertiary: #FFFFFF;
  --tertiary-container: #F4E5D4;
  --on-tertiary-container: #503417;
  --background: #F8F7F3;
  --on-background: #111C31;
  --surface: #FFFEFC;
  --on-surface: #111C31;
  --surface-variant: #EBEDF2;
  --on-surface-variant: #586477;
  --surface-tint: #174FFF;
  --surface-container-lowest: #FFFFFF;
  --surface-container-low: #FCFBF8;
  --surface-container: #F0F0ED;
  --surface-container-high: #E9EBED;
  --surface-container-highest: #E2E5EA;
  --outline: #7B879A;
  --outline-variant: #DDE1E8;
  --error: #A93632;
  --on-error: #FFFFFF;
  --error-container: #FBE3DF;
  --on-error-container: #7A302A;
  --bg-rgb: 248,247,243;
  --bar-rgb: 233,235,237;
  --ambient-one: 98,152,255; --ambient-two: 255,207,164; --ambient-opacity: .15;
}
:root[data-palette="spectrum"] {
  color-scheme: light;
  --primary: #7138ED;
  --on-primary: #FFFFFF;
  --primary-container: #EADDFF;
  --on-primary-container: #422279;
  --secondary: #6B5A85;
  --on-secondary: #FFFFFF;
  --secondary-container: #ECE3F6;
  --on-secondary-container: #372744;
  --tertiary: #9B503C;
  --on-tertiary: #FFFFFF;
  --tertiary-container: #FFE0CF;
  --on-tertiary-container: #643422;
  --background: #F2EDFF;
  --on-background: #241D3B;
  --surface: #FCFAFF;
  --on-surface: #241D3B;
  --surface-variant: #E7DFF4;
  --on-surface-variant: #6A5E7C;
  --surface-tint: #7138ED;
  --surface-container-lowest: #FFFFFF;
  --surface-container-low: #F9F5FF;
  --surface-container: #F0E8FC;
  --surface-container-high: #E9DFF7;
  --surface-container-highest: #E1D5F0;
  --outline: #8B7BA4;
  --outline-variant: #D9CCE9;
  --error: #A93632;
  --on-error: #FFFFFF;
  --error-container: #FBE3DF;
  --on-error-container: #7A302A;
  --bg-rgb: 242,237,255;
  --bar-rgb: 233,223,247;
  --ambient-one: 157,104,255; --ambient-two: 255,186,152; --ambient-opacity: .15;
}

:root {font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;font-size:100%;line-height:1.5;--nav-height:106px;--bg:var(--background);--panel:var(--surface);--fg:var(--on-surface);--muted:var(--on-surface-variant);--accent:var(--primary);--line:var(--outline-variant)}
* {box-sizing:border-box}
body {margin:0;background:var(--background);color:var(--on-background)}
[hidden],dialog:not([open]) {display:none!important}
html:has(dialog[open]) {overflow:hidden}
button,input,select {font:inherit}
button,.file-label {touch-action:manipulation}
button {cursor:pointer}
button:disabled {cursor:default;opacity:.48}
input:disabled,select:disabled {opacity:.6}
button:focus-visible,a:focus-visible,input:focus-visible,summary:focus-visible {outline:3px solid var(--primary);outline-offset:3px}
a {color:inherit}
.sr-only {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.ambient {position:fixed;inset:0;pointer-events:none;background:radial-gradient(circle 90vw at 50% 28%,rgba(var(--ambient-one),var(--ambient-opacity)),rgba(var(--ambient-one),0)),radial-gradient(circle 90vw at 44.3% 44%,rgba(var(--ambient-two),var(--ambient-opacity)),rgba(var(--ambient-two),0))}
.app-shell {position:relative;max-width:840px;margin:auto}
.brand {position:sticky;top:0;z-index:5;min-height:calc(64px + env(safe-area-inset-top));padding:env(safe-area-inset-top) 12px 0 16px;display:flex;align-items:center;justify-content:space-between;gap:8px;background:var(--background)}
.brand a {display:flex;align-items:center;gap:10px;text-decoration:none;white-space:nowrap}
.brand strong {font-size:1.75rem;font-weight:900;letter-spacing:-1.2px;line-height:1.2}
.brand a>span {font-size:.75rem;color:var(--on-surface-variant)}
.top-actions {display:flex;flex-shrink:0}
.icon-button {width:48px;min-width:44px;min-height:48px;display:inline-flex;align-items:center;justify-content:center;padding:10px;border:0;border-radius:20px;background:transparent;color:var(--on-surface-variant)}
.kai-icon {display:block;width:24px;height:24px;flex:none}
main {padding:0 20px calc(var(--nav-height) + 20px)}
h1,h2,h3,p {margin:0}
h2 {font-size:1.3125rem;line-height:1.286;font-weight:600}
h3 {font-size:1.0625rem;line-height:1.353;font-weight:600}
.section-line {display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0}
.section-line>span {font-size:.75rem;color:var(--on-surface-variant)}
.date-bar {display:grid;grid-template-columns:minmax(0,1fr) repeat(3,48px);align-items:center;margin-bottom:16px}
.date-heading {position:relative;display:flex;flex-direction:column;gap:3px;padding:8px 12px;min-width:0;border-radius:12px;cursor:pointer}
#date-title {font-size:1.625rem;line-height:1.23;font-weight:700;overflow-wrap:anywhere}
#date-subtitle {font-size:.75rem;line-height:1.5;color:var(--on-surface-variant)}
.date-heading input,.editor-date input {position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;margin:0;min-width:0}
.date-heading:focus-within,.editor-date:focus-within {outline:2px solid var(--primary);outline-offset:2px}
.today {grid-column:1/-1;justify-self:start}
.calorie-hero {position:relative;isolation:isolate;overflow:hidden;border-radius:32px;min-height:222px;--hero-radius:138px}
.ribbon-layer {position:absolute;inset:12px 0 30px 100px;z-index:-2;pointer-events:none}
.ribbon-layer img {width:100%;height:100%;object-fit:contain;display:block}
.hero-shade {position:absolute;inset:0;z-index:-1;pointer-events:none;background:linear-gradient(to right,rgba(var(--bg-rgb),.97),rgba(var(--bg-rgb),.82) 37%,rgba(var(--bg-rgb),0) 74%)}
.hero-content {display:flex;flex-direction:column;align-items:start;gap:6px;padding:24px 20px 22px}
.hero-title {font-size:.875rem;line-height:1.5;color:var(--on-surface-variant)}
.hero-value {font:400 4rem/1.08 Georgia,"Times New Roman",serif;letter-spacing:-1.8px;color:var(--on-background);text-shadow:0 0 12px var(--background);overflow-wrap:anywhere}
.hero-unit {font-size:1.0625rem;line-height:1.353;font-weight:600;color:var(--on-surface-variant)}
.hero-detail {font-size:.75rem;line-height:1.5;padding-top:8px}
[data-palette=graphite] .calorie-hero {min-height:244px}
[data-palette=graphite] .ribbon-layer {inset:0 0 20px}
[data-palette=graphite] .hero-shade {background:radial-gradient(circle var(--hero-radius) at 50% 43%,rgba(var(--bg-rgb),.88),rgba(var(--bg-rgb),.78) 62%,rgba(var(--bg-rgb),0))}
[data-palette=graphite] .hero-content {align-items:center;text-align:center;padding-top:30px}
[data-palette=graphite] .hero-value {font-family:inherit;font-weight:700}
[data-palette=graphite] .hero-detail {padding-top:10px}
.calorie-hero[data-digits=long] .hero-value {font-size:3.375rem}
.calorie-hero[data-digits=longer] .hero-value {font-size:2.875rem}
.metrics {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:16px}
.metric {background:var(--surface);border-radius:20px;padding:12px;min-width:0}
.metric>span {font-size:.75rem;font-weight:500;line-height:1.5;color:var(--on-surface-variant);overflow-wrap:anywhere}
.metric p {font-size:.875rem;line-height:1.5;font-weight:600;margin-top:5px;overflow-wrap:anywhere}
.metric strong {font-weight:inherit}
.entries-section {margin-top:20px}
#entries {display:flex;flex-direction:column;gap:16px;margin-top:16px}
.meal-card {background:var(--surface);color:var(--on-surface);border:0;border-radius:26px;padding:18px;width:100%;text-align:left}
.meal-header {display:flex;align-items:center;gap:10px;min-width:0}
.meal-header .meal-title {font-size:1.0625rem;line-height:1.353;font-weight:600;flex:1;overflow-wrap:anywhere}
.meal-header .meal-total {font-size:.875rem;line-height:1.5;font-weight:600;white-space:nowrap}
.icon-badge {width:44px;height:44px;border-radius:50%;background:var(--secondary-container);color:var(--on-secondary-container);display:flex;align-items:center;justify-content:center;flex:none}
.icon-badge .kai-icon {width:22px;height:22px}
.empty-meal {display:flex;flex-direction:column;gap:8px}
.empty-meal .meal-header {width:100%}
.empty-caption {font-size:.875rem;line-height:1.5;color:var(--on-surface-variant)}
.entry-card {padding:14px 0 2px;border-bottom:1px solid var(--outline-variant)}
.entry-card:last-child {border:0}
.entry-card h3 {font-size:.875rem;line-height:1.5;overflow-wrap:anywhere}
.entry-card p {font-size:.875rem;line-height:1.5;color:var(--on-surface-variant);margin-top:3px}
.entry-card .entry-nutrients {font-size:.8125rem;display:flex;gap:6px;flex-wrap:wrap;color:var(--on-surface-variant);margin-top:3px}
.entry-nutrients b {font-weight:400}
.entry-actions {display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.entry-card .photo-image {max-height:160px;margin-top:12px}
.primary,.secondary,.text-button,.danger {display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;border:1px solid transparent;border-radius:20px;padding:10px 16px;text-decoration:none;font-size:.875rem;line-height:1.43;font-weight:600}
.primary {background:var(--primary);color:var(--on-primary)}
.secondary {background:transparent;border-color:var(--outline);color:var(--primary)}
.text-button {background:transparent;color:var(--primary);padding:8px 12px}
.danger {background:var(--error-container);color:var(--on-error-container)}
.plan-button {width:100%;margin-top:16px}
.plan-button .kai-icon {width:18px;height:18px}
.muted,.field-help {font-size:.875rem;line-height:1.5;color:var(--on-surface-variant)}
#day-state {font-size:.75rem;margin-top:16px}
.draft-banner {margin:8px 0 16px;padding:12px 16px;border-radius:20px;background:var(--secondary-container)}
.draft-banner p {margin-top:8px;font-size:.75rem}
.nav-shell {position:fixed;z-index:10;bottom:0;left:50%;transform:translateX(-50%);width:min(100%,840px);padding:8px 16px calc(8px + env(safe-area-inset-bottom));pointer-events:none}
.bottom-bar {pointer-events:auto;background:rgba(var(--bar-rgb),.97);box-shadow:0 4px 12px #0003;border-radius:30px;padding:8px 12px;display:grid;grid-template-columns:1fr 1.25fr 1fr 1fr;align-items:center}
.bottom-bar[data-adding="no"] {grid-template-columns:repeat(3,minmax(0,1fr))}
.bottom-bar[data-demo="yes"][data-adding="no"] {grid-template-columns:repeat(2,minmax(0,1fr))}
.nav-item,.central-add {border:0;background:transparent;color:var(--on-surface-variant);display:flex;align-items:center;justify-content:center;flex-direction:column;gap:3px;min-height:56px;padding:7px 4px;border-radius:20px;font-size:.6875rem;line-height:1.4545;min-width:0;overflow-wrap:anywhere}
.nav-item .kai-icon {width:21px;height:21px}
.nav-item>span:not([data-icon]),.nav-item small {max-width:100%;overflow-wrap:anywhere}
.nav-item.selected {color:var(--primary)}
.nav-item small {font-size:.5625rem;line-height:1.25}
.central-add {gap:5px;color:var(--on-surface);padding:0 4px}
.plus-circle {width:52px;height:52px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:var(--primary);color:var(--on-primary)}
.plus-circle .kai-icon {width:28px;height:28px}
.panel {background:var(--surface);border-radius:26px;padding:18px}
.storage-info {font-size:.8125rem;color:var(--on-surface-variant);margin-top:20px}
.storage-info summary {cursor:pointer;font-weight:600;color:var(--on-surface);padding:4px 0}
.storage-info p {margin:12px 0}
.status-chip {display:inline-block;font-size:.6875rem;font-weight:400;margin-left:8px}
.server-line {display:flex;align-items:center;gap:12px;justify-content:space-between;margin-top:16px;flex-wrap:wrap}
.environment {font-size:.6875rem;overflow-wrap:anywhere;white-space:pre-line}
#notice:not(:empty),#error,#editor-error {padding:12px 16px;border-radius:14px;margin:12px 0;background:var(--secondary-container);color:var(--on-secondary-container);font-size:.875rem}
#error,#editor-error {background:var(--error-container);color:var(--on-error-container)}
footer {font-size:.6875rem;color:var(--on-surface-variant);text-align:center;margin-top:24px}
dialog {color:var(--on-surface);background:var(--surface-container-low);border:0;border-radius:28px;max-width:min(95vw,600px);max-height:calc(var(--visible-height,100dvh) * .92);padding:24px;overflow:auto}
dialog::backdrop {background:#0008}
.manual-sheet {position:fixed;inset:auto 0 0;margin:0 auto;width:min(100%,640px);max-width:100%;padding:0;border-radius:28px 28px 0 0;overscroll-behavior:contain}
.drag-handle {width:32px;height:4px;border-radius:4px;background:var(--on-surface-variant);opacity:.4;margin:20px auto}
.sheet-content {padding:0 24px calc(32px + env(safe-area-inset-bottom))}
.sheet-content h2 {font-size:1.4375rem;line-height:1.26;font-weight:700}
.sheet-content .section-line {align-items:start}
.sheet-content .icon-button {margin-top:-10px;margin-right:-12px}
.editor-date {position:relative;display:block;color:var(--on-surface-variant);font-size:.875rem;margin-top:12px;padding:2px 0;cursor:pointer}
#entry-form>.muted {margin:12px 0}
#repeat-note {overflow-wrap:anywhere}
.field {display:block;font-size:.75rem;color:var(--on-surface-variant);margin:12px 0;min-width:0}
.field input {display:block;width:100%;min-width:0;margin-top:4px;min-height:56px;border:1px solid var(--outline);border-radius:4px;padding:14px 16px;font-size:1rem;line-height:1.5;color:var(--on-surface);background:transparent}
.field input[readonly] {background:var(--surface-container)}
fieldset {margin:16px 0 0;border:0;padding:0;min-width:0}
legend {padding:0;font-size:.875rem;line-height:1.5;font-weight:600;margin-bottom:8px}
.choice-grid,.nutrition-fields {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.choice {position:relative;display:block;min-width:0;cursor:pointer}
.choice input {position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}
.choice span,.unit-chip {display:flex;align-items:center;justify-content:center;min-height:36px;padding:8px 10px;border:1px solid var(--outline);border-radius:8px;font-size:.875rem;line-height:1.43;font-weight:500;background:transparent;color:var(--on-surface-variant);text-align:center;overflow-wrap:anywhere}
.choice input:checked+span,.unit-chip.selected {background:var(--secondary-container);border-color:transparent;color:var(--on-secondary-container)}
.choice:focus-within {outline:2px solid var(--primary);outline-offset:2px;border-radius:8px}
.field-help {font-size:.75rem;margin-bottom:8px}
.nutrition-fields .field {margin:0}
.portion-preview {background:var(--secondary-container);color:var(--on-secondary-container);border-radius:12px;padding:16px;margin-top:16px;font-size:.875rem}
.portion-preview h3 {font-size:.875rem;font-weight:700}
.portion-preview p {margin-top:4px}
.photo-section {margin:20px 0;padding:16px 0;border-top:1px solid var(--outline-variant);border-bottom:1px solid var(--outline-variant)}
.photo-section h3 {font-size:1rem}
.photo-section .muted {font-size:.75rem;margin:6px 0 12px}
.photo-actions {display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.file-label {cursor:pointer;position:relative;overflow:hidden}
.file-label input {position:absolute;inset:0;opacity:0;margin:0;padding:0;width:100%;height:100%;cursor:pointer}
.photo-image {display:block;max-width:100%;max-height:200px;object-fit:contain;border-radius:14px;margin-bottom:12px}
.review-unavailable {width:100%}
.draft-status {font-size:.75rem;line-height:1.5;color:var(--on-surface-variant);margin:14px 0}
.editor-actions {display:flex;gap:8px;align-items:stretch}
.editor-actions>button {flex:1;min-width:0}
.recovery-actions {display:flex;flex-direction:column;gap:8px;margin-top:10px}
video {display:block;width:100%;max-height:50dvh;background:#000;border-radius:14px;margin-top:16px}
#camera-status {font-size:.875rem;margin:12px 0}
.appearance-sheet {min-width:min(340px,92vw)}
.appearance-sheet>.muted {margin:12px 0}
.palette-options {display:flex;flex-direction:column;gap:8px;margin:0}
.palette-option {display:flex;gap:12px;align-items:center;padding:14px;background:var(--surface);border-radius:14px;cursor:pointer}
.palette-option input {width:20px;height:20px;accent-color:var(--primary);margin:0}
.palette-dot {width:28px;height:28px;border-radius:50%;display:block}
.palette-dot.graphite {background:#D8FF78;border:6px solid #0F1517}
.palette-dot.porcelain {background:#174FFF;border:6px solid #F8F7F3}
.palette-dot.spectrum {background:#7138ED;border:6px solid #F2EDFF}
.large-type .calorie-hero {min-height:222px}
.large-type .ribbon-layer {inset:12px 0 30px 92px}
.large-type .hero-content {align-items:start;text-align:left;padding-top:24px}
.large-type .hero-value {font-size:2.625rem}
.large-type .hero-shade {background:linear-gradient(to right,rgba(var(--bg-rgb),.97),rgba(var(--bg-rgb),.82) 37%,rgba(var(--bg-rgb),0) 74%)}
.large-type .brand a>span {display:none}
.large-type .bottom-bar {grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
.large-type .central-add {grid-column:1/-1;grid-row:1;flex-direction:row;background:var(--primary);color:var(--on-primary);border-radius:18px;min-height:52px;padding:12px;font-size:.875rem;gap:6px}
.large-type .plus-circle {width:18px;height:18px;background:transparent;color:inherit}
.large-type .plus-circle .kai-icon {width:18px;height:18px}
.large-type .nav-item {grid-row:2}
.large-font .date-bar {grid-template-columns:repeat(3,minmax(0,1fr))}
.large-font .date-heading {grid-column:1/-1}
.large-font .date-bar>.icon-button {justify-self:center}
.large-font .section-line {flex-wrap:wrap}
.large-font .choice-grid,.large-font .nutrition-fields {grid-template-columns:1fr}
.large-font .editor-actions {flex-direction:column}
@media(max-width:355px) {
  .bottom-bar {grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
  .central-add {grid-column:1/-1;grid-row:1;flex-direction:row;background:var(--primary);color:var(--on-primary);border-radius:18px;min-height:52px;padding:12px;font-size:.875rem;gap:6px}
  .plus-circle {width:18px;height:18px;background:transparent;color:inherit}
  .plus-circle .kai-icon {width:18px;height:18px}
  .nav-item {grid-row:2}
  .date-bar {grid-template-columns:minmax(0,1fr) repeat(3,44px)}
  .date-bar .icon-button {width:44px;padding:10px}
}
@media(prefers-reduced-motion:no-preference) {button {transition:background-color .15s ease} }
.field select,.field textarea {display:block;width:100%;min-width:0;margin:4px 0 0;min-height:48px;border:1px solid var(--outline);border-radius:4px;padding:12px;font:inherit;color:var(--on-surface);background:var(--surface)}
.field textarea {resize:vertical}
.feature-page {padding:20px 0;overflow-wrap:anywhere}
.feature-page h1 {font-size:1.5rem;margin-bottom:16px}
.feature-page .field {margin:12px 0}
.feature-page .panel {margin:16px 0;padding:18px}
.feature-page h2 {font-size:1.25rem;margin:0 0 8px}
.feature-page h3 {font-size:1rem}
.feature-page p {margin:6px 0;white-space:pre-line}
.small {font-size:.8125rem;line-height:1.5;color:var(--on-surface-variant)}
.fluid-total {margin:16px 0}.fluid-total strong {font-size:2rem}.fluid-add-actions,.fluid-history {display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}.fluid-entry {margin:12px 0}.fluid-entry h3 {overflow-wrap:anywhere}#fluid-error {color:var(--error);margin:12px 0}
.period-navigation {display:grid;grid-template-columns:48px minmax(0,1fr) 48px;align-items:center;gap:8px}
.period-navigation .field {margin:0}
.statistics-totals {display:grid;gap:12px}
.result-row {padding:14px;border-radius:16px;background:var(--surface-variant)}
.result-row[data-signal=ON_TARGET],.result-row[data-signal=FAVORABLE] {background:#E1F0DC;color:#244F34}
.result-row[data-signal=UNFAVORABLE] {background:#FBE3DF;color:#7A302A}
.result-row .small {color:inherit}
[data-palette=graphite] .result-row[data-signal=ON_TARGET],[data-palette=graphite] .result-row[data-signal=FAVORABLE] {background:#254735;color:#DAEED7}
[data-palette=graphite] .result-row[data-signal=UNFAVORABLE] {background:#572C2A;color:#FFDAD5}
.balance-chart {display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:8px;margin-top:16px}
.balance-column {text-align:center;min-width:0}
.balance-track {height:96px;position:relative;margin:0 0 6px;background:transparent}
.balance-bar {display:block;position:absolute;bottom:0;left:24%;width:52%;border-radius:5px;background:var(--primary)}
.balance-plan {position:absolute;left:6%;right:6%;height:2px;background:var(--on-surface-variant)}
.balance-missing {position:absolute;bottom:0;left:0;right:0}
.day-statistics .section-line {align-items:start;flex-wrap:wrap;gap:8px}
.day-statistics .status-chip {white-space:normal}
.client-note {font-weight:600}
.day-statistics details {margin-top:12px}
.checkbox-label {display:flex;align-items:center;gap:12px;margin:16px 0;line-height:1.5}
.checkbox-label input {min-width:24px;min-height:24px;accent-color:var(--primary)}
.demo-banner {margin-top:16px;padding:18px;border:2px solid var(--primary);overflow-wrap:anywhere}
.demo-banner p {margin:8px 0}
.day-marker-label {margin:12px 0;font-size:.875rem}
a {color:var(--primary)}
.ambient {background:none;overflow:hidden}
.ambient-dot {position:absolute;left:0;top:0;width:180vw;height:180vw;border-radius:50%;background:radial-gradient(closest-side,rgba(var(--ambient-one),var(--ambient-opacity)),rgba(var(--ambient-one),0));will-change:transform}
.ambient-1 {background:radial-gradient(closest-side,rgba(var(--ambient-two),var(--ambient-opacity)),rgba(var(--ambient-two),0))}
.ribbon-canvas {position:absolute;inset:0;width:100%;height:100%}
.appearance-sheet {max-height:85dvh;overflow:auto}
.appearance-sheet fieldset+fieldset {margin-top:16px}
.choice span {min-height:44px}
#portability-dialog {width:min(620px,96vw);max-height:90dvh;overflow:auto;overflow-wrap:anywhere}
#portability-dialog p {margin:12px 0}
#portability-dialog .field {margin:12px 0}
.data-tabs {display:flex;flex-wrap:wrap;gap:8px;margin:16px 0}
#portability-status[data-error=true] {color:var(--error)}
#summary-downloads {display:flex;flex-wrap:wrap;gap:8px}
#import-preview ul {padding-left:20px}
#portability-dialog>.section-line {position:sticky;top:0;z-index:2;background:var(--surface-container-low);padding:8px 0}
.account-panel {margin:16px 0;overflow-wrap:anywhere}
.account-panel details {margin:16px 0;border-top:1px solid var(--outline-variant);padding-top:12px}
.account-panel summary {cursor:pointer;font-weight:600}
.account-panel .field {margin-top:12px}
.account-actions,.access-row {display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.access-row>p {width:100%}
#sync-conflicts article {border:1px solid var(--outline-variant)}
#sync-conflicts button {margin:4px 0;width:100%}
.relationship-card h4 {margin:4px 0 12px}
.relationship-card button {display:block;margin:8px 0;max-width:100%}
#relationships-status {overflow-wrap:anywhere}
.catalog-entry-actions {display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.catalog-sheet {width:min(680px,96vw);max-height:90dvh;overflow:auto;overflow-wrap:anywhere}
.catalog-header {position:sticky;top:0;z-index:3;background:var(--surface-container-low);padding:8px 0;gap:8px}
.catalog-header h2 {flex:1;font-size:1.15rem}
.catalog-sheet .field {margin:12px 0}
.catalog-sheet button {margin:6px 6px 6px 0}
.catalog-card h3 {margin:4px 0 12px}
.catalog-card a {display:block;margin:8px 0}
.catalog-sheet #catalog-status[data-error=true],.catalog-sheet #catalog-error {color:var(--error)}
.catalog-controls {margin-bottom:16px}
.cheat-sheet {width:min(680px,96vw);max-height:90dvh;overflow:auto;overflow-wrap:anywhere}
.cheat-header {position:sticky;top:0;z-index:3;background:var(--surface-container-low);padding:8px 0;gap:12px}
.cheat-header h2 {flex:1;font-size:1.2rem}
.cheat-sheet .field {margin:12px 0}
.cheat-sheet button {margin:6px 6px 6px 0}
.cheat-sheet #cheat-error,.cheat-sheet #cheat-validation {color:var(--error)}
.cheat-presets {display:flex;flex-wrap:wrap;gap:6px}

/* Keep scrollable form content below the header, including keyboard focus. */
html {scroll-padding-block:calc(max(64px,2.1rem) + env(safe-area-inset-top) + 12px) calc(var(--nav-height) + 16px)}
.catalog-sheet[open],.cheat-sheet[open] {display:flex;flex-direction:column;overflow:hidden}
.catalog-header,.cheat-header {position:relative;top:auto;flex-shrink:0}
.catalog-sheet>p,.cheat-sheet>p {flex-shrink:0}
#catalog-content,#cheat-content {min-height:0;overflow:auto;overscroll-behavior:contain;scroll-padding-block:12px;padding:0 6px 8px;margin:0 -6px}
.catalog-sheet button,.cheat-sheet button {max-width:calc(100% - 6px);overflow-wrap:normal;word-break:normal}
.catalog-header h2,.cheat-header h2 {min-width:0;overflow-wrap:normal;word-break:normal}

/* Text remains enlarged; space comes from reflow and smaller side gutters. */
html,body {height:100%;overflow:hidden}
.app-shell {height:calc(var(--visible-height,100dvh) - var(--nav-height));display:flex;flex-direction:column}
.brand {flex-shrink:0}
#app-main {flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scroll-padding-block:16px;padding-bottom:24px}
.large-font .catalog-sheet,.large-font .cheat-sheet {padding:16px 8px}
.large-font .catalog-header {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));justify-content:space-between;gap:8px}
.large-font .catalog-header h2 {grid-column:1/-1;grid-row:2}
.large-font .catalog-header #catalog-close {grid-column:2;grid-row:1;justify-self:end}
.large-font .cheat-header {display:grid;grid-template-columns:minmax(0,1fr);gap:8px}
.large-font .cheat-header h2 {grid-row:2}
.large-font .catalog-header button,.large-font .cheat-header button {width:max-content;max-width:100%;padding-inline:12px;margin:0}
.large-font :is(#catalog-content,#cheat-content) button {width:100%;max-width:100%;margin:6px 0;padding-inline:8px}
.large-font .cheat-presets button {width:auto;margin:0;flex:1 0 auto}
.large-font :is(#cheat-spacing-warning,#cheat-delete-warning) {padding:8px}
.large-font #sync-conflicts article {padding:12px}
.large-font #sync-conflicts button {overflow-wrap:normal;word-break:normal;padding-inline:8px}
.catalog-header h2,.cheat-header h2,.catalog-sheet button,.cheat-sheet button {hyphens:none}
.large-font #cheat-content :is(p,h3,h4),
.large-font :is(#catalog-editor-form,#ingredient-editor-form)>p,
.large-font #sync-conflicts>p {overflow-wrap:normal;hyphens:auto}
@media(max-width:360px) {
  .catalog-header {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .catalog-header h2 {grid-column:1/-1;grid-row:2}
  .catalog-header #catalog-close {grid-column:2;grid-row:1;justify-self:end}
  .catalog-header button {width:max-content;max-width:100%;margin:0}
}
.discovery-header {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.discovery-header h2 {grid-column:1/-1;grid-row:2}
.discovery-header #discovery-close {grid-column:2;grid-row:1;justify-self:end}
.discovery-header button {width:max-content;max-width:100%;margin:0}
#discovery-content {min-height:0;overflow:auto;overscroll-behavior:contain;scroll-padding-block:12px;padding:0 6px 8px;margin:0 -6px}
.discovery-notices {max-height:30dvh;overflow:auto;flex-shrink:0}
#discovery-error {color:var(--error)}
.discovery-tabs {display:flex;flex-wrap:wrap;gap:4px}
.discovery-card {margin-block:12px}
.discovery-photo {padding:16px;border:1px solid var(--outline-variant);border-radius:12px;color:var(--on-surface-variant)}
.discovery-prose {white-space:pre-wrap}
#discovery-content textarea {font:inherit;max-width:100%;width:100%;box-sizing:border-box}
#discovery-content .checkbox-label {display:flex;gap:8px;align-items:start;margin:10px 0}
#discovery-content .checkbox-label input {flex-shrink:0;width:auto}
.large-font #discovery-content button {width:100%;max-width:100%;margin:6px 0;padding-inline:8px}
.large-font #discovery-content :is(p,h3,h4) {overflow-wrap:normal;hyphens:auto}

.password-controls {display:flex;align-items:stretch;gap:8px;margin-top:4px;min-width:0}
.password-controls input {flex:1 1 auto;min-width:0;margin-top:0}
.password-controls button {flex:0 0 auto;min-height:48px;padding:8px 12px;font-size:.875rem}
.password-controls button:focus-visible {outline:2px solid var(--primary);outline-offset:2px}

/* Owner-approved desktop composition; mobile colors and diary functions retained. */
.welcome-page {padding-block:20px}
.welcome-hero {padding:clamp(24px,5vw,64px);border-radius:28px;background:linear-gradient(115deg,var(--surface),var(--primary-container));border:1px solid var(--outline-variant)}
.eyebrow {font-size:.875rem;color:var(--primary);font-weight:700;letter-spacing:.08em}
.welcome-hero h1 {font-size:clamp(2rem,4vw,3.5rem);line-height:1.12;max-width:14ch;margin:20px 0}
.welcome-hero>p {max-width:50ch;font-size:1.125rem;color:var(--on-surface-variant)}
.welcome-actions,.auth-tabs,.auth-links,.settings-tools {display:flex;gap:12px;flex-wrap:wrap}
.welcome-actions {margin-top:28px}
.welcome-benefits {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin:24px 0}
.welcome-benefits .panel {margin:0}
.welcome-benefits h2 {font-size:1.25rem}
.welcome-benefits p {color:var(--on-surface-variant)}
.auth-tabs {margin-bottom:24px}
.auth-tabs [aria-pressed=true] {background:var(--primary-container);color:var(--on-primary-container);border-color:var(--primary)}
.auth-hint {max-width:56ch;color:var(--on-surface-variant)}
.auth-feedback:not(:empty) {margin-top:16px;padding:12px 16px;border-radius:14px;background:var(--secondary-container);color:var(--on-secondary-container)}
.auth-feedback[data-error] {background:var(--error-container);color:var(--on-error-container)}
body[data-auth=onboarding] #profile-title,body[data-auth=onboarding] #account-title {display:none}
body[data-auth=onboarding] #account-status {margin-bottom:20px}
body[data-auth=onboarding] #auth-step-title {font-size:2rem;line-height:1.2;margin:24px 0 12px}
.auth-links {margin-top:16px}
#account-form {max-width:560px}
#profile-form {max-width:720px}
#profile-stage:empty {display:none}
.settings-tools {border-top:1px solid var(--outline-variant);padding-top:20px;margin-top:20px}
.settings-tools h3 {width:100%}
body[data-auth=onboarding] .bottom-bar {display:none}
body[data-auth=onboarding] .app-shell {height:var(--visible-height,100dvh)}
@media(max-width:700px) {
  .welcome-benefits {grid-template-columns:minmax(0,1fr)}
  .welcome-hero {padding:24px 20px}
  .welcome-actions>* {flex:1 1 180px}
  .auth-tabs>* {flex:1 1 180px}
}
@media(min-width:1100px) {
  .app-shell,body[data-auth=onboarding] .app-shell {max-width:1480px;width:calc(100% - 64px);height:100dvh;padding:24px 0;display:grid;grid-template-columns:208px minmax(0,1fr);grid-template-rows:56px minmax(0,1fr);gap:24px}
  .brand {grid-column:2;grid-row:1;padding:0 8px;background:transparent}
  #app-main {grid-column:2;grid-row:2;padding:0 8px 32px;scroll-padding-top:24px}
  .nav-shell {left:max(32px,calc((100vw - 1480px)/2));top:24px;bottom:24px;right:auto;transform:none;width:208px;padding:0}
  .bottom-bar {position:relative;width:100%;height:100%;max-width:none;display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:12px;padding:80px 16px 20px;border-radius:24px}
  .bottom-bar::before {content:'Ваш дневник';position:absolute;top:28px;left:24px;font-size:1.125rem;font-weight:700}
  .bottom-bar button {flex:0 0 auto;width:100%;min-height:56px;display:flex;flex-direction:row;justify-content:flex-start;gap:12px;padding:12px 16px;border-radius:16px}
  .bottom-bar #add-entry {order:5;margin-top:20px}
  body[data-auth=onboarding] .app-shell {grid-template-columns:minmax(0,1fr);max-width:1180px}
  body[data-auth=onboarding] .brand,body[data-auth=onboarding] #app-main {grid-column:1}
  .feature-page h1 {font-size:2rem}
  #profile {display:grid;grid-template-columns:minmax(280px,.85fr) minmax(0,1.15fr);gap:24px;align-items:start}
  #profile>h1 {grid-column:1/-1;margin-bottom:0}
  #profile>.muted {grid-column:2;grid-row:2}
  #account-panel {grid-column:1;grid-row:2/5;margin:0}
  #profile-setup {grid-column:2}
  #profile-error {grid-column:2}
  body[data-auth=onboarding] #profile {display:block;max-width:760px;margin:0 auto}
  body[data-auth=onboarding] #profile>.muted {display:none}
  body[data-auth=onboarding] #account-panel {margin:24px 0}
  #automatic-profile,#manual-profile {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 20px}
  #automatic-profile :is(#profile-age,#activity-description,#goal-confirmation) {grid-column:1/-1}
  #diary {display:grid;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:20px;align-content:start}
  #diary>.date-bar,#diary>#notice,#diary>#error,#diary>.draft-banner {grid-column:1/-1}
  #diary>.calorie-hero {grid-column:1;grid-row:auto;margin:0;min-height:240px}
  #diary>.metrics {grid-column:2;margin:0;align-self:stretch;grid-template-columns:1fr}
  #diary>.entries-section {grid-column:1/-1}
  #diary>.plan-button,#diary>.day-marker-label {justify-self:start}
}

.welcome-copy {min-width:0}
.welcome-page .welcome-hero h1 {font-size:clamp(2.25rem,4vw,3.5rem);max-width:18ch;overflow-wrap:anywhere}
.welcome-visual {display:none}
.welcome-actions>* {min-width:0;max-width:100%;overflow-wrap:anywhere}
@media(min-width:1100px) {
 .welcome-hero {display:grid;grid-template-columns:minmax(0,1.4fr) minmax(180px,.6fr);gap:24px;align-items:center;padding:40px}
 .welcome-visual {display:block;width:100%;height:280px;object-fit:contain;border-radius:20px;opacity:.85}
 .welcome-page .welcome-hero h1 {margin:16px 0}
}

/* Keep profile completion focused; full account tools appear after setup. */
body[data-setup=pending] #account-panel>:not(#account-status):not(.account-actions) {display:none}
body[data-setup=pending] #account-panel .account-actions>:not(#account-logout) {display:none}
@media(min-width:1100px) {
 body[data-setup=pending] #profile {display:block;max-width:880px;margin:0 auto}
 body[data-setup=pending] #account-panel {margin:20px 0;padding:16px 20px}
 body[data-setup=pending] #profile-setup {max-width:720px}
}
