:root {
  /* Neutral palette */
  --bg: #f9fafb;
  --bg-deep: #f3f4f6;
  --paper: #ffffff;
  --paper-strong: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;

  /* Primary accent: amber/orange */
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.1);

  /* Secondary: teal (actually use it now) */
  --accent-2: #0d9488;
  --accent-2-soft: rgba(13, 148, 136, 0.1);

  /* Semantic */
  --good: #10b981;
  --good-soft: rgba(16, 185, 129, 0.1);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.1);
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.1);

  /* Shadows — 4-level system */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Spacing (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radius — tighter, modern */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Typography */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", "Fira Code", monospace;

  /* Dark mode ready */
  color-scheme: light dark;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-deep: #1e293b;
    --paper: #1e293b;
    --paper-strong: #1e293b;
    --ink: #f1f5f9;
    --muted: #94a3b8;
    --line: rgba(148, 163, 184, 0.15);
    --accent-soft: rgba(217, 119, 6, 0.15);
    --accent-2-soft: rgba(13, 148, 136, 0.15);
    --good-soft: rgba(16, 185, 129, 0.15);
    --warn-soft: rgba(245, 158, 11, 0.15);
    --bad-soft: rgba(239, 68, 68, 0.15);
    --info-soft: rgba(59, 130, 246, 0.15);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--sans);
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(13, 148, 136, 0.07), transparent 24%),
    var(--bg);
  padding: var(--space-6) var(--space-5) var(--space-7);
}

a,
button,
input,
select,
textarea,
.panel,
.health-tile,
.dashboard-card,
.inspect-card,
.summary-stat,
.note,
.result,
.drop-zone,
.history-tab,
.zoom-btn,
.debug-toggle,
.ghost-btn {
  transition: all 0.15s ease;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: var(--space-5);
}

.nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  top: 18px;
  z-index: 20;
  padding: 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  border: 1px solid rgba(229, 231, 235, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
}

.nav a {
  position: relative;
  padding: 10px 14px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-radius: 999px;
}

.nav a:hover {
  color: var(--ink);
  background: var(--bg-deep);
}

.nav a.active {
  color: var(--ink);
  background: var(--accent-soft);
}

.nav a.active::after {
  display: none;
}

.hero {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.9fr);
  gap: var(--space-5);
  margin-top: var(--space-4);
  align-items: start;
}

h1 {
  font-family: var(--sans);
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 700;
  max-width: 10ch;
}

.subtitle {
  margin-top: var(--space-4);
  max-width: 62ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.hero-notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-2);
}

.note {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.note-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.note-value {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.skeleton {
  color: transparent;
  display: inline-block;
  min-width: 80px;
  height: 1em;
  background: linear-gradient(90deg, var(--line) 25%, var(--bg-deep) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  vertical-align: middle;
}

.inline-skeleton {
  width: 100%;
  min-width: 72px;
  min-height: 18px;
  border-radius: 6px;
}

.model-select,
input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--sans);
  outline: none;
  box-shadow: none;
}

.model-select {
  cursor: pointer;
  appearance: none;
}

input::placeholder {
  color: var(--muted);
}

.model-select:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.panel:hover,
.health-tile:hover,
.dashboard-card:hover,
.inspect-card:hover,
.summary-stat:hover,
.note:hover {
  box-shadow: var(--shadow-md);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.panel h2 {
  font-family: var(--sans);
  font-size: 1.5rem;
  line-height: 1.1;
  font-weight: 700;
}

.panel-copy {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 48ch;
}

.panel-subgrid {
  display: grid;
  gap: var(--space-4);
}

.section-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 4px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.pill.good {
  background: var(--good-soft);
  color: var(--good);
}

.pill.error {
  background: var(--bad-soft);
  color: var(--bad);
}

.health-grid,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.health-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  background: var(--paper);
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.health-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-dot.good {
  background: var(--good);
  box-shadow: 0 0 0 2px var(--good-soft);
}

.health-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--warn-soft);
}

.health-dot.bad {
  background: var(--bad);
  box-shadow: 0 0 0 2px var(--bad-soft);
}

.health-dot.neutral {
  background: var(--muted);
  opacity: 0.8;
  box-shadow: 0 0 0 2px var(--line);
}

.health-name {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.health-status,
.health-detail {
  font-family: var(--mono);
}

.health-status {
  font-size: 14px;
  font-weight: 700;
}

.health-detail {
  font-size: 12px;
  color: var(--muted);
}

.form-grid,
.settings-grid,
.dashboard-stack,
.scan-left,
.scan-right,
.inspect,
.debug-console {
  display: grid;
}

.form-grid {
  gap: var(--space-3);
}

.field,
.setting {
  display: grid;
  gap: 7px;
}

.field.tight,
.setting.tight {
  gap: 4px;
}

.field-inline {
  display: flex;
  gap: var(--space-3);
  align-items: end;
  flex-wrap: wrap;
}

.field-inline > * {
  flex: 1 1 180px;
}

label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.auth-shell {
  min-height: calc(100vh - 80px);
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  align-items: center;
}

.auth-hero {
  padding: var(--space-6) 0;
}

.auth-card {
  margin-top: var(--space-4);
}

.auth-error {
  min-height: 20px;
  color: var(--bad);
  font-size: 14px;
}

button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: scale(0.98);
}

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

.spinner {
  display: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 16px auto 0;
}

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

.drop-zone {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  min-height: 210px;
  padding: var(--space-4);
  background: var(--bg);
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px transparent;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.drop-zone-inner {
  display: grid;
  gap: 10px;
  width: 100%;
  justify-items: center;
}

.drop-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 700;
}

.drop-title {
  font-family: var(--sans);
  font-size: 1.5rem;
  line-height: 1.1;
  max-width: 10ch;
  font-weight: 700;
}

.drop-copy,
.mini-note,
.empty-state {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.mini-note.strong {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.18);
}

.file-chip,
.meta-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 9999px;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}

.file-chip {
  display: none;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-zone img {
  width: min(100%, 260px);
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius);
  display: none;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.preview-actions {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.preview-actions.stacked {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 12px;
}

.ghost-btn,
.history-tab,
.zoom-btn,
.debug-toggle {
  width: auto;
  box-shadow: none;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost-btn:hover,
.history-tab:hover,
.zoom-btn:hover,
.debug-toggle:hover {
  background: var(--bg-deep);
}

.result {
  margin-top: 0;
  display: none;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.result.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

.result.ok {
  border-color: var(--line);
}

.result.error {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

.result-title {
  font-family: var(--sans);
  font-size: 1.75rem;
  line-height: 1.1;
  margin-bottom: 8px;
  font-weight: 700;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.result-grid {
  overflow: hidden;
  display: grid;
  gap: 14px;
}

.result-art {
  float: left;
  width: 148px;
  margin: 0 18px 14px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.result-art img {
  width: 100%;
  display: block;
  aspect-ratio: 0.72;
  object-fit: cover;
}

.price-grid,
.inspect-grid,
.debug-timers {
  display: grid;
  gap: 10px;
}

.price-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.inspect {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  gap: 12px;
}

.inspect:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.inspect-title,
.error-title,
.dashboard-label,
.inspect-label,
.timer-label,
.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.inspect-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.inspect-card,
.timer-chip,
.price-card,
.dashboard-card {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: none;
}

.inspect-value {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.inspect-raw {
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.debug-console {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  gap: 10px;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.debug-toggle {
  all: unset;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
}

.debug-timers {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.timer-value,
.health-status,
.history-table .time-cell,
.history-table .model-cell,
.history-table .ms-cell,
.summary-value {
  font-family: var(--mono);
}

.timer-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.timer-value.fast,
.ms-fast,
.match-yes,
.status-good {
  color: var(--good);
}

.timer-value.mid,
.ms-mid {
  color: var(--warn);
}

.timer-value.slow,
.ms-slow,
.match-no,
.status-bad {
  color: var(--bad);
}

.debug-list {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

.debug-line {
  display: block;
  padding: 2px 0 2px 1.4em;
  text-indent: -1.4em;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.debug-line:last-child {
  border-bottom: none;
}

.debug-line .prefix {
  opacity: 0.45;
}

.debug-line.is-timer {
  color: var(--good);
}

.debug-line.is-query {
  color: var(--info);
}

.debug-line.is-match {
  color: var(--accent-2);
}

.debug-line.is-fail {
  color: var(--bad);
}

.debug-line.is-ollama {
  color: var(--warn);
}

.debug-line.is-gemini {
  color: var(--accent-2);
}

.debug-line.is-fallback {
  color: var(--muted);
}

.scan-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.scan-left {
  gap: 14px;
  position: sticky;
  top: 18px;
}

.scan-right {
  gap: 14px;
}

.stack {
  display: grid;
  gap: var(--space-4);
}

.surface {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--paper) 75%, var(--bg)));
  padding: var(--space-4);
}

.surface.muted {
  background: var(--bg);
}

.surface-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.surface-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.surface-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.mini-note {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 12px 14px;
}

.zoom-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.zoom-modal.visible {
  display: flex;
}

.zoom-shell {
  position: relative;
  width: min(92vw, 1100px);
  height: min(90vh, 900px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
}

.zoom-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  z-index: 2;
}

.zoom-stage {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: grid;
  place-items: center;
  background: var(--bg-deep);
}

.zoom-stage img {
  max-width: none;
  max-height: none;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}

.price-label {
  display: block;
  margin-bottom: 8px;
}

.price-value,
.dashboard-value {
  color: var(--ink);
  font-weight: 700;
}

.price-value {
  font-size: 1.9rem;
  line-height: 1;
  margin-bottom: 8px;
}

.price-range {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tcg-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.tcg-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.error-copy {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.settings-panel {
  background: var(--paper);
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}

.provider-setting {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--paper), var(--bg));
}

.setting label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.setting-card {
  display: grid;
  gap: var(--space-3);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--paper), color-mix(in srgb, var(--paper) 72%, var(--bg)));
  min-height: 100%;
}

.setting-card.wide {
  grid-column: 1 / -1;
}

.setting-card.compact {
  gap: var(--space-2);
}

.setting-card-head {
  display: grid;
  gap: 4px;
}

.setting-card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.setting-card-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.setting-subcopy {
  margin-top: -2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 72ch;
}

.setting-hint {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: none;
}

.setting input[type="range"] {
  width: 100%;
  height: 36px;
  padding: 4px 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.setting input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--bg-deep);
}

.setting input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--paper);
  margin-top: -7px;
  box-shadow: var(--shadow-md);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.setting input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-lg);
}

.setting input[type="range"]::-moz-range-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--bg-deep);
}

.setting input[type="range"]::-moz-range-progress {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--accent);
}

.setting input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--paper);
  box-shadow: var(--shadow-md);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.setting input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-lg);
}

.setting-status {
  display: flex;
  align-items: end;
  padding-bottom: 8px;
}

.setting-saved {
  font-size: 12px;
  font-weight: 600;
  color: var(--good);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.setting-saved.show {
  opacity: 1;
}

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

.settings-footnote {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-chip.good {
  background: var(--good-soft);
  color: var(--good);
}

.status-chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.history-panel {
  grid-column: 1 / -1;
}

.history-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.history-tab {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.history-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.history-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th {
  background: var(--bg-deep);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.history-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-table tbody tr:nth-child(odd) {
  background: var(--paper);
}

.history-table tbody tr:nth-child(even) {
  background: var(--bg);
}

.history-table tbody tr:hover {
  background: var(--accent-soft);
}

.history-table tbody tr.clickable-row {
  cursor: pointer;
}

.history-table tbody tr.clickable-row td:first-child {
  font-weight: 600;
}

.history-table .model-cell,
.history-table .card-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-table .card-cell {
  font-weight: 600;
}

.history-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px !important;
}

.history-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.summary-stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.summary-value {
  font-weight: 700;
  font-size: 15px;
}

.search-toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.search-toolbar .field {
  flex: 1 1 320px;
}

.search-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.search-actions button {
  width: auto;
  min-width: 120px;
}

.search-summary {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 12px;
  color: var(--muted);
}

.summary-chip strong {
  color: var(--ink);
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}

.plan-free { background: var(--bg-deep); color: var(--muted); border-color: var(--line); }
.plan-collector { background: var(--info-soft); color: var(--info); border-color: rgba(59, 130, 246, 0.2); }
.plan-pro { background: var(--good-soft); color: var(--good); border-color: rgba(16, 185, 129, 0.2); }
.plan-max { background: var(--accent-2-soft); color: var(--accent-2); border-color: rgba(13, 148, 136, 0.22); }
.plan-custom { background: var(--warn-soft); color: var(--warn); border-color: rgba(245, 158, 11, 0.22); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: min(100%, 620px);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--line);
  max-height: min(90vh, 960px);
  overflow: auto;
}

.modal h2 {
  margin-bottom: var(--space-4);
}

.modal-grid {
  display: grid;
  gap: var(--space-4);
}

.modal-field {
  display: grid;
  gap: 6px;
}

.modal-field label {
  display: block;
}

.modal-field textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-family: var(--sans);
}

.modal-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.field-hint {
  font-size: 11px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
}

.modal-actions button {
  width: auto;
  min-width: 120px;
}

.btn-cancel {
  background: var(--bg-deep);
  color: var(--ink);
  border-color: var(--line);
}

.btn-save {
  background: var(--accent);
  color: #fff;
}

.modal-status {
  font-size: 13px;
  min-height: 20px;
}

.modal-status.ok { color: var(--good); }
.modal-status.err { color: var(--bad); }

.credit-adjust {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.credit-adjust input {
  max-width: 110px;
  text-align: center;
}

.credit-adjust button {
  width: auto;
  padding: 9px 12px;
  background: var(--bg-deep);
  color: var(--ink);
  border-color: var(--line);
}

.credit-adjust button:hover {
  background: var(--accent-soft);
}

.user-meta {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: var(--space-4);
}

.audit-section {
  margin-top: var(--space-5);
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
}

.audit-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.audit-list {
  max-height: 220px;
  overflow-y: auto;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.audit-entry {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  background: var(--paper);
}

.audit-entry:last-child { border-bottom: none; }
.audit-time { color: var(--muted); white-space: nowrap; min-width: 120px; }
.audit-field { font-weight: 700; min-width: 68px; }
.audit-change { color: var(--ink); }
.audit-change .old { color: var(--bad); text-decoration: line-through; }
.audit-change .new { color: var(--good); }
.audit-reason { color: var(--muted); font-style: italic; margin-left: auto; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-empty { color: var(--muted); padding: var(--space-3); text-align: center; }

/* Add-on entitlement grid */
.addon-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.addon-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}

.addon-row:last-child { border-bottom: none; }

.addon-row > label {
  min-width: 160px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.addon-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.addon-controls input[type="datetime-local"] {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--paper);
  color: var(--ink);
}

.btn-quick {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}

.btn-quick:hover {
  background: var(--accent);
  color: white;
}

.btn-revoke {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--bad);
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  color: var(--bad);
  cursor: pointer;
}

.btn-revoke:hover {
  background: var(--bad);
  color: white;
}

/* Expandable debug rows in history */
.expandable-row { cursor: pointer; }
.expandable-row:hover { background: var(--accent-soft) !important; }
.expandable-row td:first-child::before {
  content: '▶';
  font-size: 9px;
  margin-right: 6px;
  color: var(--muted);
  transition: transform 0.15s ease;
  display: inline-block;
}

.debug-detail-row td {
  padding: 0 !important;
  background: var(--bg-deep);
}

.debug-detail {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.debug-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.debug-meta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  min-width: 90px;
}

.debug-meta-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.debug-raw {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}

.debug-console {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
}

.dbg-line { padding: 1px 0; }
.dbg-timer { color: #38bdf8; }
.dbg-query { color: #a78bfa; }
.dbg-match { color: #34d399; }
.dbg-fail { color: #f87171; }
.dbg-config { color: #94a3b8; }

.dashboard-layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.dashboard-card {
  border-radius: var(--radius-sm);
}

.dashboard-label {
  display: block;
  margin-bottom: 8px;
}

.dashboard-value {
  font-size: 2rem;
  line-height: 1;
}

.inspect-grid {
  display: grid;
}

code {
  font-family: var(--mono);
  font-size: 0.95em;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@media (max-width: 920px) {
  .hero-grid,
  .grid,
  .scan-layout,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .result-art {
    float: none;
    width: 100%;
    max-width: 200px;
    margin: 0 auto 14px;
  }

  h1 {
    max-width: 12ch;
  }

  .scan-left {
    position: static;
  }

  .nav {
    top: 10px;
  }

  .setting-card.wide,
  .provider-setting {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  body {
    padding: var(--space-4) var(--space-3) var(--space-6);
  }

  .panel {
    padding: var(--space-4);
  }

  .nav {
    padding: 8px;
  }

  h1 {
    font-size: 2.4rem;
  }

  .drop-title {
    font-size: 1.35rem;
  }

  .result-title {
    font-size: 1.45rem;
  }

  .price-value {
    font-size: 1.55rem;
  }

  .nav a {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
  }

  .hero-notes {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: var(--space-4);
  }

  .search-actions,
  .modal-actions {
    width: 100%;
  }

  .search-actions button,
  .modal-actions button {
    width: 100%;
  }
}
