:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2420;
  --muted: #776b62;
  --line: #e8e0d6;
  --accent: #b23a48;
  --accent-ink: #ffffff;
  --accent-soft: #f8e7e9;
  --ok: #2f7a4f;
  --ok-soft: #e6f3eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #26221f;
    --text: #f2ebe4;
    --muted: #b0a59b;
    --line: #3a342f;
    --accent: #e0697a;
    --accent-ink: #1c1917;
    --accent-soft: #3a2629;
    --ok: #74c894;
    --ok-soft: #1f3327;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 960px; margin: 0 auto; padding: 16px 16px 80px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 40px 0; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }

header.top { display: flex; align-items: center; gap: 10px; margin: 8px 0 16px; }
header.top h1 { font-size: 1.5rem; }
header.top .who { margin-left: auto; color: var(--muted); font-size: .9rem; }

nav.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 2px; }
nav.tabs button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
nav.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.intro { margin-bottom: 16px; }
.intro p { margin: 0 0 6px; }
.next { display: inline-block; background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; font-size: .95rem; }
.hint { color: var(--muted); font-size: .95rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.card .img { aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.card .img img { width: 100%; height: 100%; object-fit: contain; }
.card .img.ph { font-size: 2rem; background: var(--accent-soft); aspect-ratio: auto; height: 72px; }
.card .body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { font-size: 1.05rem; }
.price { font-weight: 600; }
.notes { color: var(--muted); margin: 0; font-size: .95rem; white-space: pre-wrap; }
.card .actions { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card.claimed .img, .card.claimed h3 { opacity: .55; }
.status { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 8px 10px; font-weight: 600; font-size: .95rem; }
.status small { display: block; font-weight: 400; color: var(--text); opacity: .8; }

button.btn, a.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.big { width: 100%; font-size: 1.05rem; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 6px; min-height: 0; font-weight: 400; cursor: pointer; font: inherit; font-size: .9rem; }
button:disabled { opacity: .5; cursor: not-allowed; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.15rem; margin-bottom: 10px; }
.section-title { font-size: 1.15rem; margin: 26px 0 12px; }

form { display: grid; gap: 12px; }
label { display: block; font-weight: 600; font-size: .95rem; }
label > input, label > textarea, label > select { display: block; margin-top: 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }
.preview-thumb { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .9rem; }
.preview-thumb img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--line); }

.occasions { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.occasions li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.occasions .grow { flex: 1; min-width: 160px; }
.occasions .meta { color: var(--muted); font-size: .9rem; }

details.received { margin-top: 22px; }
details.received summary { cursor: pointer; color: var(--muted); }
details.received ul { padding-left: 18px; }

.giver { border-top: 1px solid var(--line); padding: 12px 0; }
.giver:first-of-type { border-top: none; }
.giver h3 { font-size: 1.05rem; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.giver.done h3 { color: var(--ok); }
.giver ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.giver li label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.giver li input { width: 22px; height: 22px; min-height: 0; margin-top: 1px; flex: none; accent-color: var(--ok); }
.giver li q { color: var(--muted); display: block; font-size: .9rem; }
.progress { color: var(--muted); margin: -4px 0 8px; }

dialog {
  border: none; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 12, 8, .45); }
dialog form { padding: 20px; }
dialog h2 { font-size: 1.2rem; }
dialog .sub { margin: -6px 0 0; color: var(--muted); }
dialog .buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.error { color: var(--accent); font-weight: 600; margin: 0; }

fieldset.choice { border: none; margin: 0; padding: 0; display: grid; gap: 8px; }
fieldset.choice legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: 4px; }
fieldset.choice label {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
fieldset.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
fieldset.choice input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
fieldset.choice small { display: block; font-weight: 400; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  transition: transform .25s ease; max-width: calc(100vw - 32px); text-align: center; z-index: 10;
}
#toast.show { transform: translateX(-50%) translateY(0); }
