/* Food scanner: isolated tokens keep camera, product and label screens consistent. */
dialog.food-scan{color:var(--ink);background:var(--surface-2);border:0;border-radius:30px;padding:0;width:min(100% - 32px,540px);max-width:540px;max-height:92dvh;box-shadow:0 32px 120px var(--shadow-3);overflow:auto;overscroll-behavior:contain;color-scheme:light}
dialog.food-scan::backdrop{background:var(--scrim);backdrop-filter:blur(7px)}
.food-scan *{box-sizing:border-box}.food-scan [hidden]{display:none!important}.food-scan button{font-family:inherit;cursor:pointer}.food-scan button:disabled{opacity:.55;cursor:default}.food-scan button:focus-visible,.food-scan input:focus-visible,.food-scan select:focus-visible{outline:3px solid var(--brand);outline-offset:3px}.food-scan h2:focus{outline:none}
.food-scan .scan-header{display:flex;align-items:center;justify-content:space-between;gap:16px;position:sticky;top:0;z-index:4;padding:14px 20px;background:var(--frost);border-bottom:1px solid var(--line);backdrop-filter:blur(12px);color:var(--ink);font-size:14px;font-weight:650}
.food-scan .scan-header button{display:grid;place-items:center;width:42px;height:42px;padding:0;border:1px solid var(--line);border-radius:50%;font-size:23px;line-height:1;background:transparent;color:var(--ink);box-shadow:none}
.food-scan .scan-content{padding:20px 24px 0}.food-scan h2{font-size:29px;line-height:1.13;letter-spacing:-1px;margin:8px 0 14px;color:var(--ink);font-weight:750}.food-scan h3{font-size:17px;margin:0;color:var(--ink)}.food-scan p{font-size:14px;line-height:1.55;color:var(--muted)}.food-scan svg{width:24px;height:24px;flex-shrink:0}.food-scan .scan-kicker{font-size:11px;letter-spacing:1.2px;text-transform:uppercase;font-weight:700;margin:0 0 10px;color:var(--brand)}
.food-scan .scan-hero{position:relative;isolation:isolate;background:radial-gradient(ellipse at 90% 0,var(--brand-deep),transparent 75%),var(--hero);border-radius:24px;padding:22px 24px 24px;color:var(--on-dark);margin-bottom:24px;overflow:hidden}.food-scan .scan-hero h2{color:var(--on-dark);font-size:31px;margin:12px 0}.food-scan .scan-hero p{color:var(--on-dark-soft);margin-bottom:22px;max-width:280px}.food-scan .scan-hero .scan-kicker{color:var(--lime);font-size:10px;margin:0}.scan-art{height:118px;position:relative;display:grid;place-items:center;margin-bottom:12px}.scan-pack{background:linear-gradient(155deg,var(--surface),var(--tint-2));border-radius:10px;width:79px;height:100px;transform:rotate(-10deg);display:flex;flex-direction:column;justify-content:space-evenly;align-items:center;box-shadow:12px 14px 30px var(--shadow-3);color:var(--ink)}.scan-pack span{font-size:14px;letter-spacing:-.6px;font-weight:800}.food-scan .scan-pack svg{width:49px;height:49px}.scan-art:before{content:'';position:absolute;width:156px;height:104px;border:1px solid var(--glass-2);border-radius:20px}.scan-art i{position:absolute;width:176px;height:2px;top:58px;background:var(--lime);box-shadow:0 0 20px var(--glass-2);animation:scan-sweep 3s ease-in-out infinite}
.food-scan .scan-primary,.food-scan .scan-secondary{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;min-height:54px;padding:14px 17px;border:0;border-radius:16px;background:var(--lime);color:var(--on-accent);font-size:15px;font-weight:750;box-shadow:none;line-height:1.3}.food-scan .scan-primary:hover{background:var(--lime)}.food-scan .scan-secondary{background:var(--tint)}.food-scan .scan-primary span{margin-left:auto;white-space:nowrap;font-size:13px}
.food-scan form{margin:0}.food-scan label{display:flex;flex-direction:column;gap:8px;margin:0 0 17px;color:var(--ink);font-size:13px;font-weight:600}.food-scan label>span{display:inline;font-size:11px;font-weight:400;color:var(--muted);margin-top:-5px}.food-scan input,.food-scan select{background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:13px 14px;min-height:49px;color:var(--ink);font-size:16px;font-family:inherit;width:100%;min-width:0;box-shadow:none}.food-scan select{padding-right:24px}.food-scan .scan-code-row{display:flex;gap:8px;margin-top:-8px;margin-bottom:24px}.scan-code-row button{flex:0 0 50px;border:0;border-radius:13px;background:var(--hero);color:var(--lime);font-size:24px}.scan-section-title{display:flex;justify-content:space-between;align-items:center;margin:28px 0 9px}.scan-section-title>span{font-size:11px;color:var(--muted)}.food-scan .scan-recent>button{display:flex;align-items:center;gap:13px;width:100%;text-align:left;background:transparent;border:0;border-bottom:1px solid var(--line);padding:13px 0;color:var(--ink);border-radius:0;box-shadow:none}.scan-recent>button>span:nth-child(2){display:flex;flex-direction:column;gap:4px;min-width:0;flex:1}.scan-recent strong{font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.scan-recent small{font-size:12px;color:var(--muted)}.scan-recent b{font-weight:400;font-size:20px}
.food-scan .scan-footnote{font-size:12px;line-height:1.6;color:var(--muted);margin:20px 0 24px}.food-scan a{color:var(--brand);text-underline-offset:3px}.food-scan .scan-error,.food-scan .scan-notice{background:var(--warn-bg);color:var(--warn);padding:14px 16px;border-radius:14px;font-size:13px;margin:15px 0 22px}.scan-loading{display:flex;flex-direction:column;align-items:center;text-align:center;padding:64px 10px 80px;gap:14px}.food-scan .scan-loading>svg{width:60px;height:60px;color:var(--brand)}.scan-loading h2{margin-bottom:0}.scan-loading p{margin:0 0 20px}.scan-spinner{width:26px;height:26px;border:2px solid var(--line);border-top-color:var(--brand);border-radius:50%;animation:scan-spin 1s linear infinite}.scan-camera{position:relative;aspect-ratio:1/1.05;background:var(--hero);border-radius:22px;overflow:hidden;margin:22px 0}.scan-camera video{width:100%;height:100%;object-fit:cover}.scan-target{position:absolute;inset:30% 8%;border:2px solid var(--lime);border-radius:18px;box-shadow:0 0 0 150px var(--shadow-3);pointer-events:none}
.scan-product-heading{display:flex;align-items:center;gap:20px;margin:8px 0 22px}.scan-product-heading>div{min-width:0}.food-scan .scan-product-heading h2{font-size:27px;overflow-wrap:anywhere;margin:5px 0 9px}.scan-product-heading>div>span{font-size:11px;letter-spacing:1px;color:var(--muted)}.food-scan .scan-product-heading .scan-kicker{font-size:10px;margin-bottom:6px}.scan-thumb{width:46px;height:55px;border-radius:10px;background:var(--tint);display:grid;place-items:center;flex-shrink:0;overflow:hidden;padding:5px}.scan-thumb img{width:100%;height:100%;object-fit:contain}.scan-product-heading .scan-thumb{width:86px;height:102px;border-radius:17px;padding:10px}.scan-baseline{display:flex;justify-content:space-between;gap:8px;align-items:center;padding:13px 0 22px;border-bottom:1px solid var(--line);margin-bottom:24px;font-size:12px;color:var(--muted)}.food-scan .scan-baseline button{padding:8px 0;background:transparent;border:0;color:var(--brand);font-size:12px;min-height:40px;text-decoration:underline;text-underline-offset:4px}.food-scan .scan-amount-label{text-align:center;color:var(--ink);margin-bottom:12px;font-size:15px}
.scan-quantity{display:flex;align-items:center;justify-content:center;gap:18px}.food-scan .scan-quantity button{width:46px;height:46px;flex-shrink:0;border:1px solid var(--line);border-radius:50%;background:var(--surface);color:var(--ink);font-size:23px;padding:0}.scan-quantity>div{display:flex;flex-direction:column;align-items:center;max-width:170px}.food-scan .scan-quantity input{background:transparent;border:0;border-radius:0;text-align:center;font-size:49px;font-weight:750;letter-spacing:-2px;padding:0;line-height:1.2;min-height:60px;appearance:textfield}.scan-quantity input::-webkit-inner-spin-button{appearance:none}.scan-quantity>div>span{font-size:13px;color:var(--muted)}.scan-shortcuts{display:flex;justify-content:center;flex-wrap:wrap;gap:8px;margin:20px 0 25px}.food-scan .scan-shortcuts button{padding:9px 13px;min-height:40px;background:var(--tint);border:0;color:var(--ink);border-radius:20px;font-size:12px}
.scan-totals{background:var(--hero);border-radius:23px;padding:22px;color:var(--on-dark);margin-bottom:24px}.scan-energy{display:flex;justify-content:space-between;align-items:center;gap:12px;padding-bottom:19px;border-bottom:1px solid var(--glass-2)}.scan-energy>span{font-size:12px;color:var(--on-dark-soft)}.scan-energy strong{font-size:35px;letter-spacing:-1px;color:var(--lime)}.scan-energy small{font-size:13px;font-weight:500;letter-spacing:0}.scan-macros{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;padding-top:19px}.scan-macros>div{display:flex;flex-direction:column;gap:7px}.scan-macros strong{font-size:19px;font-weight:650;letter-spacing:-.5px}.scan-macros span{font-size:10px;color:var(--on-dark-soft)}.food-scan .scan-totals p{font-size:11px;color:var(--muted);margin:18px 0 0}.scan-log-fields,.scan-label-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 14px}.scan-label-grid label{align-self:end}.food-scan .scan-unit{display:flex;gap:12px;padding:0;margin:5px 0 22px;border:0}.scan-unit legend{font-size:13px;margin-bottom:10px;color:var(--ink)}.food-scan .scan-unit label{flex:1;flex-direction:row;align-items:center;gap:10px;padding:13px;background:var(--surface);border:1px solid var(--line);border-radius:13px;margin:0;cursor:pointer}.food-scan .scan-unit label:has(:checked){background:var(--tint);border-color:var(--ok)}.food-scan .scan-unit input{width:18px;height:18px;min-height:18px;flex:0 0 18px;accent-color:var(--brand);margin:0;padding:0;appearance:auto}
.food-scan .scan-bottom{position:sticky;bottom:0;z-index:3;background:linear-gradient(var(--transparent),var(--surface-2) 13px);padding:20px 0 max(20px,env(safe-area-inset-bottom));margin-top:0}.diary-scan-entry{display:flex;align-items:center;gap:14px;text-align:left;padding:17px 20px;width:100%;border:0;border-radius:18px;background:var(--hero);color:var(--on-dark);margin:18px 0 23px;box-shadow:none}.diary-scan-entry>svg{width:30px;height:30px;color:var(--lime);flex-shrink:0}.diary-scan-entry>span{flex:1;display:flex;flex-direction:column;gap:3px}.diary-scan-entry strong{font-size:16px}.diary-scan-entry small{font-size:12px;color:var(--on-dark-soft)}.diary-scan-entry>b{font-size:22px;color:var(--lime)}.diary-quick-options{display:flex;justify-content:center;gap:10px;flex-wrap:wrap}
@keyframes scan-sweep{0%,100%{transform:translateY(-25px)}50%{transform:translateY(28px)}}@keyframes scan-spin{to{transform:rotate(360deg)}}
@media(max-width:600px){dialog.food-scan{width:100%;max-width:none;height:100%;height:100dvh;max-height:100%;max-height:100dvh;margin:0;border-radius:0}.food-scan .scan-header{padding-top:max(12px,env(safe-area-inset-top));padding-left:20px;padding-right:20px}.food-scan .scan-content{padding:20px 22px 0}.food-scan .scan-hero{padding:20px}.food-scan .scan-hero h2{font-size:30px}.food-scan .scan-product-heading h2{font-size:25px}}
@media(max-width:350px){.food-scan .scan-content{padding:16px 16px 0}.food-scan .scan-hero h2{font-size:27px}.food-scan .scan-product-heading{gap:12px}.scan-product-heading .scan-thumb{width:65px;height:84px}.food-scan .scan-primary{font-size:13px}.food-scan .scan-primary span{font-size:11px}.scan-log-fields{grid-template-columns:1fr}.scan-energy strong{font-size:30px}}
@media(prefers-reduced-motion:reduce){.scan-art i,.scan-spinner{animation:none}}

/* Existing mobile styles use !important globally; these overrides stay inside this dialog. */
html:has(#food-scan-dialog[open]),body:has(#food-scan-dialog[open]){overflow:hidden!important}
dialog#food-scan-dialog[open]{padding:0!important;border:0!important;overflow-x:hidden;box-shadow:0 32px 120px var(--shadow-3)!important}
#food-scan-dialog .scan-quantity input{font-size:49px!important;min-height:60px!important;border-radius:0!important}
#food-scan-dialog .scan-unit input{min-height:18px!important;border-radius:50%!important}
/* The camera opens immediately: a bottom sheet on phones, a centered dialog on larger screens.
   Keep these scoped overrides after the app's generic fullscreen mobile dialogs. */
dialog#food-scan-dialog[open]{inset:auto 0 0!important;margin:0 auto!important;width:min(100%,540px)!important;max-width:540px!important;height:auto!important;max-height:calc(100dvh - 64px)!important;border-radius:28px 28px 0 0!important;background:var(--surface-2)!important;overscroll-behavior:contain}
dialog#food-scan-dialog::backdrop{background:var(--scrim);backdrop-filter:blur(3px)}
#food-scan-dialog .scan-sheet-handle{width:38px;height:4px;border-radius:4px;background:var(--tint-2);margin:11px auto 0}
#food-scan-dialog .scan-header{padding:12px 22px 6px!important;border-bottom:0;background:var(--surface-2)}
#food-scan-dialog .scan-header button{width:44px;height:44px;min-height:44px;border:0;background:var(--surface-2);color:var(--ink);flex-shrink:0}
#food-scan-dialog .scan-camera-header h2{font-size:23px!important;line-height:1.25;letter-spacing:-.8px;margin:0!important}
#food-scan-dialog .scan-content{padding:12px 22px max(20px,env(safe-area-inset-bottom))}
#food-scan-dialog[data-step="camera"] .scan-content{padding:0 22px max(20px,env(safe-area-inset-bottom))}
#food-scan-dialog .scan-camera-intro{font-size:13px;margin:0 0 18px;line-height:1.6}
#food-scan-dialog .scan-camera{height:clamp(180px,39dvh,306px);aspect-ratio:auto;margin:0;border-radius:20px;background:var(--hero)}
#food-scan-dialog .scan-camera video{display:block;width:100%;height:100%;object-fit:cover}
#food-scan-dialog .scan-target{inset:33% 7%;height:34%;border:1px solid var(--glass-2);border-radius:14px;box-shadow:0 0 0 400px var(--shadow-3)}
#food-scan-dialog .scan-target i{position:absolute;width:24px;height:24px;border-color:var(--lime);border-style:solid;border-width:0}
#food-scan-dialog .scan-target i:nth-child(1){left:-2px;top:-2px;border-top-width:3px;border-left-width:3px;border-radius:14px 0 0 0}
#food-scan-dialog .scan-target i:nth-child(2){right:-2px;top:-2px;border-top-width:3px;border-right-width:3px;border-radius:0 14px 0 0}
#food-scan-dialog .scan-target i:nth-child(3){left:-2px;bottom:-2px;border-bottom-width:3px;border-left-width:3px;border-radius:0 0 0 14px}
#food-scan-dialog .scan-target i:nth-child(4){right:-2px;bottom:-2px;border-bottom-width:3px;border-right-width:3px;border-radius:0 0 14px 0}
#food-scan-dialog .scan-camera-status{position:absolute;top:13px;left:13px;display:flex;gap:6px;align-items:center;background:var(--scrim);border:1px solid var(--glass-2);padding:7px 10px;border-radius:20px;color:var(--on-dark);font-size:11px;line-height:1.4}
#food-scan-dialog .scan-camera-status:before{content:'';width:6px;height:6px;border-radius:50%;background:var(--tint)}
#food-scan-dialog .scan-camera-status.is-live:before{background:var(--lime)}
#food-scan-dialog .scan-camera-hint{position:absolute;bottom:17px;left:12px;right:12px;text-align:center;color:var(--on-dark);font-size:12px;text-shadow:0 1px 4px var(--shadow-3)}
#food-scan-dialog .scan-auto-label{display:flex;gap:6px;align-items:center;justify-content:center;text-align:center;font-size:11px;line-height:1.5;color:var(--muted);margin:13px 0 17px}
#food-scan-dialog .scan-auto-label svg{width:15px;height:15px}
#food-scan-dialog .scan-camera-tools{display:flex;gap:10px}
#food-scan-dialog .scan-camera-tools button{min-height:50px;border:1px solid var(--line);border-radius:14px;background:var(--surface);font-size:13px;font-weight:600;box-shadow:none;color:var(--ink)}
#food-scan-dialog .scan-camera-tools .scan-secondary{flex:1;width:auto;padding:12px;gap:8px}
#food-scan-dialog .scan-torch{display:grid;place-items:center;flex:0 0 54px;padding:12px}
#food-scan-dialog .scan-torch[aria-pressed="true"]{background:var(--lime);border-color:var(--lime);color:var(--on-accent)}
#food-scan-dialog .scan-context{margin-top:19px;border-top:1px solid var(--line);padding-top:16px;display:flex;justify-content:space-between;gap:12px;font-size:12px;color:var(--muted);line-height:1.5}
#food-scan-dialog .scan-context strong{color:var(--ink);font-weight:600}
@media(max-width:350px){#food-scan-dialog .scan-content,#food-scan-dialog[data-step="camera"] .scan-content{padding-left:16px;padding-right:16px}#food-scan-dialog .scan-header{padding-left:16px!important;padding-right:16px!important}}
@media(min-width:600px){dialog#food-scan-dialog[open]{inset:0!important;margin:auto!important;height:fit-content!important;border-radius:28px!important}#food-scan-dialog .scan-sheet-handle{display:none}#food-scan-dialog .scan-header{padding-top:22px!important}}
@media(max-height:500px){dialog#food-scan-dialog[open]{max-height:calc(100dvh - 24px)!important}}
