/* Family Gift List: mobile first, big type, big tap targets, no animation. */
:root {
  color-scheme: light dark;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #efe9df;
  --text: #1d2420;
  --muted: #59625c;
  --line: #d8d0c3;
  --accent: #1f5c45;        /* pine */
  --accent-text: #ffffff;
  --festive: #a83232;       /* cranberry, used sparingly */
  --gold: #b8892a;
  --amber-bg: #fff1d6;
  --amber-text: #7a4b00;
  --ok-bg: #e3f1e8;
  --ok-text: #1f5c45;
  --mine-bg: #e6eefb;
  --mine-text: #1e3f7a;
  --focus: #2b6cb0;
  --radius: 12px;
  --tap: 48px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111814;
    --surface: #1a231e;
    --surface-2: #232e28;
    --text: #edf0ec;
    --muted: #a9b3ac;
    --line: #34413a;
    --accent: #5fb38e;
    --accent-text: #0d1511;
    --festive: #e07a7a;
    --gold: #d9b45c;
    --amber-bg: #3a2c10;
    --amber-text: #ffd27a;
    --ok-bg: #173226;
    --ok-text: #8fd6b2;
    --mine-bg: #1b2a44;
    --mine-text: #a9c4f5;
    --focus: #8ab4f8;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
* { animation: none !important; transition: none !important; }

[hidden] { display: none !important; }

a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 18px; /* >= 16px stops iOS zooming on focus */
}
textarea { min-height: 96px; resize: vertical; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
.hint { color: var(--muted); font-size: 16px; font-weight: 400; margin: 4px 0 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-festive { background: var(--festive); border-color: var(--festive); color: #fff; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--accent); text-decoration: underline; padding: 10px 8px; }
.btn-block { width: 100%; }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 16px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--festive);
  padding: 8px 16px 0;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.brand { font-size: 22px; margin: 4px 0; color: var(--accent); letter-spacing: 0.2px; }
.who { font-size: 16px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.who strong { color: var(--text); }
.mainnav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; -webkit-overflow-scrolling: touch; }
.mainnav .btn { flex: 0 0 auto; }
.mainnav .btn[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 16px;
  margin: 0 -16px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.tab {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 56px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}
.tab-name { font-weight: 700; }
.tab-count { font-size: 16px; color: var(--muted); }
.tab[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 -4px 0 var(--accent); }
.tab .amber { color: var(--amber-text); font-weight: 700; }

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 0 16px 96px; outline: none; }
.loading, .empty { color: var(--muted); padding: 24px 0; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 12px; }
.view-head h2 { margin: 0; font-size: 26px; }
.counter { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-text); font-weight: 600; font-size: 16px; }
.counter.amber { background: var(--amber-bg); color: var(--amber-text); }

/* ---------- cards ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
}
.thumb {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  background: var(--surface-2);
  object-fit: contain;
  display: block;
}
.thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--gold); }
.card-body { min-width: 0; }
.card-for { font-size: 16px; color: var(--festive); font-weight: 700; margin: 0 0 2px; }
.card-title { margin: 0; font-size: 19px; line-height: 1.3; overflow-wrap: anywhere; }
.card-meta { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.card-meta .price { color: var(--text); font-weight: 700; }
.card-why { margin: 8px 0 0; font-size: 17px; overflow-wrap: anywhere; white-space: pre-line; }
.card-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 16px; }
.badge-taken { background: var(--surface-2); color: var(--muted); }
.badge-mine { background: var(--mine-bg); color: var(--mine-text); }
.card.is-taken { opacity: 0.8; }
.card.is-archived .card-title::after { content: " (removed from list)"; font-weight: 400; color: var(--muted); font-size: 16px; }

@media (min-width: 560px) {
  .card { grid-template-columns: 120px 1fr; }
  .thumb { width: 120px; height: 120px; }
}

/* ---------- filters ---------- */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.filters .row { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .filters .row { grid-template-columns: 1fr 1fr 1fr; } }
.filters label { margin-top: 8px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-size: 16px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.result-count { color: var(--muted); font-size: 16px; margin: 0 0 8px; }

/* ---------- login ---------- */
.login {
  max-width: 420px;
  margin: 8vh auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--festive);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 4px; color: var(--accent); font-size: 28px; }
.login p { margin: 0 0 8px; color: var(--muted); }
.login .btn { margin-top: 20px; }
.error { color: var(--festive); font-weight: 600; margin: 12px 0 0; }

/* ---------- sheet (dialog) ---------- */
.sheet {
  width: min(640px, 100vw);
  max-width: 100vw;
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  color: var(--text);
}
@media (min-width: 640px) { .sheet { margin: auto; border-radius: 16px; max-height: 92dvh; } }
.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
.sheet form { padding: 16px 16px 24px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.fetch-row { display: flex; gap: 8px; }
.fetch-row input { flex: 1; }
.fetch-row .btn { flex: 0 0 auto; border-radius: 10px; }
.preview-img { max-width: 120px; max-height: 120px; margin-top: 8px; border-radius: 8px; background: var(--surface-2); }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1 1 140px; }
.msg { margin: 8px 0 0; font-size: 16px; }
.msg.bad { color: var(--festive); font-weight: 600; }
.msg.good { color: var(--ok-text); font-weight: 600; }

/* ---------- admin ---------- */
.people { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.person summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-height: 56px; cursor: pointer; }
.person summary::-webkit-details-marker { display: none; }
.person summary .name { font-weight: 700; flex: 1; }
.person summary .tag { font-size: 14px; background: var(--surface-2); padding: 2px 8px; border-radius: 999px; color: var(--muted); }
.person .inner { padding: 0 12px 14px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px 8px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 400; margin: 0; }
.check input { width: 24px; height: 24px; min-height: 0; flex: 0 0 auto; }
.add-person { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 18px; }
.add-person label { flex: 0 0 100%; margin: 0; }
.add-person input { flex: 1 1 12rem; min-width: 0; }
.add-person .btn { flex: 0 0 auto; border-radius: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.noscript { padding: 24px; text-align: center; }
