/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ════════════════════════════════════════════════════════════════════════
   DESIGN TOKENS — "4a Warm Editorial / 5 Dark Editorial"
   Light: warm cream + terracotta. Dark: near-black + amber.
   Legacy aliases (--blue, --chili, --text …) kept so inline styles
   across all pages continue working without edits.
   ════════════════════════════════════════════════════════════════════════ */
:root {
  /* ── 4a Warm Editorial ── */
  --bg: #f4ebdd;
  --surface: #fdf8f0;
  --surface-raised: #fdf8f0;
  --ink: #3a2e22;
  --ink-muted: #9a8b76;
  --ink-subtle: #b5a690;
  --line: #ece0cd;
  --line-strong: #3a2e22;
  --badge-text: #6b5a44;

  /* Accent — terracotta (light) */
  --accent: #c2603f;
  --accent-soft: rgba(194,96,63,.1);

  /* Semantic status / danger — unchanged */
  --pistachio: #5F6B3C;
  --pistachio-soft: #EEF0E2;
  --mustard: #C98A12;
  --red: #D9381E;

  /* Legacy aliases → keep all inline references working */
  --chili: var(--accent);
  --chili-soft: var(--accent-soft);
  --text: var(--ink);
  --text-muted: var(--ink-muted);
  --text-subtle: var(--ink-subtle);
  --gray: var(--ink-muted);
  --gray-light: #ede3d5;
  --border: var(--line);
  --border-subtle: #f0e8d8;
  --blue: var(--accent);
  --blue-hover: #a84f32;
  --blue-light: var(--accent-soft);
  --blue-subtle: rgba(194,96,63,.18);
  --yellow: var(--mustard);
  --green: var(--pistachio);

  /* Warm editorial shadows */
  --shadow: 2px 2px 0 rgba(58,46,34,.18);
  --shadow-hover: 3px 3px 0 rgba(58,46,34,.22);
  --shadow-sm: var(--shadow);
  --shadow-md: var(--shadow);
  --shadow-lg: 4px 4px 0 rgba(58,46,34,.25);
  --card-shadow: var(--shadow);

  --radius: 7px;
  --radius-sm: 5px;
  --radius-full: 9999px;

  /* Type — Spectral serif (display) + IBM Plex Mono (UI/data) */
  --display: 'Spectral', Georgia, 'Times New Roman', serif;
  --body: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
  --mono: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
  --font: var(--body);
}

[data-theme="dark"] {
  /* ── 5 Dark Editorial ── */
  --bg: #1b1a17;
  --surface: #26241f;
  --surface-raised: #2f2c26;
  --ink: #efe9dd;
  --ink-muted: #8f8a7e;
  --ink-subtle: #65615a;
  --line: #322f29;
  --line-strong: #4a463d;
  --badge-text: #cfc8b9;

  /* Accent — amber (dark) */
  --accent: #e0a45e;
  --accent-soft: rgba(224,164,94,.15);

  --pistachio: #9BAA6B;
  --pistachio-soft: #232619;
  --mustard: #D9A33A;

  --gray-light: #2f2c26;
  --border-subtle: #2f2c26;
  --blue-hover: #e8b87a;
  --blue-subtle: rgba(224,164,94,.2);

  --shadow: 2px 2px 0 rgba(0,0,0,.45);
  --shadow-hover: 3px 3px 0 rgba(0,0,0,.55);
  --shadow-sm: var(--shadow);
  --shadow-md: var(--shadow);
  --shadow-lg: 4px 4px 0 rgba(0,0,0,.6);
  --card-shadow: var(--shadow);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  transition: background .25s, color .25s;
  letter-spacing: -.005em;
a { color: var(--chili); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo {
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text);
  flex: 1;
  letter-spacing: 0;
}
.nav-links { display: flex; gap: .25rem; align-items: center; }
.nav-link {
  padding: .35rem .7rem;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition: all .12s;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active {
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow);
}

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-bar-wrap { flex: 1; min-width: 0; }
.search-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.search-bar:focus-within { border-color: var(--ink-muted); box-shadow: var(--shadow-hover); }
.search-icon { margin-left: .7rem; color: var(--ink-subtle); flex-shrink: 0; }
#search-input,
#admin-search {
  flex: 1;
  border: none;
  background: transparent;
  padding: .38rem .45rem;
  font-size: .875rem;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
#search-input::placeholder,
#admin-search::placeholder { color: var(--text-subtle); }
.search-filter-btn {
  border: none;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink-muted);
  padding: .38rem .75rem;
  font-size: .72rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--body);
  display: flex;
  align-items: center;
  gap: .3rem;
  white-space: nowrap;
  transition: color .12s, background .12s;
  flex-shrink: 0;
}
.search-filter-btn:hover { color: var(--text); }
.search-filter-btn.active { color: var(--surface); background: var(--accent); border-left-color: var(--accent); }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 52px;
  z-index: 90;
  gap: .6rem;
}
.toolbar-left { display: flex; align-items: center; gap: .65rem; }
.toolbar-right { display: flex; align-items: center; gap: .5rem; }

.toolbar-filter-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .48rem .8rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
  font-family: var(--body);
}
.toolbar-filter-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.toolbar-filter-btn:active { transform: translateY(0); box-shadow: none; }
.toolbar-filter-btn.has-filters { background: var(--ink); color: var(--bg); }

.toolbar-count {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--ink-muted);
  font-weight: 500;
}

/* .view-btn — toolbar action buttons */
.view-btn {
  padding: .38rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .1s, color .1s, background .1s, box-shadow .1s;
  font-family: var(--body);
  white-space: nowrap;
}
.view-btn:hover { border-color: var(--ink-muted); color: var(--ink); box-shadow: var(--shadow-hover); }
.view-btn.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
#btn-map-toggle { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ── App body — list + collapsible map panel ──────────────────────────────── */
.app-body {
  display: flex;
  height: calc(100dvh - 52px - 41px); /* nav + toolbar */
  overflow: hidden;
  position: relative; /* filter drawer positions against this */
}

#list-container {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  transition: flex .3s ease;
}

/* Map panel — 50% width when open */
.map-panel {
  width: 0;
  overflow: hidden;
  transition: width .32s ease;
  position: relative;
  border-left: 0px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  flex-shrink: 0;
}
.app-body.map-open .map-panel {
  width: 50%;
  border-left-width: 1px;
}

/* Collapsed — narrow strip so toggle tab remains visible */
.map-panel.collapsed {
  width: 20px !important;
  overflow: visible;
}
.map-panel.collapsed #map { visibility: hidden; }

/* Toggle tab on left edge */
.map-panel-toggle {
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 24px;
  height: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px 0 0 6px;
  border-right: none;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -2px 0 8px rgba(0,0,0,.07);
  transition: color .15s, background .15s;
}
.app-body:not(.map-open) .map-panel-toggle { display: none; }
.map-panel-toggle:hover { color: var(--text); background: var(--gray-light); }

/* Map fills entire panel */
#map { flex: 1; min-height: 0; width: 100%; }

/* Mobile: full-screen slide-over */
@media (max-width: 768px) {
  .app-body {
    height: auto;
    overflow: visible;
    flex-direction: column;
  }
  #list-container { height: auto; overflow: visible; }

  /* Filter drawer: in-flow on mobile so it pushes cards down instead of covering them */
  .filter-drawer {
    position: static;
    transform: none !important;
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    border-radius: 0;
    border-bottom: none;
    box-shadow: none;
    pointer-events: none;
    transition: max-height .28s cubic-bezier(.32,.72,0,1), padding .2s ease, border-bottom-width 0s .28s;
  }
  .filter-drawer.open {
    max-height: 85dvh;
    overflow-y: auto;
    padding-top: 1.25rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--line);
    pointer-events: all;
    transition: max-height .28s cubic-bezier(.32,.72,0,1), padding .2s ease, border-bottom-width 0s;
  }
  /* no right-side constraint needed on mobile (map is a full overlay) */
  .app-body.map-open .filter-drawer { right: auto; }

  .map-panel {
    position: fixed;
    inset: 93px 0 0 0;
    width: 100% !important;
    height: calc(100dvh - 93px);
    transform: translateX(100%);
    transition: transform .3s ease;
    border-left: none;
    z-index: 85;
  }
  .app-body.map-open .map-panel { transform: translateX(0); width: 100% !important; }
  .map-panel.collapsed { width: 100% !important; transform: translateX(100%); }
  .map-panel-toggle { display: none !important; }
  .cards { padding-bottom: 5rem; }
}

/* Card number badge — catalog number style */
.card-num {
  position: absolute;
  top: .5rem;
  left: .5rem;
  z-index: 3;
  background: var(--bg);
  color: var(--badge-text);
  font-family: var(--mono);
  font-size: .65rem;
  font-weight: 500;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .1rem .38rem;
  line-height: 1.3;
}
.card.map-highlighted .card-num { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ── Card Grid container — no layout of its own; children set their own grid ─ */
.cards { display: block; }

/* ── Grid layout — flat or inside a section ───────────────────────────────── */
.cards-grid {
  padding: 1.1rem 1.25rem;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  padding-bottom: 4rem;
  max-width: 1800px;
  margin: 0 auto;
}
@media (min-width: 600px)  { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .cards-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1600px) { .cards-grid { grid-template-columns: repeat(5, 1fr); } }

/* When map is open, force 3 columns */
.app-body.map-open .cards-grid { grid-template-columns: repeat(3, 1fr); }

/* ── List (row) view ──────────────────────────────────────────────────────── */
.cards-list {
  display: flex;
  flex-direction: column;
  padding: .5rem 1rem;
}
.card-row {
  display: grid;
  grid-template-columns: minmax(140px,2fr) minmax(80px,1fr) 48px 80px minmax(80px,1fr) 80px auto;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  transition: background .12s;
}
.card-row:hover { background: var(--gray-light); }
.card-row.selected { background: var(--blue-light); outline: 1.5px solid var(--blue); }
.card-row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-been { background: var(--ink); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 4px; padding: .1rem .35rem; }
.badge-want { background: var(--blue); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 4px; padding: .1rem .35rem; }
.badge-closed { background: var(--red); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 4px; padding: .1rem .35rem; }

/* ── Card — editorial index card ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--line);
  transition: transform .12s ease, box-shadow .12s ease;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 0 220px;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.card.closed { opacity: .65; }

/* Image — fixed height, no border below */
.card-img-wrap {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  height: 104px;
  background: var(--line);
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--line);
}
/* Skipped cards: drained, greyed image */
.card.skipped .card-img,
.card.skipped .card-img-placeholder { filter: grayscale(.9); opacity: .7; }

/* Broken image (dead Yelp CDN link) → hide and show a quiet placeholder glyph */
.card-img.broken { display: none; }
.card-img-wrap:has(.card-img.broken)::after {
  content: '🍽';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--ink-subtle);
  pointer-events: none;
}

.card-img-placeholder {
  width: 100%;
  height: 100%;
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--ink-subtle);
}

/* Body */
.card-body {
  padding: .8rem .85rem .85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.card-name {
  font-family: var(--display);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--text);
}
.card-name a {
  color: inherit;
  transition: color .12s;
}
.card-name a:hover { color: var(--accent); text-decoration: none; }

/* Mono data row */
.card-meta {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--ink-muted);
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  align-items: center;
  letter-spacing: 0;
}
.card-meta-sep { color: var(--line-strong); opacity: .4; }
.stars { color: var(--accent); font-weight: 500; }
.price { font-weight: 500; color: var(--ink); }
.cat { color: var(--ink-muted); }

.card-location {
  font-size: .78rem;
  color: var(--ink-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .3rem;
}

/* Tags — small lowercase pills (the inline color set by JS tints text/border) */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: auto;
  padding-top: .1rem;
}
.card-tags .chip,
.tag {
  background: var(--chili-soft);
  color: var(--chili);
  font-size: .66rem;
  font-weight: 700;
  padding: .14rem .5rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  letter-spacing: 0;
  text-transform: lowercase;
  border: 1px solid transparent;
  cursor: default;
}
.tag.alt { background: var(--pistachio-soft); color: var(--pistachio); }
.tag-remove { cursor: pointer; opacity: .4; font-size: .6rem; transition: opacity .1s; }
.tag-remove:hover { opacity: 1; }

/* ★ SIGNATURE: status rubber stamps — overlaid, centered on the card image */
.stamp {
  position: absolute;
  top: 50%; left: 50%;
  z-index: 3;
  font-family: var(--display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 1.15rem;
  line-height: 1;
  padding: .35rem .8rem;
  border: 4px solid currentColor;
  border-radius: 6px;
  transform: translate(-50%, -50%) rotate(-9deg);
  mix-blend-mode: multiply;
  opacity: 1;
  pointer-events: none;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.55' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .85 0'/%3E%3C/filter%3E%3Crect width='120' height='40' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.55' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .85 0'/%3E%3C/filter%3E%3Crect width='120' height='40' filter='url(%23n)'/%3E%3C/svg%3E");
}
.stamp.been { color: var(--ink); } /* ink reads like a real rubber stamp; dark mode → chalk white via --ink + screen blend */
.stamp.skip { color: var(--ink-subtle); transform: translate(-50%, -50%) rotate(6deg); }
[data-theme="dark"] .stamp { mix-blend-mode: screen; }

/* Open / closed flag — mono ink chip, pinned bottom-left of the image.
   bg/text use --ink/--surface so the chip stays legible on photos in both
   themes; OPEN vs CLOSED are distinguished by the word + time, not colour. */
.open-flag {
  position: absolute;
  bottom: .55rem; left: .55rem;
  z-index: 3;
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .05em;
  background: var(--ink);
  color: var(--surface);
  padding: .16rem .45rem;
  border-radius: 3px;
}

.open-flag.closed { background: var(--ink-muted); color: var(--surface); }

/* Status badges (still used in admin list rows) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: .65rem;
  font-weight: 700;
  padding: .18rem .5rem;
  border-radius: var(--radius-full);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.status-badge.want { background: var(--gray-light); color: var(--ink-subtle); border: 1px solid var(--line); }
.status-badge.been { background: var(--ink); color: var(--bg); }
.status-badge.skip { background: var(--gray-light); color: var(--ink-muted); border: 1px solid var(--line); text-decoration: line-through; }

/* Permanently-closed / needs-check corner badge — top-right to clear card-num */
.closed-badge, .warn-badge {
  position: absolute;
  top: .55rem;
  right: .55rem;
  z-index: 3;
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 600;
  padding: .14rem .45rem;
  border-radius: var(--radius);
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1.5px solid var(--ink);
}
.closed-badge { background: var(--ink); color: var(--bg); }
.warn-badge { background: var(--mustard); color: #fff; border-color: var(--mustard); }

/* Notes — dashed rule above italic field-notes */
.card-notes-rendered {
  font-size: .76rem;
  color: var(--ink-muted);
  line-height: 1.45;
  font-style: italic;
  border-top: 1px dashed var(--line);
  padding-top: .5rem;
  margin-top: .15rem;
  min-height: 20px;
}
.card-notes-rendered ul, .card-notes-rendered ol { margin: .15rem 0 .15rem 1rem; }
.card-notes-rendered li { margin-bottom: .1rem; }
.card-notes-rendered p { margin: .1rem 0; }
.card-notes-rendered:empty::before { content: ''; }

.card-notes {
  width: 100%;
  padding: .45rem .55rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .76rem;
  font-family: var(--font);
  resize: none;
  min-height: 52px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.card-notes:focus { outline: none; border-color: var(--blue); }

/* Website */
.card-website {
  font-size: .7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  color: var(--blue);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card actions */
.card-actions {
  padding: .55rem .85rem .7rem;
  display: flex;
  gap: .3rem;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.btn-sm {
  padding: .28rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--badge-text);
  cursor: pointer;
  transition: border-color .1s, color .1s, background .1s;
  font-family: var(--body);
}
.btn-sm:hover { border-color: var(--ink-muted); color: var(--ink); }
.btn-sm.active { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn-sm.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-sm.danger:hover { background: var(--red); color: #fff; }

/* Thumbnail edit */
.card-img-edit {
  position: absolute;
  bottom: .5rem;
  right: .5rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .22rem .5rem;
  font-size: .65rem;
  font-weight: 600;
  cursor: pointer;
  display: none;
  font-family: var(--font);
  z-index: 3;
  letter-spacing: .02em;
}
.card-img-wrap:hover .card-img-edit { display: block; }


/* ── Filter drawer ────────────────────────────────────────────────────────── */
.filter-drawer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: 0 4px 12px rgba(58,46,34,.1);
  z-index: 200;
  transform: translateY(-110%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  max-height: calc(100dvh - 93px);
  overflow-y: auto;
  pointer-events: none;
}
.filter-drawer.open {
  transform: translateY(0);
  pointer-events: all;
}
.app-body.map-open .filter-drawer { right: 50%; }
.filter-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.filter-label {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .35rem;
  display: block;
}
.chip {
  padding: .25rem .65rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  font-size: .72rem;
  font-weight: 400;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink-muted);
  transition: border-color .1s, color .1s, background .1s;
  user-select: none;
  font-family: var(--body);
}
.chip:hover { border-color: var(--ink-muted); color: var(--ink); }
.chip.active { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.sort-select {
  padding: .4rem .6rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  font-size: .82rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--body);
}

/* ── Multi-select ─────────────────────────────────────────────────────────── */
.select-bar {
  position: sticky;
  top: 52px;
  z-index: 89;
  background: var(--accent);
  color: var(--surface);
  padding: .45rem 1rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.select-bar button {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  padding: .25rem .65rem;
  border-radius: var(--radius-sm);
  font-size: .7rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: .02em;
  transition: background .15s;
}
.select-bar button:hover { background: rgba(255,255,255,.25); }
.select-bar button.danger { background: rgba(240,62,62,.3); border-color: rgba(240,62,62,.5); }
.select-bar .select-spacer { flex: 1; }

.card.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.card-checkbox {
  position: absolute;
  top: .6rem;
  right: .6rem;
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,.8);
  background: rgba(0,0,0,.3);
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .75rem;
}
.card.selected .card-checkbox { background: var(--blue); border-color: var(--blue); }

/* ── Banners ──────────────────────────────────────────────────────────────── */
.banner {
  margin: .75rem 1.25rem 0;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.banner-warn { background: #fff9db; border: 1px solid #ffe066; color: #5c3d00; }
.banner-info { background: var(--blue-light); border: 1px solid var(--blue-subtle); color: var(--blue); }
.banner-blue  { background: var(--blue); border: 1px solid var(--blue-hover); color: #fff; }
.banner-alert { background: #fff4e6; border: 1px solid #ffc078; color: #7c3800; }
.banner-btn-blue {
  background: var(--blue) !important;
  color: #fff !important;
}
.banner-btn-blue:hover { background: var(--blue-hover) !important; }
.banner-btn {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border: none;
  padding: .32rem .7rem;
  border-radius: var(--radius-sm);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font);
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* Rate bar */
.rate-bar {
  background: var(--blue-light);
  color: var(--blue);
  font-size: .7rem;
  font-weight: 600;
  text-align: center;
  padding: .2rem;
  letter-spacing: .02em;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 6rem 2rem;
  color: var(--text-muted);
}
.empty h2 {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .5rem;
}
.empty p { font-size: .82rem; line-height: 1.7; }

/* ── Import / forms ───────────────────────────────────────────────────────── */
.import-box {
  max-width: 560px;
  margin: 2rem auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--ink);
  padding: 1.75rem;
}
.import-box h2 { font-family: var(--display); margin-bottom: .5rem; font-size: 1.2rem; font-weight: 800; letter-spacing: -.03em; }
.import-box p { font-size: .875rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.6; }
.import-input {
  width: 100%;
  padding: .65rem .875rem;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: .75rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--body);
  transition: box-shadow .12s;
}
.import-input:focus { outline: none; box-shadow: var(--shadow); }
.btn-primary {
  background: var(--accent);
  color: var(--surface);
  border: 1px solid var(--accent);
  padding: .65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  width: 100%;
  box-shadow: var(--shadow);
  font-family: var(--body);
  transition: opacity .1s, box-shadow .1s;
}
.btn-primary:hover { opacity: .9; box-shadow: var(--shadow-hover); }
.btn-primary:active { opacity: .8; box-shadow: none; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.progress-list { margin-top: 1rem; font-size: .8rem; color: var(--text-muted); }
.progress-item { padding: .28rem 0; display: flex; align-items: flex-start; gap: .5rem; line-height: 1.4; }
.progress-item.done { color: var(--green); }
.progress-item.err { color: var(--red); }
.progress-item.warn { color: var(--yellow); }

/* ── Random picker modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--bg);
  border-radius: 6px;
  padding: 2rem;
  max-width: 360px;
  width: 92%;
  text-align: center;
  box-shadow: 6px 6px 0 rgba(22,22,22,.9);
  border: 2px solid var(--ink);
  animation: slideUp .28s cubic-bezier(.32,.72,0,1);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.modal h2 { font-family: var(--mono); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--chili); }
.modal .picked-name { font-family: var(--display); font-size: 1.65rem; font-weight: 800; color: var(--text); margin: 1rem 0 .5rem; letter-spacing: -.03em; line-height: 1.15; }
.modal .picked-meta { color: var(--text-muted); font-size: .84rem; }
.modal-close {
  margin-top: 1.25rem;
  background: var(--gray-light);
  color: var(--text);
  border: none;
  padding: .55rem 1.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 700;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: background .15s;
}
.modal-close:hover { background: var(--border); }

/* ── Nav menu (⋮ dropdown) ────────────────────────────────────────────────── */
.nav-menu-wrap { position: relative; }
.nav-menu-btn {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: .28rem .55rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
  font-family: var(--body);
  display: flex;
  align-items: center;
}
.nav-menu-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.nav-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
}
.nav-menu-dropdown.open { display: block; }
.nav-menu-item {
  display: block;
  width: 100%;
  padding: .6rem 1rem;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.nav-menu-item:hover { background: var(--gray-light); color: var(--text); }
.nav-menu-divider { height: 1px; background: var(--border); margin: .25rem 0; }
/* On mobile: nav links fold into menu */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 52px;
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .5rem 0;
    z-index: 150;
  }
}

/* ── Dark mode toggle (legacy class kept for JS compat) ───────────────────── */
.dark-toggle {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .28rem .6rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
  white-space: nowrap;
  font-family: var(--font);
}
.dark-toggle:hover { border-color: var(--text); color: var(--text); }

/* ── Color swatches ───────────────────────────────────────────────────────── */
.color-swatch {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 5px;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform .12s, border-color .12s;
  vertical-align: middle;
}
.color-swatch:hover { transform: scale(1.18); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.08); }
.color-palette { display: flex; gap: .3rem; flex-wrap: wrap; }

/* ── Tag popover ──────────────────────────────────────────────────────────── */
.tag-popover {
  position: fixed;
  z-index: 2000;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: .55rem;
  width: 230px;
}
.tag-pop-search {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem .55rem;
  font-size: .82rem;
  font-family: var(--font);
  outline: none;
  background: var(--bg);
  color: var(--text);
  margin-bottom: .35rem;
  box-sizing: border-box;
}
.tag-pop-search:focus { border-color: var(--blue); }
.tag-pop-list { max-height: 160px; overflow-y: auto; margin-bottom: .1rem; }
.tag-pop-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  transition: background .1s;
}
.tag-pop-item:hover { background: var(--gray-light); }
.tag-pop-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid rgba(0,0,0,.12); }
.tag-pop-divider { height: 1px; background: var(--border); margin: .35rem 0; }
.tag-pop-create { padding-top: .1rem; }
.tag-pop-create-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; }
.tag-pop-empty { color: var(--text-subtle); padding: .3rem .4rem; font-size: .78rem; }

/* ── Connection tiles ─────────────────────────────────────────────────────── */
.connections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.connection-tile {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.connection-tile-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--gray-light);
}
.connection-tile-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #D32323;
}
.connection-tile-name {
  font-weight: 700;
  font-size: .92rem;
}
.connection-tile-status {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .15rem;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background .2s;
}
.status-dot.ok       { background: var(--green); }
.status-dot.error    { background: var(--red); }
.status-dot.checking { background: var(--yellow); animation: pulse-dot .9s ease-in-out infinite alternate; }
@keyframes pulse-dot { from { opacity:.4 } to { opacity:1 } }
.connection-tile-body { padding: 1rem; }
.conn-field { margin-bottom: .85rem; }
.conn-field-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-subtle);
  margin-bottom: .3rem;
}
.conn-field-value { font-size: .82rem; }

/* ── Color picker with wheel ──────────────────────────────────────────────── */
.color-picker-wrap .color-palette { display: flex; gap: .3rem; flex-wrap: wrap; }
.cpick-wheel::-webkit-color-swatch-wrapper { padding: 0; }
.cpick-wheel::-webkit-color-swatch { border: none; border-radius: 3px; }
.cpick-hex:focus { border-color: var(--blue); }

/* ── Search import results ────────────────────────────────────────────────── */
.search-import-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: .35rem;
  transition: border-color .12s;
}
.search-import-row:hover { border-color: var(--blue); }

/* ── Attribution ──────────────────────────────────────────────────────────── */
.yelp-attr {
  text-align: center;
  padding: .75rem;
  font-size: .68rem;
  color: var(--text-subtle);
  border-top: 1px solid var(--border);
  background: var(--surface);
  letter-spacing: .02em;
}
.yelp-attr a { color: var(--red); font-weight: 700; }

/* stat-pill kept for admin compat */
.stat-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .22rem .65rem; border-radius: var(--radius-full);
  border: 1px solid var(--line); font-size: .7rem; font-weight: 400;
  letter-spacing: 0; user-select: none; font-family: var(--mono);
}
.stat-pill.want { background: var(--accent-soft); color: var(--accent); border-color: rgba(194,96,63,.25); }
.stat-pill.been { background: var(--gray-light); color: var(--ink); border-color: var(--line); }
.stat-pill.skip { background: var(--gray-light); color: var(--text-subtle); border-color: var(--line); }
.stat-pill.closed { background: rgba(217,56,30,.08); color: var(--red); border-color: rgba(217,56,30,.25); cursor: pointer; }
.stat-pill.closed:hover { opacity: .8; }
[data-theme="dark"] .stat-pill.want { border-color: rgba(224,164,94,.25); }
[data-theme="dark"] .stat-pill.closed { background: rgba(217,56,30,.15); }

/* ── Card inline edit panel ───────────────────────────────────────────────── */
.card-edit-panel {
  display: none; flex-direction: column; gap: .6rem;
  padding: .875rem 1rem 1rem; border-top: 1px solid var(--border);
  background: var(--surface);
}
.card.editing .card-edit-panel { display: flex; }
.card.editing .card-actions { display: none; }
.card.editing { transform: none !important; box-shadow: 0 0 0 2px var(--blue), var(--shadow-md) !important; }

.card-edit-hd {
  display: flex; align-items: center; justify-content: space-between;
}
.card-edit-hd-label {
  font-size: .65rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-subtle);
}
.card-edit-x {
  background: none; border: none; cursor: pointer; color: var(--text-subtle);
  font-size: .85rem; padding: .15rem .25rem; border-radius: 4px;
  font-family: var(--font); line-height: 1; transition: color .1s;
}
.card-edit-x:hover { color: var(--text); }

.card-edit-status-row { display: flex; gap: .35rem; }
.edit-status-btn {
  flex: 1; padding: .32rem .4rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: .72rem; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: all .12s;
  letter-spacing: .01em; text-align: center;
}
.edit-status-btn:hover { border-color: var(--text); color: var(--text); }
.edit-status-btn[data-s="want"].active { background: var(--chili-soft); border-color: var(--chili); color: var(--chili); }
.edit-status-btn[data-s="been"].active { background: var(--gray-light); border-color: var(--ink); color: var(--ink); }
.edit-status-btn[data-s="skip"].active { background: var(--gray-light); border-color: var(--ink-subtle); color: var(--ink-subtle); }

.card-edit-tags-section { display: flex; flex-direction: column; gap: .35rem; }
.card-edit-tags-list { display: flex; flex-wrap: wrap; gap: .3rem; min-height: 20px; }
.edit-tag-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--blue-light); border: 1px solid var(--blue-subtle);
  color: var(--blue); border-radius: var(--radius-full);
  font-size: .7rem; font-weight: 600; padding: .2rem .55rem;
}
.edit-tag-rm {
  background: none; border: none; cursor: pointer; color: inherit;
  opacity: .6; font-size: .8rem; line-height: 1; padding: 0;
  font-family: var(--font);
}
.edit-tag-rm:hover { opacity: 1; }
.card-edit-tag-input-wrap { position: relative; }
.card-edit-tag-input {
  width: 100%; padding: .32rem .6rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .8rem; font-family: var(--font);
  background: var(--bg); color: var(--text); outline: none; transition: border-color .15s;
}
.card-edit-tag-input:focus { border-color: var(--blue); }
.card-edit-tag-drop {
  position: absolute; top: calc(100% + 3px); left: 0; right: 0;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 300; max-height: 130px; overflow-y: auto;
}
.card-edit-tag-drop-item {
  padding: .35rem .6rem; font-size: .8rem; cursor: pointer;
  transition: background .1s; color: var(--text);
}
.card-edit-tag-drop-item:hover { background: var(--gray-light); }

.card-edit-footer { display: flex; gap: .5rem; }
.card-edit-footer .btn-sm { flex: 1; text-align: center; padding: .38rem; }

/* Notes expand/collapse */
.card-notes-rendered {
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  display: -webkit-box; overflow: hidden; cursor: pointer;
  position: relative;
}
.card-notes-rendered.expanded { display: block; overflow: visible; }
.card-notes-rendered::after {
  content: 'more'; position: absolute; bottom: 0; right: 0;
  background: linear-gradient(to right, transparent, var(--surface) 30%);
  padding-left: 1.5rem; font-size: .68rem; font-weight: 700;
  color: var(--text-subtle); letter-spacing: .02em;
  pointer-events: none;
}
.card-notes-rendered.expanded::after { display: none; }

/* ── Map drag-to-resize handle ────────────────────────────────────────────── */
.map-resize-handle {
  width: 6px; flex-shrink: 0; background: var(--border);
  cursor: col-resize; position: relative; z-index: 5;
  transition: background .15s; display: none;
}
.app-body.map-open .map-resize-handle { display: block; }
.map-resize-handle:hover, .map-resize-handle.dragging { background: var(--blue); }
.map-resize-handle::before {
  content: '⋮'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); color: var(--text-subtle);
  font-size: .6rem; pointer-events: none; line-height: 1;
}
@media (max-width: 768px) { .map-resize-handle { display: none !important; } }

/* ── Mobile bottom tab bar ────────────────────────────────────────────────── */
.mobile-tab-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; height: 56px;
  background: var(--surface); border-top: 1px solid var(--line);
  z-index: 95; box-shadow: 0 -2px 12px rgba(58,46,34,.08);
}
.mobile-tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .18rem; border: none; background: transparent;
  font-size: .58rem; font-weight: 500; color: var(--ink-subtle);
  letter-spacing: .04em; text-transform: uppercase; cursor: pointer;
  font-family: var(--font); transition: color .15s;
}
.mobile-tab-btn.active { color: var(--accent); }
.mobile-tab-btn svg { width: 20px; height: 20px; }
@media (max-width: 768px) {
  .mobile-tab-bar { display: flex; }
  #btn-map-toggle { display: none !important; }
  .cards { padding-bottom: 5.5rem; }
  .app-body { height: calc(100dvh - 93px - 56px); }
  .map-panel { bottom: 56px !important; inset: 93px 0 56px 0 !important; height: calc(100dvh - 93px - 56px) !important; }
}

/* ── Random modal bigger ──────────────────────────────────────────────────── */
#random-modal-img { height: 260px; }
#random-modal-card { max-width: 460px; }
#random-modal-name { font-size: 1.45rem; }

/* ── Grouped sections ─────────────────────────────────────────────────────── */
.section-group { }
.section-header {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .9rem 1.25rem .6rem;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--line);
}
.section-header:hover .section-title { color: var(--accent); }
.section-chevron {
  font-size: .7rem;
  color: var(--ink-muted);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.section-chevron.collapsed { transform: rotate(-90deg); }
.section-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  transition: color .12s;
}
.section-count {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--ink-muted);
  margin-left: auto;
}
.section-cards {
  padding: 1rem 1.25rem 1.5rem;
}
.section-cards.collapsed { display: none; }

/* ── View toggle ──────────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.view-toggle-btn {
  padding: .36rem .55rem;
  border: none;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  font-size: .8rem;
  line-height: 1;
  transition: background .1s, color .1s;
  border-right: 1px solid var(--line);
}
.view-toggle-btn:last-child { border-right: none; }
.view-toggle-btn:hover { color: var(--ink); }
.view-toggle-btn.active { background: var(--ink); color: var(--surface); }

/* ── Active filter chips bar ──────────────────────────────────────────────── */
.active-filters-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.active-filters-bar.visible { display: flex; }
.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .18rem .55rem;
  background: var(--accent-soft);
  border: 1px solid rgba(194,96,63,.25);
  color: var(--accent);
  font-family: var(--mono);
  font-size: .68rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background .1s;
}
[data-theme="dark"] .active-filter-chip {
  border-color: rgba(224,164,94,.25);
}
.active-filter-chip:hover { background: var(--accent); color: var(--surface); }
.clear-all-btn {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: .18rem .4rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.clear-all-btn:hover { color: var(--accent); }

/* ── List view ────────────────────────────────────────────────────────────── */
.cards-list-view {
  padding: 0 1.25rem 4rem;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .1s;
  border-radius: 3px;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
}
.list-row:hover { background: var(--accent-soft); }
.list-row-thumb {
  width: 72px;
  height: 54px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--line);
  border: 1px solid var(--line);
}
.list-row-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--ink-subtle);
}
.list-row-info { flex: 1; min-width: 0; }
.list-row-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row-meta {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-muted);
  margin-top: .18rem;
}
.list-row-status {
  font-family: var(--mono);
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-subtle);
  flex-shrink: 0;
}
.list-row-num {
  font-family: var(--mono);
  font-size: .65rem;
  color: var(--badge-text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 500;
}

/* ── Table view ───────────────────────────────────────────────────────────── */
.biz-table-wrap {
  overflow-x: auto;
  padding: 0 1.25rem 4rem;
}
.biz-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: .75rem;
}
.biz-table th {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-muted);
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  background: var(--bg);
  position: sticky;
  top: 0;
}
.biz-table th:hover { color: var(--ink); }
.biz-table th.sort-asc::after { content: ' ↑'; color: var(--accent); }
.biz-table th.sort-desc::after { content: ' ↓'; color: var(--accent); }
.biz-table td {
  padding: .48rem .75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}
.biz-table tr:hover td { background: var(--accent-soft); }
.biz-table tr.selected td { background: var(--accent-soft); }
.td-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: .82rem;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.td-thumb {
  width: 44px;
  height: 33px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--line);
  border: 1px solid var(--line);
  vertical-align: middle;
  display: block;
}
.td-status {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-subtle);
}
.td-rating { color: var(--accent); font-weight: 500; }
.biz-table input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }

/* Bulk action bar */
.bulk-bar {
  position: sticky;
  top: 93px;
  background: var(--ink);
  color: var(--surface);
  padding: .45rem 1.25rem;
  display: none;
  align-items: center;
  gap: .75rem;
  font-family: var(--mono);
  font-size: .75rem;
  z-index: 85;
}
.bulk-bar.visible { display: flex; }
.bulk-bar-count { font-weight: 500; }
.bulk-bar select {
  background: rgba(255,255,255,.12);
  color: var(--surface);
  border: 1px solid rgba(255,255,255,.25);
  padding: .22rem .5rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .72rem;
  cursor: pointer;
}
.bulk-bar-clear {
  margin-left: auto;
  background: rgba(255,255,255,.1);
  color: var(--surface);
  border: 1px solid rgba(255,255,255,.2);
  padding: .2rem .55rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .7rem;
  cursor: pointer;
}
.bulk-bar-clear:hover { background: rgba(255,255,255,.2); }

/* ── Stats bar (line below toolbar) ──────────────────────────────────────── */
#stats-bar {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--ink-muted);
  padding: .4rem 1.25rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
#stats-bar .ledger-item b { color: var(--ink); font-weight: 600; }
#stats-bar .dot { color: var(--accent); }
#stats-bar .ledger-item.closed { cursor: pointer; }
#stats-bar .ledger-item.closed:hover { color: var(--accent); }

/* ── Quality floor ────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .card:hover { transform: none; }
}

/* ── Password modal ───────────────────────────────────────────────────────── */
.pw-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.55);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.pw-overlay.open { display: flex; }
.pw-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.75rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.pw-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
}
.pw-subtitle {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-muted);
  margin-top: -.4rem;
}
.pw-input {
  font-family: var(--mono);
  font-size: .88rem;
  padding: .55rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}
.pw-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.pw-submit {
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 600;
  padding: .6rem 1rem;
  background: var(--accent);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
}
.pw-submit:hover { opacity: .88; }
.pw-error {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--red);
  min-height: 1em;
  text-align: center;
}
