:root {
  /* colour */
  --bg: #f6f7eb;
  --surface: #ffffff;
  --border: #e3e1d6;
  --border-strong: #dcdad2;
  --text: #393e41;
  --text-soft: #565b5f;
  --muted: #6b7175;
  --on-dark: #ffffff;
  --accent: #c73d28;
  --accent-hover: #a8321f;
  --soon-bg: #f9ece7;
  --tag-bg: #efede4;
  --placeholder-bg: #edead9;
  --placeholder-icon: #aca895;
  --hover-tint: rgba(57, 62, 65, 0.05);
  --press-tint: rgba(57, 62, 65, 0.08);
  --shadow-sm: 0 2px 10px rgba(57, 62, 65, 0.06);
  --shadow-md: 0 8px 24px rgba(57, 62, 65, 0.12);
  --shadow-lg: 0 8px 24px rgba(57, 62, 65, 0.25);
  --overlay: rgba(57, 62, 65, 0.45);

  /* type: one scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-title: 30px;

  /* corners: three sizes */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  /* controls share one height */
  --control-h: 40px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

body {
  margin: 0;
  font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

button, input, select, textarea { font-family: inherit; }

.page {
  max-width: 1184px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.header h1 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 14px;
  min-height: var(--control-h);
  min-width: 200px;
}

.search-box input {
  border: none;
  outline: none;
  font-size: var(--fs-md);
  background: transparent;
  color: var(--text);
  width: 100%;
}

.search-box input::placeholder { color: var(--muted); }
.search-box svg { flex: 0 0 auto; color: var(--muted); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--on-dark);
  border: none;
  border-radius: var(--r-md);
  min-height: var(--control-h);
  padding: 0 16px;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }

.save-status {
  font-size: var(--fs-sm);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}
.save-status.is-saved { transition: opacity 0.6s 1.5s; opacity: 0; }
.save-status.is-error { color: var(--accent); font-weight: 600; }
.save-status button {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--text);
  color: var(--on-dark);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: var(--fs-md);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
}
.toast button {
  background: none;
  border: none;
  color: var(--on-dark);
  font-weight: 700;
  font-size: var(--fs-md);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}

.menu { position: relative; }
.menu-btn {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.menu-btn::-webkit-details-marker { display: none; }
.menu-btn:hover, .menu[open] .menu-btn { border-color: var(--muted); }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.menu-list button {
  background: none;
  border: none;
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  color: var(--text);
  cursor: pointer;
}
.menu-list button:hover { background: var(--tag-bg); }

/* a person's own ⋯ menu, next to Edit dates */
.person-menu .menu-btn.small { width: 34px; height: 34px; border-radius: var(--r-md); }
.person-menu .menu-list { left: 0; right: auto; min-width: 230px; }

.menu-account {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.menu-account-label { font-size: var(--fs-xs); color: var(--muted); }
.menu-account-email {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

.backup-note {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.5;
}



.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.icon-btn:hover { color: var(--accent); }

.pills {
  display: flex;
  gap: 22px;
  margin-top: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }

#pills-container { border-bottom: 1px solid var(--border); }

.pill {
  flex: 0 0 auto;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text);
  padding: 8px 0 10px;
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover { border-bottom-color: var(--border-strong); }

/* counts sit in a small quiet badge so they don't run into the name */
.pill .count {
  display: inline-block;
  margin-left: 6px;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--text-soft);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}

.pill.active {
  font-weight: 700;
  border-bottom-color: var(--text);
}
.pill.active .count {
  background: var(--text);
  color: var(--on-dark);
}


.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.empty-state {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-md);
}

/* gift cards: compact, similar heights; the whole card opens the gift */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.card-top { display: flex; gap: 14px; align-items: flex-start; }

.card-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: contain; }

.card-head { min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.card-title {
  font: inherit;
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.3;
  background: none;
  border: none;
  text-align: left;
  padding: 0;
  color: var(--text);
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card:hover .card-title { text-decoration: underline; text-underline-offset: 3px; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  font-size: var(--fs-md);
  color: var(--muted);
}
/* a long shop name with no spaces ("PenguinRandomHouse.com") stays on one
   line and ends in "…" instead of running past the card; full name on hover */
.card-meta .vendor { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .price { font-size: var(--fs-md); font-weight: 700; color: var(--text); }

.bought-badge {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text);
  background: var(--tag-bg);
  border-radius: var(--r-sm);
  padding: 1px 7px;
}

.chip {
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--text-soft);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  width: fit-content;
}

#category-list .chip {
  text-transform: none;
  font-size: var(--fs-sm);
  letter-spacing: normal;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.card-summary {
  margin: 0;
  font-size: var(--fs-md);
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--fs-md);
  color: var(--muted);
  font-style: italic;
}
.card-note svg { flex: 0 0 auto; margin-top: 2px; }

/* who it's for: one checkbox per person, ticked = bought */
.card-people {
  list-style: none;
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.person-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  width: fit-content;
}
.person-check input { accent-color: var(--text); width: 16px; height: 16px; margin: 0; cursor: pointer; }
.person-check .bought-word { font-weight: 500; font-size: var(--fs-sm); color: var(--muted); }
.person-check.is-bought .person-name { text-decoration: line-through; color: var(--muted); }

.card-links {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  font-size: var(--fs-md);
}
.card-links a,
.card-links button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.card-links .quiet { font-weight: 500; color: var(--muted); }
.card-links svg { color: var(--muted); }
.card-links a:hover,
.card-links button:hover { text-decoration: underline; text-underline-offset: 3px; }

.card-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
}
.card-delete:hover { color: var(--accent); }

/* coming up + person dates */

/* layout: people column + gifts; on phones a "For:" picker instead */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 40px;
  margin-top: 28px;
  align-items: start;
}
.layout.no-people { grid-template-columns: minmax(0, 1fr); }
.layout.no-people .people-panel,
.layout.no-people .people-picker { display: none; }
.main-col > .tabbar { margin-top: 0; }

/* category tabs, with a quiet "Show: Everything ▾" at the end of the row */
.tabbar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: 28px;
  border-bottom: 1px solid var(--border);
}
.tabbar[hidden] { display: none; }
.tabbar #pills-container { margin-top: 0; border-bottom: 0; flex: 1; min-width: 0; }
.show-menu { flex: 0 0 auto; }
.show-btn {
  list-style: none;
  display: inline-flex;
  align-items: center;
  padding: 8px 2px 10px;
  font-size: var(--fs-sm);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.show-btn::-webkit-details-marker { display: none; }
.show-btn:hover { color: var(--text); }
.show-btn .val { color: var(--text); font-weight: 600; margin-left: 4px; }
.show-btn:not(.is-all) .val { font-weight: 700; }
.show-btn .caret { font-size: 10px; margin-left: 5px; }
.show-menu .menu-list { min-width: 210px; }
.show-menu .menu-list button { display: flex; justify-content: space-between; gap: 16px; }
.show-menu .tick { display: inline-block; width: 18px; }
.show-menu .n { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .show-btn .colon { display: none; }
  .show-btn.is-all .val { display: none; }
  .show-btn:not(.is-all) .lbl { display: none; }
}
.main-col > .welcome { margin-top: 0; }

.people-panel { position: sticky; top: 16px; }
.side-label {
  margin: 0 0 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.people-list { display: flex; flex-direction: column; }
.people-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: calc(100% + 20px);
  margin: 0 -10px;
  padding: 7px 10px;
  border: none;
  border-radius: var(--r-sm);
  background: none;
  font: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.people-row:hover { background: var(--hover-tint); }
.people-row.is-selected { background: var(--tag-bg); font-weight: 700; }
.people-row .n { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.people-row .w { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); white-space: nowrap; }
.people-row .w.is-soon { color: var(--accent); font-weight: 600; }
.people-row .soon-dot { margin-left: 0; vertical-align: 0; }

.people-picker { display: none; position: relative; }
.people-picker-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  font: inherit;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
}
.people-picker-btn .lbl { color: var(--muted); font-weight: 500; }
.people-picker-btn .next { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-picker-btn .next.is-soon { color: var(--accent); font-weight: 600; }
.people-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 6px 16px;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 20px; }
  .people-panel { display: none; }
  .people-picker { display: block; }
}

/* first visit: an empty list */
.welcome {
  margin-top: 32px;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
}
.welcome h2 { margin: 0 0 8px; font-family: 'Fraunces', serif; font-size: var(--fs-xl); font-weight: 600; }
.welcome p { margin: 0 0 20px; font-size: var(--fs-md); line-height: 1.55; color: var(--muted); }

/* sign-in is its own page, not a pop-up over an empty app */
.modal-overlay.login-page {
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 12vh;
}
.login-brand { margin: 0 0 20px; font-family: 'Fraunces', serif; font-size: var(--fs-title); font-weight: 600; color: var(--text); }
.login-page .modal { border: 1px solid var(--border); }

.backup-actions { display: flex; flex-wrap: wrap; gap: 10px; }
label.btn-secondary { display: inline-flex; align-items: center; cursor: pointer; }

/* categories window */
.category-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.category-row .cat-name { flex: 1; font-size: var(--fs-md); font-weight: 600; }
.category-row .cat-count { font-size: var(--fs-sm); color: var(--muted); }
.category-row input { flex: 1; font: inherit; font-size: var(--fs-md); padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-md); }

/* person header actions */
.person-header .header-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* filter rows that scroll sideways fade at the edge */
.pills.has-more {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}

/* add/edit gift: Save stays in reach at the bottom of a long form */
#gift-form .modal-actions {
  position: sticky;
  bottom: -24px;
  margin: 4px -24px -24px;
  padding: 14px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  z-index: 2;
}

/* person page: gifts grouped by occasion */
.grid-heading {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 12px 0 -4px;
}
.grid-heading:first-child { margin-top: 0; }
.grid-heading h3 { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.grid-heading .when { font-size: var(--fs-sm); color: var(--muted); }
.grid-heading .when.is-soon { color: var(--accent); font-weight: 600; }
.grid-heading.sub h3 { font-size: var(--fs-md); }
.grid-heading .link-btn { font-size: var(--fs-lg); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.grid-heading .link-btn .chev { font-size: var(--fs-xs); color: var(--muted); }
/* "Show 2 previous gifts ▾": a quiet, left-aligned section opener with a rule
   running to the right, matching "Previous gifts ▾" on a person's page */
.previous-toggle-row { margin-top: 24px; display: flex; align-items: center; gap: 12px; }
.previous-toggle-row::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.previous-toggle-row .link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.previous-toggle-row .link-btn:hover { color: var(--text); text-decoration: underline; }
#previous-toggle::after { content: '▾'; font-size: var(--fs-xs); }
#previous-toggle[aria-expanded="true"]::after { content: '▴'; }

/* card: which occasion each person's gift is for */
.person-check .occ-label { font-weight: 500; font-size: var(--fs-sm); color: var(--muted); }

/* form: "Gift for" chips with the occasion as quiet text inside */
.person-chip { font-size: var(--fs-sm); padding: 2px 2px 2px 10px; gap: 2px; }
.person-chip .who { font-weight: 700; }
.person-chip.is-bought .who { text-decoration: line-through; color: var(--muted); }
.person-chip .occ-pick {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  padding: 0 2px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.person-chip .occ-pick .caret { font-size: 10px; }
.person-chip .occ-pick:hover { color: var(--text); }
.person-chip .occ-pick:focus-within { outline: 2px solid var(--text); outline-offset: 1px; }
.person-chip .occ-pick select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0; /* not the form's 40px fields: stay inside "· Christmas ▾" */
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font: inherit;
}
/* the × gets its own comfortable tap target, clear of the occasion menu */
.person-chip button[data-remove-shortlist] {
  margin-left: 4px;
  min-width: 28px;
  min-height: 28px;
  justify-content: center;
  border-radius: var(--r-sm);
}
.person-chip button[data-remove-shortlist]:hover { background: var(--press-tint); }

.person-header {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.person-header h2 { margin: 0 4px 0 0; font-family: 'Fraunces', serif; font-size: var(--fs-xl); font-weight: 600; }
.occasion-chip {
  font-size: var(--fs-sm);
  background: var(--tag-bg);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 4px 10px;
}
.occasion-chip .when { color: var(--text-soft); }
.occasion-chip.is-soon { background: var(--soon-bg); }
.occasion-chip.is-soon .when { color: var(--accent); font-weight: 600; }

.soon-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 2px;
}

.dates-list { display: flex; flex-direction: column; }
.date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-md);
}
.date-row .date-when { color: var(--muted); }
.date-form { display: flex; flex-direction: column; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); }
.checkbox input { accent-color: var(--text); width: 16px; height: 16px; }

/* modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { margin: 0; font-family: 'Fraunces', serif; font-size: var(--fs-xl); font-weight: 600; }

#gift-form,
#login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

.link-fetch-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fetch-row {
  display: flex;
  gap: 8px;
}

.fetch-row input {
  flex: 1;
  min-width: 0;
  min-height: var(--control-h);
  font-size: var(--fs-md);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
}

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

/* small buttons: 34px, the same as the person ⋯ beside Edit dates
   (doubled class so the 40px .btn-primary/.btn-secondary rules below don't win) */
.btn-small.btn-small { min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); }
label.btn-secondary { display: inline-flex; align-items: center; }
#image-input:focus-visible + label { outline: 2px solid var(--text); outline-offset: 2px; }

.field label .optional { font-weight: 500; color: var(--muted); margin-left: 4px; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  min-height: var(--control-h);
  padding: 0 16px;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--muted); }

.btn-secondary:disabled { opacity: 0.6; cursor: wait; }

.fetch-status {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  min-height: 16px;
}

.fetch-status.is-error { color: var(--accent); }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field[hidden] { display: none; }

.field label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  min-height: var(--control-h);
  width: 100%;
  font-size: var(--fs-md);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.field textarea { resize: vertical; min-height: 60px; }

.category-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-toggle {
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.chip-toggle[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--on-dark);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  min-height: var(--control-h);
  padding: 4px 6px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--border-strong);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 3px 4px 3px 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.tag-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 2px;
}
.tag-chip button:hover { color: var(--accent); }
.tag-chip a { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.tag-chip a svg { color: var(--muted); }
.tag-chip a:hover { text-decoration: underline; text-underline-offset: 3px; }
.open-link { width: fit-content; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.open-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.tag-input input {
  flex: 1;
  min-width: 120px;
  min-height: 0; /* the box itself is the 40px control */
  border: none;
  outline: none;
  font-size: var(--fs-md);
  padding: 4px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

#category-list,
#archived-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-preview .thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--r-md);
  background: var(--placeholder-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.image-preview .thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-preview .thumb svg { color: var(--placeholder-icon); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.modal-actions .btn-danger { margin-right: auto; }

.btn-danger {
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { color: var(--accent); }

@media (max-width: 480px) {
  .page { padding: 24px 16px 60px; }
  .grid { grid-template-columns: 1fr; }
  .search-box { min-width: 0; flex: 1; }
  .header-actions { width: 100%; flex-wrap: nowrap; }
  .save-status { position: fixed; top: 12px; right: 16px; z-index: 30; background: var(--bg); padding: 2px 8px; border-radius: var(--r-sm); }
  .save-status:empty { display: none; }
}

/* phones: 16px text in boxes, or iOS zooms the page in when you tap one */
@media (max-width: 860px) {
  input, select, textarea,
  .field input, .field select, .field textarea,
  .search-box input, .fetch-row input, .tag-input input,
  .category-row input { font-size: var(--fs-lg); }
}

.confirm-message { margin: 0; font-size: var(--fs-md); color: var(--text); line-height: 1.5; }

/* ⋯ menu: a link styled like the menu's buttons */
.menu-list a { padding: 9px 10px; border-radius: var(--r-sm); font-size: var(--fs-md); color: var(--text); text-decoration: none; }
.menu-list a:hover { background: var(--tag-bg); text-decoration: none; }

/* sign-in: the agree-to-terms line under the form */
.login-legal { max-width: 380px; margin: 16px 0 0; text-align: center; font-size: var(--fs-sm); line-height: 1.5; color: var(--muted); }
.login-legal a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* Privacy and Terms pages */
.legal { max-width: 680px; margin: 0 auto; padding: 40px 24px 80px; font-size: var(--fs-lg); line-height: 1.6; }
.legal h1 { margin: 8px 0 4px; font-family: 'Fraunces', serif; font-size: var(--fs-title); font-weight: 600; }
.legal h2 { margin: 32px 0 8px; font-size: var(--fs-xl); font-weight: 700; }
.legal p, .legal ul { margin: 0 0 12px; }
.legal li { margin-bottom: 6px; }
.legal a { text-decoration: underline; text-underline-offset: 3px; }
.legal-back { font-size: var(--fs-md); }
.legal-back a { color: var(--muted); text-decoration: none; }
.legal-date { color: var(--muted); font-size: var(--fs-md); }
.legal-lead { font-size: var(--fs-lg); padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.legal-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--fs-md); color: var(--muted); }
@media (max-width: 480px) { .legal { padding: 24px 16px 60px; } }

/* Backup window: deleting the whole list, set apart at the bottom */
.delete-zone { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.delete-zone h3 { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.delete-zone .fetch-status:empty { display: none; }
.btn-delete {
  align-self: flex-start;
  min-height: var(--control-h);
  padding: 0 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
}
.btn-delete:hover { background: var(--accent); color: var(--on-dark); }
.btn-delete:disabled { opacity: 0.6; cursor: wait; }
