:root {
  --page-bg: #edf1e8;
  --bg: #fbfcf8;
  --surface: #ffffff;
  --surface-soft: #f5f7f2;
  --border: #e4e8df;
  --primary: #16813c;
  --primary-dark: #0b672e;
  --primary-soft: #eaf5e9;
  --text: #131814;
  --muted: #5b665d;
  --gold: #f5b91e;
  --danger: #b42318;
  --shell-width: 390px;
  --safe-top: 17px;
  --bottom-nav-height: 66px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { background: #eef2ea; }
body { margin: 0; color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
.back-to-hub { display: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.prototype-stage { background: radial-gradient(circle at 50% 8%, #fbfdf7, #e3e9df 72%); }
.device-shell { border: 8px solid #111; box-shadow: 0 18px 45px rgba(24,40,25,.24); }
.app-surface, .screen { background: var(--bg); }
.screen-scroll { padding: 0 14px calc(var(--bottom-nav-height) + 8px); overflow-y: auto; overflow-x: hidden; }
.screen.route-enter .screen-scroll { animation: route-in .18s ease-out; }
@keyframes route-in { from { opacity: .55; transform: translateX(5px); } to { opacity: 1; transform: none; } }

.topbar { min-height: 48px; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin: 0 -2px 4px; }
.topbar h1 { margin: 0; text-align: center; font-size: 15px; line-height: 1.2; font-weight: 680; }
.topbar .side { width: 44px; min-height: 44px; display: grid; place-items: center; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 12px; display: grid; place-items: center; color: #171b18; background: transparent; }
.icon { display: block; }

.greeting { padding: 5px 3px 9px; }
.eyebrow { color: #263128; font-size: 10.5px; font-weight: 650; }
.greeting h1 { margin: 2px 0 0; font-size: 19px; line-height: 1.15; font-weight: 735; }
.header-actions { display: flex; align-items: center; gap: 3px; }
.avatar { width: 37px; height: 37px; flex: 0 0 37px; display: grid; place-items: center; border-radius: 50%; border: 2px solid #e7dfd2; background: linear-gradient(145deg,#e3c2a2,#bb8c68); color: #fff; font-size: 10px; font-weight: 800; }

.hero { height: 132px; position: relative; overflow: hidden; padding: 14px 16px; border-radius: 13px; color: #fff; background: linear-gradient(110deg,#0a6e30 0%,#287e3e 62%,#7b9f57 100%); }
.hero small { display: block; margin-bottom: 7px; font-size: 9px; opacity: .92; }
.hero h2 { position: relative; z-index: 2; max-width: 170px; margin: 0 0 7px; font-size: 13px; font-weight: 620; }
.hero .metric { position: relative; z-index: 2; font-size: 36px; line-height: .95; font-weight: 760; }
.hero p { position: relative; z-index: 2; margin: 3px 0; font-size: 9.5px; }
.hero-plant { position: absolute; right: -9px; bottom: -15px; width: 158px; height: 148px; background-image: url("./assets/plant-grid.png"); background-size: 200% 300%; background-position: left top; border-radius: 70% 0 0 0; mix-blend-mode: screen; opacity: .85; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 10px 0 12px; }
.quick { min-width: 0; height: 74px; padding: 7px 2px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: #202821; font-size: 9px; line-height: 1.15; font-weight: 650; text-align: center; }
.quick .tile { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-size: 17px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 1px 6px; }
.section-head h2 { margin: 0; font-size: 12px; line-height: 1.2; font-weight: 740; }
.link-btn { min-height: 34px; padding: 6px 3px 6px 12px; border: 0; color: var(--primary-dark); background: transparent; font-size: 9.5px; font-weight: 700; }
.tip-head { margin-top: 8px; }
.list { display: grid; gap: 6px; }
.list-row { position: relative; width: 100%; min-height: 69px; padding: 6px 8px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: #fff; text-align: left; }
.recent-list .list-row { min-height: 65px; }
.row-copy { min-width: 0; flex: 1; }
.row-copy strong { display: block; font-size: 10.5px; line-height: 1.2; font-weight: 740; }
.row-copy span, .row-copy small { display: block; margin-top: 2px; color: var(--muted); font-size: 8.5px; line-height: 1.25; }
.match { color: var(--primary-dark)!important; font-weight: 720; }
.plant-art { flex: none; width: 60px; height: 54px; border-radius: 9px; background-image: url("./assets/plant-grid.png"); background-repeat: no-repeat; background-size: 200% 300%; background-color: #edf1e9; }
.plant-monstera { background-position: left top; }
.plant-snake { background-position: right top; }
.plant-peace-lily { background-position: left center; }
.plant-fiddle { background-position: right center; }
.plant-aglaonema { background-position: left bottom; }
.plant-calathea { background-position: right bottom; }
.tip { min-height: 52px; padding: 8px 10px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 11px; background: #fff; font-size: 9px; line-height: 1.35; }
.tip-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; background: #f4f5f0; }
.tip-sun { margin-left: auto; font-size: 16px; }

.bottom-nav { position: relative; z-index: 5; height: var(--bottom-nav-height); display: grid; grid-template-columns: repeat(5,1fr); padding: 5px 6px 7px; border-top: 1px solid #e1e6de; background: rgba(255,255,255,.98); }
.nav-btn { min-width: 0; min-height: 48px; padding: 3px 1px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; color: #697169; background: transparent; font-size: 8px; }
.nav-btn.active { color: var(--primary); font-weight: 720; }
.nav-btn.camera { width: 52px; height: 52px; min-height: 52px; margin: -12px auto 0; border: 4px solid #fff; border-radius: 50%; color: #fff; background: var(--primary); box-shadow: 0 0 0 1px #d8e4d8; }
.nav-btn.camera span { display: none; }

.camera-preview { position: relative; width: 100%; height: 406px; overflow: hidden; border-radius: 15px; background: url("./assets/monstera-closeup.png") center/cover no-repeat; }
.analysis-overlay { position: absolute; z-index: 4; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: #fff; background: rgba(6,45,22,.78); text-align: center; backdrop-filter: blur(2px); }
.analysis-overlay[hidden] { display: none; }
.analysis-overlay strong { font-size: 13px; }
.analysis-overlay small { font-size: 9px; opacity: .85; }
.analysis-spinner { width: 33px; height: 33px; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.scan-corner { position: absolute; width: 37px; height: 37px; border-color: #fff; border-style: solid; filter: drop-shadow(0 1px 2px rgba(0,0,0,.28)); }
.c1 { top: 22px; left: 19px; border-width: 3px 0 0 3px; border-radius: 12px 0 0; }
.c2 { top: 22px; right: 19px; border-width: 3px 3px 0 0; border-radius: 0 12px 0 0; }
.c3 { bottom: 22px; left: 19px; border-width: 0 0 3px 3px; border-radius: 0 0 0 12px; }
.c4 { right: 19px; bottom: 22px; border-width: 0 3px 3px 0; border-radius: 0 0 12px; }
.scan-note { margin: 13px 0 12px; color: #2a312b; text-align: center; font-size: 9.5px; line-height: 1.45; }
.camera-tools { display: flex; align-items: center; justify-content: center; gap: 38px; }
.tool-circle { width: 43px; height: 43px; border: 1px solid var(--border); border-radius: 50%; color: #283129; background: #fff; font-size: 17px; }
.shutter { width: 64px; height: 64px; padding: 5px; border: 2px solid var(--primary); border-radius: 50%; background: #fff; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--primary); }
.shutter:disabled, .tool-circle:disabled { cursor: wait; opacity: .55; }
.scan-options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 12px; opacity: 0; height: 1px; overflow: hidden; }
.scan-options label { font-size: 8px; }
.scan-options select { width: 100%; }

.result-card { min-height: 107px; padding: 9px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--border); border-radius: 13px; background: #f6f7f1; }
.result-card .plant-art { width: 102px; height: 90px; border-radius: 11px; }
.result-photo, .result-placeholder { flex: none; width: 102px; height: 90px; border-radius: 11px; background-position: center; background-size: cover; }
.result-placeholder { display: grid; place-items: center; background: #e9f3e6; font-size: 34px; }
.result-placeholder.small { width: 60px; height: 54px; border-radius: 9px; font-size: 22px; }
.result-card .row-copy strong { font-size: 11px; }
.result-card .row-copy span, .result-card .row-copy small { font-size: 8px; }
.match-pill { width: max-content; margin-top: 5px!important; padding: 3px 7px; border-radius: 99px; color: #fff!important; background: var(--primary); font-size: 7.5px!important; font-weight: 700; }
.stars { margin-top: 3px; color: var(--gold); font-size: 10px; letter-spacing: 1px; }
.care-list { margin-top: 10px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.care-row { min-height: 52px; padding: 7px 0; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; border-bottom: 1px solid #edf0ea; }
.care-row:last-child { border-bottom: 0; }
.care-symbol { font-size: 16px; text-align: center; }
.care-row b { display: block; font-size: 8.5px; }
.care-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 7.5px; }
.detail-link { width: 100%; min-height: 42px; margin-top: 8px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 10px; color: var(--primary-dark); background: var(--primary-soft); font-size: 9px; font-weight: 680; }
.about { margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 11px; background: #fff; }
.about h3 { margin: 0 0 5px; font-size: 10px; }
.about p { margin: 0; font-size: 8.5px; line-height: 1.45; }
.save-mini { width: 100%; min-height: 40px; margin-top: 8px; border: 0; border-radius: 10px; color: #fff; background: var(--primary); font-size: 9px; font-weight: 700; }

.filters { display: flex; gap: 7px; margin: 0 0 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.collection-filters { justify-content: space-between; }
.chip { min-height: 34px; padding: 0 15px; white-space: nowrap; border: 1px solid var(--border); border-radius: 99px; color: #2d352f; background: #fff; font-size: 8.5px; }
.chip.active { border-color: var(--primary); color: #fff; background: var(--primary); }
.collection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.plant-card { position: relative; min-width: 0; padding: 6px 6px 9px; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: #fff; text-align: left; }
.plant-card .plant-art { width: 100%; height: 143px; border-radius: 8px; }
.plant-card strong { display: block; max-width: calc(100% - 23px); margin-top: 7px; overflow: hidden; font-size: 9.5px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
.plant-card small { display: block; margin-top: 2px; color: var(--muted); font-size: 7.5px; }
.favorite { position: absolute; right: 9px; bottom: 13px; font-size: 17px; }

.searchbox { height: 44px; margin-bottom: 11px; padding: 0 12px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-soft); }
.searchbox input { width: 100%; height: 100%; margin-left: 7px; border: 0; outline: 0; background: transparent; }
.empty { padding: 31px 15px; border: 1px dashed #cbd6c8; border-radius: 15px; background: var(--surface-soft); text-align: center; }
.empty .big { font-size: 41px; }
.empty h2 { margin: 8px 0 4px; font-size: 15px; }
.empty p { color: var(--muted); font-size: 10px; line-height: 1.5; }
.primary-btn { min-height: 44px; padding: 0 17px; border: 0; border-radius: 11px; color: #fff; background: var(--primary); font-size: 10px; font-weight: 700; }
.form-card { padding: 12px; display: grid; gap: 10px; border: 1px solid var(--border); border-radius: 13px; background: #fff; }
.field label { display: block; margin-bottom: 5px; font-size: 9px; font-weight: 700; }
.field input, .field select { width: 100%; height: 44px; padding: 0 9px; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.reminder { padding: 9px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 11px; background: #fff; }
.reminder.done { opacity: .55; }
.reminder.done strong { text-decoration: line-through; }
.check { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.profile-card { padding: 19px; border: 1px solid var(--border); border-radius: 13px; background: #fff; text-align: center; }
.profile-card .avatar { width: 65px; height: 65px; margin: auto; font-size: 16px; }
.profile-card h2 { margin: 9px 0 2px; font-size: 16px; }
.profile-card p { margin: 0; color: var(--muted); font-size: 9px; }
.settings { margin-top: 10px; display: grid; gap: 7px; }
.source-badge { padding: 4px 7px; border-radius: 99px; color: var(--muted); background: var(--surface-soft); font-size: 8px; }
.source-badge.claude { width: max-content; margin: 0 0 5px!important; color: #0b672e!important; background: #ddf2df; font-weight: 760; }
.compact-list { margin: 0; padding-left: 16px; color: var(--muted); font-size: 8.5px; line-height: 1.45; }
.compact-list li + li { margin-top: 3px; }
.about.safety { border-color: #e5d7a5; background: #fffdf5; }
.diagnostic { grid-template-columns: 1fr 1fr; }
.diagnostic .field:last-of-type { grid-column: 1/-1; }
.toast { position: absolute; z-index: 30; left: 50%; bottom: 78px; max-width: 86%; padding: 9px 13px; transform: translateX(-50%); border-radius: 9px; color: #fff; background: #17341f; font-size: 9px; text-align: center; }

@media (max-width: 520px) {
  .device-shell { border: 0; }
  .back-to-hub { display: none; }
}
@media (prefers-reduced-motion: reduce) { .screen.route-enter .screen-scroll { animation: none; } }

/* ── VisionVix store integration: credits pill + exit-consent modal ── */
.credits-pill { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 12px; z-index: 60; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.95); box-shadow: 0 4px 14px rgba(19,24,20,.12); font-size: 11px; font-weight: 700; color: var(--text); }
.credits-pill .credits-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.exit-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(12,18,13,.55); }
.exit-card { width: min(320px, 90vw); padding: 22px 18px; border-radius: 16px; background: #fff; text-align: center; box-shadow: 0 18px 45px rgba(10,20,12,.3); }
.exit-mark { font-size: 34px; }
.exit-title { margin: 10px 0 6px; font-size: 16px; }
.exit-text { margin: 0 0 16px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.exit-actions { display: flex; gap: 9px; }
.exit-btn { flex: 1; min-height: 44px; border: 0; border-radius: 11px; font-size: 11px; font-weight: 700; }
.exit-btn-ghost { color: var(--text); background: var(--surface-soft); }
.exit-btn-danger { color: #fff; background: var(--primary-dark); }
#credits-pill[hidden], .exit-modal[hidden] { display: none !important; }

/* ── Low/empty-credits bottom sheet ── */
.credits-sheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center; padding: 0 12px calc(var(--bottom-nav-height) + 12px); background: rgba(12,18,13,.55); }
.credits-sheet-card { width: min(390px, 100%); padding: 14px 22px 18px; border-radius: 26px; background: #fff; text-align: center; box-shadow: 0 18px 45px rgba(10,20,12,.3); animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(26px); opacity: .5; } to { transform: none; opacity: 1; } }
.credits-sheet-handle { display: block; width: 42px; height: 5px; margin: 0 auto 18px; border-radius: 99px; background: #dfe3dc; }
.credits-sheet-icon { position: relative; width: 70px; height: 70px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: #fdf3d5; }
.credits-sheet-balance { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: #fff; font-size: 19px; font-weight: 800; }
.credits-sheet-warn { position: absolute; right: 1px; bottom: 3px; width: 21px; height: 18px; display: grid; place-items: end center; padding-bottom: 2px; background: var(--gold); clip-path: polygon(50% 0, 100% 100%, 0 100%); color: #fff; font-size: 10px; font-weight: 800; filter: drop-shadow(0 0 1.5px #fff); }
.credits-sheet-title { margin: 13px 0 8px; font-size: 17px; font-weight: 800; color: var(--text); }
.credits-sheet-text { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.credits-sheet-text strong { color: var(--primary-dark); font-weight: 800; }
.credits-add-btn { width: 100%; min-height: 48px; margin-top: 17px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 999px; background: var(--primary); color: #fff; font-size: 14px; font-weight: 700; }
.credits-add-plus { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: var(--primary); font-size: 15px; font-weight: 800; line-height: 1; }
.credits-or { display: flex; align-items: center; gap: 10px; margin: 13px 0 2px; color: var(--muted); font-size: 11px; }
.credits-or::before, .credits-or::after { content: ""; flex: 1; height: 1px; background: #e7eae3; }
.credits-later { min-height: 40px; border: 0; background: transparent; color: var(--primary-dark); font-size: 13px; font-weight: 700; }
#creditsModal[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .credits-sheet-card { animation: none; } }
