:root {
  --bg: #0b0d12;
  --bg-elev: #12161f;
  --bg-elev-2: #181d28;
  --border: #232a3a;
  --border-strong: #2f384c;
  --text: #e7ecf3;
  --text-muted: #8c97ad;
  --text-dim: #65718a;
  --accent: #6aa3ff;
  --accent-strong: #4d8bff;
  --accent-soft: rgba(106, 163, 255, 0.12);
  --good: #38d39f;
  --good-soft: rgba(56, 211, 159, 0.14);
  --warn: #ffb547;
  --bad: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 8px;
  --content-max: 1240px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fc;
    --bg-elev: #ffffff;
    --bg-elev-2: #ffffff;
    --border: #e3e8f0;
    --border-strong: #cdd5e3;
    --text: #1a2030;
    --text-muted: #5a6678;
    --text-dim: #8b95a8;
    --accent-soft: rgba(77, 139, 255, 0.1);
    --good-soft: rgba(56, 211, 159, 0.18);
    --shadow: 0 8px 24px rgba(20, 30, 60, 0.08);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

.topbar {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 24px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4d8bff 0%, #38d39f 100%);
  box-shadow: var(--shadow);
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 11px;
  background: var(--bg);
  border-radius: 6px;
  clip-path: polygon(20% 10%, 90% 50%, 20% 90%);
}
@media (prefers-color-scheme: light) {
  .brand-mark::after {
    background: #ffffff;
  }
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.hint {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  transition: background 0.15s, border-color 0.15s;
}
.hint:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.threshold-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-variant-numeric: tabular-nums;
}
.threshold-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.threshold-chip .threshold-chip-amount {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  /* Match the green used for the under-threshold card highlight, so the
     chip's color visually previews what it controls. */
  color: var(--good);
  font-weight: 700;
}
.threshold-chip.off .threshold-chip-amount {
  display: none;
}
.threshold-chip .dollar {
  color: var(--text-dim);
  font-weight: 500;
  margin-right: 1px;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel.error {
  border-color: var(--bad);
  background: rgba(255, 107, 107, 0.06);
}

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

.muted.small {
  font-size: 13px;
}

textarea#html-input {
  width: 100%;
  min-height: 200px;
  margin-top: 10px;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'SF Mono', ui-monospace, 'Menlo', 'Consolas', monospace;
  font-size: 12.5px;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea#html-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
}

.controls .spacer {
  flex: 1;
}

.threshold {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14px;
}
.threshold .dollar {
  color: var(--text-dim);
}
.threshold input {
  width: 64px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}
.checkbox input[type='checkbox'] {
  accent-color: var(--accent-strong);
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent-strong);
  color: white;
  border-color: var(--accent-strong);
}
button.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}
button.primary:disabled {
  opacity: 0.7;
  cursor: progress;
}

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

kbd {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-muted);
}

button.small {
  padding: 6px 12px;
  font-size: 13px;
}

.bookmarklet-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 18px 0 4px;
}

.bookmarklet {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-strong) 0%, var(--good) 100%);
  color: white;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(77, 139, 255, 0.35);
  cursor: grab;
  user-select: none;
  transition: transform 0.12s, box-shadow 0.12s;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.bookmarklet:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(77, 139, 255, 0.45);
}
.bookmarklet:active {
  cursor: grabbing;
  transform: translateY(0);
}
.bookmarklet .bm-pin {
  font-size: 18px;
  line-height: 1;
  display: inline-block;
  transform: rotate(45deg);
}
.bookmarklet[data-ready='true'] {
  box-shadow: 0 10px 28px rgba(56, 211, 159, 0.4);
}
#bookmarklet-status {
  margin: 6px 0 0;
}
#bookmarklet-status.warn {
  color: var(--warn, #ffb547);
}

.step-h {
  margin-top: 22px;
  font-size: 15px;
  font-weight: 600;
}

details.setup > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
  user-select: none;
}
details.setup > summary::-webkit-details-marker {
  display: none;
}
details.setup > summary > h2 {
  margin: 0;
}
details.setup > summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  color: var(--text-dim);
  font-size: 14px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
details.setup[open] > summary::before {
  transform: rotate(90deg);
}
.setup-hint {
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 13px;
}
details.setup > summary:hover .setup-hint {
  opacity: 1;
}
details.setup[open] > summary .setup-hint::before {
  content: 'click to collapse';
}
details.setup:not([open]) > summary .setup-hint::before {
  content: 'click to expand';
}
.setup-body {
  margin-top: 2px;
}

details.alt {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
details.alt > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13.5px;
  list-style: none;
  padding: 4px 0;
}
details.alt > summary::-webkit-details-marker {
  display: none;
}
details.alt > summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  color: var(--text-dim);
  transition: transform 0.12s;
}
details.alt[open] > summary::before {
  transform: rotate(90deg);
}
details.alt > summary:hover {
  color: var(--text);
}

.session-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 14px;
  max-width: var(--content-max);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}
.session-banner .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.session-banner[data-state="ok"] {
  border-color: var(--good);
  background: var(--good-soft);
}
.session-banner[data-state="ok"] .dot {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(56, 211, 159, 0.18);
}
.session-banner[data-state="warn"] {
  border-color: var(--warn);
  background: rgba(255, 181, 71, 0.12);
}
.session-banner[data-state="warn"] .dot {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(255, 181, 71, 0.2);
}
.session-banner[data-state="error"] {
  border-color: var(--bad);
  background: rgba(255, 107, 107, 0.1);
}
.session-banner[data-state="error"] .dot {
  background: var(--bad);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.18);
}
.session-banner em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
}

.install-panel {
  padding: 18px 22px;
}
.install-panel summary h2 {
  font-size: 16px;
}
.install-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 16px;
}
.install-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.install-step-body {
  flex: 1;
  min-width: 0;
}
.install-step-title {
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 2px;
}
.install-step-body p {
  margin: 4px 0 8px;
}
.install-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-strong);
  color: white;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  margin-top: 4px;
  border: 1px solid var(--accent-strong);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.install-download:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.install-download:active {
  transform: translateY(1px);
}
.install-download code {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
  color: white;
}
.install-browsers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px;
}
.install-browser {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px 14px;
}
.install-browser h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.install-browser .steps {
  margin: 6px 0 0;
  font-size: 13.5px;
}
.install-browser .steps li {
  margin-bottom: 3px;
}
.install-browser p {
  margin-top: 10px;
}
@media (max-width: 720px) {
  .install-browsers {
    grid-template-columns: 1fr;
  }
}
.install-step code,
.install-browser code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-family: 'SF Mono', ui-monospace, 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text);
}
.install-download code,
a.install-download code {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 12.5px;
  padding: 1px 6px;
}
.banner-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 2px;
  font-weight: 600;
}
.banner-link:hover {
  text-decoration-thickness: 2px;
}

.sync-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sync-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.sync-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.sync-meta {
  margin-left: auto;
  text-align: right;
  max-width: 460px;
}
@media (max-width: 720px) {
  .sync-meta {
    margin-left: 0;
    text-align: left;
    max-width: 100%;
  }
}
.sync-panel #sync-btn {
  min-width: 160px;
}
.sync-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sync-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  overflow: hidden;
  border: 1px solid var(--border);
}
.sync-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
  transition: width 0.4s ease;
}
.sync-progress-text {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.banner-import {
  display: flex;
  align-items: center;
  gap: 12px;
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--text);
  font-size: 14px;
  padding: 14px 20px;
}
.banner-import .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 6px rgba(56, 211, 159, 0.18);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.banner-import .dot.dim {
  background: var(--text-dim);
  box-shadow: none;
  animation: none;
}
.banner-import strong {
  color: var(--good);
  font-weight: 700;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.steps {
  margin: 12px 0 4px;
  padding-left: 22px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.steps li {
  margin-bottom: 6px;
}
.steps li::marker {
  color: var(--text-dim);
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
}
.inline-link:hover {
  background: var(--accent-soft);
}

#copy-snippet-status {
  margin-left: 4px;
  font-size: 12.5px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: stretch;
}
.summary .stat-meta {
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.stat .num {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  color: var(--text-muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat.highlight {
  border-color: var(--good);
  background: var(--good-soft);
}
.stat.highlight .num {
  color: var(--good);
}

@media (max-width: 720px) {
  .summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

.results-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}
.results-toolbar h2 {
  margin: 0;
  margin-right: auto;
}

.filter-pills {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.pill:hover {
  color: var(--text);
}
.pill.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.sort select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}
.card.under-threshold {
  border-color: var(--good);
  box-shadow: 0 0 0 1px var(--good-soft) inset;
}
.card.on-sale .badges .sale {
  display: inline-block;
}

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #1a2030 0%, #2a334a 100%);
  overflow: hidden;
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster img[data-loaded='false'] {
  visibility: hidden;
}
.poster-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.poster-fallback::before {
  content: 'No poster';
}
.poster img[data-loaded='true'] + .poster-fallback {
  display: none;
}

.badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  backdrop-filter: blur(6px);
  background: rgba(0, 0, 0, 0.55);
  color: white;
}
.badge.sale {
  background: var(--warn);
  color: #1a1300;
  display: none;
}
.badge.under {
  background: var(--good);
  color: #062018;
}
.badge.upgrade {
  background: #5b7cff;
  color: #06112e;
}
.badge.owned {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
}
.buy.upgrade .lbl {
  color: #5b7cff;
}
.buy.owned .lbl {
  color: rgba(255, 255, 255, 0.55);
}

.card-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  margin: 0;
  color: var(--text-dim);
  font-size: 12.5px;
}
.prices {
  display: flex;
  gap: 14px;
  align-items: baseline;
  margin-top: auto;
}
.prices .buy,
.prices .rent {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.prices .lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.prices .val {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.prices .val.missing {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 13px;
}
.card.under-threshold .buy .val {
  color: var(--good);
}
.list-strike {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
  display: none;
}
.list-strike.shown {
  display: inline;
}
.open {
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
  margin-top: 2px;
}
.open:hover {
  text-decoration: underline;
}

footer {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-dim);
}
footer code {
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.prefs-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.prefs-dialog::backdrop {
  background: rgba(8, 10, 16, 0.55);
  backdrop-filter: blur(2px);
}
.prefs-dialog form {
  margin: 0;
  display: flex;
  flex-direction: column;
}
.prefs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.prefs-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.prefs-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.prefs-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.prefs-field label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.prefs-input-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: max-content;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prefs-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.prefs-dollar {
  color: var(--text-dim);
  font-size: 14px;
}
.prefs-input-row input {
  width: 90px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.prefs-field p {
  margin: 0;
}
.prefs-footnote {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.prefs-footnote code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-family: 'SF Mono', ui-monospace, 'Menlo', 'Consolas', monospace;
  font-size: 11.5px;
  color: var(--text);
}
.prefs-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-elev-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- sync-errors chip + dialog ----------------------------------------
 * The chip is the red "!" pill that sits next to the session banner when
 * the last sync had per-item price-lookup failures. It's both a visual
 * indicator (count) and a button that opens the detail dialog.
 *
 * The dialog is a polished glass-card popup — wider than the prefs
 * dialog (because it shows a list), scrollable body, sticky footer.
 */

.status-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  max-width: var(--content-max);
  margin: 0 auto 14px;
}
.status-row .session-banner {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.sync-errors-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 107, 107, 0.55);
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.18), rgba(255, 107, 107, 0.08));
  color: var(--bad);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 1px 0 rgba(255, 107, 107, 0.12), 0 4px 14px rgba(255, 107, 107, 0.18);
  -webkit-tap-highlight-color: transparent;
}
.sync-errors-chip:hover {
  background: linear-gradient(180deg, rgba(255, 107, 107, 0.26), rgba(255, 107, 107, 0.12));
  box-shadow: 0 1px 0 rgba(255, 107, 107, 0.18), 0 6px 18px rgba(255, 107, 107, 0.28);
}
.sync-errors-chip:active {
  transform: translateY(1px);
}
.sync-errors-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.35), 0 6px 18px rgba(255, 107, 107, 0.28);
}
.sync-errors-bang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  /* Subtle inner glow + soft pulse so it actually reads as "alert" */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18),
              0 0 0 4px rgba(255, 107, 107, 0.18);
  animation: sync-errors-pulse 2.4s ease-in-out infinite;
}
@keyframes sync-errors-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 0 4px rgba(255, 107, 107, 0.18); }
  50%      { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 0 7px rgba(255, 107, 107, 0.06); }
}
.sync-errors-count {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- errors dialog --------------------------------------------------- */

.errors-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(80vh, 720px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  /* Make the dialog itself the flex container so the header + footer
     stay put while only the body scrolls. */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* :not(open) so the flex display above doesn't force the dialog visible
   when the browser hasn't opened it. */
.errors-dialog:not([open]) {
  display: none;
}
.errors-dialog::backdrop {
  background: rgba(8, 10, 16, 0.55);
  backdrop-filter: blur(2px);
}
.errors-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 107, 107, 0.10), rgba(255, 107, 107, 0)) padding-box,
    var(--bg-elev) padding-box;
}
.errors-header-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.errors-header-titles h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.errors-header-titles h2::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
}
.errors-summary {
  margin: 0;
  font-size: 12.5px;
}
.errors-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ghost.small {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ghost.small:hover {
  background: var(--bg-elev-2);
  border-color: var(--border-strong);
}
.ghost.small.copied {
  color: var(--good);
  border-color: var(--good);
  background: var(--good-soft);
}
.errors-body {
  padding: 14px 18px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.errors-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: errors-counter;
}
.errors-list li {
  counter-increment: errors-counter;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}
.errors-list li:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
}
.errors-list li::before {
  content: counter(errors-counter);
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 107, 107, 0.12);
  color: var(--bad);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.errors-list .err-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  margin: 0 0 4px;
  word-break: break-word;
}
.errors-list .err-title a {
  color: var(--accent);
  font-weight: 500;
  font-size: 11.5px;
  text-decoration: none;
  white-space: nowrap;
}
.errors-list .err-title a:hover { text-decoration: underline; }
.errors-list .err-message {
  margin: 0;
  font-family: 'SF Mono', ui-monospace, 'Menlo', 'Consolas', monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}
.errors-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.errors-footer code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-family: 'SF Mono', ui-monospace, 'Menlo', 'Consolas', monospace;
  font-size: 11.5px;
  color: var(--text);
}
