:root {
  color-scheme: light;
  /* Ground, then three surface steps. Panels float on the ground; hierarchy
     comes from radius + hairline + a faint top highlight, never heavy shadow. */
  --bg: #f3f4f7;
  --bg-glow-1: rgba(79, 95, 251, 0.09);
  --bg-glow-2: rgba(8, 135, 90, 0.05);
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --surface-muted: #eff1f5;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --line: rgba(15, 18, 30, 0.08);
  --line-strong: rgba(15, 18, 30, 0.15);
  --text: #0b0d12;
  --muted: #5a6275;
  /* One accent: selection, focus, the primary action, the primary series. */
  --accent: #4152ee;
  --accent-fill: #4f5ffb;
  --accent-strong: #3242d8;
  --accent-soft: rgba(79, 95, 251, 0.1);
  --accent-ring: rgba(79, 95, 251, 0.28);
  --on-accent: #ffffff;
  --up: #077a52;
  --down: #c92a42;
  --warn: #a35600;
  --up-soft: rgba(7, 122, 82, 0.1);
  --down-soft: rgba(201, 42, 66, 0.09);
  --warn-soft: rgba(163, 86, 0, 0.1);
  --hot: var(--down);
  --warm: var(--warn);
  --blue: var(--accent);
  --sidebar: #11141b;
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow: 0 1px 2px rgba(15, 18, 30, 0.04), 0 0 0 1px var(--line);
  --shadow-pop: 0 16px 40px -8px rgba(15, 18, 30, 0.18), 0 2px 6px rgba(15, 18, 30, 0.06), 0 0 0 1px var(--line);
  --th-bg: var(--surface);
  --td-bg: transparent;
  --row-hover: rgba(15, 18, 30, 0.035);
  --row-selected: var(--accent-soft);
  --media-bg: #eef0f4;
  --series-1: var(--accent-fill);
  --series-2: #c26a00;
  --series-3: #0d8f84;
  --series-4: #b42fc4;
  --font-sans: "Inter var", "InterVariable", "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-display: "Inter Display", "Inter var", "InterVariable", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;
  --appbar-h: 60px;
  /* Fluid page frame: gutters grow with the window, content caps at 1600px. */
  --gutter: clamp(16px, 2.4vw, 40px);
  --page-max: 1600px;
  /* Motion: one rhythm everywhere. Springs settle; exits are quicker. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017 19.4%, 1.067, 1.099 24.3%, 1.108 26%, 1.1 28.2%, 1.067 31.7%, 1.008 39.3%, 0.985 43.5%, 0.98 47.5%, 0.993 59.2%, 1.001 71.5%, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --dur-4: 520ms;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07090d;
  --bg-glow-1: rgba(79, 95, 251, 0.14);
  --bg-glow-2: rgba(47, 214, 155, 0.06);
  --surface: #0d1016;
  --surface-soft: #11141b;
  --surface-muted: #171b24;
  --surface-glass: rgba(10, 12, 17, 0.66);
  --line: rgba(255, 255, 255, 0.065);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #eceef4;
  --muted: #8b93a7;
  --accent: #8f9cff;
  --accent-fill: #4f5ffb;
  --accent-strong: #b3bcff;
  --accent-soft: rgba(111, 127, 255, 0.14);
  --accent-ring: rgba(111, 127, 255, 0.4);
  --on-accent: #ffffff;
  --up: #2fd69b;
  --down: #ff6b7f;
  --warn: #f5b544;
  --up-soft: rgba(47, 214, 155, 0.12);
  --down-soft: rgba(255, 107, 127, 0.12);
  --warn-soft: rgba(245, 181, 68, 0.12);
  --sidebar: #05070a;
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--line);
  --shadow-pop: 0 20px 50px -10px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--line-strong);
  --row-hover: rgba(255, 255, 255, 0.03);
  --media-bg: #12161e;
  --series-1: #7b8bff;
  --series-2: #f5b544;
  --series-3: #3fd0c2;
  --series-4: #e07bf0;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 8% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 100% -5%, var(--bg-glow-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  caret-color: var(--accent);
  scrollbar-color: var(--line-strong) transparent;
}

::selection { background: var(--accent-ring); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background: var(--line-strong) padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted) padding-box; }

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-160%);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  box-shadow: var(--shadow-pop);
  transition: transform var(--dur-2) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 6px 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--highlight);
  touch-action: manipulation;
  transition:
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-spring),
    opacity var(--dur-2) var(--ease-out);
}

button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

button:active:not(:disabled) { transform: scale(0.97); transition-duration: 60ms; }

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.primary {
  border-color: transparent;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 60%), var(--accent-fill);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 16px -6px rgba(79, 95, 251, 0.6);
}

button.primary:hover {
  border-color: transparent;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 60%), var(--accent-fill);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 10px 24px -8px rgba(79, 95, 251, 0.75);
}

input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 11px;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--muted) 45%, transparent); }

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%238b93a7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  min-height: 0;
  accent-color: var(--accent-fill);
}

textarea {
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background-color: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
  outline: none;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

::placeholder { color: var(--muted); opacity: 0.8; }

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

a:hover { text-decoration: underline; }

/* ---- App shell: a floating glass bar (workspaces + status), section pills below. */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--appbar-h) minmax(0, 1fr);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  height: var(--appbar-h);
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.wordmark:hover { text-decoration: none; }

.wordmark-mark {
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: 9px;
  background: linear-gradient(145deg, #6c7bff, #3a48e0 60%, #2fd69b 140%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 12px -4px rgba(79, 95, 251, 0.7);
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Pill nav with one sliding indicator (positioned by navigation.js). */
.ws-tabs,
.subnav-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.nav-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: var(--ind-w, 0);
  transform: translateX(var(--ind-x, 0));
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--line-strong);
  opacity: var(--ind-o, 0);
  pointer-events: none;
  transition:
    transform var(--dur-4) var(--ease-spring),
    width var(--dur-4) var(--ease-spring),
    opacity var(--dur-2) var(--ease-out);
}

[data-theme="dark"] .nav-indicator { background: #232836; }
.nav-indicator.no-anim { transition: none; }

.ws-tab,
.subnav-tab,
.status-item,
.icon-button {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.ws-tab,
.subnav-tab {
  position: relative;
  z-index: 1;
  height: 32px;
  min-height: 32px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
}

.subnav-tab { height: 30px; min-height: 30px; padding: 0 14px; font-size: 13px; }

.ws-tab:hover,
.subnav-tab:hover { border-color: transparent; background: transparent; color: var(--text); }
.ws-tab.active,
.subnav-tab.active { color: var(--text); font-weight: 600; }
.ws-tab:active:not(:disabled),
.subnav-tab:active:not(:disabled) { transform: scale(0.96); }

.appbar-status {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 450;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-item:hover { border-color: transparent; background: var(--surface-muted); color: var(--text); }
.status-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-dot.is-ok { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.status-dot.is-ok::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--up);
  animation: pulse-ring 2.4s var(--ease-out) infinite;
}
.status-dot.is-stale { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-count { color: var(--text); font-weight: 600; }

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.55; }
  70%, 100% { transform: scale(2.6); opacity: 0; }
}

.appbar-actions { display: flex; align-items: center; gap: 4px; }
.appbar-actions select { width: 84px; min-height: 34px; border-radius: var(--r-pill); }
body[data-view="market"] #currencySelect { display: none; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-pill);
  color: var(--muted);
}

.icon-button:hover { border-color: transparent; background: var(--surface-muted); color: var(--text); }

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--dur-4) var(--ease-spring);
}

#refreshButton:hover svg,
#marketRefresh:hover svg { transform: rotate(-60deg); }
#themeToggle:hover svg { transform: rotate(-20deg) scale(1.08); }

.workspace {
  min-width: 0;
  height: calc(100vh - var(--appbar-h));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.subnav {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px var(--gutter) 0;
}

body[data-workspace="market"] .subnav { display: none; }
.subnav-group[hidden] { display: none; }

.status-line {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-label { margin: 0; color: var(--muted); font-size: 12px; }
.db-label strong { color: var(--text); font-weight: 500; }

.view {
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 16px;
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 16px var(--gutter) 20px;
  animation: view-in var(--dur-3) var(--ease-out) backwards;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
}

.metrics {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.surface {
  border: 0;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow), var(--highlight);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric.attention strong {
  color: var(--hot);
}

.ingest-summary-surface {
  flex: none;
}

.ingest-summary-surface #ingestSummaryCard {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(420px, 1.2fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.overview-grid > .surface {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.overview-grid > .surface .section-heading { flex: none; }

.overview-grid .tracked-summary {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

.surface {
  min-width: 0;
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tracked-summary,
.registry-list {
  display: grid;
  gap: 8px;
}

.summary-row,
.registry-card {
  display: grid;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  padding: 12px;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

.registry-card:hover { border-color: var(--line-strong); }

.summary-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.registry-card { grid-template-columns: minmax(0, 1fr) auto; }

.registry-card-main {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.registry-actions-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.button-stack {
  display: grid;
  gap: 8px;
}

.row-title,
.registry-title {
  font-weight: 600;
}

.registry-card-thumb,
.delta-card-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.registry-card-thumb {
  width: 64px;
  height: 88px;
  border-radius: var(--r-md);
}

.delta-card-thumb {
  width: 46px;
  height: 64px;
  border-radius: var(--r-md);
}

.registry-card-thumb img,
.delta-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.registry-card-thumb.empty,
.delta-card-thumb.empty {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 6px;
}

.row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta,
.registry-meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.delta-tabs {
  flex: none;
  display: inline-flex;
  align-self: flex-start;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.delta-tab-button {
  min-height: 32px;
  border-color: transparent;
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-weight: 500;
}

.delta-tab-button:hover { border-color: transparent; background: transparent; color: var(--text); }

.delta-tab-button.active {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--line-strong);
  color: var(--text);
  font-weight: 600;
}

.delta-tab-panel { display: none; }
.delta-tab-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Board panel: heading + filters fixed, table fills + scrolls. */
.delta-surface {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.delta-surface .section-heading,
.delta-surface .delta-filter-bar { flex: none; }

.delta-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 10px;
}

.delta-onboarding-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.delta-onboarding-layout > .surface {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.control-grid {
  display: grid;
  gap: 10px;
}

.control-grid.compact {
  grid-template-columns: minmax(0, 1fr) 160px;
  margin-bottom: 12px;
}

.listing-filters {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}

.save-active-filter {
  align-self: end;
  min-height: 36px;
}

.save-active-filter.saved {
  border-color: transparent;
  background: var(--up-soft);
  color: var(--up);
}

.layout-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.layout-toggle button {
  min-height: 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
}

.layout-toggle button:hover { background: transparent; color: var(--text); }

.layout-toggle button.active {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--line-strong);
  color: var(--text);
  font-weight: 600;
}

.filters-manager-surface {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.filters-manager-surface .section-heading { flex: none; }

.filter-card-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.filter-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--highlight);
  transition: transform var(--dur-3) var(--ease-out), border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}

.filter-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--highlight), 0 12px 28px -12px rgba(0, 0, 0, 0.35);
}

.filter-card.disabled {
  opacity: 0.62;
}

.filter-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.filter-card-title {
  color: var(--text);
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  font-size: 15px;
  font-weight: 600;
}

.filter-match-count {
  flex: none;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
}

.pipeline-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.priority-badge {
  border-radius: var(--r-pill);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.priority-urgent { background: var(--down-soft); color: var(--down); }
.priority-normal { background: var(--surface-muted); color: var(--muted); }
.priority-low { background: var(--accent-soft); color: var(--accent); }

.pipeline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.pipeline-toggle input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--accent);
}

.pipeline-purpose {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.filter-card-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.filter-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-self: end;
}

.filter-card-actions .dark {
  border-color: transparent;
  background: var(--text);
  color: var(--surface);
}

.filter-card-actions .dark:hover { background: color-mix(in srgb, var(--text) 85%, transparent); }

.filter-card-actions .danger {
  color: var(--hot);
}

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

.filter-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(3, 5, 10, 0.55);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  padding: 20px;
  overscroll-behavior: contain;
  animation: fade-in var(--dur-2) var(--ease-out) both;
}

.filter-editor-card {
  position: relative;
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: var(--r-xl);
  border: 0;
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow-pop), var(--highlight);
  overscroll-behavior: contain;
  animation: pop-in var(--dur-4) var(--ease-spring) both;
}

.filter-editor-card:focus-visible,
.review-modal-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.filter-editor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-editor-error {
  min-height: 18px;
  margin: 10px 0;
  color: var(--hot);
  font-size: 12px;
  font-weight: 600;
}

.control-grid label span,
.filter-field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.control-grid .wide { grid-column: 1 / -1; }

.control-grid .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
}

.control-grid .checkbox input {
  width: auto;
  min-height: 0;
}

.control-grid .checkbox span { margin-bottom: 0; }

.registry-admin-form {
  display: grid;
  gap: 12px;
}

.save-notice {
  border: 1px solid color-mix(in srgb, var(--up) 30%, transparent);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--up-soft);
  color: var(--up);
  font-weight: 600;
  animation: rise-in var(--dur-3) var(--ease-out) both;
}

.save-notice.pending {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
}

.mercari-test-results {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px;
  background: var(--surface-soft);
  display: grid;
  gap: 10px;
}

.mercari-test-summary,
.mercari-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mercari-test-summary { justify-content: space-between; }

.mercari-test-row img {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--surface-muted);
}

.registry-admin-header {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.registry-admin-header img {
  width: 88px;
  height: 122px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  object-fit: contain;
}

.setup-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.setup-check {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  padding: 9px;
}

.setup-check span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.setup-check strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
}

.advanced-setup {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.advanced-setup summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.advanced-setup .button-row { margin-top: 10px; }

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

.filter-field { min-width: 0; }

.multi-filter { position: relative; }

.multi-filter summary {
  display: block;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
  color: var(--text);
  padding: 8px 30px 7px 9px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

.multi-filter summary::-webkit-details-marker { display: none; }

.multi-filter summary::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 15px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--dur-3) var(--ease-spring);
}

.multi-filter summary:hover { border-color: color-mix(in srgb, var(--muted) 45%, transparent); }

.multi-filter[open] summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.multi-filter[open] summary::after { transform: translateY(3px) rotate(225deg); }

.multi-options {
  position: absolute;
  z-index: 30;
  left: 0;
  width: min(260px, 88vw);
  max-height: 280px;
  overflow: auto;
  margin-top: 7px;
  padding: 6px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transform-origin: top left;
  animation: menu-in var(--dur-3) var(--ease-spring) both;
}

.multi-filter.align-right .multi-options {
  left: auto;
  right: 0;
}

.multi-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  transition: background-color var(--dur-1) var(--ease-out);
}

.multi-option:hover,
.multi-option:focus-within {
  background: var(--surface-muted);
}

.multi-options label {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 9px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.multi-options label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-options input {
  width: 15px;
  min-height: 15px;
  accent-color: var(--accent);
}

.option-only {
  min-height: 24px;
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  box-shadow: none;
  transition: opacity var(--dur-1) var(--ease-out);
}

.multi-option:hover .option-only,
.multi-option:focus-within .option-only {
  opacity: 1;
}

.option-only:hover,
.option-only:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.registry-list {
  max-height: calc(100vh - 245px);
  overflow: auto;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.table-wrap[hidden] { display: none; }

/* Listings view: filters fixed, table area fills the rest and scrolls. */
.filters-surface { flex: none; }

.table-surface {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.listings-table-wrap,
.delta-table-wrap {
  flex: 1;
  min-height: 0;
}

.listings-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.delta-card-cell {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.delta-card-cell > div:last-child { min-width: 0; }

.delta-card-cell > div:last-child > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Delta table column widths (positional). Card flexes; numbers stay narrow. */
.delta-table th:nth-child(2), .delta-table td:nth-child(2),
.delta-table th:nth-child(3), .delta-table td:nth-child(3),
.delta-table th:nth-child(4), .delta-table td:nth-child(4),
.delta-table th:nth-child(5), .delta-table td:nth-child(5),
.delta-table th:nth-child(6), .delta-table td:nth-child(6) { width: 58px; }

.delta-table th:nth-child(7), .delta-table td:nth-child(7) { width: 66px; }
.delta-table th:nth-child(8), .delta-table td:nth-child(8) { width: 80px; }
.delta-table th:nth-child(9), .delta-table td:nth-child(9) { width: 80px; }
.delta-table th:nth-child(10), .delta-table td:nth-child(10) { width: 66px; }
.delta-table th:nth-child(11), .delta-table td:nth-child(11) { width: 108px; }

.delta-table td:nth-child(n+2) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action column button fills its fixed cell instead of overflowing it. */
.delta-table td:nth-child(11) button {
  width: 100%;
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
  white-space: nowrap;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--th-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.sort-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.sort-button:hover { color: var(--accent-strong); }

.sort-button.active { color: var(--text); }

.sort-button.active::after {
  content: attr(data-direction);
  margin-left: 5px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.delta-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 14px 0;
}

.delta-filter-bar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.delta-filter-bar input,
.delta-filter-bar select {
  min-width: 0;
}

.delta-toggle {
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: start;
  min-height: 36px;
  padding-bottom: 2px;
}

.delta-toggle input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.delta-onboard-top-n {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.delta-onboard-top-n input {
  width: 56px;
}

.delta-sort-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.delta-sort-button.active::after {
  content: attr(data-direction);
  margin-left: 5px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.delta-multiplier {
  display: inline-flex;
  min-width: 54px;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
  padding: 4px 8px;
}

.delta-multiplier.hot {
  background: var(--warn-soft);
  color: var(--warn);
}

td {
  background: var(--td-bg);
  color: var(--text);
  transition: background-color var(--dur-1) var(--ease-out);
}

tbody tr:hover td { background: var(--row-hover); }
tr.selected td { background: var(--row-selected); }

tbody tr:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* Row thumbnails + quick actions (Track A) */
.cell-image { width: 46px; }

.row-thumb {
  display: grid;
  place-items: center;
  width: 32px;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--media-bg);
  color: var(--muted);
}

.row-thumb img { width: 100%; height: 100%; object-fit: cover; }

.row-actions { width: 104px; padding: 0 8px 0 0; }

.quick-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out);
}

tbody tr:hover .quick-actions,
.listing-card:hover .quick-actions,
tbody tr:focus-within .quick-actions,
.listing-card:focus-within .quick-actions {
  opacity: 1;
  transform: none;
}

.quick-actions button {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.quick-actions .quick-reject:hover {
  border-color: var(--hot);
  color: var(--hot);
}

/* Title + Target absorb leftover width (no fixed width) and truncate to one
   line; full text is available in the row modal. */
.title-cell { font-weight: 600; }

.listing-open-button {
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  padding: 2px;
  text-align: left;
}

.listing-open-button:hover {
  color: var(--accent-strong);
}

.cell-target_name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-badge {
  margin-top: 4px;
  font-weight: 600;
}

.cell-review_attention_at,
.cell-last_seen_at {
  width: 90px;
  white-space: normal;
  line-height: 1.3;
}

.cell-latest_price_native { width: 86px; }
.cell-condition_bucket { width: 64px; }
.cell-review_state { width: 78px; }
.cell-status { width: 62px; }

.cell-review_state,
.cell-status,
.cell-latest_price_native,
.cell-condition_bucket {
  white-space: nowrap;
}

.cell-listing_type {
  width: 48px;
  text-align: center;
}

/* Listing card grid (Track A) */
.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.listings-grid[hidden] { display: none; }

.listing-card {
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--highlight);
  transition: transform var(--dur-3) var(--ease-out), border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}

.listing-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-3px);
  box-shadow: var(--highlight), 0 16px 32px -14px rgba(0, 0, 0, 0.45);
}

.listing-card-media img { transition: transform var(--dur-4) var(--ease-out); }
.listing-card:hover .listing-card-media img { transform: scale(1.04); }
.listing-card:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.listing-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.listing-card-media {
  position: relative;
  height: 180px;
  background: var(--media-bg);
}

.listing-card-media img { width: 100%; height: 100%; object-fit: cover; }

.listing-card-media.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.listing-card-pill {
  position: absolute;
  top: 8px;
  left: 8px;
}

.listing-card-body {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 10px;
}

.listing-card-title {
  font-weight: 600;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

button.listing-card-title {
  min-height: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 2px;
  text-align: left;
}

.muted { color: var(--muted); }

.margin-positive { color: var(--up); font-weight: 600; }
.margin-negative { color: var(--warm); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.new,
.pill.revised {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.reviewed,
.pill.purchased,
.pill.bidded_on,
.pill.watching,
.pill.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.ignored,
.pill.rejected,
.pill.insufficient_pricing_data {
  background: var(--surface-muted);
  color: var(--muted);
}

.pill.noise-ok {
  background: var(--surface-muted);
  color: var(--muted);
}

.pill.noise-warning {
  border-color: color-mix(in srgb, var(--down) 35%, transparent);
  background: var(--down-soft);
  color: var(--down);
}

.type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.type-icon.auction {
  background: var(--warn-soft);
  color: var(--warn);
}

.type-icon.buy {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Review modal */
.review-modal[hidden] { display: none; }

.review-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(3, 5, 10, 0.6);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  overscroll-behavior: contain;
  animation: fade-in var(--dur-2) var(--ease-out) both;
}

.review-modal-card {
  position: relative;
  width: min(1400px, calc(100vw - 140px));
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.9fr);
  gap: 18px;
  padding: 18px;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop), var(--highlight);
  overflow: visible;
  animation: pop-in var(--dur-4) var(--ease-spring) both;
}

.modal-media {
  min-width: 0;
  /* Flex column: the photo flexes to fill leftover height while the thumbnail
     strip and the flaw-reason panel stay pinned and always on-screen. Nothing
     here scrolls away, so drawing a box and picking a flaw never requires a
     scroll. */
  min-height: 0;
  max-height: calc(100vh - 84px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-panel {
  min-width: 0;
  max-height: calc(100vh - 92px);
  overflow: auto;
  padding-right: 4px;
}

.modal-panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Keep the header clear of the absolutely-positioned close button. */
.modal-panel > .muted:first-child,
.modal-panel > h2 {
  padding-right: 48px;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--surface-soft);
}

.detail .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail .value {
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0 12px;
}

.actions button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
}

.rejection-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 0 12px;
}

.rejection-actions .label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.rejection-actions button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
}

.market-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.gallery {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-main {
  position: relative;
  display: block;
  flex: 1;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--media-bg);
}

.gallery-main img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--media-bg);
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 34px;
  height: 34px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-pop);
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.gallery-nav.prev { left: 10px; }
.gallery-nav.next { right: 10px; }

.thumbnail-row {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.image-thumb {
  flex: 0 0 64px;
  display: block;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--media-bg);
  padding: 0;
}

.image-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb { transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-spring); }
.image-thumb:hover { transform: translateY(-2px); }

.image-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- image annotation overlay ---- */
.annot-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
}

/* Always-visible hint of what a drag will draw, pinned to the photo corner. */
.annot-active-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 4px 9px;
  border-radius: var(--r-pill);
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.annot-active-badge .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.annot-active-badge .label { text-transform: capitalize; }
.annot-active-badge .verb { opacity: 0.75; font-weight: 500; }

.annot-box {
  position: absolute;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-sizing: border-box;
  cursor: move;
}

.annot-box.draft {
  border-style: dashed;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.annot-box.selected {
  border-color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 14%, transparent);
}

.annot-tag {
  position: absolute;
  top: -2px;
  left: -2px;
  transform: translateY(-100%);
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  border-radius: var(--r-sm, 4px);
  background: var(--accent);
  color: #fff;
  text-transform: capitalize;
}

.annot-box.selected .annot-tag { background: #f59e0b; }

.annot-del {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.annot-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid #f59e0b;
  border-radius: 3px;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.4);
}

.annot-handle-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.annot-handle-n  { top: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.annot-handle-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.annot-handle-e  { top: calc(50% - 7px); right: -7px; cursor: ew-resize; }
.annot-handle-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.annot-handle-s  { bottom: -7px; left: calc(50% - 7px); cursor: ns-resize; }
.annot-handle-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
.annot-handle-w  { top: calc(50% - 7px); left: -7px; cursor: ew-resize; }

.annot-panel {
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-soft);
  display: grid;
  gap: 10px;
}

.annot-panel-flash {
  animation: annot-flash 0.9s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .annot-panel-flash { animation: none; }
}

@keyframes annot-flash {
  0%, 60% { border-color: var(--danger, #d33); box-shadow: 0 0 0 2px var(--danger, #d33); }
  100% { border-color: var(--line); box-shadow: none; }
}

.annot-group { display: grid; gap: 6px; }

.annot-group-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.annot-group-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
}

.annot-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.annot-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

/* Present (asserted) categories fill in. */
.annot-on-image.on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.annot-descriptor.on {
  border-color: #f59e0b;
  background: #f59e0b;
  color: #fff;
}

/* The annotatable category armed for drawing gets a ring. */
.annot-on-image.active {
  box-shadow: 0 0 0 2px var(--accent-soft);
  border-color: var(--accent);
}

.annot-kbd {
  font-size: 10px;
  opacity: 0.7;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 3px;
}

.description-block {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
}

.description-block h3,
.history strong {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.description-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.translation-link {
  margin-top: 8px;
  font-size: 12px;
}

.outcome-block {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
}

.outcome-block h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.outcome-block .modal-grid {
  grid-template-columns: repeat(3, 1fr);
}

.outcome-block input,
.outcome-block select,
.outcome-block textarea {
  width: 100%;
  margin-top: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm, 6px);
  padding: 5px 6px;
  font: inherit;
  background: var(--surface);
  color: inherit;
}

.outcome-block .outcome-note {
  display: block;
  margin: 10px 0;
}

.outcome-block .actions {
  grid-template-columns: 1fr;
}

.history {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.history-row {
  display: grid;
  grid-template-columns: 115px 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

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

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 16px;
}

.modal-close,
.modal-nav {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-pop);
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.modal-close { top: 14px; right: 14px; }

.modal-nav {
  top: 50%;
  transform: translateY(-50%);
}

.modal-nav.prev { left: -58px; }
.modal-nav.next { right: -58px; }

.modal-position {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Toasts (Track B) */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
  color: var(--text);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-4) var(--ease-spring);
}

.toast.visible { opacity: 1; transform: none; }
.toast::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-1px);
}
.toast-success::before { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.toast-error::before { background: var(--down); box-shadow: 0 0 0 3px var(--down-soft); }
.toast-info::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Spinner (Track B) */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}

button.is-busy { position: relative; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Skeletons (Track B) */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-muted);
  border-radius: var(--r-sm);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 1.6s var(--ease-in-out) infinite;
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton-line { display: block; height: 12px; width: 100%; }
.skeleton-line.short { width: 60%; }
.skeleton-number { display: inline-block; height: 24px; width: 48px; }
.skeleton-card .listing-card-media { height: 180px; }
.skeleton-row td { background: var(--td-bg); }

@media (prefers-reduced-motion: reduce) {
  .skeleton::after, .spinner, .toast { animation: none; transition: none; }
}

@media (max-width: 1120px) {
  /* Narrow windows: the fixed-height dashboard can't apply, so revert to
     natural page scroll. */
  .workspace {
    height: auto;
    overflow: visible;
  }

  .view.active { display: block; }

  .table-surface,
  .delta-surface,
  .delta-tab-panel.active,
  .overview-grid,
  .delta-onboarding-layout {
    display: block;
    min-height: 0;
  }

  .listings-table-wrap { max-height: 70vh; }
  .delta-table-wrap { max-height: 70vh; }

  .metrics,
  .overview-grid,
  .delta-onboarding-layout,
  .delta-filter-bar,
  .listing-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .wordmark span, .appbar-status { display: none; }
  .ws-tab { padding: 0 12px; }

  .metrics,
  .overview-grid,
  .delta-onboarding-layout,
  .setup-checklist,
  .delta-filter-bar,
  .listing-filters,
  .filter-editor-grid,
  .control-grid.compact,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .registry-card { grid-template-columns: 1fr; }

  .delta-toggle { justify-content: start; }

  .review-modal { padding: 12px; }

  .review-modal-card {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    grid-template-columns: 1fr;
  }

  .modal-nav.prev { left: 10px; }
  .modal-nav.next { right: 10px; }

  .gallery-main {
    height: min(52vh, 520px);
    min-height: 260px;
  }

  .modal-panel { max-height: none; }
}

/* Subscribers view */
.subscribers-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.6fr);
  gap: 14px;
  align-items: start;
}

.subscriber-list-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subscriber-detail-pane {
  min-height: 240px;
}

.subscriber-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.subscriber-list {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.subscriber-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  box-shadow: none;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out);
}

.subscriber-row:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  transform: translateX(2px);
}

.subscriber-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.subscriber-setup-step {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  padding: 16px;
  margin-top: 12px;
}

.subscriber-setup-step:first-of-type {
  margin-top: 14px;
}

.subscriber-setup-step.done {
  border-color: color-mix(in srgb, var(--up) 28%, transparent);
}

.step-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.step-heading h4 {
  margin: 0;
  font-size: 14px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.step-badge.done {
  border-color: transparent;
  background: var(--up-soft);
  color: var(--up);
}

.subscriber-test-error {
  margin-top: 4px;
  color: var(--hot);
  font-size: 12px;
  font-weight: 600;
}

.subscriber-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.subscriber-editor-grid label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field-help {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.subscriber-editor-grid input,
.subscriber-editor-grid select,
.subscriber-editor-grid textarea {
  width: 100%;
  margin-top: 5px;
}

.subscriber-editor-notes { grid-column: 1 / -1; }

.subscriber-editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Subscription rows carry a variable set of controls (filter, backlog, thread,
   toggle, remove), so they wrap instead of using the 3-column summary grid. */
.subscription-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.subscription-row > span:first-child {
  flex: 1 1 220px;
  min-width: 0;
}

.subscription-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.subscription-filter select { margin-top: 0; }

.field-optional {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
}

/* auto-fit so added fields wrap to a new row instead of overflowing the panel */
.subscriber-add-target {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 10px;
  align-items: start;
}

.subscriber-add-target label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.subscriber-add-target select,
.subscriber-add-target input {
  margin-top: 5px;
}

.subscriber-add-target button {
  align-self: end;
  margin-bottom: 22px;
}

@media (max-width: 900px) {
  .subscribers-layout { grid-template-columns: 1fr; }
  .subscriber-editor-grid { grid-template-columns: 1fr; }
  .subscriber-add-target { grid-template-columns: 1fr; }
  .subscriber-add-target button { margin-bottom: 0; }
}

/* ---- Market view ------------------------------------------------------- */
/* Panels on the ground, big tight figures, tabular numbers everywhere.
   Everything here is mk-prefixed. The page is fluid up to --page-max; the
   board drops low-priority columns by container width, never by viewport. */
#marketView.active {
  overflow-y: auto;
  gap: 0;
  max-width: none;
  padding: 0;
}

.mk-page {
  position: relative;
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 28px var(--gutter) 72px;
  font-variant-numeric: tabular-nums;
  container: mkpage / inline-size;
}

.mk-page :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Type */
.mk-title, .mk-symbol-lg {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 1.6vw + 12px, 32px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.15;
}
.mk-symbol, .mk-symbol-lg {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}
.mk-symbol { font-size: 12px; font-weight: 500; letter-spacing: 0; }
.mk-symbol.mk-symbol-lg { font-size: clamp(18px, 0.8vw + 12px, 22px); font-weight: 600; letter-spacing: -0.01em; }
.mk-secondary { margin: 0; font-size: 13px; color: var(--muted); font-weight: 400; }
.mk-label {
  margin: 0;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.mk-big {
  font-family: var(--font-display);
  font-size: clamp(38px, 2.6vw + 16px, 56px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.mk-muted, .mk-low, .mk-missing, .mk-fallback { color: var(--muted); }
.mk-up { color: var(--up); }
.mk-down { color: var(--down); }
.mk-notice {
  display: inline-flex;
  margin: 0 0 16px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
  animation: rise-in var(--dur-3) var(--ease-out) both;
}
.mk-notice[hidden], .mk-float[hidden] { display: none; }
.mk-error { margin: 16px 0; font-size: 14px; color: var(--down); }
.mk-empty, .mk-empty-line { padding: 24px 0; text-align: center; font-size: 14px; color: var(--muted); }
.mk-empty-line { margin: 0; }

/* Controls */
.mk-text-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.mk-text-button:hover { text-decoration: underline; border: 0; background: none; color: var(--accent); }
.mk-chip-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}
.mk-chip-button:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); text-decoration: none; }
.mk-link { color: var(--accent); font-size: 13px; font-weight: 500; }
.mk-link:hover { text-decoration: underline; }
.mk-primary {
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 60%), var(--accent-fill);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
}
.mk-primary:hover { background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 60%), var(--accent-fill); }
.mk-float {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  padding: 6px;
  transform: translateX(-50%);
  border-radius: var(--r-pill);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
  box-shadow: var(--shadow-pop), 0 12px 32px -10px rgba(79, 95, 251, 0.55);
  animation: float-in var(--dur-4) var(--ease-spring) both;
}
@keyframes float-in {
  from { opacity: 0; transform: translate(-50%, 24px) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.mk-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--line);
}
.mk-seg button {
  min-height: 0;
  height: 30px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}
.mk-seg button:hover { color: var(--text); background: transparent; }
.mk-seg button.active {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--line-strong);
  color: var(--text);
  font-weight: 600;
}
[data-theme="dark"] .mk-seg button.active { background: #232836; }
.mk-filter { width: 240px; min-height: 36px; border-radius: var(--r-pill); padding-left: 16px; }

/* One panel recipe for the board, chart, tiles and tables. */
.mk-panel,
.mk-card-tile,
.mk-deal,
.mk-skel-card,
.mk-chart-host,
.mk-tile,
.mk-hero {
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow), var(--highlight);
}

/* Board */
.mk-page-head, .mk-detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 24px;
}
.mk-head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.mk-sort-select { width: auto; min-height: 36px; padding-left: 14px; border-radius: var(--r-pill); }
.mk-table { width: 100%; table-layout: auto; border-collapse: collapse; }
.mk-table th {
  position: static;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  color: var(--muted);
  white-space: nowrap;
}
.mk-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 14px;
  vertical-align: middle;
}
.mk-table tbody:last-child tr:last-child td,
.mk-panel .mk-table tbody tr:last-child td { border-bottom: 0; }
.mk-table th.num, .mk-table td.num { text-align: right; }
.mk-visit { margin-top: 6px; }
.mk-updated { white-space: nowrap; }

/* Board: a grid of cards, one per tracked card. The board is a size container
   (mkboard): one column below 640px, two to 1099px, three from there. Cards
   wrap onto new rows; nothing scrolls sideways. */
.mk-board { container: mkboard / inline-size; }
.mk-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
@container mkboard (min-width: 640px) {
  .mk-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container mkboard (min-width: 1100px) {
  .mk-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.mk-card-tile {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 18px;
  transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}
.mk-card-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--highlight), 0 18px 32px -18px rgba(0, 0, 0, 0.5);
}

.mk-card-head { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.mk-card-text { display: grid; gap: 4px; min-width: 0; padding-top: 2px; }
.mk-card-name { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.mk-card-text .mk-symbol {
  justify-self: start;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.mk-card-text .mk-secondary { font-size: 12.5px; }

/* The two grade tiles, Raw then PSA 10. A tile is a button; its compare
   checkbox is a sibling (a control cannot sit inside a button). */
.mk-grade-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mk-grade-slot { position: relative; display: flex; min-width: 0; }
.mk-grade-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 12px 12px 10px;
  border: 0;
  border-radius: var(--r-lg);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font-weight: 400;
  text-align: left;
  transition: background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
button.mk-grade-tile:hover { border: 0; background: var(--row-hover); }
.mk-grade-empty { color: var(--muted); cursor: default; }
.mk-grade-empty .mk-secondary { font-size: 12.5px; }
.mk-grade-fv {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.mk-grade-fv .mk-fallback { font-family: var(--font-sans); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.mk-pct-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.mk-pct-chip.mk-up { background: var(--up-soft); color: var(--up); }
.mk-pct-chip.mk-down { background: var(--down-soft); color: var(--down); }
.mk-grade-spark { display: flex; align-items: center; justify-content: center; width: 100%; height: 44px; }
.mk-spark-fluid { width: 100%; height: 44px; }
.mk-grade-foot { font-size: 12px; line-height: 1.4; }
.mk-grade-since { font-size: 12px; }
.mk-nowrap { white-space: nowrap; }

.mk-pick {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  opacity: 0;
  accent-color: var(--accent-fill);
  cursor: pointer;
  transition: opacity var(--dur-2) var(--ease-out);
}
.mk-grade-slot:hover .mk-pick, .mk-grade-slot:focus-within .mk-pick, .mk-pick:checked { opacity: 1; }
@media (hover: none) {
  .mk-pick { opacity: 1; }
}
.mk-picked .mk-grade-tile,
.mk-picked button.mk-grade-tile:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.mk-grade-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mk-card-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.mk-card-foot strong { font-weight: 600; letter-spacing: -0.01em; }

.mk-art {
  flex: none;
  width: 72px;
  aspect-ratio: 63 / 88;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--media-bg);
  object-fit: cover;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.6);
  transition: transform var(--dur-4) var(--ease-spring), box-shadow var(--dur-3) var(--ease-out);
}
.mk-card-tile:hover .mk-art {
  transform: translateY(-2px) rotate(-2deg) scale(1.04);
  box-shadow: 0 14px 24px -10px rgba(0, 0, 0, 0.65);
}

.mk-art-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font: 600 10px var(--font-mono);
}

.mk-new {
  position: relative;
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
.mk-new::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-ring 2.4s var(--ease-out) infinite;
}

.mk-grade-tile.mk-fresh { animation: mk-fresh 1.8s var(--ease-out) 1 backwards; }

@keyframes mk-fresh {
  0%, 12% { background-color: var(--accent-soft); }
  100% { background-color: transparent; }
}

/* First paint of a board or ticker page: cards rise in, one after another. */
.mk-enter .mk-card-tile {
  animation: rise-in var(--dur-4) var(--ease-out) backwards;
  animation-delay: calc(min(var(--i, 0), 14) * 40ms);
}
.mk-enter-page > * { animation: rise-in var(--dur-4) var(--ease-out) backwards; }
.mk-enter-page > :nth-child(2) { animation-delay: 40ms; }
.mk-enter-page > :nth-child(3) { animation-delay: 80ms; }
.mk-enter-page > :nth-child(4) { animation-delay: 120ms; }
.mk-enter-page > :nth-child(5) { animation-delay: 160ms; }
.mk-enter-page > :nth-child(n+6) { animation-delay: 200ms; }

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

.mk-empty-state { padding: 72px 0; text-align: center; }
.mk-empty-state p { margin: 0 0 4px; }

.mk-skel-card { display: grid; gap: 16px; padding: 18px; }
.mk-skel-card-head { display: flex; gap: 14px; }
.mk-skel-art { flex: none; width: 72px; height: 100px; }
.mk-skel-lines { flex: 1; display: grid; align-content: start; gap: 12px; }
.mk-skel-row { height: 16px; }
.mk-skel-grade { height: 148px; border-radius: var(--r-lg); }
.mk-fallback { font-size: 13px; }

/* Ticker page */
.mk-back { margin-bottom: 20px; }
.mk-back svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-3) var(--ease-spring); }
.mk-back:hover svg { transform: translateX(-3px); }
.mk-detail-head .mk-secondary { margin-top: 6px; font-size: 14px; }

/* Hero + tiles: stacked on narrow pages, side by side on wide ones. */
.mk-detail-top {
  display: grid;
  gap: 16px;
  margin: 0 0 32px;
}
@container mkpage (min-width: 1180px) {
  .mk-detail-top { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .mk-detail-top .mk-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.mk-hero {
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: clamp(20px, 2vw, 32px);
  isolation: isolate;
}
.mk-hero::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto auto;
  z-index: -1;
  width: 70%;
  height: 160%;
  background: radial-gradient(closest-side, var(--accent-soft), transparent);
  opacity: 0.9;
  pointer-events: none;
}
.mk-hero.is-up::before { background: radial-gradient(closest-side, var(--up-soft), transparent); }
.mk-hero.is-down::before { background: radial-gradient(closest-side, var(--down-soft), transparent); }
.mk-hero > .mk-label { margin-bottom: 10px; }
.mk-headline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.mk-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  font-size: 15px;
  font-weight: 600;
}
.mk-change.mk-up { background: var(--up-soft); }
.mk-change.mk-down { background: var(--down-soft); }
.mk-change svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mk-change-note { margin-left: -6px; }
.mk-hero .mk-secondary { margin-top: 12px; }
.mk-summary { margin: 14px 0 0; max-width: 64ch; font-size: 14px; line-height: 1.55; }

.mk-section { margin: 0 0 32px; }
.mk-section > .mk-label { margin-bottom: 12px; }
.mk-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.mk-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@container mkpage (max-width: 760px) {
  .mk-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.mk-tile {
  padding: 18px 20px;
  transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}
.mk-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow), var(--highlight), 0 14px 28px -16px rgba(0, 0, 0, 0.45); }
.mk-tile-value {
  margin: 10px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(20px, 0.8vw + 14px, 26px);
  font-weight: 600;
  letter-spacing: -0.03em;
}
.mk-panel { overflow: hidden; padding: 4px 8px; }

.mk-card-pop { border-top: 1px solid var(--line); padding: 14px 16px; }
.mk-pop-summary { display: grid; grid-template-columns: 1fr 1fr 1.8fr; gap: 12px; margin: 0; }
.mk-pop-summary dt { color: var(--muted); font-size: 11px; line-height: 1.4; }
.mk-pop-summary dd { margin: 4px 0 0; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-pop-note { margin: 10px 0 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.mk-pop-warning { color: var(--warn); }
.mk-pop-panel { padding: 20px; }
.mk-pop-full { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.mk-pop-full summary { cursor: pointer; font-weight: 500; }
.mk-pop-full p { margin: 12px 0; max-width: 75ch; }
.mk-pop-scroll { overflow-x: auto; }
.mk-pop-full .mk-table { max-width: 640px; }
.mk-compact td { height: 44px; padding-top: 0; padding-bottom: 0; }
.mk-compact tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
.mk-compact tbody tr:hover td { background: var(--row-hover); }
/* Undervalued now: live listings at least 10% under fair value, as cards. */
.mk-count {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--up-soft);
  color: var(--up);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
}
.mk-deal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mk-deal {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}
a.mk-deal:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--highlight), 0 18px 32px -18px rgba(0, 0, 0, 0.5);
}
.mk-deal-img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--media-bg);
  object-fit: cover;
}
.mk-deal-img-empty { display: grid; place-items: center; color: var(--muted); }
.mk-deal-img-empty svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mk-deal-body { display: flex; flex: 1; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 16px 16px; }
.mk-deal-price {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.mk-deal-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.mk-deal-chip {
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--up-soft);
  color: var(--up);
  font-size: 12px;
  font-weight: 600;
}
.mk-deal-saves { font-size: 12.5px; }
.mk-deal-title {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}
.mk-deal-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}
.mk-deal:hover .mk-deal-open { text-decoration: underline; text-underline-offset: 3px; }
.mk-deal-open svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mk-deal-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; }
.mk-deal-status { margin-top: 12px; }
.mk-deal-skel { pointer-events: none; }
.mk-deal-skel .mk-skel.mk-deal-img { border-radius: 0; }
.mk-deal-skel .mk-deal-body { gap: 10px; align-items: stretch; }
.mk-deals-enter .mk-deal {
  animation: rise-in var(--dur-4) var(--ease-out) backwards;
  animation-delay: calc(min(var(--i, 0), 8) * 50ms);
}

.mk-sales-more { padding: 14px 0 6px; text-align: center; }
.mk-about {
  padding: 16px 20px;
  border-radius: var(--r-lg);
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
.mk-about summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.mk-about summary:hover { color: var(--text); }
.mk-about summary::-webkit-details-marker { display: none; }
.mk-about summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 10px 2px 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--dur-3) var(--ease-spring);
}
.mk-about[open] summary::before { transform: rotate(45deg); }
.mk-about[open] > p { animation: rise-in var(--dur-3) var(--ease-out) backwards; }
.mk-about p { margin: 12px 0 0; max-width: 76ch; font-size: 13px; line-height: 1.6; color: var(--muted); }
.mk-about strong { font-weight: 600; color: var(--text); }

/* Loading skeleton: the final layout in blocks, no spinner. */
.mk-skel {
  position: relative;
  overflow: hidden;
  background: var(--surface-muted);
  border-radius: var(--r-md);
}
.mk-skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 6%, transparent), transparent);
  animation: shimmer 1.6s var(--ease-in-out) infinite;
}
.mk-skel-line { height: 20px; margin-bottom: 16px; }
.mk-skel-head { height: 168px; margin-bottom: 16px; border-radius: var(--r-xl); }
.mk-skel-chart { height: clamp(300px, 40vh, 520px); margin-bottom: 32px; border-radius: var(--r-xl); }
.mk-skel-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.mk-skel-tile { height: 104px; border-radius: var(--r-xl); }

/* Charts */
.mk-chart-host { position: relative; padding: 12px 4px 4px; }
.mk-chart { display: block; max-width: 100%; overflow: visible; }
.mk-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.mk-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mk-line { fill: none; stroke: var(--accent-fill); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
[data-theme="dark"] .mk-line { stroke: var(--series-1); }
.mk-area { fill: url(#mkAreaAccent); stroke: none; pointer-events: none; }
.mk-lone { fill: var(--series-1); }
.mk-band { fill: var(--series-1); fill-opacity: 0.1; stroke: none; }
.mk-dot { fill: var(--series-1); fill-opacity: 0.4; stroke: none; cursor: pointer; transition: fill-opacity var(--dur-1) var(--ease-out); }
.mk-dot-hot { fill-opacity: 1; stroke: var(--surface); stroke-width: 2; }
.mk-bar { fill: var(--muted); fill-opacity: 0.22; rx: 2px; transition: fill-opacity var(--dur-1) var(--ease-out); }
.mk-bar:hover { fill-opacity: 0.4; }
.mk-overlay { fill: transparent; }
.mk-crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.mk-ref { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.mk-series { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.mk-series-1 { stroke: var(--series-1); }
.mk-series-2 { stroke: var(--series-2); }
.mk-series-3 { stroke: var(--series-3); }
.mk-series-4 { stroke: var(--series-4); }
.mk-end { font: 600 12px var(--font-mono); }
.mk-end-1 { fill: var(--series-1); }
.mk-end-2 { fill: var(--series-2); }
.mk-end-3 { fill: var(--series-3); }
.mk-end-4 { fill: var(--series-4); }
.mk-grad-stop-top { stop-color: var(--series-1); stop-opacity: 0.28; }
.mk-grad-stop-bottom { stop-color: var(--series-1); stop-opacity: 0; }
.mk-grad-up-top { stop-color: var(--up); stop-opacity: 0.22; }
.mk-grad-down-top { stop-color: var(--down); stop-opacity: 0.22; }
.mk-grad-up-bottom { stop-color: var(--up); stop-opacity: 0; }
.mk-grad-down-bottom { stop-color: var(--down); stop-opacity: 0; }
.mk-svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* A freshly drawn chart sweeps in from the left once per load. */
.mk-reveal .mk-plot { animation: chart-reveal 1100ms var(--ease-out) both; }
.mk-reveal .mk-area { animation: fade-in 1200ms var(--ease-out) 200ms both; }
@keyframes chart-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.mk-spark { display: block; overflow: visible; }
.mk-spark path { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.mk-spark path.mk-spark-bridge { stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.55; }
.mk-spark path.mk-spark-area { stroke: none; }
.mk-spark-fluid path { vector-effect: non-scaling-stroke; }
.mk-spark path.mk-spark-lone { stroke-width: 4; }
.mk-spark-up path { stroke: var(--up); }
.mk-spark-down path { stroke: var(--down); }
.mk-spark-up path.mk-spark-area { fill: url(#mkSparkUp); }
.mk-spark-down path.mk-spark-area { fill: url(#mkSparkDown); }
.mk-spark-up circle { fill: var(--up); }
.mk-spark-down circle { fill: var(--down); }
.mk-enter .mk-spark { animation: chart-reveal 900ms var(--ease-out) backwards; animation-delay: calc(120ms + min(var(--i, 0), 14) * 40ms); }
.mk-tooltip {
  position: absolute;
  z-index: 20;
  max-width: 280px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
  transition: left 90ms var(--ease-out), top 90ms var(--ease-out);
}
.mk-tooltip strong { font-size: 13px; font-weight: 600; }
.mk-tooltip[hidden] { display: none; }
.mk-tip-muted { color: var(--muted); }

@media (min-width: 1121px) {
  .registry-list { max-height: calc(100vh - 301px); }
}

/* Per-view loading: a view's content stays hidden until its data arrives, so a
   slow request never shows zeros or empty tables. */
.view-placeholder { display: none; }
.view[data-load-state="loading"] > :not(.view-placeholder),
.view[data-load-state="error"] > :not(.view-placeholder) { display: none; }
.view[data-load-state="loading"] > .view-placeholder,
.view[data-load-state="error"] > .view-placeholder {
  display: grid;
  gap: 12px;
  padding: 8px 0;
}
.view[data-load-state="error"] > .view-placeholder,
.view[data-refresh-error] > .view-placeholder {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--down, #b3261e);
}
.view-skeleton-block { display: block; height: 320px; width: 100%; }

/* ---- Motion vocabulary ---------------------------------------------------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(0.965); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.97); } }

/* Reduced motion: everything lands in its final state at once. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .status-dot.is-ok::after, .mk-new::after { display: none; }
}

/* Phones (375px): tighten the app bar so it never forces sideways scrolling. */
@media (max-width: 480px) {
  .appbar { gap: 8px; }
  .wordmark { display: none; }
  .ws-tab { padding: 0 6px; }
  .appbar-actions { gap: 2px; }
  .appbar-actions select { width: 60px; padding-left: 8px; padding-right: 22px; background-position: right 7px center; }
  .appbar-actions .icon-button { width: 34px; min-height: 34px; height: 34px; }
}

/* ---- Listing record ------------------------------------------------------ */
/* Our saved copy of one Mercari listing. Two columns when the page container
   is wide (gallery and summary side by side), one column below that. Sizes
   follow the container, never the viewport, so a split window behaves. */
#listingView.active {
  overflow-y: auto;
  gap: 0;
  max-width: none;
  padding: 0;
}

.lr-page {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 20px var(--gutter) 72px;
  font-variant-numeric: tabular-nums;
  container: lrpage / inline-size;
}

.lr-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  margin-bottom: 16px;
}
.lr-back svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-3) var(--ease-spring); }
.lr-back:hover svg { transform: translateX(-3px); }

.lr-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}
.lr-grid > * { animation: rise-in var(--dur-4) var(--ease-out) backwards; }
.lr-grid > :nth-child(2) { animation-delay: 40ms; }
.lr-grid > :nth-child(3) { animation-delay: 80ms; }
.lr-grid > :nth-child(4) { animation-delay: 120ms; }
@container lrpage (min-width: 880px) {
  .lr-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; }
}

/* Gallery: the frame reserves its space before the photo arrives. */
.lr-gallery { display: grid; gap: 12px; min-width: 0; }
.lr-stage { position: relative; border-radius: var(--r-xl); }
.lr-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: min(78vh, 820px);
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--media-bg);
  box-shadow: var(--shadow), var(--highlight);
  cursor: zoom-in;
}
button.lr-frame { padding: 0; border: 0; color: inherit; font: inherit; }
button.lr-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.lr-frame.is-missing, .lr-frame-empty { cursor: default; }
.lr-frame-empty { display: grid; place-items: center; }
.lr-main {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity var(--dur-3) var(--ease-out);
}
.lr-main[hidden] { display: none; }
.lr-frame.is-loading .lr-main { opacity: 0; }
.lr-frame.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: shimmer 1.6s var(--ease-in-out) infinite;
  pointer-events: none;
}
[data-theme="dark"] .lr-frame.is-loading::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

.lr-missing {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}
.lr-missing svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lr-missing-overlay {
  position: absolute;
  inset: 0;
  align-content: center;
  border-radius: var(--r-xl);
  background: var(--media-bg);
  pointer-events: none;
}
.lr-missing-overlay[hidden] { display: none; }

.lr-chip, .lr-counter {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
.lr-chip { top: 12px; left: 12px; padding-left: 8px; }
.lr-chip[hidden] { display: none; }
.lr-chip svg { width: 13px; height: 13px; fill: none; stroke: var(--up); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lr-counter { right: 12px; bottom: 12px; }

.lr-nav {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--shadow-pop);
}
.lr-nav:hover { background: var(--surface); }
.lr-nav.prev { left: 12px; }
.lr-nav.next { right: 12px; }
.lr-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.lr-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lr-thumb {
  position: relative;
  display: block;
  width: 100%;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-md);
  background: var(--media-bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.lr-thumb:hover { background: var(--media-bg); transform: translateY(-2px); }
.lr-thumb.active { box-shadow: 0 0 0 2px var(--accent); }
.lr-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lr-thumb-empty { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); }
.lr-thumb-empty svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lr-thumb-saved {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: none;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lr-thumb.is-saved .lr-thumb-saved { display: grid; }
.lr-thumb-saved svg { width: 11px; height: 11px; fill: none; stroke: var(--up); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Summary */
.lr-summary {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: clamp(18px, 2vw, 28px);
}
.lr-status {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  min-height: 26px;
  padding: 3px 11px 3px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.lr-status svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.lr-status.is-active { background: var(--up-soft); color: var(--up); }
.lr-status.is-sold { background: var(--accent-soft); color: var(--accent); }
.lr-status.is-ended { background: var(--warn-soft); color: var(--warn); }

.lr-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 1.2vw + 12px, 28px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.lr-target { margin-top: -6px; }
.lr-price-block { display: grid; gap: 4px; }
.lr-price {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 2.2vw + 16px, 48px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.lr-price-block [data-lr-approx]:empty { display: none; }

.lr-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.lr-action { min-height: 44px; }
.lr-actions a.mk-primary { display: inline-flex; align-items: center; text-decoration: none; }
.lr-actions a.mk-primary:hover, .lr-actions a.mk-chip-button:hover { text-decoration: none; }
.lr-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 13px;
}
.lr-note svg { flex: none; width: 16px; height: 16px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.lr-facts { display: grid; margin: 0; border-top: 1px solid var(--line); }
.lr-fact {
  display: grid;
  grid-template-columns: minmax(96px, 9.5rem) minmax(0, 1fr);
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.lr-fact dt { color: var(--muted); font-size: 13px; }
.lr-fact dd { margin: 0; overflow-wrap: anywhere; }
.lr-fact-note { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.lr-mono { font-family: var(--font-mono); font-size: 12.5px; }
@container lrpage (max-width: 480px) {
  .lr-fact { grid-template-columns: minmax(0, 1fr); }
}

/* Description + history */
.lr-panel { min-width: 0; padding: clamp(16px, 1.6vw, 24px); }
.lr-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.lr-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--surface-muted); }
.lr-tab {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
}
.lr-tab:hover { background: transparent; color: var(--text); }
.lr-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.lr-text {
  max-width: 70ch;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.lr-text-note { margin-top: 12px; }

.lr-timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.lr-timeline li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "time status" "event status";
  align-items: center;
  gap: 2px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.lr-timeline li:last-child { border-bottom: 0; }
.lr-time { grid-area: time; color: var(--muted); font-size: 12.5px; }
.lr-event { grid-area: event; overflow-wrap: anywhere; }
.lr-timeline .lr-status { grid-area: status; min-height: 22px; font-size: 11.5px; }
.lr-provenance { margin: 20px 4px 0; color: var(--muted); font-size: 12.5px; }

/* States */
.lr-state { display: grid; justify-items: start; gap: 10px; padding: clamp(24px, 4vw, 48px); }
.lr-state-icon { color: var(--muted); }
.lr-state-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.lr-state-title { margin: 0; font-family: var(--font-display); font-size: clamp(20px, 1.2vw + 12px, 26px); font-weight: 650; letter-spacing: -0.03em; }
.lr-skel-title { display: block; height: 28px; width: 85%; }
.lr-skel-price { display: block; height: 48px; width: 50%; }
.mk-row-links { display: inline-flex; gap: 14px; }

/* Lightbox: full-screen photo viewer. Always dark, like any photo viewer,
   so photos read the same in both themes. */
html:has(.lr-lightbox[open]) { overflow: hidden; }
.lr-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f5f6f8;
  overflow: hidden;
}
.lr-lightbox::backdrop {
  background: rgba(5, 6, 10, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.lr-lightbox[open] { animation: lr-lb-in var(--dur-3) var(--ease-out); }
.lr-lightbox[open]::backdrop { animation: lr-lb-fade var(--dur-3) var(--ease-out); }
@keyframes lr-lb-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes lr-lb-fade { from { opacity: 0; } to { opacity: 1; } }

.lr-lb-bar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) 12px;
  pointer-events: none;
}
.lr-lb-bar > * { pointer-events: auto; }
.lr-lb-counter {
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: rgba(18, 20, 26, 0.72);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.lr-lb-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(18, 20, 26, 0.72);
  color: inherit;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-out);
}
.lr-lb-close:hover { background: rgba(40, 43, 52, 0.9); }
.lr-lb-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.lr-lightbox :focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.lr-lb-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.lr-lb-track::-webkit-scrollbar { display: none; }
.lr-lb-slide {
  flex: 0 0 100%;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 72px var(--gutter) 40px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  cursor: zoom-out;
}
.lr-lb-slide img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 112px);
  object-fit: contain;
  border-radius: var(--r-md);
  cursor: default;
  user-select: none;
}
.lr-lb-missing { color: rgba(255, 255, 255, 0.7); }

.lr-lb-nav {
  position: fixed;
  z-index: 2;
  background: rgba(18, 20, 26, 0.72);
  color: #f5f6f8;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
.lr-lb-nav:hover { background: rgba(40, 43, 52, 0.9); }
.lr-lb-nav.prev { left: var(--gutter); }
.lr-lb-nav.next { right: var(--gutter); }
.lr-lb-nav:disabled { opacity: 0.35; cursor: default; }
.lr-lb-nav[hidden] { display: none; }
@media (max-width: 600px) {
  .lr-lb-nav { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); translate: none; }
  .lr-lb-slide { padding: 64px 0 84px; }
  .lr-lb-slide img { max-height: calc(100dvh - 148px); border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .lr-lightbox[open], .lr-lightbox[open]::backdrop { animation: none; }
  .lr-grid > * { animation: none; }
  .lr-thumb:hover { transform: none; }
}

/* eBay listings on the ticker page */
.mk-ebay .mk-panel + .mk-section-head,
.mk-ebay .mk-deal-grid + .mk-section-head { margin-top: 20px; }
.mk-ebay-title { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-ebay-disclosure { margin-top: 12px; font-size: 12px; }
