:root,html[data-theme="light"]{
  color-scheme:light;
  --page:#fafbfe;
  --surface:#ffffff;
  --surface-soft:#f5f2fb;
  --ink:#252137;
  --muted:#696276;
  --line:#e6e1ef;
  --purple:#6b50e7;
  --soft:#f0edfc;
  --green:#237d59;
  --orange:#9a6326;
  --shadow:0 20px 50px #3c275724;
  --on-purple:#ffffff;
}
html[data-theme="dark"]{
  color-scheme:dark;
  --page:#121018;
  --surface:#1f1a2b;
  --surface-soft:#292235;
  --ink:#f4f1fc;
  --muted:#bcb3cb;
  --line:#41364f;
  --purple:#ad97ff;
  --soft:#302646;
  --green:#7bd5aa;
  --orange:#edbc7b;
  --shadow:0 22px 60px #00000066;
  --on-purple:#20142f;
}
@media(prefers-color-scheme:dark){
  html:not([data-theme]){
    color-scheme:dark;
    --page:#121018;--surface:#1f1a2b;--surface-soft:#292235;
    --ink:#f4f1fc;--muted:#bcb3cb;--line:#41364f;
    --purple:#ad97ff;--soft:#302646;--green:#7bd5aa;--orange:#edbc7b;
    --shadow:0 22px 60px #00000066;--on-purple:#20142f;
  }
}
html{background:var(--page);color:var(--ink)}
body{background:var(--page);color:var(--ink)}

.theme-picker{position:relative;flex-shrink:0}
.theme-picker>summary{display:flex;align-items:center;justify-content:center;gap:8px;min-width:44px;min-height:44px;padding:10px;border:1px solid var(--line);border-radius:11px;color:var(--ink);background:var(--surface);cursor:pointer;list-style:none;font-size:14px;line-height:1.4}
.theme-picker>summary::-webkit-details-marker{display:none}
.theme-picker>summary::before{content:"";display:block;width:19px;height:19px;flex-shrink:0;background:currentColor;mask:center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='13' rx='2'/%3E%3Cpath d='M8 21h8m-4-4v4'/%3E%3C/svg%3E")}
html[data-theme-preference="light"] .theme-picker>summary::before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2m0 16v2M2 12h2m16 0h2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41'/%3E%3C/svg%3E")}
html[data-theme-preference="dark"] .theme-picker>summary::before{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.9 13A9 9 0 0 1 11 3.1 9 9 0 1 0 20.9 13Z'/%3E%3C/svg%3E")}
.theme-options{position:absolute;inset-inline-end:0;top:calc(100% + 8px);z-index:30;min-width:190px;max-width:min(300px,85vw);padding:7px;display:grid;gap:3px;border:1px solid var(--line);border-radius:14px;background:var(--surface);box-shadow:var(--shadow)}
.theme-options button{display:flex;align-items:center;gap:12px;min-height:44px;padding:10px 12px;border:0;border-radius:8px;text-align:start;font:inherit;font-size:14px;line-height:1.5;color:var(--ink);background:transparent;cursor:pointer}
.theme-options button::after{content:"";margin-inline-start:auto;flex-shrink:0;width:8px;height:8px;border-radius:50%;border:1.5px solid var(--muted)}
.theme-options button[aria-pressed="true"]{background:var(--soft);color:var(--purple);font-weight:700}
.theme-options button[aria-pressed="true"]::after{background:var(--purple);border-color:var(--purple)}
.theme-options button:hover{background:var(--surface-soft)}
.theme-picker summary:focus-visible,.theme-options button:focus-visible{outline:3px solid var(--purple);outline-offset:3px}

/* Preserve readable palettes in the existing photo-result and phone illustrations. */
html[data-theme="dark"] .button:not(.button-quiet){color:var(--on-purple)}
html[data-theme="dark"] .button:not(.button-quiet):hover{background:color-mix(in srgb,var(--purple) 88%,white)}
html[data-theme="dark"] :is(.button-quiet,.language-list,.floating-tag,.nutrition-card,.phone,.consent,.portion-input input){background:var(--surface);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] :is(.nav-link,.intro,.trial-note,.fine,.hero-platforms,.hero-platforms a,.nutrition-heading,.macro-label,.unit,.estimate,.footer-links,.app-copy>p:not(.eyebrow),.diary-tile small,.phone-ring small){color:var(--muted)}
html[data-theme="dark"] .small-ring::after,html[data-theme="dark"] .phone-ring>div{background:var(--surface)}
html[data-theme="dark"] .macro{background:color-mix(in srgb,var(--purple) 10%,var(--surface));border-color:var(--purple)}
html[data-theme="dark"] .macro.c{background:color-mix(in srgb,var(--orange) 10%,var(--surface));border-color:var(--orange)}
html[data-theme="dark"] .macro.f{background:color-mix(in srgb,var(--green) 10%,var(--surface));border-color:var(--green)}
html[data-theme="dark"] .check-icon{background:color-mix(in srgb,var(--green) 15%,var(--surface));color:var(--green)}
html[data-theme="dark"] .app-section{background:var(--soft)}
html[data-theme="dark"] :is(.app-orbit,.diary-tile){border-color:var(--line)}
html[data-theme="dark"] .status.error{color:#f3a5b2}
html[data-theme="dark"] .stage-ring{background:radial-gradient(ellipse at 60% 45%,#4a2d6c66,transparent 72%)}
@media(prefers-reduced-motion:reduce){.theme-picker *{scroll-behavior:auto;transition:none}}
