:root {
  --bg: #f4f1ea; --surface: #fffdf8; --ink: #22201b; --muted: #77705f; --line: #e2dccd;
  --accent: #0f766e; --accent-ink: #ffffff; --danger: #b42318; --warn-bg: #fdf0e7;
  --radius: 14px; --gutter: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1a17; --surface: #25231f; --ink: #eeeae0; --muted: #a39b88; --line: #3a372f;
          --accent: #2bb3a3; --accent-ink: #0d1514; --danger: #f97066; --warn-bg: #3a2a20; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
main { max-width: 720px; margin: 0 auto; padding: 8px var(--gutter) calc(32px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px; background: var(--bg);
  border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.back { color: var(--ink); text-decoration: none; font-weight: 600; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 10px 18px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  display: inline-block; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: 15px; }
.btn.quiet { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .6; }

.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); }
.pill.state-failed { color: var(--danger); }
.pill.state-ready, .pill.state-listed { color: var(--accent); }

h1 { font-size: 24px; margin: 12px 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 8px; }
.count { font-weight: 400; }

.empty { text-align: center; padding: 64px 0; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card { display: flex; gap: 12px; align-items: center; padding: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.card img, .card .noimg { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--line);
  flex: none; }
.card .meta { display: flex; flex-direction: column; min-width: 0; }
.card strong, .card .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.state-failed { border-color: var(--danger); }

form label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 0; }
input, textarea, select { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit;
  font-weight: 400; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; }
textarea { resize: vertical; }
input[readonly], textarea[readonly] { opacity: .7; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.drop { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 16px; margin: 12px 0 0;
  background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius); cursor: pointer; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.drop-title { font-size: 17px; }
.drop .muted { font-weight: 400; }
.drop.has-files { border-style: solid; border-color: var(--accent); }
.previews { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.previews img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.typed { margin: 18px 0; }
.typed summary { font-weight: 600; cursor: pointer; }
.capture .btn.wide { margin-top: 20px; }

.strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scroll-snap-type: x mandatory; }
.strip img { height: 160px; border-radius: 10px; scroll-snap-align: start; background: var(--line); }
.strip.edit figure { margin: 0; flex: none; scroll-snap-align: start; }
.strip.edit img { height: 220px; display: block; }
figcaption { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 14px; }
.pos { width: 56px; margin: 0; padding: 6px 8px; }
.toggle { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.toggle input { width: auto; margin: 0; }

.price { margin-top: 4px; }
.price label { max-width: 160px; }
.suggest { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; font-size: 14px; }
.comps { margin: 14px 0; }
.comps summary { font-weight: 600; cursor: pointer; }
.comps ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.comps a { display: flex; gap: 10px; color: var(--ink); text-decoration: none; font-size: 14px; }
.comps img { width: 48px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 8px; }
.actions.secondary { margin-top: 0; }
.actions form { margin: 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { width: 110px; margin: 0; }

.working { text-align: center; padding: 32px 0 16px; }
.spinner { width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.alert { padding: 14px 16px; margin: 12px 0; border-radius: var(--radius); background: var(--warn-bg);
  border: 1px solid var(--danger); }
.alert p { margin: 6px 0 12px; overflow-wrap: anywhere; }
.refs { margin-top: 18px; }
.refs summary { cursor: pointer; font-weight: 600; }
