:root {
  color-scheme: light;
  --canvas: #eff3f0;
  --paper: #ffffff;
  --ink: #14221c;
  --muted: #53645b;
  --line: #d7e2da;
  --track: #e2ebe5;
  --accent: #176749;
  --on-accent: #ffffff;
  --accent-surface: #e5f2e9;
  --notice: #f4f8f5;
  --danger: #a42d37;
  --shadow: 0 16px 58px #122c1d24;
  --radius: 19px;
  --space: clamp(16px, 3.5vw, 45px);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #111915;
    --paper: #1b2922;
    --ink: #edf4ef;
    --muted: #abbdb2;
    --line: #34473c;
    --track: #35473e;
    --accent: #76d6a7;
    --on-accent: #12241b;
    --accent-surface: #21392d;
    --notice: #1c2e24;
    --danger: #ff9fa8;
    --shadow: 0 20px 65px #0006;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #111915;
  --paper: #1b2922;
  --ink: #edf4ef;
  --muted: #abbdb2;
  --line: #34473c;
  --track: #35473e;
  --accent: #76d6a7;
  --on-accent: #12241b;
  --accent-surface: #21392d;
  --notice: #1c2e24;
  --danger: #ff9fa8;
  --shadow: 0 20px 65px #0006;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; line-height: 1.45; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.35rem); letter-spacing: -.058em; line-height: 1.03; }
h2 { font-size: 1.04rem; letter-spacing: -.017em; }
h3 { font-size: 1rem; }
small, .small { font-size: .85rem; }
.quiet, small { color: var(--muted); }
strong, .row-value, .energy-number, .macro-line, .metrics { font-variant-numeric: tabular-nums; }
.skip-link { position: fixed; z-index: 10; inset: 6px auto auto 6px; padding: 12px; background: var(--paper); transform: translateY(-140%); }
.skip-link:focus { transform: translateY(0); }
.topbar { position: relative; z-index: 2; background: var(--paper); border-bottom: 1px solid var(--line); }
.top-inner {
  max-width: 1510px;
  padding: calc(10px + env(safe-area-inset-top)) var(--space) 10px;
  margin: 0 auto;
  min-height: 65px;
  display: flex;
  gap: 24px;
  align-items: center;
}
.wordmark { font-weight: 900; letter-spacing: -.08em; font-size: 1.72rem; color: var(--ink); border: 0; background: none; padding: 0; min-height: 44px; }
.wordmark span { color: var(--accent); }
.top-actions { display: flex; gap: 9px; align-items: center; margin-left: auto; }
.button, .icon-button, .date-step {
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 44px;
  padding: 8px 15px;
  font-weight: 650;
  color: var(--ink);
  background: var(--track);
}
.button span { font-size: 1.18em; vertical-align: -.03em; margin-right: 3px; }
.button.primary { background: var(--accent); color: var(--on-accent); }
.button.secondary, .icon-button { background: var(--paper); border-color: var(--line); }
.button.subtle { color: var(--muted); background: none; text-decoration: underline; text-underline-offset: .2em; padding-inline: 6px; }
.button.destructive { color: var(--paper); background: var(--danger); }
.icon-button { width: 44px; padding: 0; font-size: 1.3rem; line-height: 1; }
.button:not(:disabled):active, .text-button:active, .nav-link:active, .row-button:active { transform: translateY(1px); }
.date-controls { display: flex; gap: 6px; align-items: center; }
.date-step { border-color: var(--line); width: 44px; padding: 0; background: var(--paper); font-size: 1.2rem; color: var(--accent); }
.date-picker { position: relative; display: grid; min-height: 44px; padding: 0 12px; justify-items: center; align-items: center; color: var(--muted); font-weight: 630; white-space: nowrap; }
.date-picker input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.date-picker input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.date-picker:focus-within { outline: 2px solid var(--accent); border-radius: 8px; }
.shell { max-width: 1510px; margin: 0 auto; display: grid; grid-template-columns: 170px minmax(0, 1fr); }
.navigation { padding: 26px 12px 26px var(--space); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.nav-link { min-height: 47px; background: transparent; color: var(--muted); border: 0; border-radius: 11px; display: flex; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; font-size: .91rem; font-weight: 650; }
.nav-link[aria-current="page"] { color: var(--accent); background: var(--accent-surface); }
.nav-icon { display: inline-block; width: 16px; height: 16px; flex: none; position: relative; border: 1.6px solid currentColor; border-radius: 4px; }
.nav-icon.home::after { content: ""; position: absolute; width: 4px; height: 5px; left: 4.5px; bottom: 0; background: currentColor; }
.nav-icon.diary { border-radius: 2px 5px 5px 2px; }
.nav-icon.diary::after { content: ""; position: absolute; width: 6px; height: 2px; top: 4px; left: 3px; background: currentColor; }
.nav-icon.training { border: 0; background: currentColor; clip-path: polygon(56% 0, 13% 58%, 44% 58%, 34% 100%, 87% 39%, 55% 39%); }
.nav-icon.trends { border: 0; background: currentColor; clip-path: polygon(0 70%, 22% 70%, 22% 100%, 0 100%, 0 70%, 40% 70%, 40% 43%, 62% 43%, 62% 100%, 40% 100%, 40% 70%, 78% 70%, 78% 10%, 100% 10%, 100% 100%, 78% 100%, 78% 70%); }
.screen { min-width: 0; min-height: calc(100dvh - 67px); padding: 28px var(--space) 46px; outline: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 3px 0 23px; }
.page-heading p { color: var(--muted); font-weight: 540; margin-top: 8px; }
.notice { padding: 6px 12px; background: var(--notice); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; color: var(--muted); font-size: .9rem; }
.card { border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-header small { display: block; margin-top: 1px; }
.overview { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 13px; }
.energy { min-width: 0; padding: 16px 21px 18px; background: var(--accent-surface); border-color: transparent; }
.energy h2 { color: var(--accent); }
.energy-number { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 14px; margin: 7px 0 14px; }
.energy-number strong { font-weight: 780; font-size: clamp(2.8rem, 6vw, 4.25rem); letter-spacing: -.075em; line-height: 1; }
.energy-number span { color: var(--muted); font-weight: 560; }
.energy-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 12px; margin-top: 11px; color: var(--muted); font-size: .88rem; }
.energy-footer .text-button { min-height: 32px; }
progress { display: block; width: 100%; height: 8px; background: var(--track); border: 0; border-radius: 999px; appearance: none; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.energy progress, .energy progress::-webkit-progress-bar { background: color-mix(in srgb, var(--accent) 20%, var(--accent-surface)); }
.macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-top: 13px; }
.macro { padding: 15px 16px; }
.macro h2, .metrics h2 { color: var(--muted); font-size: .93rem; font-weight: 610; }
.macro-line { display: flex; align-items: baseline; gap: 6px 9px; flex-wrap: wrap; margin: 8px 0 10px; }
.macro-line strong, .metrics strong { font-size: 1.56rem; font-weight: 740; letter-spacing: -.045em; }
.macro-line > span { color: var(--muted); font-size: .86rem; }
.macro-line > small { color: var(--accent); margin-left: auto; }
.coverage { display: block; color: var(--muted); font-weight: 450; font-size: .82rem; margin-top: 5px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 15px; padding: 16px 20px; margin-top: 13px; }
.metrics small { display: block; }
.workout-preview, .list, .settings-card { padding: 10px 18px 15px; }
.workout-preview .quiet { margin: 8px 0 4px; }
.row-button { border: 0; background: transparent; color: var(--ink); display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 11px 0; min-height: 52px; text-align: left; width: 100%; }
.row-button + .row-button, .search-row + .search-row { border-top: 1px solid var(--line); }
.row-button > span:first-child { flex: 1; min-width: 0; }
.row-button strong { display: block; overflow-wrap: anywhere; }
.row-button small { display: block; margin-top: 3px; }
.row-button .row-value { flex: none; text-align: right; color: var(--accent); font-weight: 650; }
.text-button { padding: 0; color: var(--accent); border: 0; background: transparent; font-weight: 650; font-size: .89rem; min-height: 44px; text-align: left; }
.text-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.section-heading h2 { font-size: 1.23rem; }
.meal-card { padding: 9px 18px; margin-bottom: 10px; }
.meal-card .card-header > div:first-child { padding: 7px 0; }
.toolbar { margin-bottom: 12px; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); background: var(--notice); padding: 22px; }
.empty > strong { display: block; font-size: 1.06rem; }
.empty > p { color: var(--muted); margin-top: 4px; }
.empty > .button { margin-top: 15px; }
.list .quiet { margin: 8px 0; }
.settings-card { padding: 19px; margin-bottom: 14px; }
.settings-card p { margin: 8px 0 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 13px; margin-bottom: 14px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 5px; margin: 0 0 10px; }
.field span { font-size: .88rem; font-weight: 650; }
.field input, .field select {
  background: var(--paper); color: var(--ink); min-height: 45px; min-width: 0; width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 16px;
}
.field input[type="file"] { padding: 7px; }
.field input::placeholder { color: var(--muted); opacity: .86; }
.settings-card form { margin-top: 14px; }
.actions-wrap, .sheet-actions, .search-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.segmented { display: inline-flex; gap: 4px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 3px; }
.segmented button { border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 6px 14px; min-height: 44px; font-weight: 620; }
.segmented button[aria-pressed="true"] { color: var(--accent); background: var(--accent-surface); }
.trend-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 11px; }
.trend-row > span:last-child { text-align: end; }
dialog { width: min(580px, calc(100% - 28px)); max-height: min(88dvh, 840px); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); overflow: auto; }
dialog::backdrop { background: #0d201b80; }
.sheet-top { display: flex; position: sticky; top: 0; z-index: 1; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.sheet-top h2 { font-size: 1.36rem; overflow-wrap: anywhere; }
.sheet-body { padding: 16px 20px 24px; }
.sheet-body p { margin: 0 0 12px; }
.sheet-body h3 { margin: 14px 0 7px; }
.template-items { list-style: none; padding: 0; margin: 10px 0; }
.template-items li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.template-items span { min-width: 0; overflow-wrap: anywhere; }
.template-items strong { flex: none; }
.sheet-actions { margin-top: 16px; }
.search-actions { margin: 0 0 13px; }
.search-actions button { padding-inline: 10px; font-size: .92rem; }
.search-row { display: flex; align-items: center; gap: 10px; }
.search-row > .row-button { flex: 1; }
.star { flex: none; border: 0; border-radius: 9px; background: var(--accent-surface); color: var(--accent); width: 44px; height: 44px; font-size: 1.27rem; }
.selected-food { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.selected-food strong, .selected-food small { display: block; overflow-wrap: anywhere; }
.intake-preview, .detail-facts { background: var(--notice); border-radius: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 11px; margin: 12px 0; }
.detail-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.intake-preview span, .detail-facts span { color: var(--muted); font-size: .84rem; }
.intake-preview strong, .detail-facts strong, .detail-facts small { display: block; }
.inline-detail, .phase { padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; margin: 11px 0; }
.inline-detail summary { cursor: pointer; font-weight: 650; padding: 4px 0; }
.inline-detail .form-grid { margin: 9px 0 0; }
.phase legend { color: var(--muted); font-weight: 650; padding: 0 5px; }
.phase .form-grid { margin: 0; }
.fuel-table { display: grid; gap: 0; margin-bottom: 12px; }
.fuel-head, .fuel-row { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr)); gap: 0 9px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.fuel-head { color: var(--muted); font-size: .85rem; font-weight: 650; }
.fuel-row small { display: block; }
.form-error { color: var(--danger); margin: 12px 0 0 !important; font-weight: 650; }
.toast { pointer-events: none; opacity: 0; position: fixed; z-index: 3; bottom: 26px; right: var(--space); max-width: min(380px, 90vw); padding: 10px 14px; color: var(--on-accent); background: var(--accent); box-shadow: var(--shadow); border-radius: 13px; }
.toast.visible { opacity: 1; }
.update { position: fixed; z-index: 3; inset: auto auto 20px 20px; background: var(--paper); color: var(--ink); padding: 6px 10px; border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; gap: 8px; }

@media (max-width: 820px) {
  .top-inner { flex-wrap: wrap; gap: 0 10px; }
  .top-date { order: 3; flex-basis: 100%; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
  .date-controls { justify-content: space-between; }
  .date-picker { flex: 1; }
  .date-step { min-height: 42px; }
  .shell { display: block; }
  .screen { min-height: auto; padding-top: 20px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .navigation {
    position: fixed; z-index: 2; inset: auto 0 0; border: 0; border-top: 1px solid var(--line);
    padding: 5px max(var(--space), env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(var(--space), env(safe-area-inset-right));
    background: var(--paper); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px;
  }
  .nav-link { min-height: 50px; flex-direction: column; gap: 3px; justify-content: center; padding: 6px 3px; font-size: .83rem; }
  .toast, .update { bottom: calc(77px + env(safe-area-inset-bottom)); }
}
@media (max-width: 575px) {
  .top-inner { padding-inline: 15px; }
  .top-date { padding-top: 5px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
  .overview { display: contents; }
  .screen:has(.overview) { display: flex; flex-direction: column; }
  .energy { order: 0; padding-inline: 17px; }
  .macros { order: 1; gap: 0; margin-top: 11px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: block; }
  .macro { border: 0; border-radius: 0; padding: 9px 15px 8px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(148px, auto); align-items: baseline; gap: 2px 8px; }
  .macro + .macro { border-top: 1px solid var(--line); }
  .macro-line { min-width: 0; margin: 0; gap: 3px 9px; }
  .macro-line strong { font-size: 1.24rem; }
  .macro-line > span { font-size: .77rem; }
  .macro-line > small { margin: 0; }
  .macro progress, .macro .coverage { grid-column: 1 / -1; }
  .macro progress { height: 4px; }
  .metrics { order: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 16px; }
  .metrics strong { font-size: 1.3rem; }
  .workout-preview { order: 3; margin-top: 12px; padding-inline: 15px; }
  .section-heading, .screen:has(.overview) .meal-card, .screen:has(.overview) .empty { order: 4; }
  .trend-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-card, .meal-card, .list { padding-inline: 14px; }
  dialog { position: fixed; inset: auto 0 0; max-width: 100%; width: 100%; margin: 0; border-radius: 23px 23px 0 0; max-height: min(86vh, 86dvh); }
  .sheet-body { padding-inline: 15px; padding-bottom: calc(19px + env(safe-area-inset-bottom)); }
  .sheet-top { padding-inline: 15px; }
}
@media (max-width: 350px) {
  .form-grid, .detail-facts { grid-template-columns: 1fr; }
  .macro-line { gap: 4px; }
  .macro h2 { font-size: .83rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
