:root {
  /* v38 Stuff Valet brand. Change the brand color here (and the app icon). */
  --brand: #9A3F22; --brand-dark: #7A311A; --brand-soft: #F6D9B8; --brand-tint: #FBEDE3;
  --bg: #F6F4EF; --panel: #FFFFFF; --border: #E6E2D9; --text: #1D1C1A; --muted: #6B675F;
  --accent: var(--brand); --danger: #B42318; --radius: 14px;
  --ai: #6E4BB5; --ai-soft: #EFE9F8;
  --shadow: 0 1px 2px rgba(29,28,26,.06), 0 1px 1px rgba(29,28,26,.04);
  --font: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.screen { display: none; min-height: 100vh; padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.screen.active { display: block; }

/* Login */
#login-screen { align-items: center; justify-content: center; min-height: 100vh; }
#login-screen.active { display: flex; }
.login-box { width: 100%; max-width: 320px; }
.login-box h1 { text-align: center; margin-bottom: 24px; }
.login-box input { width: 100%; padding: 14px; margin-bottom: 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.login-box button { width: 100%; padding: 14px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 600; }
.login-error { color: var(--danger); text-align: center; min-height: 20px; margin-bottom: 8px; }

/* Nav */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel); border-top: 1px solid var(--border); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; padding: 14px 0; background: none; border: none; color: var(--muted); font-size: 13px; }
.tabbar button.active { color: var(--accent); }

/* Capture */
.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
select, .text-input { width: 100%; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#capture-photo-input { display: none; }
.photo-picker-btn { display: block; width: 100%; padding: 40px 0; text-align: center; border-radius: var(--radius); border: 2px dashed var(--border); background: var(--panel); color: var(--muted); margin-bottom: 14px; }
.photo-preview { width: 100%; border-radius: var(--radius); margin-bottom: 14px; display: none; }
#save-capture-btn { width: 100%; padding: 16px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; margin-bottom: 14px; }
#save-capture-btn:disabled { opacity: 0.5; }
textarea.text-input { min-height: 70px; resize: vertical; }
.queue-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 6px; }

/* Grid */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--panel); }
.grid .cell { position: relative; }
.empty-state { text-align: center; color: var(--muted); margin-top: 60px; }

/* Swipe / full-screen viewer */
#viewer { position: fixed; inset: 0; background: #000; z-index: 50; display: none; flex-direction: column; }
#viewer.active { display: flex; }
#viewer-imgwrap { flex: 1; position: relative; overflow: hidden; touch-action: pan-y; }
#viewer-imgwrap img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); color: #fff; }
.viewer-bar button { background: none; border: none; color: #fff; font-size: 15px; padding: 10px 14px; min-width: 44px; min-height: 44px; }
.viewer-caption { color: #ccc; text-align: center; padding: 0 16px 16px; font-size: 14px; }

/* Detail / edit sheet */
#detail-sheet { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
#detail-sheet.active { display: block; }
#detail-sheet img { width: 100%; border-radius: var(--radius); margin-bottom: 14px; }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; }
.detail-actions button { flex: 1; padding: 14px; border-radius: var(--radius); border: none; font-weight: 600; }
#detail-save-btn { background: var(--accent); color: #fff; }
.close-btn { background: none; border: none; color: var(--muted); font-size: 15px; padding: 12px 16px 16px 0; min-height: 44px; }

/* Retire / restore / history */
.detail-actions.hidden { display: none; }
#detail-retire-btn { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
#detail-delete-btn.hidden { display: none; }
.danger-link { display: block; width: 100%; background: none; border: none; color: var(--danger); font-size: 14px; padding: 14px; margin-top: 4px; text-align: center; }
#detail-history { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }
.retire-panel { display: none; }
.retire-panel.active { display: block; }
#retire-confirm-btn { background: var(--accent); color: #fff; }
#retire-cancel-btn { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.grid .cell.retired img { opacity: .45; }


/* Utility */
.hidden { display: none !important; }

/* Home: Categories / Locations toggle + icon grid */
.home-toggle { display: flex; gap: 8px; margin-bottom: 18px; }
.toggle-btn { flex: 1; padding: 12px 0; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); color: var(--muted); font-weight: 600; }
.toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }

.app-footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  text-align: center; font-size: 12px; color: var(--text);
  background: var(--bg); border-top: 1px solid var(--border);
}
.app-footer strong { color: var(--text); }

.settings-btn {
  flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-size: 18px; line-height: 1;
}

/* Settings screen -- fixed overlay, same pattern as capture-screen/detail-sheet */
#settings-screen { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); }
#settings-screen.active { display: block; }
#settings-screen h2 { margin-top: 8px; }
.icon-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px 6px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); }
.icon-tile .icon { font-size: 32px; line-height: 1; }
.icon-tile .label { font-size: 13px; text-align: center; }

/* Grid screen header */
.grid-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.grid-title { font-weight: 700; font-size: 17px; }

/* Floating add button */
.fab { position: fixed; right: 18px; bottom: calc(24px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,0.4); z-index: 15; }

/* Capture sheet -- a fixed overlay now, opened from either tree, not a tab */
#capture-screen { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
#capture-screen.active { display: block; }

/* Detail sheet: side-by-side room/spot */
.location-row { display: flex; gap: 8px; }
.location-row select { flex: 1; }

/* v15: automatic photo analysis markers (detail sheet) */
.ai-status { font-size: 13px; color: var(--muted); margin: -4px 0 12px; min-height: 0; }
.ai-status:empty { display: none; }
.field-group.ai-filled .text-input { border-color: var(--ai); box-shadow: inset 3px 0 0 var(--ai); }
.ai-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--ai); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; vertical-align: 1px; }
.ai-suggest { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding: 8px 10px; border-radius: var(--radius); border: 1px dashed var(--ai); font-size: 13px; color: var(--text); }
.ai-suggest.hidden { display: none; }
.ai-suggest button { padding: 6px 14px; border-radius: 999px; border: none; background: var(--ai); color: #fff; font-weight: 700; }

/* v16: needs-review banner/chip, replace photo */
.review-banner { display: block; width: 100%; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); border: 1px dashed var(--ai); background: var(--ai-soft); color: var(--text); font-size: 14px; text-align: left; }
.chip.review-chip { border-color: var(--ai); color: var(--ai); }
.chip.review-chip.active { background: var(--ai); border-color: var(--ai); color: #fff; }
#detail-photo-input { display: none; }
.replace-photo-row { display: flex; align-items: center; gap: 10px; margin: -6px 0 14px; }
.replace-photo-btn { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; }
.detail-photo-status { font-size: 13px; color: var(--muted); }

/* v17: Ask Stuff */
#ask-screen { position: fixed; inset: 0; background: var(--bg); z-index: 45; display: none; flex-direction: column; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
#ask-screen.active { display: flex; }
.ask-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ask-header h2 { margin: 0; font-size: 18px; }
.ask-header .close-btn { padding-bottom: 12px; }
.ask-clear { background: none; border: none; color: var(--muted); font-size: 14px; padding: 8px; }
.ask-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.ask-q { align-self: flex-end; max-width: 85%; background: var(--accent); color: #fff; padding: 9px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.ask-a { align-self: flex-start; max-width: 92%; background: var(--panel); border: 1px solid var(--border); padding: 9px 12px; border-radius: 14px 14px 14px 4px; white-space: pre-wrap; line-height: 1.4; }
.ask-a.pending { color: var(--muted); font-style: italic; }
.ask-a.error { color: var(--muted); }
.ask-thumbs { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
.ask-thumbs img { width: 64px; height: 64px; flex: 0 0 64px; object-fit: cover; border-radius: 8px; background: var(--panel); }
.ask-hint { color: var(--muted); font-size: 13px; line-height: 1.5; padding: 8px 2px; }
.ask-form { display: flex; gap: 8px; padding-top: 8px; }
.ask-form .text-input { flex: 1; margin: 0; }
#ask-send { padding: 0 18px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 600; }
#ask-send:disabled { opacity: .5; }
#detail-ai-fix .ai-suggest { margin-top: 8px; }

/* v18: Ask Stuff rules */
.settings-help { font-size: 13px; color: var(--muted); margin: 2px 0 8px; line-height: 1.4; }
.ask-rules { width: 100%; min-height: 160px; font-family: inherit; font-size: 15px; line-height: 1.45; resize: vertical; }
.ask-rules-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
#ask-rules-save, #person-add-btn { padding: 10px 18px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 600; }
.ask-rule { align-self: flex-start; max-width: 92%; font-size: 13px; color: var(--muted); padding: 2px 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ask-rule strong { color: var(--text); }
.ask-rule button { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--ai); background: transparent; color: var(--ai); font-size: 13px; }
.ask-rule button[data-save] { background: var(--ai); color: #fff; font-weight: 700; }
.stars { display: flex; gap: 4px; }
.star { background: none; border: none; cursor: pointer; padding: 2px 4px; font-size: 30px; line-height: 1; color: var(--border); }
.star.on { color: #eab308; }

/* v21: AI estimated value note under the EstValue field */
.value-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.value-note:empty { display: none; }
.value-note .value-tag { padding: 2px 8px; border-radius: 999px; background: var(--ai); color: #fff; font-weight: 700; }
.value-note button { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--ai); background: transparent; color: var(--text); font-size: 12px; }

/* v22: insurance report */
#report-screen { position: fixed; inset: 0; background: var(--bg); z-index: 58; display: none; overflow-y: auto; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); padding-bottom: 60px; }
#report-screen.active { display: block; }
.report-open { width: 100%; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 16px; }
.rp-bar select { width: 100%; margin: 8px 0 0; }
.rp-bar select + select { margin-top: 6px; }
.rp-actions { margin-top: 8px; }
.rp-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.rp-actions button { flex: 1; padding: 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--accent); color: #fff; }
.rp-head { margin-bottom: 14px; }
.rp-total { font-size: 18px; font-weight: 600; }
.rp-sub { font-size: 13px; opacity: .75; }
.rp-room h3 { margin: 18px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.rp-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); break-inside: avoid; cursor: pointer; }
.rp-item img, .rp-noimg { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; background: var(--panel); }
.rp-main { flex: 1; min-width: 0; }
.rp-name { font-weight: 600; }
.rp-val { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; order: 3; }
.rp-tag { font-size: 11px; opacity: .75; }
.rp-tag.ai { color: #b06a00; opacity: 1; }
.rp-none { font-size: 13px; opacity: .6; }
.rp-roomtotal { text-align: right; padding: 8px 0; }
.rp-grand { text-align: right; font-size: 18px; padding: 14px 0; border-top: 2px solid var(--border); margin-top: 10px; }
.evidence-note { margin-top: 16px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--panel); }
.evidence-note p { margin: 6px 0 0; }
#report-missing { margin-top: 24px; }
.rp-mlabel { font-weight: 600; margin: 12px 0 4px; }
.rp-mitem { display: inline-block; margin: 0 6px 6px 0; padding: 6px 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel); color: var(--text); }
.print-only { display: none; }
/* v45: quantity + purchase date side by side; insurance report cover page */
.field-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.field-row input[type="date"] { min-height: 46px; -webkit-appearance: none; appearance: none; }
.rp-cover-edit { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.rp-cover-edit summary { font-weight: 600; cursor: pointer; }
.rp-cover-edit .rp-sub { margin: 6px 0 10px; display: block; }
.rp-cover { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 2px solid var(--border); }
.rp-cover h1 { margin: 0 0 2px; font-size: 22px; }
.rp-cover-row { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.rp-cover-label { flex: 0 0 38%; font-size: 13px; opacity: .75; }
.rp-cover-val { flex: 1; min-width: 0; overflow-wrap: anywhere; }

@media print {
  html, body { background: #fff !important; }
  body > *:not(#report-screen) { display: none !important; }
  #report-screen { position: static !important; display: block !important; overflow: visible; background: #fff !important; color: #000; padding: 0; }
  .no-print { display: none !important; }
  .print-only { display: block; }
  .rp-item { cursor: default; }
  /* The cover is its own first page. */
  .rp-cover { break-after: page; page-break-after: always; border: 0; padding-top: 1in; }
  .rp-cover h1 { font-size: 28px; }
  .rp-cover-row { padding: 12px 0; border-bottom: 1px solid #999; }
  /* Never split an item (photo + details + value) across two pages, and keep
     a room's heading with its first item. Block, not flex: Safari ignores
     break-inside on flex items when printing. */
  .rp-item { display: block; overflow: hidden; break-inside: avoid; page-break-inside: avoid; padding: 10px 0; }
  .rp-item img, .rp-item .rp-noimg { float: left; width: 1.1in; height: 1.1in; margin-right: 12px; }
  .rp-item .rp-val { float: right; margin-left: 12px; }
  .rp-item .rp-main { overflow: hidden; }
  .rp-room h3 { break-after: avoid; page-break-after: avoid; }
  .rp-roomtotal, .rp-grand, .evidence-note { break-inside: avoid; page-break-inside: avoid; }
}

/* v23: owners */
.person-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.person-x { background: none; border: 0; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.ask-rules-row .text-input { flex: 1; }

/* v24: proof photos */
#proof-input { display: none; }
.proof-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.proof-thumb { width: 84px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 4px; color: var(--muted); font-size: 11px; }
.proof-thumb img { width: 100%; height: 64px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 2px; }
.proof-add-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.proof-add-row select { flex: 1; }
#proof-lightbox { position: fixed; inset: 0; background: #000; z-index: 70; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; }
#proof-lightbox.active { display: flex; }
#proof-lightbox img { max-width: 100%; max-height: 72vh; object-fit: contain; }
.proof-lightbox-actions { display: flex; gap: 12px; }
.proof-lightbox-actions button { padding: 10px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); color: var(--text); }
.proof-lightbox-actions .danger-link { color: #ff6b6b; }

/* v25: receipt suggestion */
.proof-suggest { margin: 8px 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); font-size: 14px; }
.proof-suggest-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.proof-use { padding: 8px 14px; border-radius: var(--radius); border: none; background: var(--accent); color: #fff; font-weight: 600; }
.proof-link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; }

/* v27: inline "add new category" box (name + which group to file it under) */
.newbox { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.newbox-label { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
#detail-room-new, #detail-spot-new { margin-top: 8px; }

/* v27: small confirmation after a move / new category is filed */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  max-width: 90vw; padding: 10px 16px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 9999;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* v28: add buttons, manage screen, dialog */
.new-btn { display: block; width: 100%; margin-top: 14px; padding: 12px; border-radius: var(--radius); border: 1px dashed var(--border); background: transparent; color: var(--accent); font-weight: 600; }
.add-chip { color: var(--accent); border-style: dashed; margin-bottom: 8px; }
#manage-screen { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); }
#manage-screen.active { display: block; }
#manage-screen h2 { margin-top: 8px; }
.mg-head, .mg-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mg-head { margin-top: 18px; padding: 8px 0; border-bottom: 1px solid var(--border); font-weight: 700; }
.mg-head .mg-name { flex: 1; min-width: 40%; }
.mg-row { padding: 8px 0 8px 14px; border-bottom: 1px solid var(--border); }
.mg-row .mg-name { flex: 1; min-width: 40%; }
.mg-sub { padding: 8px 0 0 14px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.mg-count { color: var(--muted); font-size: 12px; }
.mg-btn { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; }
.mg-btn.danger { color: var(--danger); }
.mg-note { color: var(--muted); font-size: 12px; }
.dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.dialog-overlay.active { display: flex; }
.dialog-box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.dialog-box h3 { margin: 0 0 8px; }
.dialog-box .field-group { margin-bottom: 10px; }
.dialog-box .detail-actions { margin-top: 12px; }
#dialog-cancel { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.mg-actions { display: flex; gap: 6px; flex: 1 0 100%; justify-content: flex-end; margin-bottom: 2px; }
.mg-head .mg-name, .mg-row .mg-name { min-width: 0; }

/* v29: Settings is a menu; each row opens its own screen */
.settings-sub { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: none; overflow-y: auto; padding: 12px; padding-top: max(24px, calc(env(safe-area-inset-top) + 14px)); }
.settings-sub.active { display: block; }
.settings-sub h2 { margin-top: 8px; }
.menu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.menu-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); color: var(--text); }
.menu-btn:disabled { opacity: .6; cursor: default; }
.menu-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.menu-title { font-size: 17px; font-weight: 600; }
.menu-sub { font-size: 13px; color: var(--muted); }
.menu-chev { font-size: 26px; color: var(--muted); line-height: 1; }
.menu-soon { font-size: 12px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }

/* v30: talk to the butler */
.ask-mic { flex: 0 0 48px; width: 48px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel); font-size: 20px; padding: 0; }
.ask-mic.listening { background: var(--danger); border-color: var(--danger); animation: mic-pulse 1.1s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(180,35,24,.45); } 50% { box-shadow: 0 0 0 10px rgba(180,35,24,0); } }
.ask-speak { font-size: 18px; }
.ask-say { align-self: flex-start; background: none; border: none; color: var(--muted); font-size: 16px; padding: 2px 6px; margin-top: -4px; }
.ask-mic.unsupported { opacity: .45; }
/* v33: conversation mode -- steady red ring between turns, pulsing while listening */
.ask-mic.conv { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(180,35,24,.3); }

/* v31: natural (cloud) voice toggle */
.field-group label.check-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; font-size: 16px; color: var(--text); }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }

/* v32: natural voice picker */
#cloud-voice-pick { margin-top: 12px; }
.voice-pick-row { display: flex; gap: 8px; align-items: stretch; }
.voice-pick-row select { flex: 1; min-width: 0; }
.voice-play-btn { padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 15px; }

/* v33.3: voice log (troubleshooting) */
.voice-log { margin-top: 16px; }
.voice-log summary { color: var(--muted); font-size: 14px; cursor: pointer; }
.voice-log pre { max-height: 260px; overflow: auto; font-size: 10.5px; line-height: 1.35; white-space: pre-wrap; word-break: break-all; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 8px; -webkit-user-select: text; user-select: text; }

/* v35: more photos of an item */
#view-input, #capture-more-input { display: none; }
.view-thumb { width: 76px; }
.view-thumb img { height: 68px; margin: 0; }
.capture-more { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.capture-more-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.capture-more-thumb { position: relative; width: 56px; height: 56px; }
.capture-more-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; display: block; }
.capture-more-thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.7); color: #fff; font-size: 14px; line-height: 22px; padding: 0; }
.capture-more-btn { display: inline-block; padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text); font-size: 15px; }

/* v35: photos and outfits in Ask Stuff answers */
.ask-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 6px; width: 100%; }
.ask-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0; overflow: hidden; text-align: left; color: var(--text); }
.ask-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.ask-card-name { display: block; padding: 6px 8px 0; font-size: 13px; }
.ask-card-where { display: block; padding: 0 8px 6px; font-size: 11px; color: var(--muted); }
.ask-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; width: 100%; }
.ask-grid .ask-pic { padding: 0; border: none; background: none; }
.ask-grid img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; display: block; background: var(--panel); }
.ask-outfits { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; margin-top: 6px; padding-bottom: 4px; width: 100%; }
.outfit-card { flex: 0 0 88%; scroll-snap-align: start; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; box-sizing: border-box; }
.outfit-card:only-child { flex-basis: 100%; }
.outfit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.outfit-head span { color: var(--muted); font-size: 12px; }
.outfit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.outfit-piece { padding: 0; border: none; background: none; text-align: left; color: var(--text); }
.outfit-piece img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; display: block; }
.outfit-nophoto { width: 100%; aspect-ratio: 1 / 1; border-radius: 8px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); color: var(--muted); font-size: 12px; box-sizing: border-box; }
.outfit-role { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.outfit-name { display: block; font-size: 13px; }
.outfit-hint { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* v36: weather line under an answer */
.ask-weather { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* v37: photos in Ask Stuff */
.ask-plus { font-size: 26px; line-height: 1; color: var(--text); }
.ask-attach { display: flex; align-items: center; gap: 10px; padding: 8px 0 0; font-size: 13px; color: var(--muted, #888); }
.ask-attach.hidden { display: none; }
.ask-attach img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.ask-attach span { flex: 1; }
.ask-attach-x { flex: 0 0 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 0; }
.ask-q-photo { padding: 4px; }
.ask-q-img { display: block; width: 180px; max-width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 11px; cursor: zoom-in; }
.ask-q-img.big { width: 100%; aspect-ratio: auto; object-fit: contain; cursor: zoom-out; }
.ask-q-photo .ask-q-text { display: block; padding: 6px 8px 4px; }
.outfit-piece.from-photo img { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* =====================================================================
   v38 -- Stuff Valet look: warm off-white, terracotta header band,
   Manrope, line icons, bottom tab bar. Overrides the older rules above.
   ===================================================================== */
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; display: block; }
h1, h2, h3 { letter-spacing: -0.3px; }
.screen { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
select, .text-input { background: var(--panel); border-color: var(--border); }
select:focus, .text-input:focus, input:focus { outline: 2px solid var(--brand-soft); outline-offset: 0; border-color: var(--brand); }
.close-btn { color: var(--brand); font-weight: 700; }

/* Login */
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-brand h1 { margin: 0; font-size: 30px; font-weight: 800; }
.login-brand em, .brand-name em { font-style: normal; color: var(--brand); }
.login-brand .brand-mark { width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: var(--brand-soft); display: grid; place-items: center; }
.login-brand .brand-mark .ic { width: 34px; height: 34px; stroke-width: 2; }
.login-box input { background: var(--panel); }
.login-box button { background: var(--brand); border-radius: var(--radius); font-weight: 700; }

/* Home: header band */
#home-screen { padding: 0; padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.home-band { background: var(--brand); color: #fff; padding: max(14px, calc(env(safe-area-inset-top) + 8px)) 16px 16px; border-radius: 0 0 24px 24px; display: flex; flex-direction: column; gap: 12px; }
.band-top { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark .ic { width: 24px; height: 24px; stroke: var(--brand-soft); stroke-width: 2; }
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -0.5px; }
.home-band .brand-name em { color: var(--brand-soft); font-weight: 600; }
.search-bar { display: flex; align-items: center; gap: 8px; background: #fff; color: var(--text); border-radius: 14px; height: 50px; padding: 0 4px 0 14px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.search-bar input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 16px; color: var(--text); padding: 0; height: 100%; }
.search-bar input:focus { outline: none; }
.search-bar input::-webkit-search-cancel-button { display: none; }
.sb-btn { width: 44px; height: 44px; border: none; background: none; color: var(--text); display: grid; place-items: center; padding: 0; border-radius: 10px; }
.sb-btn:active { background: var(--bg); }
.band-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.band-chips::-webkit-scrollbar { display: none; }
.band-chip { flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 18px; border: none; background: rgba(255,255,255,.16); color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; }
.band-chip:active { background: rgba(255,255,255,.28); }

.home-body { padding: 16px 16px 0; display: flex; flex-direction: column; gap: 20px; }
.home-sec { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; }
.sec-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.recent-row { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; scroll-padding-left: 16px; scroll-snap-type: x proximity; }
.recent-row::-webkit-scrollbar { display: none; }
.recent-card { flex: 0 0 128px; border: none; background: none; padding: 0; text-align: left; color: var(--text); display: flex; flex-direction: column; gap: 5px; }
.recent-card img { width: 128px; height: 128px; object-fit: cover; border-radius: 14px; background: var(--border); display: block; }
.recent-name { font-size: 14px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recent-where { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seg { background: #ECE8DF; border-radius: 12px; padding: 4px; gap: 4px; margin: 0; }
.seg .toggle-btn { border: none; background: transparent; color: var(--muted); padding: 9px 0; border-radius: 9px; font-weight: 700; font-size: 14px; }
.seg .toggle-btn.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.icon-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.icon-tile { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px; border: none; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; color: var(--text); }
.tile-img { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 10px; background: var(--brand-tint) center / cover no-repeat; display: grid; place-items: center; color: var(--brand); font-weight: 800; font-size: 20px; }
.tile-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.icon-tile .label { font-size: 15px; font-weight: 700; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-count { font-size: 12px; color: var(--muted); }
.new-btn { margin-top: 0; border: 1.5px solid var(--border); border-style: solid; color: var(--brand); background: transparent; font-weight: 700; border-radius: var(--radius); }

.ask-row { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: var(--brand-tint); color: var(--brand-dark); border-radius: var(--radius); padding: 12px 14px; font-weight: 700; text-align: left; }
.ask-row .ic { color: var(--brand); }
.review-banner { margin: 0; border-color: var(--ai); color: var(--text); }
#home-search-results.grid { gap: 8px; }
.grid img { border-radius: 10px; background: var(--border); }

/* Bottom tab bar */
.tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--border); padding: 6px 4px env(safe-area-inset-bottom); }
body.signed-in .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 8px; border: none; background: none; color: var(--muted); font-size: 11px; font-weight: 600; min-height: 52px; }
.tab .ic { width: 24px; height: 24px; }
.tab.active { color: var(--brand); font-weight: 800; }
.tab-add { justify-content: flex-start; }
.tab-add-circle { width: 56px; height: 56px; margin-top: -24px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(154,63,34,.35); }
.tab-add-circle .ic { width: 26px; height: 26px; stroke-width: 2; }
.fab { display: none !important; }
.app-footer { position: static; margin-top: 28px; background: none; border: none; color: var(--muted); padding: 10px 0; }
.app-footer strong { color: var(--muted); }

/* Grid screen */
.grid-header { margin-bottom: 8px; }
.grid-title { font-size: 20px; font-weight: 800; }
.chip { background: var(--panel); border-color: var(--border); color: var(--text); font-weight: 600; padding: 7px 13px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Sheets */
#capture-screen, #detail-sheet, #settings-screen, .settings-sub, #manage-screen, #report-screen { background: var(--bg); }
#detail-sheet img#detail-img { border-radius: 18px; box-shadow: var(--shadow); }
.field-group label { font-weight: 600; color: var(--muted); }
#detail-save-btn, #retire-confirm-btn, #save-capture-btn, .rp-actions button, #ask-rules-save, #person-add-btn, .proof-use { background: var(--brand); }
#detail-retire-btn, #retire-cancel-btn { background: var(--panel); }
.photo-picker-btn { background: var(--panel); border-color: #D6CFC2; color: var(--muted); font-weight: 600; }
.menu-btn { border: none; box-shadow: var(--shadow); }
.dialog-overlay { background: rgba(29,28,26,.45); }
.dialog-box { border: none; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast { background: var(--text); }

/* Ask -> Your Valet */
#ask-screen { padding: 0; padding-bottom: env(safe-area-inset-bottom); }
.ask-header { padding: max(12px, calc(env(safe-area-inset-top) + 6px)) 8px 10px; gap: 4px; border-bottom: 1px solid var(--border); background: var(--bg); justify-content: flex-start; }
.icon-btn { width: 44px; height: 44px; border: none; background: none; color: var(--text); display: grid; place-items: center; padding: 0; border-radius: 12px; flex: 0 0 auto; }
.valet-badge { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-soft); display: grid; place-items: center; flex: 0 0 auto; }
.valet-badge .ic { width: 18px; height: 18px; stroke-width: 2; }
.ask-title { flex: 1; display: flex; flex-direction: column; margin-left: 6px; min-width: 0; }
.ask-title h2 { margin: 0; font-size: 16px; font-weight: 800; }
.ask-sub { font-size: 12px; color: var(--muted); }
.ask-clear { color: var(--brand); font-weight: 700; font-size: 15px; padding: 10px; }
.ask-log { padding: 14px 16px; gap: 10px; }
.ask-hint { padding: 8px 16px; }
.ask-q { background: var(--brand); border-radius: 18px 18px 6px 18px; padding: 9px 13px; }
.ask-a { background: var(--panel); border: none; box-shadow: var(--shadow); border-radius: 18px 18px 18px 6px; padding: 11px 14px; }
.ask-say { color: var(--muted); padding: 4px 6px; }
.ask-say .ic { width: 18px; height: 18px; }
.ask-card, .outfit-card { border: none; box-shadow: var(--shadow); }
.ask-attach { padding: 8px 16px 0; }
.ask-form { align-items: center; gap: 8px; padding: 10px 12px 12px; background: var(--panel); border-top: 1px solid var(--border); }
.round-btn { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; border: none; display: grid; place-items: center; padding: 0; }
.ask-plus { background: #EFEBE2; color: var(--text); }
.send-btn, #ask-send { background: var(--brand); color: #fff; padding: 0; border-radius: 50%; }
.send-btn .ic { stroke-width: 2.2; }
.ask-field { flex: 1; min-width: 0; display: flex; align-items: center; height: 44px; border-radius: 22px; background: var(--bg); padding: 0 4px 0 16px; }
.ask-field input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 16px; color: var(--text); padding: 0; }
.ask-field input:focus { outline: none; }
.ask-mic { flex: 0 0 36px; width: 36px; height: 36px; border: none; background: none; color: var(--text); display: grid; place-items: center; border-radius: 50%; }
.ask-mic .ic { width: 20px; height: 20px; }
.ask-mic.listening { background: var(--danger); color: #fff; }
.ask-attach-x { color: var(--text); }
.outfit-piece.from-photo img { outline-color: var(--brand); }

/* v38: item read view (detail sheet) */
#detail-sheet { padding: 0; padding-bottom: 0; }
.dv-hero { position: relative; background: var(--border); }
#detail-sheet .dv-hero img { width: 100%; height: min(62vh, 420px); object-fit: cover; border-radius: 0; margin: 0; display: block; box-shadow: none; }
.hero-btn { position: absolute; top: max(14px, calc(env(safe-area-inset-top) + 8px)); left: 14px; width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,.92); color: var(--text); display: grid; place-items: center; padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.dv-body { position: relative; margin-top: -20px; background: var(--bg); border-radius: 22px 22px 0 0; padding: 22px 16px 24px; }
#detail-view { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
#detail-view.hidden { display: none; }
.dv-cat { font-size: 13px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .6px; }
.dv-name { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.5px; }
.dv-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); }
.dv-meta .ic { width: 16px; height: 16px; stroke-width: 2; }
.dv-sep { color: #C9C3B6; }
.dv-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.dv-facts:empty { display: none; }
.dv-fact { background: var(--panel); border-radius: 14px; padding: 11px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); min-width: 0; }
.dv-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.dv-value { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.dv-ai { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--ai-soft); color: var(--ai); font-size: 11px; font-weight: 700; vertical-align: 1px; }
.dv-notes { margin: 6px 0 0; font-size: 15px; line-height: 1.5; color: #4A4740; white-space: pre-wrap; }
#detail-history { margin: 0 0 12px; }
#detail-history:empty { display: none; }
.dv-edit-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.dv-edit-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.link-btn { background: none; border: none; color: var(--brand); font-weight: 700; font-size: 15px; padding: 10px 4px; }
.replace-photo-row { margin: 0 0 14px; }
.dv-bar { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--border); }
.dv-bar.hidden { display: none; }
.btn-outline, .btn-primary { flex: 1; height: 50px; border-radius: 14px; font-size: 16px; font-weight: 700; }
.btn-outline { border: 1.5px solid var(--brand); background: var(--panel); color: var(--brand); }
.btn-primary { flex: 1.4; border: none; background: var(--brand); color: #fff; }
#detail-sheet.editing .dv-body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
#detail-sheet img#detail-img { width: 100%; height: min(62vh, 420px); object-fit: cover; border-radius: 0; margin: 0; box-shadow: none; }
/* v38: every two-way toggle is a segmented control */
.home-toggle { background: #ECE8DF; border-radius: 12px; padding: 4px; gap: 4px; }
.home-toggle .toggle-btn { border: none; background: transparent; color: var(--muted); padding: 10px 0; border-radius: 9px; font-weight: 700; font-size: 15px; }
.home-toggle .toggle-btn.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.settings-sub h2, #settings-screen h2, #manage-screen h2 { font-size: 26px; font-weight: 800; }

