/* styles.css — how the app looks. Colors are set once at the top so they're easy to change. */
:root {
  --bg: #f6f1ea;          /* warm paper background */
  --card: #ffffff;
  --ink: #2b2420;         /* main text */
  --muted: #7d726a;       /* secondary text */
  --accent: #9c4a2f;      /* rust / terracotta, a "vintage" accent */
  --accent-ink: #ffffff;
  --line: #e4dbd0;
  --danger: #b3261e;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1916;
    --card: #27221e;
    --ink: #f1ebe4;
    --muted: #a99d93;
    --accent: #d98a62;
    --accent-ink: #1c1916;
    --line: #3a332d;
    --danger: #f2827a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  background: var(--bg);
}
.topbar h1 { font-size: 20px; margin: 0; font-family: Georgia, "Times New Roman", serif; letter-spacing: .2px; }
.spacer { width: 56px; }
.link-btn {
  background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600;
  padding: 8px 4px; cursor: pointer;
}
.link-btn.small { font-size: 14px; font-weight: 500; padding: 4px 0 12px; }

/* ---------- totals ---------- */
.totals { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 8px; margin: 4px 0 12px; }
.total-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; display: flex; flex-direction: column; min-width: 0;
}
.total-card .label { font-size: 12px; color: var(--muted); }
.total-card .value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.search {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; margin-bottom: 12px;
}

/* ---------- list ---------- */
.purchase-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.purchase-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; cursor: pointer;
}
.purchase-item img, .purchase-item .no-photo {
  width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--line); display: grid; place-items: center; color: var(--muted); font-size: 22px;
}
.purchase-item .info { flex: 1; min-width: 0; }
.purchase-item .vendor { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.purchase-item .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.purchase-item .price { font-weight: 700; font-variant-numeric: tabular-nums; }
.month-heading { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 10px 4px 0; display: flex; justify-content: space-between; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* big "+ Add purchase" button that floats at the bottom */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 14px 26px; font: inherit; font-weight: 700; font-size: 17px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); cursor: pointer;
}

/* ---------- form ---------- */
.tracking-badge {
  text-align: center; font-size: 14px; color: var(--muted); margin-bottom: 10px;
}
.tracking-badge strong { color: var(--ink); font-family: ui-monospace, Menlo, monospace; font-size: 16px; }

.photo-picker {
  display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--card);
  overflow: hidden; cursor: pointer; color: var(--muted); font-size: 17px;
}
.photo-picker img { width: 100%; height: 100%; object-fit: cover; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .price-check input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: 17px; /* 16px+ stops iPhone zooming in */
}
.row { display: flex; gap: 8px; }
.icon-btn {
  flex: none; width: 48px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 20px; cursor: pointer;
}
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-weight: 600; }

.primary, .danger {
  display: block; width: 100%; padding: 15px; border-radius: 12px; border: 0;
  font: inherit; font-weight: 700; font-size: 17px; cursor: pointer; margin-top: 8px;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); margin-top: 24px; }

/* ---------- detail ---------- */
.detail img { width: 100%; border-radius: var(--radius); display: block; margin-bottom: 12px; }
.detail dl { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0; padding: 4px 14px; }
.detail .kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail .kv:last-child { border-bottom: 0; }
.detail dt { color: var(--muted); flex: none; }
.detail dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.detail a { color: var(--accent); }

/* ---------- little pop-up message ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 15px; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}

/* ---------- Price check (search phrase + eBay / Etsy buttons) ---------- */
.price-check {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 16px 0;
}
.price-check .pc-title { display: block; font-weight: 600; margin-bottom: 8px; }
.price-check .row { display: flex; gap: 8px; }
.price-check input { flex: 1; min-width: 0; }
.pc-buttons { display: flex; gap: 8px; margin-top: 10px; }
.pc-btn {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.pc-btn.disabled { opacity: 0.4; pointer-events: none; }
.price-check a.pc-btn, .detail .price-check a.pc-btn { color: var(--accent-ink); }
