:root {
  color-scheme: light;
  --ink: #172440;
  --mid: #3c4e6e;
  --muted: #536582;
  --paper: #fff;
  --back: #f4f7fd;
  --line: #dce5f2;
  --blue: #254fd2;
  --deep-blue: #17358b;
  --blue-soft: #eaf0ff;
  --green: #136752;
  --green-soft: #e2f5ed;
  --violet: #6847bb;
  --violet-soft: #f0eaff;
  --radius: 18px;
  font-family: Poppins, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--back);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p, figure { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
a, button { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .56; cursor: wait; }
:focus-visible { outline: 3px solid #4c70f5; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: fixed; top: 10px; left: 10px; transform: translateY(-160%); z-index: 9; background: white; padding: 14px; }
.skip:focus { transform: none; }
[data-icon] { display: inline-grid; place-items: center; flex: none; width: 21px; height: 21px; }
[data-icon] svg { width: 100%; height: 100%; }

.rail { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 234px; z-index: 3; padding: 27px 16px 20px; background: var(--paper); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 500; letter-spacing: -.04em; white-space: nowrap; }
.brand b { font-weight: 700; }
.brand-icon { width: 36px; height: 36px; padding: 7px; border-radius: 11px; background: var(--blue); color: white; }
.nav { margin-top: 42px; display: grid; gap: 7px; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 47px; padding: 0 13px; border-radius: 10px; color: var(--mid); font-weight: 600; font-size: .91rem; }
.nav a:hover, .nav a[aria-current] { color: var(--deep-blue); background: var(--blue-soft); }
.rail-profile { margin-top: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--back); text-align: left; min-height: 60px; width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px; color: var(--ink); }
.rail-profile > span:nth-child(2) { min-width: 0; flex: 1; }
.rail-profile strong, .rail-profile small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rail-profile strong { font-size: .82rem; }
.rail-profile small { font-size: .75rem; color: var(--muted); }
.rail-profile > [data-icon] { width: 15px; }
.avatar { display: grid; place-items: center; flex: none; border-radius: 10px; width: 34px; height: 34px; background: #dce7ff; color: var(--deep-blue); font-size: .8rem; font-weight: 700; }
main { margin-left: 234px; max-width: 1620px; min-height: 100vh; padding: 18px clamp(18px, 3.4vw, 52px) 44px; }
.top { min-height: 48px; margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top > p { font-size: .85rem; font-weight: 600; color: var(--mid); }
.mobile-brand { display: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 7px 13px; border: 1px solid transparent; border-radius: 10px; font-size: .86rem; font-weight: 600; line-height: 1.25; }
.button [data-icon], .icon-button [data-icon], .text-link [data-icon] { width: 17px; height: 17px; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: var(--deep-blue); }
.outline { color: var(--ink); border-color: #cdd9ed; background: white; }
.outline:hover, .icon-button:hover { color: var(--deep-blue); border-color: #a6b9e9; background: #f0f4ff; }
.text-link { display: inline-flex; align-items: center; min-height: 42px; padding: 0; border: 0; background: transparent; color: #234ab9; font-size: .86rem; font-weight: 600; }
.text-link:hover { text-decoration: underline; }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--mid); }
.danger { color: #a32144; }
.hero { display: flex; position: relative; min-height: 257px; overflow: hidden; align-items: center; isolation: isolate; border-radius: 21px; padding: 33px 35px; background: radial-gradient(ellipse at 85% 80%, #4d68e0, transparent 64%), linear-gradient(110deg, #172b73, #253db3); color: white; }
.hero-content { position: relative; z-index: 1; }
.hero-date { font-size: .85rem; color: #dce7ff; margin-bottom: 7px; font-weight: 500; }
.hero h1, .page-heading h1 { font-size: clamp(2rem, 4.2vw, 3.45rem); letter-spacing: -.062em; line-height: 1.12; font-weight: 700; }
.hero h1 { word-break: break-word; }
.hero-content > p:not(.hero-date) { max-width: 37ch; margin-top: 8px; font-size: .98rem; color: #e7edff; line-height: 1.52; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 19px; }
.hero .primary { background: white; color: var(--deep-blue); }
.hero .primary:hover { background: #eaf0ff; }
.hero-secondary { border-color: #aabbf5; color: white; background: #ffffff12; }
.hero-secondary:hover { background: #ffffff27; }
.hero-art { position: absolute; right: 2%; top: 50%; width: min(37%, 325px); aspect-ratio: 1; transform: translateY(-50%); display: grid; place-items: center; color: #d8e4ff; }
.orbit { position: absolute; border: 1px solid #b2c6ff50; border-radius: 50%; }
.orbit-one { inset: 28%; }
.orbit-two { inset: 15%; }
.orbit-three { inset: 1%; }
.orbit-centre { display: grid; place-items: center; width: 32%; aspect-ratio: 1; background: #a2b8ff1c; border: 1px solid #c4d1ff45; border-radius: 25%; transform: rotate(-10deg); }
.orbit-centre [data-icon] { width: 53%; height: 53%; }
.hero-art i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #d5e1ff; }
.hero-art i:nth-last-child(3) { left: 17%; top: 36%; }
.hero-art i:nth-last-child(2) { right: 15%; top: 42%; width: 5px; height: 5px; }
.hero-art i:last-child { right: 14%; bottom: 14%; }

.sample-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 11px; margin-top: 12px; border: 1px solid #d5dffa; border-radius: 12px; color: var(--mid); background: #eaf0ff; }
.sample-banner > span { display: flex; align-items: center; gap: 8px; }
.sample-banner [data-icon] { color: var(--blue); }
.sample-banner strong, .sample-banner small { display: block; }
.sample-banner strong { font-size: .84rem; color: var(--deep-blue); }
.sample-banner small { font-size: .76rem; }
.sample-banner .button { white-space: nowrap; }
.summary-cards, .nutrient-grid, .meal-grid, .routine-grid, .photo-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.summary-cards { margin: 15px 0; }
.stat-card, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 5px #17336708; }
.stat-card { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 14px; gap: 6px; }
.stat-card:hover { border-color: #9fb2ed; }
.stat-icon { width: 33px; height: 33px; border-radius: 9px; padding: 7px; }
.green { background: var(--green-soft); color: var(--green); }
.blue { background: var(--blue-soft); color: var(--deep-blue); }
.violet { background: var(--violet-soft); color: var(--violet); }
.stat-card > span:nth-child(2) { font-size: .85rem; color: var(--mid); font-weight: 600; }
.stat-card strong, .chart-summary strong { font-size: 1.72rem; line-height: 1.2; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.stat-card strong small, .chart-summary strong small, .nutrient strong small { font-size: .81rem; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.dashboard, .feature-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 13px; align-items: start; }
.stack { display: grid; gap: 13px; align-content: start; min-width: 0; }
.panel { padding: 17px; min-width: 0; }
.panel-head, .page-heading, .entry, .plan-tools, .utility-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.panel-head { margin-bottom: 9px; flex-wrap: wrap; }
.panel h2 { font-size: 1.12rem; line-height: 1.3; letter-spacing: -.035em; }
.help { font-size: .87rem; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.panel > .help { margin-top: 7px; }
.empty { padding: 13px; border-radius: 10px; background: #f2f5fc; color: var(--mid); font-size: .9rem; line-height: 1.55; }
.nutrient-grid { margin-top: 10px; gap: 8px; }
.nutrient { display: flex; flex-direction: column; min-width: 0; background: #f5f7fc; border-radius: 10px; padding: 10px; gap: 3px; }
.nutrient-label { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: .82rem; font-weight: 600; color: var(--mid); }
.nutrient-label [data-icon] { width: 16px; height: 16px; color: #2b60c4; }
.nutrient strong { font-size: 1.16rem; letter-spacing: -.035em; line-height: 1.25; word-break: break-word; }
.goal-value { color: var(--muted); font-size: .75rem; line-height: 1.35; }
.bar { display: block; height: 6px; border-radius: 9px; background: #dfe7fa; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; border-radius: 9px; background: #4366dc; }
.plain-list, .ingredients, .routine-moves { margin: 0; padding: 0; list-style: none; }
.entry { min-height: 55px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry-name { min-width: 0; overflow-wrap: anywhere; }
.entry-name strong { display: block; font-size: .93rem; font-weight: 600; }
.entry-name small, .routine-moves small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.row-actions { flex: none; display: flex; gap: 5px; }
.chart-summary { display: grid; gap: 1px; }
.chart-summary > span { font-size: .8rem; color: var(--muted); }
.trend { display: block; width: 100%; height: 143px; margin-top: 10px; }
.goal-card { padding: 7px 0 10px; }
.goal-card .bar { margin: 7px 0; }
.goals .goal-card + .goal-card { border-top: 1px solid var(--line); margin-top: 8px; }
.pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 8px; font-size: .8rem; font-weight: 650; }

.page-heading { margin: 10px 0 16px; }
.page-heading h1 { font-size: clamp(2rem, 3.5vw, 2.85rem); }
.page-heading p { color: var(--muted); font-size: .92rem; line-height: 1.55; margin-top: 5px; }
.subnav { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid #d4deef; margin-bottom: 15px; }
.subnav a { min-height: 45px; display: flex; align-items: center; padding: 0 12px; border-bottom: 2px solid transparent; font-size: .88rem; font-weight: 600; white-space: nowrap; color: var(--mid); }
.subnav a:hover, .subnav a[aria-current] { color: var(--deep-blue); }
.subnav a[aria-current] { border-color: var(--blue); }
.actions { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-top: 11px; }
.actions.inline { margin-top: 0; }
.date-picker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.date-control { display: flex; align-items: center; padding: 0 7px; gap: 4px; border: 1px solid #cdd9ed; border-radius: 9px; background: white; }
.date-control [data-icon] { width: 15px; height: 15px; color: var(--deep-blue); }
.date-control input { min-width: 114px; max-width: 145px; padding: 5px; border: 0; font-size: .88rem; }
.date-picker .text-link { padding: 0 5px; }
.rotation { display: grid; grid-template-columns: repeat(14, minmax(32px, 1fr)); gap: 4px; margin-top: 9px; }
.rotation button, .segmented button { min-height: 44px; border-radius: 8px; border: 1px solid #dbe5f5; background: #f2f5fd; color: var(--mid); font-size: .84rem; font-weight: 600; }
.rotation button[aria-pressed="true"], .segmented button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: white; }
.segmented { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.segmented button { padding: 5px 9px; }
.meal, .routine-session { display: flex; flex-direction: column; align-items: flex-start; }
.meal-slot { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; font-size: .85rem; font-weight: 600; color: var(--mid); }
.meal .ingredients, .routine-moves { width: 100%; }
.ingredients li { display: flex; justify-content: space-between; gap: 7px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .84rem; color: var(--mid); }
.ingredients strong { flex: none; white-space: nowrap; color: var(--ink); font-size: .81rem; }
.meal .ingredients { margin: 7px 0; }
.meal .method { margin: 0 0 11px; }
.meal .button, .meal .pill { margin-top: auto; }
.plan-totals { display: flex; flex-wrap: wrap; gap: 7px; }
.plan-totals > span { padding: 5px 8px; border-radius: 7px; background: #eef3fc; font-size: .83rem; color: var(--mid); }
.plan-totals small { font-size: .74rem; color: var(--muted); }
.log-group { margin-top: 14px; }
.log-group h3, dialog h3 { font-size: .96rem; }
.sets-detail { color: var(--mid); font-size: .82rem; margin-top: 6px; }
.sets-detail summary, .option-details summary { cursor: pointer; font-weight: 600; color: #234ab9; }
.sets-detail ol, .archive-list { margin: 5px 0; padding-left: 24px; }
.sets-detail li + li, .archive-list li + li { margin-top: 5px; }
.routine-moves { margin: 7px 0 11px; }
.routine-moves li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.routine-session .actions { margin-top: auto; }
.provider-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 10px; margin-bottom: 7px; font-weight: 700; color: white; }
.provider-mark.strava { background: #c83a0a; }
.provider-mark.garmin { background: #2c4d81; }
.provider-mark.zwift { background: #d1421e; }
.photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.photo { padding: 9px; }
.photo-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 11px; overflow: hidden; background: #e5eafb; }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.photo figcaption { padding: 5px; }
.photo-large, .image-preview { display: block; width: 100%; max-height: 54vh; object-fit: contain; }
.compare-images { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare-images img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: contain; background: #edf1fb; border-radius: 8px; }
.compare-images figcaption { font-size: .81rem; color: var(--muted); margin-top: 4px; }

dialog { width: min(560px, calc(100vw - 20px)); max-height: min(88dvh, 740px); padding: 0; border: 1px solid var(--line); border-radius: 19px; color: var(--ink); background: white; box-shadow: 0 18px 80px #13213c47; }
dialog::backdrop { background: #0d1d4080; }
dialog header, dialog footer { position: sticky; z-index: 1; display: flex; align-items: center; gap: 9px; background: white; padding: 10px 16px; }
dialog header { justify-content: space-between; top: 0; border-bottom: 1px solid var(--line); }
dialog h2 { font-size: 1.2rem; letter-spacing: -.038em; }
dialog footer { justify-content: flex-end; bottom: 0; border-top: 1px solid var(--line); }
#fields { display: grid; gap: 12px; padding: 15px 16px; }
#fields .actions { margin-top: 0; }
#fields h3 { margin-top: 5px; }
.field { display: grid; gap: 4px; min-width: 0; align-content: start; font-size: .88rem; font-weight: 600; }
input:not([type="checkbox"]), select { display: block; min-width: 0; min-height: 44px; max-width: 100%; border: 1px solid #bfcde5; border-radius: 9px; background-color: white; color: var(--ink); padding: 7px 9px; }
.field input, .field select { width: 100%; font-size: 1rem; }
.date-control input { border: 0; font-size: .93rem; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%233c4e6e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 43px; color: var(--mid); font-size: .9rem; }
.check input { accent-color: var(--blue); width: 19px; height: 19px; flex: none; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.set-edit { position: relative; display: grid; gap: 8px; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 9px; }
.set-edit + .set-edit { margin-top: 11px; }
.set-edit legend { color: var(--mid); font-size: .85rem; font-weight: 600; padding: 0 4px; }
.set-remove { position: absolute; top: -10px; right: 6px; width: 31px; height: 31px; }
.alert { background: #fcecf0; border: 1px solid #edb3c3; border-radius: 9px; padding: 9px; margin: 0 0 11px; color: #8c2042; font-size: .85rem; }
#form-error { margin: 0 16px 8px; }
.toast { position: fixed; right: 13px; bottom: 13px; z-index: 5; max-width: min(420px, calc(100vw - 26px)); background: var(--ink); color: white; padding: 10px 13px; border-radius: 10px; box-shadow: 0 4px 24px #12234125; font-size: .87rem; }
.toast:empty { display: none; }

@media (max-width: 1120px) {
  .rail { width: 197px; padding-inline: 12px; }
  main { margin-left: 197px; }
  .meal-grid, .routine-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rotation { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .rail { inset: auto 0 0; width: 100%; padding: 2px 8px env(safe-area-inset-bottom); border: 0; border-top: 1px solid var(--line); }
  .rail .brand, .rail-profile, .top > p { display: none; }
  .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0; gap: 3px; }
  .nav a { justify-content: center; flex-direction: column; gap: 1px; min-height: 53px; padding: 4px 1px; font-size: .73rem; }
  .nav a [data-icon] { width: 20px; height: 20px; }
  main { margin-left: 0; padding: 10px 13px calc(76px + env(safe-area-inset-bottom)); }
  .top { min-height: 43px; margin-bottom: 11px; }
  .mobile-brand { display: flex; }
  .top .brand-icon { width: 33px; height: 33px; }
  .toast { bottom: calc(65px + env(safe-area-inset-bottom)); }
  .hero { min-height: 210px; padding: 21px; }
  .hero-art { right: 0; width: 37%; opacity: .75; }
}
@media (max-width: 570px) {
  .hero { min-height: 191px; padding: 17px; }
  .hero h1 { font-size: clamp(1.8rem, 7vw, 2.35rem); }
  .hero-content > p:not(.hero-date) { font-size: .89rem; max-width: 30ch; }
  .hero-art { right: -5%; width: 46%; opacity: .57; }
  .hero-actions { margin-top: 13px; }
  .summary-cards { gap: 6px; margin-block: 11px; }
  .stat-card { padding: 9px 7px; gap: 4px; }
  .stat-card > span:nth-child(2) { font-size: .77rem; line-height: 1.3; min-height: 2.45em; }
  .stat-card .stat-icon { width: 29px; height: 29px; padding: 6px; }
  .stat-card strong { font-size: 1.34rem; }
  .stat-card strong small { font-size: .73rem; }
  .dashboard, .feature-grid, .meal-grid, .routine-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 11px; }
  .panel h2 { font-size: 1rem; }
  .nutrient { padding: 7px; }
  .nutrient strong { font-size: 1.04rem; }
  .nutrient strong small { font-size: .76rem; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 8px; margin-bottom: 8px; }
  .page-heading p { font-size: .86rem; }
  .utility-row, .plan-tools { flex-wrap: wrap; gap: 1px 8px; }
  .subnav a { padding-inline: 9px; font-size: .84rem; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .photo { padding: 6px; }
  .photo figcaption { flex-wrap: wrap; }
  .checks { grid-template-columns: 1fr; }
  .row-actions .icon-button { width: 41px; }
}
@media (max-width: 350px) {
  .hero .button, .sample-banner .button { font-size: .78rem; padding-inline: 7px; }
  .date-picker .icon-button { width: 38px; }
  .nav a { font-size: .68rem; }
}
