:root {
  --ink: #111111;
  --muted: #5c5c5c;
  --line: #d9d9d9;
  --paper: #ffffff;
  --bg: #f3f3f1;
  --zebra: #f6f6f6;
  --accent: #b45309;
  --tap: 52px;
  --guide-waiting: #b7cbb7;
  --guide-ready: #7a9d7a;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", "Helvetica Neue", sans-serif;
  overflow-x: hidden;
}
body { min-height: 100dvh; }

.page {
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

.hero h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.02em;
  text-align: left;
}
.hero-subrow {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin: 4px 0 12px;
  width: 100%;
  min-width: 0;
}
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  flex: 1 1 12em;
  min-width: 0;
}
.product-signature {
  margin: 0 0 0 auto;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  color: #8a8a8a;
  text-align: right;
  flex: 0 0 auto;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
}
.product-signature .app-version {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.card.query {
  padding: 12px;
}

.primary-waiting,
.primary-ready {
  background: var(--paper);
  border-width: 1px;
  border-style: solid;
}
.primary-waiting {
  border-color: var(--guide-waiting);
}
.primary-ready {
  border-color: var(--guide-ready);
}
.query-heading {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.field {
  display: block;
  position: relative;
  margin-bottom: 8px;
}
.field span, legend {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}
input[type="text"], input[type="number"] {
  width: 100%;
  height: var(--tap);
  border: 1px solid #c8c8c8;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 16px;
  text-align: center;
  background: #fff;
}
input.year-compact,
input.mileage-compact {
  width: 4.6em;
  max-width: 88px;
  flex: 0 0 auto;
  height: 50px;
  font-size: 19px;
  padding: 0 6px;
  -webkit-appearance: none;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.range-row,
.mileage-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.range-tilde {
  font-weight: 700;
  color: var(--muted);
  font-size: 16px;
  flex: 0 0 auto;
}
.mileage-unit {
  font-weight: 700;
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.pedal-wrap {
  border: 0;
  margin: 6px 0 8px;
  padding: 0;
}
.pedal {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  overflow: hidden;
}
.pedal-ordinal,
.pedal-flags {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  min-width: 0;
}
.pedal-ordinal { flex: 1 1 auto; }
.pedal-flags { flex: 0 0 auto; }
.pedal-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.pedal-flags .pedal-btn {
  width: 44px;
  min-width: 44px;
  flex: 0 0 44px;
}
.pedal-btn.is-on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

button#submit {
  width: 100%;
  height: 52px;
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
button#submit:disabled {
  background: #888;
}

.suggest {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.suggest li {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--zebra);
  font-weight: 600;
  padding: 0 12px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.suggest li:last-child { border-bottom: 0; }
.model-field { min-width: 0; }
.model-options li { justify-content: flex-start; }
.field input:disabled {
  background: #f3f3f3;
  color: var(--muted);
  cursor: not-allowed;
}

.banner {
  text-align: center;
  font-weight: 700;
  padding: 12px;
  margin: 0 0 12px;
  background: #ececec;
  border-radius: 10px;
}
.banner.error { background: #f3ece6; color: #7a3b00; }

.identity {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}
.identity-tag {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}
.identity-condition {
  margin-top: -8px;
}
.range-intel {
  margin-bottom: 10px;
}
.range-intel h2 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 15px;
}
.range-intel .hero-price {
  font-size: 28px;
}
.range-intel-empty {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  margin: 4px 0 0;
}
#range-latest { white-space: pre-line; }
.precision-value {
  margin-bottom: 10px;
}
.precision-value h2 {
  margin: 0 0 8px;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}
.precision-value .hero-price {
  font-size: 24px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.precision-year-picked {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.year-refine-label {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.year-refine {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  margin: 0 0 10px;
}
.year-refine button {
  min-width: 56px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.year-refine button.is-on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.target-refine {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
}
.target-mileage-field {
  margin: 0;
}
.target-refine .mileage-row {
  min-width: 0;
}
#estimate-target {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.target-refine .pedal {
  flex-wrap: wrap;
  overflow: visible;
  gap: 6px;
}
.target-refine .pedal-ordinal {
  flex: 1 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}
.target-refine .pedal-ordinal .pedal-btn {
  flex: 1 1 40px;
  min-width: 40px;
  max-width: 52px;
}
.w-attr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
  border: 1px dashed #8a8a8a;
  border-radius: 8px;
  background: #fff;
  color: #8a8a8a;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
}
.w-attr-btn.is-checked {
  border-style: solid;
  border-color: var(--ink);
  color: var(--ink);
  background: #fff;
}
.w-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  display: inline-block;
  position: relative;
  flex: 0 0 16px;
}
.w-attr-btn.is-checked .w-box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.retail-target-line {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.market .hero-price {
  display: block;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 4px;
}
.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  border-bottom: 1px solid #ececec;
  text-align: center;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); font-size: 13px; font-weight: 600; }
.kv strong { font-size: 16px; }

.decision h2, .details summary {
  margin: 0 0 8px;
  text-align: center;
  font-size: 15px;
}
.details summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 40px;
  align-items: center;
  text-align: center;
  border-top: 1px solid #ececec;
  font-size: 14px;
}
.detail-row span { color: var(--muted); }
.warn { color: #7a3b00; font-weight: 600; padding: 8px 0; text-align: center; }

.candidates { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.resolver {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  text-align: center;
  max-height: 220px;
  overflow-y: auto;
}
.resolver-prompt { margin: 0 0 8px; font-weight: 800; font-size: 14px; }
.resolver-options { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.resolver-options button {
  min-height: 44px;
  min-width: 44%;
  flex: 1 1 40%;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.resolver-options.generation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 8px;
}
.resolver-options .gen-btn {
  min-height: 52px;
  max-height: 72px;
  min-width: 0;
  flex: none;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.gen-label { font-size: 16px; font-weight: 800; }
.gen-sec { font-size: 11px; font-weight: 600; color: var(--muted); }
.resolver-options.year-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  gap: 6px;
}
.resolver-options.year-chips button {
  min-width: 0;
  flex: none;
  min-height: 44px;
  font-size: 13px;
}
.resolver-options.year-chips button.is-on {
  background: var(--ink);
  color: #fff;
}
.resolver-options.variant-multi {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 8px;
}
.resolver-options.variant-multi button {
  min-width: 0;
  min-height: 52px;
  padding: 6px;
  font-size: clamp(15px, 4vw, 17px);
  overflow-wrap: anywhere;
}
.resolver-options.variant-multi button.is-on {
  background: var(--ink);
  color: #fff;
}
.resolver-confirm {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}
.resolver-confirm:disabled {
  background: #aaa;
  color: #f5f5f5;
  cursor: not-allowed;
}
[hidden] { display: none !important; }
.resolver-select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  background: #fff;
}
.chart-tip { white-space: pre-line; }
.sample-note, .max-bid-note, .gap, .wider {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 0;
}
.gap { color: #7a3b00; font-weight: 700; font-size: 15px; margin: 0 0 10px; }
.fv-ref {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.fv-ref-title, .fv-ref-note, #fv-history-latest, #fv-history-count {
  margin: 0 0 4px;
  font-size: 13px;
}
.fv-ref-title { font-weight: 700; }
.fv-ref-note { color: var(--muted); margin-bottom: 0; }
.max-bid-note { font-weight: 600; }
.intel-toggle {
  display: block;
  width: 100%;
  min-height: 48px;
  margin: 12px 0;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
}
.intel { width: 100%; overflow-x: hidden; }
.intel-block h2 {
  margin: 0 0 8px;
  font-size: 15px;
  text-align: center;
}
.trend-status {
  text-align: center;
  font-weight: 800;
  margin: 0 0 8px;
  font-size: 15px;
}
.intel-note, .chart-tip {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
}
.chart {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-card {
  border-top: 1px solid #ececec;
  padding: 8px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
}
.tx-card .tx-date { font-size: 12px; color: var(--muted); }
.tx-card .tx-id {
  font-size: 13px;
  font-weight: 700;
  grid-column: 1 / -1;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.tx-card .tx-year { color: var(--accent); font-weight: 700; }
.tx-card .tx-name { color: var(--ink); font-weight: 700; }
.tx-card .tx-meta { font-size: 12px; color: var(--muted); }
.tx-mile-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 2px;
}
.tx-mile-dot.mileage-low { background: #15803d; }
.tx-mile-dot.mileage-normal { background: #eab308; }
.tx-mile-dot.mileage-high-normal { background: #ea580c; }
.tx-mile-dot.mileage-high { background: #dc2626; }
.tx-mile-dot.mileage-invalid { background: #dc2626; }
.tx-card .tx-price { font-size: 16px; font-weight: 800; text-align: right; }
.tx-card .tx-flag {
  grid-column: 1 / -1;
  color: #7a3b00;
  font-size: 12px;
  font-weight: 700;
}
.retail-placeholder { opacity: 0.85; }
.text-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: underline;
}
.text-btn[hidden],
[hidden] { display: none !important; }
.text-btn:disabled {
  text-decoration: none;
  opacity: 0.7;
}
.tx-error {
  text-align: center;
  color: #7a3b00;
  font-weight: 700;
  font-size: 13px;
  margin: 8px 0 0;
}
.more-end {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 0;
}
.card.decision h2 {
  margin: 0 0 6px;
  font-size: 15px;
  text-align: center;
}
.decision-future {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}
.authority-knowledge h2 {
  margin: 0 0 10px;
  font-size: 15px;
  text-align: center;
}
.authority-candidates {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.authority-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fafafa;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.authority-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.authority-msrp {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.authority-features {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
}
.authority-features-empty {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1;
  color: #c4c4c4;
  font-weight: 400;
}
.authority-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.authority-footer {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}
.retail-disclaimer {
  margin: 8px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}
.retail-sub {
  margin: 12px 0 8px;
  font-size: 14px;
  text-align: center;
}
.retail-fresh {
  margin: 0 0 8px;
  font-size: 12px;
  color: #8a8a8a;
  text-align: center;
  line-height: 1.4;
}
.retail-inline-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
}
.retail-spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--line);
  border-top-color: var(--guide-ready);
  border-radius: 50%;
  animation: retail-spin 0.8s linear infinite;
  flex: 0 0 auto;
}
@keyframes retail-spin {
  to { transform: rotate(360deg); }
}
.retail-fallback {
  margin: 8px 0 12px;
  text-align: center;
}
.retail-fallback p {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.retail-fallback a {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  font-size: 14px;
  color: var(--ink);
}
.retail-sort {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.retail-sort select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  max-width: 58%;
}
.retail-dist { margin-top: 10px; }
.dist-row {
  display: grid;
  grid-template-columns: 5.5em 1fr 2em;
  gap: 6px;
  align-items: center;
  margin: 3px 0;
  font-size: 12px;
  color: var(--muted);
}
.dist-bar-wrap {
  height: 8px;
  background: #ececec;
  border-radius: 99px;
  overflow: hidden;
}
.dist-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}
.retail-list { display: flex; flex-direction: column; gap: 8px; }
.retail-card {
  border-top: 1px solid #ececec;
  padding: 8px 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.retail-card .r-title {
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.retail-card .r-year { color: var(--accent); }
.retail-card .r-meta, .retail-card .r-loc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.retail-card .r-price {
  font-size: 16px;
  font-weight: 800;
  margin-top: 2px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
a.r-price-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(17, 17, 17, 0.28);
}
.r-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.retail-broader-summary {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.retail-broader-summary h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.retail-card .r-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 4px;
  max-width: 100%;
}
.retail-card .r-badge {
  display: inline-block;
  margin-top: 0;
  font-size: 11px;
  font-weight: 600;
  color: #8a8a8a;
}
.retail-card .r-badge-secondary {
  font-weight: 500;
  color: #a0a0a0;
}

@media (max-width: 374px) {
  .page { padding: 12px 12px 32px; }
  .retail-card .r-price { font-size: 15px; }
}

@media (min-width: 840px) {
  .page { max-width: 920px; padding: 28px 24px 48px; }
  .layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    align-items: start;
  }
  .hero h1 { font-size: 32px; }
  .hero-subrow { flex-wrap: nowrap; }
  .market .hero-price { font-size: 42px; }
}
