/* Sage Companion: shared Home, Settings and label-reader appearance. */
.barcode-entry { margin: 18px 0 22px; }
.barcode-entry > button { width: 100%; }
.barcode-entry summary { font-size: .75rem; color: var(--text-secondary); }
.barcode-entry label { font-size: .8rem; }
.barcode-number-row { display: flex; gap: 8px; margin: 8px 0 14px; }
.barcode-number-row input { min-width: 0; flex: 1; width: auto; padding: 10px; }
.barcode-number-row button { flex: 0 0 auto; }
.barcode-file-label { display: flex; flex-direction: column; gap: 9px; }
.barcode-file-label input { font-size: 16px; max-width: 100%; }
.product-panel { border: 1px solid var(--border-color); background: var(--bg-surface-elevated); padding: 18px; border-radius: 24px; margin-bottom: 24px; scroll-margin-top: 80px; }
.product-panel header { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.product-panel h2 { font-size: 1.1rem; overflow-wrap: anywhere; }
.product-panel header button { flex: 0 0 auto; }
.product-panel p { font-size: .8rem; color: var(--text-secondary); margin: 10px 0; overflow-wrap: anywhere; }
.product-panel label { display: block; font-size: .85rem; font-weight: 600; margin-top: 16px; }
.product-panel textarea { font-size: 16px; }
#product-confirm { width: 100%; margin: 14px 0; }
.product-fallback-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.product-fallback-actions button { flex: 1 1 140px; font-size: .8rem; }
.product-panel a { color: var(--primary); text-underline-offset: 3px; }
:root {
  color-scheme: light;
  --bg-primary: #f4f3eb; --bg-surface: #fbfaf5; --bg-surface-elevated: #fffef9;
  --bg-muted: #edf1e7; --bg-accent-subtle: #dfe8d9;
  --text-primary: #29392f; --text-secondary: #526157; --text-muted: #60705e; --text-inverse: #fffdf5;
  --primary: #344e3e; --primary-hover: #253e2f; --primary-active: #1f3528; --primary-subtle: #dce6d5;
  --primary-focus: #8da77d66; --border-focus: #a34b20; --border-color: #b9c5b1; --border-subtle: #d9dfd2;
  --accent-scanner: #e9934b; --accent-scanner-glow: #e9934b44;
  --success: #40533b; --success-bg: #e4eadf; --warning: #74501e; --warning-bg: #f1e4c8;
  --danger: #803c2b; --danger-bg: #f2dfd4;
  --radius-sm: 12px; --radius-md: 18px; --radius-lg: 26px;
  --shadow-scanner: 0 7px 20px #68502a20; --sage-orange: #e9934b; --sage-crop: #a84f20;
  --sage-hero: #dfe8d9; --sage-hero-ink: #29392f; --sage-hero-muted: #4a5c4c;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #27342f; --bg-surface: #303d38; --bg-surface-elevated: #35443c;
  --bg-muted: #42524a; --bg-accent-subtle: #455541;
  --text-primary: #f1f4e9; --text-secondary: #d4ddcf; --text-muted: #c1cdbb; --text-inverse: #24342a;
  --primary: #b9cd95; --primary-hover: #d0dfb3; --primary-active: #e3edce; --primary-subtle: #53664b;
  --primary-focus: #b9cd9555; --border-focus: #f0b67b; --border-color: #84937b; --border-subtle: #5b6e5c;
  --success: #cfddbc; --success-bg: #42583c; --warning: #f4d89f; --warning-bg: #5a462a;
  --danger: #f5c4b0; --danger-bg: #633f31; --sage-crop: #ffc78d;
  --sage-hero: #dfe8d9; --sage-hero-ink: #29392f; --sage-hero-muted: #4a5c4c;
  --shadow-scanner: 0 7px 20px #0003;
}
[data-contrast="high"] { --border-color: #222; --border-subtle: #444; --text-primary: #111; --text-secondary: #222; --text-muted: #333; --bg-primary: #fff; --bg-surface: #fff; --bg-surface-elevated: #fff; --primary: #203e29; --text-inverse: #fff; }
[data-theme="dark"][data-contrast="high"] { --border-color: #fff; --border-subtle: #ddd; --text-primary: #fff; --text-secondary: #fff; --text-muted: #eee; --bg-primary: #000; --bg-surface: #000; --bg-surface-elevated: #000; --primary: #e0efc5; --text-inverse: #142014; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
.app-container { max-width: 640px; background: var(--bg-surface); }
.app-header { background: var(--bg-surface); border-bottom: 0; padding-inline: 22px; }
.brand-title { font-size: 1.3rem; letter-spacing: -.7px; }
.sage-dino { position: relative; display: inline-block; flex-shrink: 0; width: 37px; height: 33px; background: #829784; border-radius: 19px 22px 15px 8px; transform: rotate(-5deg); }
.sage-dino::before { content: ''; position: absolute; width: 13px; height: 13px; border-radius: 50%; background: #fffdf6; top: 7px; right: 7px; }
.sage-dino::after { content: ''; position: absolute; width: 6px; height: 7px; border-radius: 50%; background: #29392f; top: 9px; right: 8px; box-shadow: -22px -12px 0 2px #b6cd88, -13px -14px 0 2px #b6cd88; }
.btn-icon { background: var(--bg-muted); border-radius: 15px; color: var(--text-primary); }
.main-content { padding: 10px 22px calc(var(--bottom-nav-height) + 32px); }
.scanner-hero-card { position: relative; overflow: hidden; text-align: left; align-items: stretch; background: var(--sage-hero); border: 0; border-radius: 32px 32px 12px 32px; box-shadow: none; padding: 24px; gap: 16px; }
.scanner-hero-card::before { display: none; }
.scanner-hero-card::after { content: ''; position: absolute; width: 130px; height: 130px; background: #b9cd9666; top: -48px; right: -48px; border-radius: 50%; pointer-events: none; }
.scanner-heading { position: relative; z-index: 1; }
.scanner-heading h1 { font-size: clamp(1.75rem, 6vw, 2.2rem); line-height: 1.13; letter-spacing: -1px; color: var(--sage-hero-ink); }
.scanner-heading p { color: var(--sage-hero-muted); margin-top: 12px; font-size: .9rem; max-width: 380px; }
.sage-kicker { display: flex; align-items: center; gap: 7px; text-transform: uppercase; letter-spacing: 1.6px; font-size: .65rem; font-weight: 650; margin-bottom: 14px; color: #4b644c; }
.sage-kicker span { width: 7px; height: 7px; border-radius: 50%; background: var(--sage-orange); }
.btn-camera-trigger { width: 100%; min-height: 56px; border-radius: 17px; background: #344e3e; color: #fffdf5; font-size: 1rem; padding: 15px; box-shadow: none; margin-top: 4px; }
.btn-camera-trigger:hover { background: #253e2f; }
.btn-camera-trigger svg { width: 23px; height: 23px; }
.camera-sub-actions { display: block; width: 100%; }
.photo-library-action { width: 100%; min-height: 50px; border: 1px solid #c2d0bb; border-radius: 17px; background: #f7f9f0; color: #29392f; font-size: .9rem; cursor: pointer; position: relative; }
.photo-library-action:focus-within { outline: 3px solid var(--border-focus); outline-offset: 3px; }
.sage-privacy { text-align: center; font-size: .7rem; color: #4c624f; }
.search-label { flex-wrap: wrap; gap: 6px; }
.search-label label { font-size: .9rem; }
.search-input-wrapper { border-radius: 18px; box-shadow: none; }
.search-input { font-size: 16px; }
.search-input::placeholder { font-size: .9rem; color: var(--text-muted); }
.sage-examples { color: var(--text-secondary); font-size: .75rem; margin-top: 6px; }
.sage-examples button { min-height: 44px; font-size: .75rem; padding: 5px 3px; text-decoration: underline; text-underline-offset: 3px; }
.filter-chips-bar { margin-top: 5px; }
.filter-chip { background: var(--bg-surface-elevated); color: var(--text-secondary); border-radius: 14px; }
.filter-chip.active { background: var(--primary-subtle); color: var(--text-primary); border-color: var(--border-color); }
.sage-report-link { width: 100%; display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--bg-muted); color: var(--text-primary); border: 0; border-radius: 20px; text-align: left; margin: 20px 0 14px; }
.sage-report-icon { width: 38px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--bg-surface-elevated); font-size: 24px; flex-shrink: 0; }
.sage-report-link strong { font-size: .85rem; display: block; }
.sage-report-link small { font-size: .7rem; color: var(--text-secondary); display: block; margin-top: 4px; }
.sage-report-link > span:last-child { margin-left: auto; font-size: 24px; }
.sage-safety-note { font-size: .73rem; line-height: 1.5; color: var(--text-secondary); margin-bottom: 22px; }
.results-title { font-size: .9rem; }
.empty-state { padding: 24px 16px; border-radius: 20px; border-color: var(--border-subtle); }
.empty-state h3 { font-size: 1rem; }
.bottom-nav { background: var(--bg-muted); border-color: var(--border-subtle); }
.nav-item.active { color: var(--text-primary); background: var(--primary-subtle); border-radius: 15px; }
.nav-scan-btn { background: var(--sage-orange); color: #303c2d; box-shadow: 0 0 0 6px var(--bg-surface); border-radius: 22px; }
.nav-scan-btn:hover { background: #f0a665; }
.sage-settings-intro { margin: 5px 0 18px; }
.sage-settings-intro h1 { font-size: 1.85rem; letter-spacing: -.9px; line-height: 1.2; }
.sage-settings-intro p { color: var(--text-secondary); font-size: .85rem; margin-top: 7px; }
.settings-header-banner { margin-bottom: 18px; }
.settings-group-title { font-size: .7rem; letter-spacing: 1.3px; color: var(--text-secondary); margin-bottom: 12px; }
.settings-list, .sensitivity-card, .pdf-loaded-card { border-radius: 24px; background: var(--bg-surface-elevated); box-shadow: none; border-color: var(--border-subtle); }
.setting-desc { font-size: .73rem; }
.setting-title { font-size: .9rem; }
.setting-item { padding: 16px; gap: 14px; }
.switch input:focus-visible + .slider { outline: 3px solid var(--border-focus); outline-offset: 4px; }
.count-box { border-radius: 15px; }
.count-box.high { background: var(--danger-bg); color: var(--danger); }
.count-box.medium { background: var(--warning-bg); color: var(--warning); }
.count-box.none { background: var(--success-bg); color: var(--success); }
.count-num { font-size: 1.5rem; color: inherit; }
.count-label { color: inherit; font-size: .62rem; line-height: 1.4; }
.category-tabs { flex-wrap: wrap; background: var(--bg-muted); border-radius: 14px; }
.category-tab-btn { flex: 1 1 90px; white-space: normal; font-size: .7rem; }
.category-tab-btn.active { background: var(--bg-surface-elevated); color: var(--text-primary); border-radius: 10px; }
.pdf-actions-row { flex-wrap: wrap; }
.pdf-actions-row button { flex: 1 1 auto; min-height: 46px; }
.sensitivity-header { flex-wrap: wrap; gap: 10px; }
.sensitivity-header > div { min-width: 0; flex: 1 1 200px; }
#sensitivity-card-title, #sensitivity-card-meta { overflow-wrap: anywhere; }
.sensitivity-tag { border-radius: 12px; }
.sage-cloud-section { border: 1px solid var(--border-subtle); border-radius: 20px; padding: 16px; background: var(--bg-surface-elevated); }
.sage-cloud-section > p { font-size: .8rem; color: var(--text-secondary); margin: 8px 0 16px; }
.sage-cloud-section .settings-group { margin: 0; }
.firestore-status-bar { flex-wrap: wrap; background: var(--bg-muted); border-color: var(--border-subtle); }
.firestore-badge { min-width: 0; flex: 1 1 200px; }
summary { cursor: pointer; min-height: 44px; padding-block: 10px; font-size: .85rem; }
input, select, textarea { accent-color: var(--primary); }
.btn-primary { background: var(--primary); color: var(--text-inverse); border-radius: 17px; min-height: 56px; font-size: 1rem; }
.btn-secondary { background: var(--bg-surface-elevated); color: var(--text-primary); border-color: var(--border-color); border-radius: 14px; min-height: 44px; }
.modal-sheet { background: var(--bg-surface); border-radius: 28px 28px 0 0; }
.modal-header, .modal-footer { background: var(--bg-surface); }
body.label-editor-open { overflow: hidden; }
.label-ocr-sheet { max-width: 640px; width: 100%; height: min(94dvh, calc(var(--label-viewport-height, 100dvh) - 24px), 950px); max-height: min(94dvh, calc(var(--label-viewport-height, 100dvh) - 24px)); display: flex; flex-direction: column; overflow: hidden; }
.label-ocr-sheet .modal-header { flex-shrink: 0; padding: 14px 20px; }
#label-ocr-cancel { flex: 0 0 auto; min-width: 78px; }
.sage-brand-small { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.15rem; }
.label-flow-steps { display: flex; list-style: none; gap: 5px; padding: 0 20px 12px; flex-shrink: 0; }
.label-flow-steps li { flex: 1; text-align: center; font-size: .75rem; padding: 10px 3px; background: var(--bg-muted); color: var(--text-secondary); border-radius: 18px; }
.label-flow-steps li[aria-current="step"] { background: var(--primary); color: var(--text-inverse); }
.label-ocr-sheet .modal-body { overflow-y: auto; overscroll-behavior: contain; padding: 2px 22px 16px; flex: 1 1 auto; min-height: 0; }
#label-ocr-title { font-size: 1.5rem; letter-spacing: -.5px; margin-bottom: 7px; line-height: 1.2; }
#label-ocr-status { font-size: .82rem; color: var(--text-secondary); line-height: 1.45; margin-bottom: 18px; }
.label-image-stage { position: relative; width: fit-content; max-width: 100%; flex-shrink: 0; margin: 12px auto 20px; touch-action: none; user-select: none; }
.label-ocr-canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 32dvh; border-radius: 18px; touch-action: none; margin: 0; border: 0; }
.label-crop-box { position: absolute; border: 2px solid var(--sage-crop); pointer-events: none; border-radius: 4px; }
.label-crop-box button { position: absolute; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; pointer-events: auto; touch-action: none; display: grid; place-items: center; }
.label-crop-box button::after { content: ''; width: 17px; height: 17px; background: #fffdf6; border: 3px solid #a84f20; border-radius: 5px; }
[data-crop-edge="nw"] { left: -23px; top: -23px; cursor: nwse-resize; }
[data-crop-edge="ne"] { right: -23px; top: -23px; cursor: nesw-resize; }
[data-crop-edge="sw"] { left: -23px; bottom: -23px; cursor: nesw-resize; }
[data-crop-edge="se"] { right: -23px; bottom: -23px; cursor: nwse-resize; }
[data-crop-edge="n"] { top: -23px; left: calc(50% - 22px); cursor: ns-resize; }
[data-crop-edge="s"] { bottom: -23px; left: calc(50% - 22px); cursor: ns-resize; }
[data-crop-edge="w"] { left: -23px; top: calc(50% - 22px); cursor: ew-resize; }
[data-crop-edge="e"] { right: -23px; top: calc(50% - 22px); cursor: ew-resize; }
[data-crop-edge="n"]::after, [data-crop-edge="s"]::after { width: 30px; height: 8px; }
[data-crop-edge="w"]::after, [data-crop-edge="e"]::after { width: 8px; height: 30px; }
.label-ocr-actions { justify-content: space-between; margin: 0; }
.label-ocr-actions button { min-width: 112px; }
.label-crop-controls { padding-block: 10px; }
.label-crop-controls input { min-height: 44px; }
.label-ocr-provider p { font-size: .75rem; color: var(--text-secondary); margin-top: 8px; }
.label-ocr-footer { flex: 0 0 auto; background: var(--bg-surface); border-top: 1px solid var(--border-subtle); padding: 12px 22px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 5px; }
.label-ocr-footer > button { width: 100%; justify-content: center; }
.label-ocr-footer p { text-align: center; color: var(--text-secondary); font-size: .7rem; }
#label-ocr-back { border: 0; background: transparent; min-height: 40px; font-size: .82rem; }
#label-ocr-text { font-size: 16px; background: var(--bg-surface-elevated); color: var(--text-primary); border-radius: 16px; min-height: 150px; }
#label-ocr-review > label { display: block; font-size: .85rem; margin-bottom: 8px; font-weight: 600; }
#label-ocr-review > p { color: var(--text-secondary); font-size: .78rem; margin-top: 8px; }
.label-ocr-sheet[data-step="review"] .label-ocr-canvas { max-height: 17dvh; }
.label-ocr-sheet[data-step="photo"] .label-ocr-canvas { max-height: 42dvh; }
.label-ocr-sheet[data-step="recognizing"] .label-image-stage { opacity: .75; }
.scanner-modal { background: #24332b; }
.scanner-header-title { font-size: .9rem; }
.scanner-bottom-controls { padding-bottom: max(16px, env(safe-area-inset-bottom)); gap: 10px; background: #24332bee; }
.btn-camera-shutter { background: #e9934b; color: #24332b; width: min(100%, 420px); border-radius: 18px; min-height: 58px; border: 0; font-size: 1.05rem; }
.scanner-bottom-controls > select { width: min(100%, 420px); color: #29392f; background: #fbfaf5; }
.scanner-examples { color: #e4ebdd; width: min(100%, 420px); }
.scanner-native-fallback { display: flex; flex-direction: column; gap: 7px; align-items: center; color: #e4ebdd; font-size: .8rem; }
.scanner-native-fallback input { max-width: 100%; font-size: 16px; }
.scanner-hint-text { color: #eef3e8; }
.scanner-barcode-entry { width: min(100%, 420px); color: #eef3e8; font-size: .8rem; }
.scanner-barcode-entry input { background: #fbfaf5; color: #29392f; }
.scanner-barcode-entry .barcode-number-row { margin-bottom: 0; }
.scanner-modal[data-camera-mode="barcode"] .scanner-reticle { width: min(78vw, 340px); height: 145px; border-radius: 14px; }
.scanner-modal[data-camera-mode="barcode"] .scanner-corner { border-color: #e9934b; }
.scanner-modal[data-camera-mode="barcode"] .scanner-laser { display: none; }
.scanner-modal .scanner-bottom-controls { max-height: 55dvh; overflow-y: auto; flex-shrink: 0; }
@media(min-width: 641px) { .app-container { margin-block: 24px; min-height: calc(100dvh - 48px); border-radius: 32px; overflow: clip; border: 1px solid var(--border-subtle); } .bottom-nav { max-width: 640px; border-radius: 24px 24px 0 0; } .label-ocr-sheet { border-radius: 28px; } }
@media(max-width: 380px) { .main-content { padding-inline: 16px; } .scanner-hero-card { padding: 21px 18px; } .sage-kicker { font-size: .6rem; } .sensitivity-card { padding: 14px; } .sensitivity-counts-row { gap: 6px; } .count-box { padding: 10px 4px; } .label-ocr-sheet .modal-body { padding-inline: 22px; } }
@media(max-height: 600px) { .label-ocr-sheet { height: 100dvh; max-height: 100dvh; } .label-ocr-sheet .modal-header { padding-block: 7px; } .label-flow-steps { padding-bottom: 5px; } .label-flow-steps li { padding-block: 5px; } .label-ocr-footer { padding-top: 7px; } .label-ocr-footer .btn-primary { min-height: 48px; } }
@media(prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
