:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1c1b19; --muted: #6b6760; --line: #e4e1da;
  --accent: #0f766e; --accent-ink: #fff; --soft: #e6f2f0; --warn: #b45309; --warn-bg: #fdf3e2; --bad: #b91c1c;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151513; --card: #1f1e1c; --ink: #f1efe9; --muted: #a39f96; --line: #33312d;
    --accent: #2dd4bf; --accent-ink: #0b2925; --soft: #183330; --warn: #fbbf24; --warn-bg: #3a2c10; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 640px; margin: 0 auto; padding: 12px 14px calc(96px + var(--safe-b)); }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
a { color: var(--accent); }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

.top { display: flex; align-items: center; gap: 10px; padding: 6px 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.top .grow { flex: 1; min-width: 0; }
.top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 8px 10px; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button.copy { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 9px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 10px; }
.full { width: 100%; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.center { min-height: 70vh; display: grid; place-items: center; text-align: center; }
.center .card { max-width: 360px; width: 100%; padding: 28px 22px; }
.logo { width: 56px; height: 56px; margin: 0 auto 10px; display: block; }

.new-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); z-index: 10; display: flex; gap: 8px; }
.new-bar button { box-shadow: 0 6px 20px rgb(0 0 0 / .18); border-radius: 999px; padding: 14px 18px; white-space: nowrap; }
.new-btn { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--safe-b)); z-index: 10;
  box-shadow: 0 6px 20px rgb(0 0 0 / .18); padding: 14px 26px; border-radius: 999px; font-size: 17px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.chip { font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); white-space: nowrap; min-height: 32px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.grey { background: var(--line); color: var(--muted); }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 8px; }
.totals div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.totals b { display: block; font-size: 18px; }
.totals span { font-size: 12px; color: var(--muted); }

.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; cursor: pointer; }
.items img, .thumb-empty { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; background: var(--line); }
.items .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.items .meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.items .price { margin-left: auto; font-weight: 700; font-size: 17px; white-space: nowrap; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph button { position: absolute; top: 4px; right: 4px; min-height: 26px; width: 26px; padding: 0; border-radius: 50%; background: rgb(0 0 0 / .6); color: #fff; border: 0; }
.add-photo { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 10px; display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; cursor: pointer; background: var(--card); }
.add-photo input { display: none; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.strip img { height: 132px; border-radius: 10px; scroll-snap-align: start; flex: none; }

textarea, input[type=text], input[type=number], select { font: inherit; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
textarea { min-height: 80px; resize: vertical; }
select { width: auto; min-height: 40px; padding: 8px 10px; }

.bubble { background: var(--soft); border-radius: 14px 14px 14px 4px; padding: 12px 14px; }
.bubble.me { background: var(--card); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; margin-left: 15%; }
.bubble ul { margin: 6px 0 0; padding-left: 20px; }
.bubble li { margin: 4px 0; }
.warnbox { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.errbox { background: #fde8e8; color: var(--bad); border-radius: 12px; padding: 10px 12px; }
@media (prefers-color-scheme: dark) { .errbox { background: #3b1515; } }
.working { display: flex; gap: 10px; align-items: center; padding: 14px; background: var(--soft); border-radius: 14px; }
.spin { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { border-top: 1px solid var(--line); padding: 12px 0; }
.field:first-of-type { border-top: 0; padding-top: 2px; }
.field .label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.field .value { white-space: pre-wrap; word-break: break-word; }
.field .title { font-size: 18px; font-weight: 600; }
.bigprice { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; padding: 4px 0; }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.links .btn, .links button { font-size: 14px; padding: 10px; }
.composer { padding: 10px 0 4px; }
.composer textarea { min-height: 52px; }
.pending-photos { display: flex; gap: 6px; margin-bottom: 6px; }
.pending-photos img { height: 48px; border-radius: 8px; }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 50; max-width: 90vw; text-align: center; }
.photos .ph .num { position: absolute; left: 4px; bottom: 4px; background: rgb(0 0 0 / .6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 999px; }
.photos .ph.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.photos .ph.sel::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding: 10px 14px calc(10px + var(--safe-b)); display: flex; gap: 8px; align-items: center; }
.selbar[hidden] { display: none; }
.selbar select { flex: 1; }
.card input[type=text] { padding: 8px 10px; }
