:root {
  --ink: #15231d;
  --forest: #173c2d;
  --forest-2: #25563f;
  --cream: #f5f2ea;
  --paper: #fffdf8;
  --gold: #f3bf55;
  --muted: #6f7973;
  --line: #deded5;
  --danger: #a33a31;
  --shadow: 0 16px 40px rgba(23, 60, 45, .12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--forest); }
body { margin: 0; min-height: 100vh; background: var(--cream); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { position: relative; width: min(100%, 680px); min-height: 100vh; margin: 0 auto; padding-bottom: calc(118px + env(safe-area-inset-bottom)); overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: calc(18px + env(safe-area-inset-top)) 20px 16px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: var(--cream); background: var(--forest); border-radius: 14px; font-size: 27px; font-weight: 800; transform: rotate(-10deg); }
h1, h2, p { margin: 0; }
h1 { font-size: 23px; line-height: 1.05; letter-spacing: -.55px; }
h2 { font-size: 24px; line-height: 1.1; letter-spacing: -.55px; }
.eyebrow { margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1.25px; text-transform: uppercase; }
.icon-button, .close-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 15px; color: var(--forest); background: rgba(255,255,255,.5); }
.icon-button svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.search-section { padding: 8px 20px 24px; }
.search-box { display: flex; align-items: center; min-height: 64px; padding: 0 16px; border: 2px solid transparent; border-radius: 21px; background: var(--paper); box-shadow: var(--shadow); transition: .2s ease; }
.search-box:focus-within { border-color: var(--forest); transform: translateY(-1px); }
.search-box > svg { width: 25px; flex: 0 0 auto; fill: none; stroke: var(--forest); stroke-width: 1.9; stroke-linecap: round; }
.search-box input { min-width: 0; flex: 1; padding: 0 13px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 20px; font-weight: 650; }
.search-box input::placeholder { color: #98a19c; font-weight: 500; }
.clear-search { width: 32px; height: 32px; border: 0; border-radius: 50%; color: var(--muted); background: #eeeee7; font-size: 22px; }
.search-hint { padding: 12px 5px 0; color: var(--muted); font-size: 13px; }
.search-hint button { display: inline-flex; align-items: center; min-height: 44px; margin: -13px 0; padding: 0 5px; border: 0; color: var(--forest-2); background: transparent; font-weight: 750; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }

.install-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 0 20px 24px; padding: 15px 16px; border-radius: 18px; color: #fdf7e7; background: var(--forest); }
.install-banner div { display: grid; gap: 3px; }
.install-banner strong { font-size: 14px; }
.install-banner span { color: #cbd8d1; font-size: 12px; }
.install-banner button { padding: 9px 12px; border: 0; border-radius: 11px; color: var(--forest); background: var(--gold); font-weight: 800; }

.section-heading { display: flex; justify-content: space-between; align-items: end; padding: 0 20px 12px; }
.count-badge { display: grid; place-items: center; min-width: 31px; height: 31px; padding: 0 9px; border-radius: 99px; color: var(--forest); background: #dfe6df; font-size: 13px; font-weight: 800; }
.category-strip { display: flex; gap: 8px; overflow-x: auto; padding: 3px 20px 14px; scrollbar-width: none; }
.category-strip::-webkit-scrollbar { display: none; }
.category-chip { flex: 0 0 auto; min-height: 44px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 700; }
.category-chip.active { border-color: var(--forest); color: #fff; background: var(--forest); }

.product-list { display: grid; gap: 10px; padding: 0 14px; }
.product-card { position: relative; display: flex; flex-wrap: wrap; align-items: stretch; border: 1px solid rgba(23,60,45,.07); border-radius: 21px; background: var(--paper); box-shadow: 0 5px 18px rgba(23,60,45,.055); overflow: hidden; animation: card-in .28s ease both; }
@keyframes card-in { from { opacity: 0; transform: translateY(7px); } }
.product-main { order: 1; display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; padding: 17px 9px 17px 17px; border: 0; color: inherit; background: transparent; text-align: left; }
.product-copy { display: grid; min-width: 0; flex: 1; gap: 5px; }
.product-name { overflow: hidden; font-size: 17px; letter-spacing: -.2px; text-overflow: ellipsis; white-space: nowrap; }
.product-meta { color: var(--muted); font-size: 12px; }
.product-code { flex: 0 0 auto; padding: 8px 11px; border-radius: 11px; color: var(--forest); background: #e6ede7; font-size: 20px; font-weight: 900; letter-spacing: .5px; }
.list-button { order: 2; width: 42px; padding: 0; border: 0; color: var(--forest); background: transparent; font-size: 25px; font-weight: 500; }
.report-button { order: 4; flex: 0 0 100%; min-height: 44px; padding: 9px 14px; border: 0; border-top: 1px solid #eee4c8; color: #765b12; background: #fffaf0; font-size: 12px; font-weight: 800; text-align: left; }
.favorite-button { order: 3; width: 43px; padding: 0 10px 0 0; border: 0; color: #a2aaa5; background: transparent; font-size: 27px; }
.favorite-button.active { color: #e6a72d; }

.empty-state { padding: 40px 30px; text-align: center; }
.empty-illustration { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 18px; border: 2px dashed #a9b4ae; border-radius: 22px; color: var(--forest); font-size: 30px; font-weight: 900; transform: rotate(-3deg); }
.empty-state p { max-width: 330px; margin: 9px auto 20px; color: var(--muted); line-height: 1.45; }

.fab { position: fixed; z-index: 6; right: max(20px, calc((100vw - 680px)/2 + 20px)); bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 7px; padding: 15px 19px; border: 0; border-radius: 18px; color: #fff; background: var(--forest); box-shadow: 0 11px 30px rgba(23,60,45,.27); font-weight: 800; }
.fab span { font-size: 23px; line-height: 16px; }

.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(2, 1fr); width: min(100%, 680px); min-height: calc(70px + env(safe-area-inset-bottom)); margin: 0 auto; padding: 7px 10px env(safe-area-inset-bottom); border-top: 1px solid rgba(23,60,45,.1); background: rgba(255,253,248,.94); box-shadow: 0 -8px 30px rgba(23,60,45,.08); backdrop-filter: blur(18px); }
.nav-button { position: relative; display: grid; place-items: center; align-content: center; gap: 3px; padding: 3px; border: 0; border-radius: 15px; color: #849089; background: transparent; font-size: 11px; font-weight: 750; }
.nav-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-button.active { color: var(--forest); background: #e9eee8; }
.nav-button b { position: absolute; top: 2px; left: calc(50% + 9px); display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; color: #fff; background: var(--danger); font-size: 10px; }

.toast { position: fixed; z-index: 12; right: 20px; bottom: calc(89px + env(safe-area-inset-bottom)); left: 20px; width: min(calc(100% - 40px), 420px); margin: 0 auto; padding: 13px 17px; border-radius: 14px; color: #fff; background: #1d3329; box-shadow: 0 10px 30px rgba(15,30,23,.22); font-size: 14px; font-weight: 750; text-align: center; animation: toast-in .2s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.view-intro { padding: 8px 20px 22px; }
.view-intro h2 { font-size: 30px; }
.view-intro > p:last-child { max-width: 520px; margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.45; }

.quick-add { display: flex; gap: 9px; padding: 0 20px 10px; }
.quick-add .search-box { min-width: 0; min-height: 57px; flex: 1; box-shadow: 0 8px 24px rgba(23,60,45,.08); }
.quick-add .search-box > svg { width: 22px; }
.quick-add .search-box input { font-size: 17px; }
.quick-add-button { padding: 0 15px; border: 0; border-radius: 17px; color: #fff; background: var(--forest); font-size: 14px; font-weight: 800; }
.shopping-suggestions { display: grid; gap: 1px; margin: 0 20px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--line); overflow: hidden; }
.suggestion-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 9px 13px; border: 0; color: var(--ink); background: var(--paper); text-align: left; }
.suggestion-button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-button strong { padding: 5px 8px; border-radius: 8px; color: var(--forest); background: #e6ede7; font-size: 13px; }
.shopping-heading { align-items: center; margin-top: 14px; }
.shopping-heading h2 { font-size: 20px; }
.text-button { max-width: 145px; padding: 5px 0; border: 0; color: var(--forest-2); background: transparent; font-size: 12px; font-weight: 800; }
.shopping-list { display: grid; gap: 9px; padding: 0 14px; }
.shopping-item { display: flex; align-items: stretch; min-height: 68px; border: 1px solid rgba(23,60,45,.07); border-radius: 19px; background: var(--paper); box-shadow: 0 5px 18px rgba(23,60,45,.045); overflow: hidden; }
.shopping-check { display: flex; align-items: center; min-width: 0; flex: 1; gap: 12px; padding: 12px 8px 12px 15px; }
.shopping-check input { position: absolute; opacity: 0; pointer-events: none; }
.checkmark { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 auto; border: 2px solid #aeb8b1; border-radius: 9px; color: transparent; font-size: 15px; font-weight: 900; }
.shopping-check input:checked + .checkmark { border-color: var(--forest); color: #fff; background: var(--forest); }
.shopping-copy { display: grid; min-width: 0; flex: 1; gap: 3px; }
.shopping-name { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.shopping-meta { color: var(--muted); font-size: 11px; }
.shopping-code { flex: 0 0 auto; padding: 7px 9px; border-radius: 10px; color: var(--forest); background: #e6ede7; font-size: 17px; font-weight: 900; }
.shopping-remove { width: 39px; padding: 0 8px 0 0; border: 0; color: #a1aaa5; background: transparent; font-size: 22px; }
.shopping-item.done { opacity: .55; box-shadow: none; }
.shopping-item.done .shopping-name { text-decoration: line-through; }
.empty-state.compact { padding-top: 50px; }

.camera-card { margin: 0 14px; padding: 10px; border: 1px solid rgba(23,60,45,.08); border-radius: 25px; background: var(--paper); box-shadow: var(--shadow); }
.camera-stage { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; max-height: 420px; border-radius: 18px; background: #dfe5de; overflow: hidden; }
.camera-stage video, .camera-stage img { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { display: grid; place-items: center; gap: 7px; padding: 25px; color: var(--forest); text-align: center; }
.camera-placeholder > span { display: grid; place-items: center; width: 70px; height: 70px; border: 2px solid rgba(23,60,45,.3); border-radius: 25px; font-size: 38px; }
.camera-placeholder small { color: var(--muted); font-size: 12px; font-weight: 600; }
.camera-guide { position: absolute; inset: 18% 12%; border: 2px solid rgba(255,255,255,.8); border-radius: 30px; box-shadow: 0 0 0 999px rgba(11,25,18,.08); pointer-events: none; }
.camera-status { min-height: 40px; padding: 12px 6px 0; color: var(--muted); font-size: 13px; line-height: 1.35; text-align: center; }
.camera-status.error { color: var(--danger); }
.camera-actions { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 4px 3px; }
.camera-actions .primary-button, .camera-actions .secondary-button { min-height: 46px; font-size: 13px; }
.capture-button { display: grid; place-items: center; width: 58px; height: 58px; flex: 0 0 auto; padding: 0; border: 3px solid var(--forest); border-radius: 50%; background: #fff; }
.capture-button span { width: 43px; height: 43px; border-radius: 50%; background: var(--forest); }
.photo-button { display: grid; place-items: center; cursor: pointer; }
.photo-button input { display: none; }
.camera-results-section { padding-top: 24px; }
.camera-results { display: grid; gap: 10px; padding: 0 14px; }
.camera-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 14px; border: 1px solid rgba(23,60,45,.08); border-radius: 19px; background: var(--paper); }
.camera-result-copy { display: grid; min-width: 0; gap: 4px; }
.camera-result-copy strong { overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.camera-result-copy span { color: var(--muted); font-size: 12px; }
.camera-result-actions { display: flex; align-items: center; gap: 7px; }
.camera-result-code { padding: 8px 10px; border-radius: 10px; color: var(--forest); background: #e6ede7; font-size: 18px; font-weight: 900; }
.camera-add { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 12px; color: #fff; background: var(--forest); font-size: 22px; }
.camera-no-result { padding: 22px; border: 1px dashed #aab5ae; border-radius: 19px; color: var(--muted); text-align: center; line-height: 1.45; }
.camera-no-result .secondary-button { display: block; margin: 15px auto 0; }

.sheet, .alert-dialog { width: min(calc(100% - 24px), 620px); max-width: none; max-height: calc(100dvh - env(safe-area-inset-top) - 8px); margin: auto auto 0; padding: 0; border: 0; border-radius: 28px 28px 0 0; color: var(--ink); background: var(--paper); box-shadow: 0 -20px 55px rgba(15,30,23,.18); overflow: hidden; }
.sheet::backdrop, .alert-dialog::backdrop { background: rgba(11, 25, 18, .54); backdrop-filter: blur(3px); }
.sheet[open] { animation: sheet-up .25s ease; }
@keyframes sheet-up { from { transform: translateY(35px); opacity: .4; } }
.sheet form, .sheet-panel { max-height: calc(100dvh - env(safe-area-inset-top) - 8px); padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.sheet-handle { width: 42px; height: 5px; margin: 2px auto 17px; border-radius: 99px; background: #d3d4ce; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.close-button { border: 0; background: #efefe9; font-size: 25px; }
.sheet label:not(.favorite-toggle):not(.file-button) { display: grid; gap: 7px; margin: 14px 0; color: var(--muted); font-size: 13px; font-weight: 750; }
.sheet input:not([type="checkbox"]):not([type="file"]) { width: 100%; min-height: 53px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 14px; outline: 0; color: var(--ink); background: #fff; font-size: 17px; }
.sheet input:focus { border-color: var(--forest-2) !important; }
.field-note { font-weight: 500; }
.favorite-toggle { display: flex; align-items: center; gap: 10px; padding: 11px 0; font-weight: 700; }
.favorite-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-star { color: #aab0ac; font-size: 27px; }
.favorite-toggle input:checked + .toggle-star { color: #e6a72d; }
.form-actions, .settings-actions { display: flex; gap: 10px; margin-top: 18px; }
.form-actions .primary-button { flex: 1; }
.primary-button, .secondary-button, .danger-button { min-height: 50px; padding: 0 17px; border-radius: 14px; font-weight: 800; }
.primary-button { border: 0; color: #fff; background: var(--forest); }
.secondary-button { border: 1px solid var(--line); color: var(--forest); background: #fff; }
.danger-button { border: 0; color: var(--danger); background: #f8eae7; }
.settings-card { display: flex; align-items: start; gap: 13px; padding: 16px; border-radius: 18px; background: #eef1eb; }
.settings-card.subtle { margin-top: 17px; background: transparent; border: 1px solid var(--line); }
.settings-icon { display: grid; place-items: center; width: 39px; height: 39px; flex: 0 0 auto; border-radius: 12px; color: #fff; background: var(--forest); font-size: 19px; font-weight: 800; }
.settings-card strong { font-size: 15px; }
.settings-card p { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.settings-actions > * { flex: 1; }
.settings-link { display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; }
.report-product { margin: 12px 0 18px; padding: 14px; border-radius: 15px; color: var(--forest); background: #e9efe9; font-weight: 800; }
.sheet textarea { width: 100%; min-height: 96px; resize: vertical; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; color: var(--ink); background: #fff; font: inherit; }
.form-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.live-camera-button { flex-basis: 100%; }
.file-button { display: grid; place-items: center; cursor: pointer; }
.file-button input { display: none; }
.version { padding: 22px 0 2px; color: #9aa29d; font-size: 12px; text-align: center; }

.alert-dialog { width: min(calc(100% - 40px), 390px); margin: auto; border-radius: 25px; }
.alert-panel { padding: 26px 24px 22px; text-align: center; }
.alert-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 15px; border-radius: 18px; color: var(--forest); background: #e5ece5; font-size: 25px; font-weight: 900; }
.alert-panel p { margin: 9px 0 20px; color: var(--muted); line-height: 1.45; }
.alert-panel .primary-button { width: 100%; }

@media (min-width: 681px) {
  body { background: #e7e3d9; }
  .app-shell { background: var(--cream); box-shadow: 0 0 70px rgba(20,40,30,.13); }
  .sheet { margin-bottom: 18px; border-radius: 28px; }
}

@media (max-width: 390px) {
  .quick-add-button { padding: 0 12px; }
  .camera-actions { flex-wrap: wrap; }
  .camera-actions .primary-button, .camera-actions .photo-button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
