:root {
  --bg: #15171c;
  --card: #1f232b;
  --card2: #272c36;
  --text: #eef0f4;
  --muted: #8d95a5;
  --border: #323845;
  --accent: #ff9f1c;
  --accent-text: #1a1206;
  --good: #3ccf7a;
  --bad: #ff5d5d;
  --info: #5aa9ff;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f3f6;
    --card: #ffffff;
    --card2: #f0f2f6;
    --text: #1b1e25;
    --muted: #6b7280;
    --border: #dfe2e8;
    --accent: #f08c00;
    --accent-text: #ffffff;
    --good: #1f9d55;
    --bad: #e03131;
    --info: #1c7ed6;
  }
}
/* Тема из Telegram (data-theme ставит game.js) */
:root[data-theme="light"] {
  --bg: #f2f3f6;
  --card: #ffffff;
  --card2: #f0f2f6;
  --text: #1b1e25;
  --muted: #6b7280;
  --border: #dfe2e8;
  --accent: #f08c00;
  --accent-text: #ffffff;
  --good: #1f9d55;
  --bad: #e03131;
  --info: #1c7ed6;
}
:root[data-theme="dark"] {
  --bg: #15171c;
  --card: #1f232b;
  --card2: #272c36;
  --text: #eef0f4;
  --muted: #8d95a5;
  --border: #323845;
  --accent: #ff9f1c;
  --accent-text: #1a1206;
  --good: #3ccf7a;
  --bad: #ff5d5d;
  --info: #5aa9ff;
}

.loading { text-align: center; color: var(--muted); padding: 60px 10px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
input { font: inherit; }

#app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.stat { display: flex; flex-direction: column; }
.stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
#money { color: var(--good); }

main { flex: 1; padding: 12px 16px 96px; }

.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  background: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 10px; color: var(--muted); font-size: 11px;
}
.tabs button.active { color: var(--text); background: var(--card2); }
.tabs button.next { color: var(--accent); }

h2 { font-size: 18px; margin: 4px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.good { color: var(--good); }
.bad { color: var(--bad); }

.hint {
  background: var(--card2); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px;
}

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; margin-bottom: 10px; display: grid; grid-template-columns: 110px 1fr; gap: 12px;
  align-items: center; cursor: pointer; width: 100%; text-align: left;
}
.card:active { transform: scale(.99); }
.card .title { font-weight: 700; }
.card .price { font-weight: 700; font-size: 17px; margin-top: 4px; }
.card .meta { font-size: 13px; color: var(--muted); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.tag.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.tag.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.tag.acc { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

svg.car { width: 100%; height: auto; display: block; }

.thumb {
  border-radius: 10px; padding: 8px 4px 2px; overflow: hidden;
  background: linear-gradient(180deg, #2f3a52 0%, #4a4660 58%, #5d6068 58%, #5d6068 63%, #33363c 63%);
}
.thumb.garage {
  background: linear-gradient(180deg, #50535b 0%, #44474e 66%, #36383d 66%);
}

.scene { position: relative; aspect-ratio: 220 / 110; border-radius: 14px; overflow: hidden; margin: 8px 0; }
.scene .scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene svg.car { position: absolute; left: 0; top: 16%; width: 100%; }

.quote { display: flex; gap: 10px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; }

.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.order {
  background: var(--card); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px;
}

.chips { display: flex; gap: 6px; overflow-x: auto; margin: -2px 0 10px; padding-bottom: 2px; }
.chip {
  background: var(--card); border: 1px solid var(--border); border-radius: 99px;
  padding: 6px 12px; font-size: 13px; white-space: nowrap; color: var(--muted);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.specs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.specs span { background: var(--card); border-radius: 8px; padding: 4px 8px; font-size: 12px; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet.hidden { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-body {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px; max-height: 92%; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 16px 28px;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } }
.grab { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 4px auto 8px; }
.sheet-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.x { background: var(--card2); width: 32px; height: 32px; border-radius: 50%; flex: none; }
.car-big { background: var(--card); border-radius: 14px; padding: 14px 20px 8px; margin: 8px 0; }

.rows { background: var(--card); border-radius: 12px; padding: 4px 12px; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.row:last-child { border-bottom: 0; }
.row b { font-variant-numeric: tabular-nums; text-align: right; }

.quote {
  background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: 14px; position: relative;
}
.quote .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chk {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 2px; min-height: 64px;
}
.chk .n { font-size: 13px; font-weight: 600; }
.chk .c { font-size: 12px; color: var(--muted); }
.chk.done { opacity: .6; cursor: default; }
.chk:disabled { cursor: default; }

.defect {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px;
}
.defect .d-name { display: flex; flex-direction: column; }
.defect .d-sub { font-size: 12px; color: var(--muted); }

.btn {
  background: var(--card2); border-radius: 10px; padding: 9px 12px; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.good { background: var(--good); color: #062b14; }
.btn.danger { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.btn.wide { width: 100%; padding: 13px; font-size: 15px; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: default; }

.chat { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.msg { max-width: 85%; padding: 8px 11px; border-radius: 14px; font-size: 14px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.him { align-self: flex-start; background: var(--card); border-bottom-left-radius: 4px; }

.offer-row { display: flex; gap: 8px; margin-top: 8px; }
.offer-row input {
  flex: 1; min-width: 0; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 16px;
}
.quick { display: flex; gap: 6px; margin-top: 8px; }
.quick .btn { flex: 1; padding: 7px 4px; font-size: 13px; }

.patience { letter-spacing: 2px; }

.banner { border-radius: 12px; padding: 12px; margin: 8px 0; font-size: 14px; }
.banner.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.banner.good { background: color-mix(in srgb, var(--good) 16%, transparent); }

.progress { height: 10px; background: var(--card2); border-radius: 10px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  max-width: 440px; width: calc(100% - 32px); z-index: 30;
  background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
