:root {
  color-scheme: dark;
  --bg: #070708;
  --surface: #121214;
  --surface-2: #1a1a1e;
  --line: #2a2a30;
  --text: #f4f4f5;
  --muted: #9b9ba3;
  --accent: #ffffff;
  --accent-dim: #d4d4d8;
  --teal: #3d8f8f;
  --teal-dim: rgba(61, 143, 143, 0.15);
  --orange: #e8a04c;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent-dim); }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

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

.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}

.tab.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 600;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

input, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
}

input, select { min-width: 0; flex: 1; }

button {
  cursor: pointer;
  font-weight: 600;
}

button.primary {
  background: var(--accent);
  color: #111;
  border: none;
}

button.ghost {
  background: transparent;
}

button.small {
  padding: 6px 10px;
  font-size: 12px;
}

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

.muted { color: var(--muted); font-size: 13px; }

.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

.table-wrap { overflow-x: auto; margin-top: 12px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--teal-dim);
  color: #9ee0e0;
}

.badge.mine { background: rgba(255,255,255,0.08); color: var(--muted); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.metric {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.metric .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.metric .value {
  font-size: 22px;
  font-weight: 650;
  margin-top: 4px;
}

.metric .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.verdict {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--teal-dim);
  border: 1px solid rgba(61, 143, 143, 0.25);
  font-size: 14px;
}

.chart-block { margin-top: 18px; }

.chart-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

canvas.chart {
  width: 100%;
  height: 140px;
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-panel {
  max-width: 420px;
  margin: 40px auto;
}

.auth-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-panel form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.hidden { display: none !important; }

.picker-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 640px) {
  .picker-row { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; }
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.legend .a::before { background: #fff; }
.legend .b::before { background: rgba(255,255,255,0.35); }

footer {
  margin-top: 48px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.lab-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.lab-slot {
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 72px;
}

.lab-slot.filled {
  border-style: solid;
  border-color: rgba(61, 143, 143, 0.45);
}

.lab-slot .slot-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.dim-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

.dim-table th, .dim-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.dim-table th:first-child, .dim-table td:first-child {
  text-align: left;
}

.dim-table .delta {
  color: var(--orange);
  font-weight: 600;
}

.rec-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--teal-dim);
  border: 1px solid rgba(61, 143, 143, 0.3);
  font-size: 14px;
  line-height: 1.55;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.winner-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 12px;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.edit-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.edit-form label {
  display: grid;
  gap: 6px;
}

.edit-form textarea {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
}


/* —— Lab polish / App Store QR —— */
body {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(61, 143, 143, 0.12), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(232, 160, 76, 0.08), transparent 50%),
    var(--bg);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.qr-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  max-width: 280px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.qr-card:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}

.qr-card img {
  border-radius: 8px;
  display: block;
  background: var(--surface-2);
}

.qr-card strong {
  display: block;
  font-size: 13px;
}

.qr-card .muted {
  display: block;
  font-size: 11px;
  line-height: 1.35;
  margin-top: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
}

.winner-banner {
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(61,143,143,0.18), rgba(232,160,76,0.08));
  border: 1px solid rgba(61, 143, 143, 0.35);
  font-size: 15px;
  line-height: 1.5;
}

.winner-banner.muted {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

.inset-card {
  margin-top: 14px;
  box-shadow: none;
}

.inset-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.chart-svg {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.legend-row {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.brand h1 {
  background: linear-gradient(90deg, #f4f4f5 0%, #9ee0e0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@media (max-width: 720px) {
  .header-actions { width: 100%; justify-content: flex-start; }
  .qr-card { max-width: 100%; }
}


/* —— Header hero mark + empty / dB notes —— */
.site-header {
  align-items: flex-start;
}

.brand-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(61, 143, 143, 0.25));
}

.note-db {
  margin: 0 0 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(61, 143, 143, 0.28);
  background: rgba(61, 143, 143, 0.08);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.callout.tire-edit-hint {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed rgba(232, 160, 76, 0.45);
  background: rgba(232, 160, 76, 0.08);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
}

.empty-state strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.empty-state span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 420px;
  margin: 0 auto;
}

.field-emphasis span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.field-emphasis input {
  border-color: rgba(232, 160, 76, 0.55);
  box-shadow: 0 0 0 3px rgba(232, 160, 76, 0.12);
}

.app-store-qr .qr-card {
  box-shadow: var(--shadow);
}

.app-store-qr .qr-card strong {
  letter-spacing: -0.01em;
}

.brand-logos {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-logos.large .brand-logo {
  width: 40px;
  height: 40px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 3px;
  border: 1px solid var(--line);
}

.drive-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drive-row { cursor: pointer; }

.drive-map {
  height: 320px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface-2);
}

.map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 160px;
  padding: 20px;
  text-align: center;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.detail-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.detail-pressure {
  margin-left: auto;
  font-weight: 650;
  color: var(--orange);
}

.detail-section {
  margin: 20px 0 10px;
  font-size: 14px;
}

.detail-metrics { margin-top: 4px; }

.detail-charts {
  display: grid;
  gap: 14px;
}

.chart-svg {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

@media (max-width: 720px) {
  .brand-hero { width: 100%; }
  .brand-mark { width: 48px; height: 48px; }
  .drive-map { height: 240px; }
}
