:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --line: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #34d399; /* emerald pulse */
  --up: #34d399;
  --down: #f87171;
  --radius: 14px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

#offline-banner {
  position: sticky; top: 0; z-index: 20;
  background: #7c5e12; color: #ffedb0; text-align: center;
  padding: 6px 10px; font-size: 13px; font-weight: 600;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: linear-gradient(var(--bg), rgba(15, 17, 21, 0.85));
  backdrop-filter: blur(8px);
}
.wordmark { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.wordmark span { color: var(--accent); }

.game-switch { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.game-switch button {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.game-switch button[aria-selected="true"] { background: var(--accent); color: #06281c; }

#view { padding: 12px 16px 24px; max-width: 720px; margin: 0 auto; }

.placeholder { color: var(--muted); text-align: center; padding: 48px 12px; }

/* --- search --- */
.search { margin-bottom: 12px; }
.search-label {
  display: block; color: var(--muted); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.search-input {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; font-size: 16px; /* 16px: avoids iOS zoom-on-focus */
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--accent); }

.status { color: var(--muted); font-size: 13px; margin: 0 2px 10px; min-height: 1em; }

.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer;
}
.result:active { background: var(--surface-2); }
.result .thumb {
  width: 44px; height: 61px; flex: 0 0 44px; object-fit: contain;
  background: var(--surface-2); border-radius: 6px;
}
.result .text { flex: 1 1 auto; min-width: 0; }
.result .name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .meta { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .price { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-weight: 800; font-size: 15px; color: var(--accent); font-variant-numeric: tabular-nums; }
.result .price-finish { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.result .price-amount { line-height: 1.1; }

/* offline cache hint: dim the row and flag the price as remembered, not live */
.result--cached { opacity: 0.82; }
.result-cached-badge {
  flex: 0 0 auto; align-self: center;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 999px;
}

/* --- card detail + fair-price check --- */
.detail-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.detail-back {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.detail-back:active { background: var(--surface-2); }
.detail-heading { min-width: 0; }
.detail-name { margin: 0; font-size: 20px; line-height: 1.2; }
.detail-meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.detail-img { display: block; max-width: 260px; width: 66%; border-radius: 10px; margin: 0 auto 4px; }

.detail-section { margin-top: 20px; }
.detail-section-title {
  margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.detail-nomarket { color: var(--muted); font-size: 14px; margin: 0; }
.detail-asof { color: var(--muted); font-size: 12px; margin: -2px 2px 10px; }

.detail-table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.detail-table th, .detail-table td { padding: 8px 12px; text-align: right; white-space: nowrap; }
.detail-table th:first-child, .detail-table td:first-child { text-align: left; }
.detail-table thead th {
  color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; background: var(--surface-2);
}
.detail-table tbody tr { border-top: 1px solid var(--line); }
.detail-table .detail-finish { font-weight: 700; }

.detail-finishes { margin-bottom: 8px; flex-wrap: wrap; }
.detail-finishes button:disabled { cursor: default; opacity: 1; }
.detail-finish-label { color: var(--muted); font-size: 12px; margin: 0 2px 10px; }
.detail-conditions { margin-bottom: 12px; flex-wrap: wrap; }
.detail-ref { color: var(--muted); font-size: 13px; margin: 0 2px 10px; }

.detail-ask { display: flex; align-items: center; gap: 12px; }
.detail-ask-label { flex: 0 0 auto; font-weight: 700; font-size: 14px; }
.detail-ask-field {
  flex: 1 1 auto; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px;
}
.detail-ask-field:focus-within { border-color: var(--accent); }
.detail-ask-prefix { color: var(--muted); font-weight: 700; }
.detail-ask-input {
  flex: 1 1 auto; min-width: 0; appearance: none; -webkit-appearance: none;
  background: transparent; color: var(--text); border: 0; outline: none;
  font-size: 16px; /* 16px: avoids iOS zoom-on-focus */
}

.detail-verdict { margin: 10px 2px 0; font-weight: 800; font-size: 16px; }
.detail-verdict[data-tone="over"] { color: var(--down); }
.detail-verdict[data-tone="under"] { color: var(--up); }
.detail-verdict[data-tone="at"] { color: var(--text); }
.detail-verdict[data-tone="none"] { color: var(--muted); font-weight: 600; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  min-height: 44px; /* comfortable thumb target */
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.tab[aria-current="page"] { color: var(--accent); }

/* --- install affordance (js/install.js) --- */
/* Slim, dismissible bar under the topbar. One line of copy, a right-aligned
   action (Install on Android/Chrome; none on iOS), and a dismiss ×. */
.install-bar {
  position: sticky; top: 0; z-index: 9;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px calc(8px);
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.install-text {
  flex: 1 1 auto; min-width: 0;
  color: var(--text); font-size: 13px; line-height: 1.35;
}
.install-action {
  flex: 0 0 auto;
  min-height: 44px; padding: 6px 16px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #06281c;
  font-weight: 800; font-size: 14px; cursor: pointer;
}
.install-action:active { filter: brightness(0.94); }
.install-dismiss {
  flex: 0 0 auto;
  min-width: 44px; min-height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.install-dismiss:active { color: var(--text); }

/* --- tap-target polish (>=44px on interactive controls) --- */
.detail-back { min-height: 44px; display: inline-flex; align-items: center; }
.detail-finishes button,
.detail-conditions button { min-height: 44px; }
