/* ===========================================================================
   Deal Hunter — Obsidian & Silver
   Premium monochrome. No green, no neon, no gradients used as decoration.
   Depth comes from surface contrast, hairline borders and layered panels.
   =========================================================================== */

:root {
  --bg:        #080808;
  --card:      #111111;
  --elevated:  #181818;
  --border:    #262626;
  --border-hi: #333333;
  --text:      #F5F5F5;
  --text-2:    #929292;
  --text-3:    #808080;   /* 4.98:1 on #080808 — passes WCAG AA for small text */
  --silver:    #C4CAD4;
  --danger:    #E06C6C;
  --danger-dim:#2A1717;

  --r-s: 4px;
  --r-m: 6px;
  --r-l: 8px;

  --rail-w: 232px;
  --ctl-h: 40px;           /* one height for every input, select and button */
  --ease: cubic-bezier(.2, 0, 0, 1);
  --dur: 220ms;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p { margin: 0; }

/* Any component-level `display` outranks the UA rule for [hidden], so hidden
   elements (chips row, new-listings pill, clear button, nav badges) would keep
   painting. One rule keeps `hidden` meaning hidden everywhere. */
[hidden] { display: none !important; }

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

/* Focus: 2px ring with offset — meets WCAG 2.2 focus-appearance guidance. */
:focus-visible {
  outline: 2px solid var(--silver);
  outline-offset: 2px;
  border-radius: var(--r-s);
}

::selection { background: rgba(196, 202, 212, .25); }

/* ============================ APP SHELL ================================== */

.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

/* ---- rail ---- */
.rail {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.wordmark { display: flex; align-items: center; min-width: 0; }
.wordmark-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  color: var(--text);
}

.nav { display: none; flex-direction: column; gap: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  background: transparent;
  border: 0;
  border-radius: var(--r-m);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--elevated); color: var(--text); }
/* animated left edge indicator */
.nav-item::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  width: 2px; height: 0;
  background: var(--silver);
  border-radius: 2px;
  transform: translateY(-50%);
  transition: height var(--dur) var(--ease);
}
.nav-item.active::before { height: 16px; }

.rail-foot { margin-left: auto; display: none; }

.conn {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--text-2);
}
.conn-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.conn.on .conn-dot { background: var(--silver); box-shadow: 0 0 0 3px rgba(196,202,212,.14); }
.conn.off .conn-dot { background: var(--danger); }

/* ---- main ---- */
.main {
  min-width: 0;
  padding: 20px 16px calc(88px + env(safe-area-inset-bottom));
}

.view { display: none; }
.view.active { display: block; animation: view-in 340ms var(--ease) both; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---- page head ---- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 {
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.15;
}
.sub {
  margin-top: 5px;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.section-label {
  display: flex; align-items: center; gap: 14px;
  margin: 30px 0 14px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.section-label i { flex: 1; height: 1px; background: var(--border); }

/* ============================ TOOLBAR ==================================== */

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--ctl-h);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  padding: 0 11px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.field:hover { border-color: var(--border-hi); }
.field:focus-within {
  border-color: var(--silver);
  background: var(--elevated);
  outline: none;
}
.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 14px;
  line-height: 1;
}

/* multi-word input: typed words become removable chips */
.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: var(--ctl-h);
  padding: 5px 9px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  cursor: text;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tags:hover { border-color: var(--border-hi); }
.tags:focus-within { border-color: var(--silver); background: var(--elevated); }
.tags input {
  flex: 1 1 140px;
  min-width: 120px;
  height: 26px;
  padding: 0 4px;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 14px;
}
.tags input::placeholder { color: var(--text-3); }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px;
  padding: 0 4px 0 10px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--silver);
  animation: fade-in 180ms var(--ease);
}
.tag button {
  display: grid; place-items: center;
  width: 18px; height: 18px;
  padding: 0; background: none; border: 0; border-radius: 50%;
  color: var(--text-3); cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tag button:hover { color: var(--text); background: var(--border); }
.tag svg { width: 9px; height: 9px; }

/* quick max-price choices */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; }
.preset {
  height: 30px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.preset:hover { border-color: var(--border-hi); color: var(--text); }
.preset[aria-pressed="true"] { background: var(--elevated); border-color: var(--silver); color: var(--text); }

/* plain-English summary of what the rule will do */
.rule-preview {
  padding: 11px 13px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.rule-preview b { color: var(--text); font-weight: 600; }
.field input::placeholder { color: var(--text-3); }
.field input[type=number] { -moz-appearance: textfield; }
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.field-icon { width: 16px; height: 16px; color: var(--text-3); flex: none; pointer-events: none; }

.field-clear {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  background: transparent; border: 0;
  border-radius: var(--r-s);
  color: var(--text-3); cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.field-clear svg { width: 13px; height: 13px; }
.field-clear:hover { color: var(--text); background: var(--border); }

.field-prefix {
  display: inline-flex; align-items: center;
  font-size: 11.5px;
  line-height: 1;
  color: var(--text-3);
  letter-spacing: .04em;
  text-transform: uppercase;
  flex: none;
}
.filters { display: flex; align-items: center; gap: 8px; min-width: 0; }
.filters .field { flex: 1; min-width: 0; }
.filter-sep { width: 1px; align-self: stretch; background: var(--border); }

/* ---- sort select ---- */
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.select { position: relative; display: inline-flex; }
.select select {
  appearance: none;
  height: var(--ctl-h);
  padding: 0 32px 0 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}
.select select:hover { border-color: var(--border-hi); }
.select svg {
  position: absolute; right: 10px; top: 50%;
  width: 15px; height: 15px;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* ---- active filter chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; animation: fade-in 260ms var(--ease); }

/* ---- new listings indicator ----
   Appears above the feed when the collector found posts the user has not
   seen. Nothing re-renders underneath: the feed, scroll position, filters
   and sort all stay exactly as they were until this is clicked. */
.new-pill {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 0 0 14px;
  padding: 9px 15px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  animation: fade-in 260ms var(--ease);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.new-pill:hover { background: var(--card); border-color: var(--silver); }
.new-pill svg { width: 13px; height: 13px; color: var(--silver); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--silver);
  animation: fade-in 220ms var(--ease);
}
.chip button {
  display: grid; place-items: center;
  width: 14px; height: 14px;
  padding: 0; background: none; border: 0;
  color: var(--text-3); cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.chip button:hover { color: var(--text); }
.chip svg { width: 9px; height: 9px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ============================ GRID / CARDS =============================== */

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  overflow: hidden;
  animation: card-in 420ms var(--ease) both;
  transition: border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.card:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0,0,0,.5);
}
.card:active { transform: translateY(0); }
.card.is-new { border-color: var(--border-hi); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---- image ---- */
.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--elevated);
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 520ms var(--ease);
}
.card:hover .card-media img { transform: scale(1.035); }
/* hairline separates media from body — deliberately brighter than --border so
   the image panel reads as a framed picture, not part of the card */
.card-media::after {
  content: "";
  position: absolute; inset: auto 0 0 0;
  height: 1px; background: var(--border-hi);
}
.card-media::before {
  content: "";
  position: absolute; inset: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  pointer-events: none;
  z-index: 1;
}
/* ---- image: loading state and fallback ---------------------------------- */
.card-media[data-media] img { opacity: 0; }
.card-media[data-media].loaded img { opacity: 1; }
/* failed download: drop the broken-image glyph, show the quiet fallback */
.card-media[data-media].failed img { display: none; }
.card-media[data-media].failed { background: var(--elevated); }
.card-media[data-media].failed::before {
  content: "Image unavailable";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-3); letter-spacing: .04em;
}
.card-media.no-media {
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(135deg, transparent 0 9px,
      rgba(255,255,255,.022) 9px 10px),
    var(--elevated);
}
.card-media.no-media .media-glyph {
  width: 26px; height: 26px;
  color: var(--text-3); opacity: .55;
}
.card-media.no-media .media-glyph svg { width: 100%; height: 100%; }

.card-rule {
  position: absolute; top: 9px; left: 9px;
  padding: 3px 8px;
  background: rgba(8,8,8,.82);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-s);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--silver);
}

/* ---- body ---- */
.card-body { display: flex; flex-direction: column; gap: 10px; padding: 15px 16px 16px; flex: 1; }

.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-title {
  font-size: 14.5px;
  font-weight: 550;
  letter-spacing: -.012em;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.price {
  flex: none;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.028em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.price.na { color: var(--text-3); font-size: 14px; font-weight: 500; }

.card-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}
.src-tag {
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-2);
}
.src-tag .dot {
  width: 4px; height: 4px; flex: none;
  border-radius: 50%;
  background: var(--text-3);
}
.src-tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.when {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-left: auto;
}

.open-post {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--silver);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.open-post:hover { border-bottom-color: var(--silver); }
.open-post svg { width: 12px; height: 12px; }

/* ============================ PANEL / FORM =============================== */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  padding: 18px;
}
.panel-head { margin-bottom: 16px; }
.panel-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.015em;
}
.hint { margin-top: 4px; font-size: 12.5px; color: var(--text-3); }

.rule-form { display: grid; gap: 18px; }

.field-wrap { display: grid; gap: 7px; min-width: 0; }
.label-text {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.label-text em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-3);
  margin-left: 5px;
}

.error {
  font-size: 13px;
  color: var(--danger);
  min-height: 1em;
}
.form-actions { display: flex; justify-content: flex-end; }
.source-add { display: flex; gap: 8px; }
.source-add .field { flex: 1; min-width: 0; }
.source-add .error { margin-top: 8px; }

/* ============================ BUTTONS ==================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--ctl-h);
  padding: 0 15px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform 120ms var(--ease),
              color var(--dur) var(--ease);
}
.btn:hover { background: #1E1E1E; border-color: var(--border-hi); }
.btn:active { transform: scale(.975); }

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  font-weight: 600;
}
.btn-primary:hover { background: var(--silver); border-color: var(--silver); color: var(--bg); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; background: var(--text); border-color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--card); color: var(--text); }

.btn-danger { background: transparent; border-color: var(--border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); border-color: #402323; }

.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: var(--r-s);
}
.btn-icon svg { width: 14px; height: 14px; }

/* ============================ STACK ROWS ================================= */

.stack { display: grid; gap: 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  animation: card-in 340ms var(--ease) both;
  transition: border-color var(--dur) var(--ease);
}
.row:hover { border-color: var(--border-hi); }

.row-main { min-width: 0; flex: 1; }
.row-title {
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 7px;
}
.row-side {
  display: flex; align-items: center; gap: 8px;
  flex: none;
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.pill.silver { color: var(--silver); border-color: var(--border-hi); }

.stat {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

/* settings definition rows */
.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
}
.kv dt { font-size: 13.5px; color: var(--text-2); }
.kv dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kv dd.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

.state {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
}
.state i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.state.on  { color: var(--silver); }
.state.on i { background: var(--silver); }
.state.off { color: var(--text-3); }

/* ============================ EMPTY / SKELETON =========================== */

.empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-l);
  animation: fade-in 300ms var(--ease);
}
.empty .glyph {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--text-3);
}
.empty .glyph svg { width: 26px; height: 26px; }
.empty h3 { font-size: 14.5px; font-weight: 550; letter-spacing: -.01em; }
.empty p { font-size: 13px; color: var(--text-2); max-width: 40ch; }
.empty .btn { margin-top: 4px; }

/* skeletons */
.skeleton {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  overflow: hidden;
}
.skeleton .sk-media { aspect-ratio: 16/10; background: var(--elevated); }
.skeleton .sk-line { height: 11px; border-radius: 3px; margin: 14px 14px 0; background: var(--elevated); }
.skeleton .sk-line.w60 { width: 60%; }
.skeleton .sk-line.w40 { width: 40%; margin-bottom: 16px; }
.shimmer {
  background: linear-gradient(90deg, var(--elevated) 25%, #202020 50%, var(--elevated) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 300% 0; } to { background-position: 0 0; } }

/* ============================ DIALOG ===================================== */

.scrim {
  position: fixed; inset: 0;
  z-index: 80;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(3px);
  animation: fade-in 200ms var(--ease);
}
.dialog {
  position: fixed;
  z-index: 81;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100vw - 32px));
  padding: 22px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-l);
  box-shadow: 0 24px 60px rgba(0,0,0,.7);
  animation: dialog-in 240ms var(--ease);
}
@keyframes dialog-in {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.dialog-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  color: var(--danger);
}
.dialog-icon svg { width: 17px; height: 17px; }
.dialog h2 { font-size: 15.5px; font-weight: 600; letter-spacing: -.015em; }
.dialog p { margin-top: 7px; font-size: 13.5px; color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

/* ============================ TOASTS ===================================== */

.toasts {
  position: fixed;
  left: 50%; bottom: calc(74px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-m);
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0,0,0,.6);
  animation: toast-in 280ms var(--ease);
}
.toast.out { animation: toast-out 240ms var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ============================ MOBILE TAB BAR ============================= */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(12,12,12,.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 4px 9px;
  background: none;
  border: 0;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: color var(--dur) var(--ease);
}
.tab svg { width: 20px; height: 20px; }
.tab.active { color: var(--text); }
.tab .count {
  position: absolute;
  top: 5px; left: calc(50% + 8px);
  min-width: 17px; height: 17px;
  display: grid; place-items: center;
  padding: 0 4px;
  background: var(--silver);
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  color: var(--bg);
}
.tabbar-indicator {
  position: absolute;
  top: 0; left: 0;
  height: 2px;
  background: var(--silver);
  border-radius: 0 0 2px 2px;
  transition: transform var(--dur) var(--ease), width var(--dur) var(--ease);
}

/* nav counts (desktop) */
.nav-item .count {
  margin-left: auto;
  min-width: 18px;
  padding: 1px 6px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  color: var(--silver);
  text-align: center;
}

/* ============================ SCROLLBAR ================================== */
/* Slim, dark, and rounded. The thumb is inset by the track colour so it reads
   as a floating pill rather than a bar stuck to the edge. Chromium-based only;
   other browsers keep their native bar. */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-corner { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: #2E2E2E;
  border: 3px solid var(--bg);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: #4A4A4A; }
::-webkit-scrollbar-thumb:active { background: var(--silver); }

/* ============================ RESPONSIVE ================================= */

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .two-up { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr auto; align-items: center; }
  .filters { width: auto; }
  .filters .field { flex: none; width: 132px; }
}

@media (min-width: 980px) {
  .app { grid-template-columns: var(--rail-w) 1fr; }

  .rail {
    position: sticky;
    top: 0;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    gap: 26px;
    padding: 22px 16px;
    border-bottom: 0;
    border-right: 1px solid var(--border);
  }
  .nav { display: flex; flex: 1; align-content: flex-start; }
  .rail-foot { display: block; margin-left: 0; }
  .nav-item { padding: 9px 11px 9px 16px; }

  .tabbar { display: none; }
  .main { padding: 34px 34px 60px; }
  .toasts { bottom: 24px; left: auto; right: 24px; transform: none; }
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1320px) {
  .main { padding: 40px 44px 72px; max-width: 1360px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================ TOOLTIP ==================================== */
/* CSS-only, from data-tip. Appears on hover and on keyboard focus. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 5px 9px;
  background: var(--elevated);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-s);
  box-shadow: 0 8px 20px rgba(0,0,0,.55);
  font-size: 11.5px;
  font-weight: 450;
  letter-spacing: .005em;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==================== TOUCH TARGETS (pointer: coarse) ==================== */
/* WCAG 2.5.8 / skill priority 2: 44x44 minimum. Scoped to touch devices so the
   desktop density stays tight. */
@media (pointer: coarse) {
  .btn { min-height: 44px; padding: 11px 16px; }
  .field-clear { width: 44px; height: 44px; }
  .field input { padding: 13px 0; min-height: 44px; }
  /* padding alone left these at 42/35/19px — min-size is what guarantees 44 */
  .select select { padding: 12px 34px 12px 13px; min-height: 44px; }
  .open-post { min-height: 44px; display: inline-flex; align-items: center; }
  .new-pill { min-height: 44px; }
  .chip { padding: 9px 12px; }
  .chip button { width: 20px; height: 20px; }
}

/* ============================ REDUCED MOTION ============================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover, .btn:active { transform: none !important; }
  .card:hover .card-media img { transform: none !important; }
  .shimmer { animation: none !important; }
}
