:root {
  --cream: #FBF6EE; --surface: #FFFDF9; --ink: #2A2420; --muted: #6B5F57; --line: #E9DFD2;
  --accent: #C64A2F; --accent-ink: #fff; --accent-soft: #FBE3DB;
  --ok: #1F6B5E; --ok-soft: #DDF0EA; --warn: #8A5300; --warn-soft: #FCEFD6; --danger: #A8321E;
  --radius: 20px; --radius-s: 12px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --focus: 0 0 0 3px #fff, 0 0 0 5px #1B4F9C;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.error { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.actions { display: flex; gap: .5rem; align-items: center; }
.actions.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: .7rem; }

/* Forms */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; min-height: 44px; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: .65rem .8rem; min-height: 44px; width: 100%; }
input[type=checkbox], input[type=radio] { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--accent); flex: none; }
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: #1B4F9C; }
fieldset { border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: .6rem .8rem; margin: 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }

/* Buttons */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #d6c8b7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: #EBC4BB; }
.btn.small { min-height: 36px; padding: .3rem .8rem; font-size: .875rem; }
.btn.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-text { font: inherit; background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: .5rem .2rem; min-height: 44px; text-align: left; }
.btn-text.small { min-height: 32px; font-size: .875rem; }
.btn-text.danger { color: var(--danger); }
.btn-text.on-dark { color: #FFC9B8; }
.icon-btn { font: inherit; font-size: 1.25rem; width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  border: none; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: rgba(0,0,0,.05); }
.chip { font: inherit; font-size: .875rem; font-weight: 500; min-height: 40px; padding: .35rem .9rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip[aria-pressed=true]::before { content: "✓ "; }
.select-chip { flex-direction: row; padding: 0 .3rem; }
.select-chip select { border: none; background: transparent; min-height: 36px; padding: .2rem .4rem; width: auto; }

/* Layout */
.shell { min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.page { max-width: 960px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.page-head { display: flex; align-items: center; gap: .5rem; margin: .5rem 0 1rem; }
.page-head h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 1rem 1.1rem; }
.notice { background: var(--accent-soft); border-radius: var(--radius-s); padding: .7rem .9rem; margin: 0; font-size: .925rem; }
.notice.warn { background: var(--warn-soft); }
.notice.ok { background: var(--ok-soft); }
.banner { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; padding: .6rem 1rem; font-size: .9rem; text-align: center; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--line); color: var(--ink); }
.badge.prio { background: var(--accent-soft); color: #8E2F1A; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.status { display: inline-block; font-size: .8rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px; background: var(--line); white-space: nowrap; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.mine { background: #DCE7FA; color: #1B4F9C; }
.status.taken { background: #ECE6DF; color: var(--muted); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.ok::before { content: "● "; } .status.mine::before { content: "★ "; } .status.taken::before { content: "✕ "; }

/* Tabs + FAB */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .6rem; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; min-height: 60px; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .tab-icon { background: var(--accent-soft); }
.tab-icon { font-size: 1.15rem; padding: .1rem 1rem; border-radius: 999px; }
.fab { position: fixed; right: 1rem; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 31; font: inherit; font-weight: 700; font-size: 1.05rem;
  background: var(--accent); color: #fff; border: none; border-radius: 18px; padding: 0 1.3rem; min-height: 56px; box-shadow: 0 6px 18px rgba(198, 74, 47, .35); cursor: pointer; }

/* Search & filters */
.search { flex-direction: row; }
.search input { border-radius: 999px; padding-left: 1rem; }
.search.wide { margin-bottom: 1rem; }
.filterbar { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .6rem; }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-panel { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }

/* Lists */
.list-cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.list-card { display: block; overflow: hidden; color: inherit; text-decoration: none; }
.list-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.list-card .img-fallback.list-cover { aspect-ratio: 16 / 9; }
.list-info { display: flex; flex-direction: column; padding: .8rem 1rem; }
.list-card.archived { opacity: .75; }

/* Item cards: masonry grid */
.masonry { list-style: none; padding: 0; margin: 0; columns: 2 170px; column-gap: .9rem; }
.masonry > li { break-inside: avoid; margin-bottom: .9rem; }
.item-card { overflow: hidden; }
.item-btn { all: unset; display: block; width: 100%; cursor: pointer; }
.item-btn:focus-visible { box-shadow: var(--focus); border-radius: var(--radius); }
.item-img { width: 100%; height: auto; max-height: 360px; object-fit: cover; background: #F1E9DD; }
.item-body { display: flex; flex-direction: column; gap: .3rem; padding: .7rem .85rem .85rem; align-items: flex-start; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.img-fallback { display: flex; align-items: center; justify-content: center; background: #F1E9DD; font-size: 1.6rem; }
.price { font-size: .9rem; }
.price strong { font-size: 1rem; }
.price-label { color: var(--muted); font-size: .8rem; }
.price.unknown .price-label { font-style: italic; }
.price-detail { color: var(--muted); font-size: .8rem; }

/* Compact rows */
.rows { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.row-card { background: var(--surface); border-radius: var(--radius-s); box-shadow: var(--shadow); }
.row-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: .8rem; width: 100%; padding: .6rem .8rem; cursor: pointer; min-height: 60px; color: inherit; text-decoration: none; }
.row-btn.static { cursor: default; }
.row-btn:focus-visible { box-shadow: var(--focus); border-radius: var(--radius-s); }
.thumb { width: 52px; height: 52px; flex: none; border-radius: 10px; object-fit: cover; font-size: 1.2rem; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; align-items: flex-start; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-price { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; max-width: 40%; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: #8E2F1A; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.received { margin-top: 1.5rem; }

/* Dialogs / bottom sheets */
dialog.sheet { border: none; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, 100vw); max-width: 100vw; max-height: 92vh; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.sheet.wide { width: min(680px, 100vw); }
dialog::backdrop { background: rgba(42, 36, 32, .45); }
.sheet-body { padding: 1rem 1.2rem 1.4rem; }
.sheet-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-img { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius-s); background: #F1E9DD; }
.confirm-msg { font-size: 1.05rem; margin: .5rem 0 1rem; }
@media (max-width: 640px) {
  dialog.sheet, dialog.sheet.wide { margin: auto 0 0; width: 100vw; border-radius: var(--radius) var(--radius) 0 0; max-height: 94vh; }
  dialog.sheet[open] { animation: up .22s ease-out; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }

.edit-image { display: flex; gap: 1rem; align-items: center; }
.edit-img { width: 110px; height: 110px; object-fit: cover; border-radius: var(--radius-s); flex: none; }
.file-btn { cursor: pointer; }
.evidence { display: flex; flex-direction: column; gap: .5rem; }
.conflict { padding: 1rem; margin-top: 1rem; border: 2px solid var(--warn); }

/* Capture */
dialog.capture { border: none; padding: 0; margin: 0; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; background: var(--cream); color: var(--ink); display: flex; flex-direction: column; }
dialog.capture:not([open]) { display: none; }
.cap-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: .4rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.cap-head h2 { margin: 0; font-size: 1.15rem; }
.cap-body { flex: 1; overflow-y: auto; padding: 1rem; max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: .8rem; }
.cap-foot { padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); max-width: 760px; width: 100%; margin: 0 auto; }
.dest select { font-weight: 600; }
.cap-sources { display: flex; flex-direction: column; gap: .6rem; }
.source-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.source { font: inherit; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 84px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow); text-align: center; color: var(--ink); }
.source span { font-size: 1.5rem; }
.source:focus-within { box-shadow: var(--focus); }
.progress { min-height: 1.2em; margin: 0; font-weight: 600; color: var(--accent); }
.drafts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .8rem; }
.draft { padding: .9rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.draft.unselected { opacity: .65; }
.draft.loading { min-height: 80px; justify-content: center; }
.draft-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.draft-main { display: flex; gap: .9rem; align-items: flex-start; }
.draft-main label { font-size: .8rem; color: var(--muted); }
.draft-img { width: 110px; flex: none; display: flex; flex-direction: column; gap: .3rem; }
.draft-img img, .draft-img .img-fallback { width: 110px; height: 110px; object-fit: cover; border-radius: var(--radius-s); }
.draft-price { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.budget input { display: inline; width: auto; min-height: 32px; padding: .2rem .5rem; }
@media (max-width: 480px) { .draft-main { flex-direction: column; } .draft-img { width: 100%; flex-direction: row; align-items: center; } }

/* Planner */
.month { position: relative; }
.month-head { position: sticky; top: 0; z-index: 5; background: var(--cream); padding: .6rem 0 .4rem; margin: .8rem 0 .3rem; }
.date-chip { display: flex; flex-direction: column; align-items: center; width: 48px; flex: none; background: var(--accent-soft); border-radius: 10px; padding: .25rem 0; color: #8E2F1A; }
.date-chip strong { font-size: 1.2rem; line-height: 1.1; }
.date-chip span { font-size: .72rem; text-transform: uppercase; }
.ideas { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: .6rem; }
.idea { padding: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.idea-main { display: flex; gap: .8rem; align-items: flex-start; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; align-self: flex-start; }
.seg button { font: inherit; font-size: .875rem; font-weight: 600; border: none; background: var(--surface); padding: .45rem .9rem; min-height: 40px; cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }
.inline-add { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.notes { white-space: pre-wrap; background: var(--surface); padding: .7rem .9rem; border-radius: var(--radius-s); margin: 0; }

/* Guest */
.guest-head { margin: .5rem 0 1rem; }
.guest-head h1 { font-size: 1.8rem; margin: .1rem 0 .4rem; }
.guest-foot { text-align: center; margin-top: 2rem; }
.guest-item .btn { width: 100%; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: min(420px, 100%); padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: .9rem; text-align: center; }
.login-card form { text-align: left; }
.logo { font-size: 2.6rem; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.or { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.prose { max-width: 680px; }
.prose h1 { margin: 1rem 0; }

/* Toasts */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 1000; display: flex; flex-direction: column; gap: .5rem; width: min(480px, calc(100vw - 2rem)); pointer-events: none; }
.toasts[popover] { inset: auto auto calc(150px + env(safe-area-inset-bottom)) 50%; margin: 0; border: 0; padding: 0; background: transparent; overflow: visible; }
.toasts[popover]:not(:popover-open) { display: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--radius-s); display: flex; align-items: center; justify-content: space-between; gap: 1rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (min-width: 900px) { .masonry { columns: 3 220px; } }
.fab-plus { font-size: 1.5rem; line-height: 1; margin-right: .2rem; }
.finding { font-style: italic; }

/* Cropper */
.crop-wrap { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; margin: 0 auto; }
.crop-wrap img { max-width: 100%; max-height: 60vh; display: block; }
.crop-rect { position: absolute; box-shadow: 0 0 0 9999px rgba(20, 15, 10, .55); outline: 2px solid #fff; cursor: move; touch-action: none; }
.crop-rect:focus-visible { outline: 3px solid #7FB0FF; }
.crop-handle { position: absolute; width: 28px; height: 28px; background: #fff; border: 2px solid var(--accent); border-radius: 50%; touch-action: none; }
.crop-handle.tl { left: -14px; top: -14px; cursor: nwse-resize; } .crop-handle.br { right: -14px; bottom: -14px; cursor: nwse-resize; }
.crop-handle.tr { right: -14px; top: -14px; cursor: nesw-resize; } .crop-handle.bl { left: -14px; bottom: -14px; cursor: nesw-resize; }
.crop-actions { margin: .8rem 0; }
dialog.sheet .crop-wrap { overflow: hidden; }

.flush { margin: 0; }
.their-list { margin-bottom: 1.2rem; }
.their-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.their-head h3 { margin: 0; flex: 1 1 auto; }
