:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2027;
  --line: #262d36;
  --text: #e8ecf1;
  --muted: #93a0b0;
  --accent: #4da3ff;
  --good: #38c172;
  --warn: #f0a020;
  --bad: #e0526b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 13, 16, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar-actions { display: flex; gap: 6px; align-items: center; }
/* Inline with the title: which build is actually running. */
.version { font-size: 12px; color: var(--muted); font-weight: 400;
           font-family: ui-monospace, Menlo, monospace; letter-spacing: .02em;
           background: none; border: 0; padding: 0 2px; cursor: pointer;
           border-bottom: 1px dotted var(--line); border-radius: 0; }
.version:active { color: var(--text); }

/* One row per build: the version, then what it changed. */
.log-entry { display: grid; grid-template-columns: 62px 1fr; gap: 4px 10px;
             padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.log-entry:first-child { border-top: 0; }
.log-entry .v { font-family: ui-monospace, Menlo, monospace; font-size: 11px;
                color: var(--accent); }
.log-entry .what { color: var(--text); }
.log-entry .when { grid-column: 2; font-size: 11px; color: var(--muted); }
#refresh { padding: 7px 11px; font-size: 17px; line-height: 1; }
#rescan { padding: 7px 10px; font-size: 13px; line-height: 1.3; }
button:disabled { opacity: .45; }

/* Actually turning, rather than just dimmer: a button that only faded read as
   disabled, not as busy. */
@keyframes spin { to { transform: rotate(360deg); } }
#refresh.spin { animation: spin .9s linear infinite; opacity: 1; }
#rescan.spin, #run-now.spin { color: var(--accent); border-color: var(--accent); }

/* The live scan row. */
.progress { display: flex; align-items: center; gap: 8px; margin-top: 6px;
            font-size: 12px; color: var(--accent); }
.progress .dot { width: 8px; height: 8px; border-radius: 50%; flex: none;
                 background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.progress .elapsed { margin-left: auto; color: var(--muted);
                     font-family: ui-monospace, Menlo, monospace; }
.progress.done { color: var(--good); }
.progress.done .dot { background: var(--good); animation: none; }
.progress.failed { color: var(--bad); }
.progress.failed .dot { background: var(--bad); animation: none; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.status { color: var(--muted); font-size: 12px; margin-top: 4px; }
.status.err { color: var(--bad); }

.tabs { display: flex; gap: 6px; margin-top: 10px; }
.tab {
  flex: 1; padding: 8px 6px; font-size: 13px; border-radius: 9px;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }

.monthly {
  font-size: 14px; color: var(--good); margin-top: 2px; font-weight: 600;
}
.monthly .terms { color: var(--muted); font-weight: 400; font-size: 12px; }
.monthly:empty { display: none; }

.panel {
  padding: 12px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  /* The filter list is taller than a phone screen. Scroll it in place rather
     than pushing the results a page and a half down. */
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel .actions { position: sticky; bottom: -12px; background: var(--panel);
                  padding: 10px 0 2px; border-top: 1px solid var(--line); }
.hidden { display: none !important; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; padding: 10px 12px 12px; }
legend { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 0 4px; }

label.check { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: 15px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.hint { color: var(--muted); font-size: 12px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row label { flex: 1 1 130px; display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=number] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 10px; font-size: 16px; width: 100%;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button, .btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; cursor: pointer;
  text-decoration: none; display: inline-block; text-align: center;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.ghost { background: transparent; }
button:active { opacity: .7; }
.btn.tiny { padding: 5px 9px; font-size: 12px; }

main { padding: 12px 14px 40px; display: grid; gap: 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.card.linked { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(77,163,255,.35); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.photos { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 2px; background: #000; }
.photos img { height: 190px; width: auto; max-width: 100%; object-fit: cover; scroll-snap-align: start; flex: none; }
.photos:empty { display: none; }

.body { padding: 12px 13px 13px; }
.headline { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.price { font-size: 21px; font-weight: 700; }
.score { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; flex: none; }
.score.hot { color: var(--good); border-color: var(--good); }

h2.title { font-size: 14px; font-weight: 500; margin: 6px 0 9px; color: var(--text); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.hw4 { color: var(--good); border-color: var(--good); }
.badge.hw3 { color: var(--bad); border-color: var(--bad); }
.badge.unknown { color: var(--warn); border-color: var(--warn); }
.badge.fsd { color: var(--warn); border-color: var(--warn); }
.badge.dealer { color: var(--muted); }

dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
dl.facts dd.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; letter-spacing: .02em; }

.desc { color: var(--muted); font-size: 13px; margin: 0 0 10px; max-height: 4.5em; overflow: hidden; }
.desc.open { max-height: none; }

.fsd-warn { background: rgba(240,160,32,.1); border: 1px solid var(--warn); color: #ffd490;
            border-radius: 9px; padding: 8px 10px; font-size: 12px; margin-bottom: 10px; }

.contact { font-size: 13px; margin-bottom: 10px; }
.contact a { color: var(--accent); text-decoration: none; }
.contact:empty { display: none; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hw-confirm { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
              display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
