:root {
  color-scheme: light;
  --bg: #fff; --text: #161616; --muted: #707070; --line: #e6e6e6; --soft: #f5f5f5; --partial: #999;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
:root[data-theme=dark] { color-scheme: dark; --bg: #111; --text: #f5f5f5; --muted: #aaa; --line: #303030; --soft: #1c1c1c; --partial: #777; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button, a, input, summary { touch-action: manipulation; }
button, summary { cursor: pointer; }
button { border: 0; }
a { color: inherit; text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }
button:disabled, input:disabled, [aria-disabled=true] { cursor: default; opacity: .55; }
a[aria-disabled=true] { pointer-events: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 29px; line-height: 1.2; font-weight: 600; letter-spacing: -1px; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 500; }
.muted { color: var(--muted); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.shell { max-width: 660px; margin: auto; padding: calc(22px + var(--safe-top) + var(--tg-content-safe-area-inset-top, 0px)) max(24px, var(--tg-safe-area-inset-right, 0px)) calc(96px + var(--safe-bottom)) max(24px, var(--tg-safe-area-inset-left, 0px)); }
.app-header { display: flex; align-items: center; min-height: 32px; margin-bottom: 24px; }
.brand { font-size: 19px; font-weight: 650; letter-spacing: -.6px; text-decoration: none; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0; }
.page-heading .muted { margin-top: 5px; }
.date-control { flex-shrink: 0; }
.date-control input { max-width: 144px; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); padding: 8px; font-size: 12px; }
.nutrition-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 4px 0 28px; }
.metric + .metric { border-left: 1px solid var(--line); padding-left: 24px; }
.metric h2 { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 7px; }
.large-number { font-size: clamp(30px, 5.5vw, 40px); font-weight: 600; letter-spacing: -1.3px; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; }
.unit { font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.metric .muted, .metric-note { font-size: 12px; color: var(--muted); }
.metric .muted { margin-top: 4px; }
.meter { height: 3px; background: var(--line); overflow: hidden; margin-top: 16px; }
.meter span { display: block; height: 100%; width: 0; background: var(--text); }
.metric-note { margin-top: 9px; }
.section { border-top: 1px solid var(--line); padding: 24px 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-heading .muted { font-size: 12px; }
.meal-list { margin: 6px 0 0; padding: 0; list-style: none; }
.meal-item { display: flex; align-items: center; gap: 16px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.meal-item:last-child { border-bottom: 0; }
.meal-info { flex: 1; min-width: 0; }
.meal-name { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.meal-time { font-size: 12px; color: var(--muted); margin-top: 3px; }
.meal-nutrition { font-size: 13px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.meal-nutrition strong { font-weight: 500; }
.meal-nutrition small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px; border: 1px solid var(--text); border-radius: 6px; background: var(--text); color: var(--bg); padding: 11px 15px; text-align: center; text-decoration: none; font-size: 14px; font-weight: 500; }
.button:hover:not(:disabled):not([aria-disabled=true]) { opacity: .85; }
.secondary { color: var(--text); background: transparent; border-color: var(--line); }
.chat-link { margin-top: 14px; }
.text-button { color: var(--muted); font-size: 13px; background: transparent; min-height: 44px; padding: 10px 0 10px 12px; }
.text-link { display: inline-flex; gap: 12px; align-items: center; min-height: 44px; margin-top: 12px; font-size: 13px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; position: relative; gap: 18px; border-top: 1px solid var(--line); padding: 18px 0; min-height: 72px; font-size: 14px; cursor: pointer; }
.switch-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.switch-row input { position: absolute; right: 0; width: 44px; height: 44px; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { width: 40px; height: 24px; padding: 3px; border-radius: 20px; flex-shrink: 0; background: var(--line); }
.switch-track:before { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--bg); }
.switch-row input:checked + .switch-track { background: var(--text); }
.switch-row input:checked + .switch-track:before { transform: translateX(16px); }
.switch-row input:focus-visible + .switch-track { outline: 2px solid var(--text); outline-offset: 4px; }
.switch-row input:disabled + .switch-track { opacity: .55; }
.weekly-section { border-top: 0; padding-top: 0; }
.weekly-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 22px; }
.weekly-summary strong { font-size: 28px; font-weight: 600; letter-spacing: -.8px; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 12px; color: var(--muted); }
.weekly-summary p { margin-top: 3px; }
.chart-note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.week-chart { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; margin-top: 24px; height: 164px; }
.day-column { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.day-bar-area { height: 132px; display: flex; align-items: flex-end; justify-content: center; width: 100%; position: relative; border-bottom: 1px solid var(--line); }
.day-bar { width: 50%; max-width: 32px; background: var(--text); height: var(--bar); min-height: 3px; }
.day-bar.partial, .legend-partial { background: repeating-linear-gradient(135deg, var(--partial) 0 2px, var(--bg) 2px 4px); }
.day-bar.unknown { height: 12px; background: transparent; border: 1px dashed var(--muted); }
.day-bar.zero { height: 3px; }
.day-value { position: absolute; bottom: calc(var(--bar) + 7px); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-label { font-size: 11px; color: var(--muted); }
.day-column.selected .day-label { color: var(--text); font-weight: 600; }
.chart-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; font-size: 11px; color: var(--muted); margin-top: 12px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; }
.legend-complete { background: var(--text); }
.legend-unknown { border: 1px dashed var(--muted); }
.disclosure { padding: 0; }
.disclosure > summary { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 12px; padding: 18px 0; list-style: none; font-size: 15px; font-weight: 500; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:after { content: "+"; color: var(--muted); font-size: 20px; font-weight: 400; }
.disclosure[open] > summary:after { content: "−"; }
.disclosure-content { padding: 0 0 24px; }
.body-metrics { margin: 0; }
.body-metrics > div { display: flex; justify-content: space-between; gap: 20px; padding: 11px 0; font-size: 13px; }
.body-metrics dt { color: var(--muted); }
.body-metrics dd { margin: 0; font-weight: 500; text-align: right; }
.medium-number { font-size: 28px; font-weight: 600; letter-spacing: -.7px; }
.weight-summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.weight-summary .muted { font-size: 12px; text-align: right; }
.weight-chart-wrap { height: 130px; padding: 18px 8px 9px; margin-top: 9px; }
.weight-chart { position: relative; height: 100%; width: 100%; border-bottom: 1px solid var(--line); }
.weight-point { position: absolute; left: var(--x); bottom: var(--y); width: 5px; height: 5px; transform: translate(-50%, 50%); border-radius: 50%; background: var(--text); }
.weight-segment { position: absolute; height: 1.5px; background: var(--text); transform-origin: 0 50%; }
.weight-dates { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; }
.weight-details { margin-top: 12px; font-size: 12px; color: var(--muted); }
.weight-details summary { padding: 12px 0; min-height: 44px; }
.weight-details ul { margin: 0; padding-left: 18px; font-variant-numeric: tabular-nums; }
.weight-details li { padding: 4px 0; }
.membership-section { border-top: 0; padding-top: 0; }
.membership-section > .muted { margin-top: 8px; }
.membership-section > .chart-note { margin-top: 5px; }
.usage-row { margin-top: 24px; }
.membership-section .meter { margin-top: 10px; }
.price { font-size: 25px; font-weight: 600; letter-spacing: -.5px; margin-bottom: 8px; }
.terms-row { display: flex; align-items: flex-start; gap: 12px; margin: 20px 0; font-size: 13px; cursor: pointer; }
.terms-row input { width: 20px; height: 20px; flex-shrink: 0; margin: 1px 0 0; accent-color: var(--text); }
#manage-subscription .muted { margin: 8px 0 20px; }
.privacy-note { margin-top: 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.account-links { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.account-links a { display: inline-flex; align-items: center; min-height: 44px; }
.tab-nav { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: var(--bg); border-top: 1px solid var(--line); padding: 0 12px calc(var(--safe-bottom) + var(--tg-content-safe-area-inset-bottom, 0px)); }
.tab-button { flex: 1; max-width: 204px; min-height: 62px; padding: 16px 8px; border-top: 2px solid transparent; color: var(--muted); background: transparent; font-size: 13px; }
.tab-button[aria-selected=true] { color: var(--text); border-top-color: var(--text); font-weight: 600; }
.tab-panel:focus { outline: none; }
.demo-banner { padding: 9px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.notice { padding: 12px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); font-size: 13px; overflow-wrap: anywhere; }
.notice[data-error=true] { border-left: 3px solid var(--text); }
.state-card { padding: 50px 16px; margin: 25px auto; text-align: center; }
.state-card h1 { font-size: 24px; }
.state-card p { color: var(--muted); font-size: 14px; margin-top: 14px; }
.state-card .button { width: auto; margin: 24px auto 0; min-width: 130px; }
.loading-mark { display: block; width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; margin: 0 auto 24px; animation: spin 1s linear infinite; }
.empty-state { padding: 28px 0; color: var(--muted); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 380px) {
  .shell { padding-left: max(18px, var(--tg-safe-area-inset-left, 0px)); padding-right: max(18px, var(--tg-safe-area-inset-right, 0px)); }
  .nutrition-grid { gap: 16px; }
  .metric + .metric { padding-left: 16px; }
  .large-number { font-size: 28px; }
  .date-control input { max-width: 132px; }
  .meal-nutrition { font-size: 12px; }
  .meal-nutrition small { font-size: 11px; }
  .week-chart { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *:before, *:after { animation: none !important; transition: none !important; } }
