:root {
  color-scheme: light dark;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --ink: #10201a;
  --ink-soft: #52665e;
  --line: #d9e2dd;
  --accent: #0f7a4d;
  --accent-ink: #ffffff;
  --accent-soft: #e2f4ea;
  --warn: #b45309;
  --danger: #b42318;
  --radius: 14px;
  --gap: 12px;
  --tap: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1210;
    --surface: #131c18;
    --surface-2: #1b2823;
    --ink: #e8f2ed;
    --ink-soft: #9db1a8;
    --line: #27352f;
    --accent: #22c07a;
    --accent-ink: #062016;
    --accent-soft: #143123;
    --warn: #f0b357;
    --danger: #ff8a7a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  -webkit-text-size-adjust: 100%;
}

header.app-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}

header.app-bar img { width: 34px; height: 34px; border-radius: 9px; }
header.app-bar h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
header.app-bar p { margin: 0; font-size: 13px; color: var(--ink-soft); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: var(--gap);
}

.card h2 {
  font-size: 15px;
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

button {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  min-height: var(--tap);
  padding: 0 16px;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { opacity: 0.5; cursor: default; }

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
  width: 100%;
  font-size: 17px;
}

button.big {
  min-height: 108px;
  font-size: 19px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

button.big span.sub { font-size: 13px; font-weight: 400; opacity: 0.85; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > button { flex: 1 1 auto; }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb button.remove {
  position: absolute;
  top: 3px;
  right: 3px;
  min-height: 28px;
  height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  border: none;
  line-height: 1;
  font-size: 17px;
}

label.field { display: block; margin-bottom: 10px; }
label.field > span {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

input[type="text"], input[type="number"], textarea, select {
  font: inherit;
  width: 100%;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  min-height: var(--tap);
}

textarea { min-height: 170px; resize: vertical; line-height: 1.55; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  min-height: 42px;
  padding: 0 14px;
  font-size: 14px;
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  white-space: nowrap;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
}

.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}

pre.preview {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  margin: 0 0 10px;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-height: 340px;
  overflow: auto;
}

.price-hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: -4px 0 10px;
}

.note {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

.note.warn { color: var(--warn); }
.note.danger { color: var(--danger); }

.item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.item:first-of-type { border-top: none; }
.item img { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; background: var(--surface-2); }
.item .meta { flex: 1; min-width: 0; }
.item .meta b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta small { color: var(--ink-soft); font-size: 13px; }

.status {
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}

.status[data-status="posted"] { background: var(--accent-soft); border-color: var(--accent); }
.status[data-status="sold"] { background: var(--surface-2); opacity: 0.7; text-decoration: line-through; }

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  background: var(--ink);
  color: var(--bg);
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.hide { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.field-group { margin-bottom: 12px; }
.field-group > .note { display: block; margin: 0 0 6px; }

label.field > span > small { float: right; font-weight: 400; color: var(--ink-soft); }
label.field > span > small.danger { color: var(--danger); font-weight: 600; }

.thumb-index {
  position: absolute;
  left: 4px;
  bottom: 4px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  padding: 0 5px;
}

#field-copy button, #questions .chip { font-size: 14px; }
#preflight .note { margin-top: 6px; }
#questions { margin: 4px 0 12px; }
