/* ============================================================
   Auto Marketplace — macOS Tahoe Liquid Glass design tokens
   ============================================================ */

:root {
  /* Brand — muted steel blue (restrained, premium) */
  --brand-50:  #f1f4f8;
  --brand-100: #dde4ed;
  --brand-200: #b9c6d6;
  --brand-300: #8fa3ba;
  --brand-400: #6b819a;
  --brand-500: #4f6580;
  --brand-600: #3e5168;
  --brand-700: #2f3e51;

  /* Accent — same family, slightly cooler */
  --accent-400: #7e93ab;
  --accent-500: #5d7491;
  --accent-600: #455872;

  /* Semantic — desaturated */
  --green-500: #5d8a6a;
  --red-500:   #b86b6b;
  --amber-500: #c2924a;

  /* Density (set by Tweaks) */
  --density: 1;
  --pad-1: calc(4px * var(--density));
  --pad-2: calc(8px * var(--density));
  --pad-3: calc(12px * var(--density));
  --pad-4: calc(16px * var(--density));
  --pad-5: calc(20px * var(--density));
  --pad-6: calc(24px * var(--density));
  --pad-8: calc(32px * var(--density));

  /* Glass intensity (set by Tweaks, 0..1) */
  --glass: 1;

  /* Type */
  --font-display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-text:    "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono:    "SF Mono", ui-monospace, Menlo, monospace;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-2xl: 28px;
  --r-pill: 999px;

  /* Mobile breakpoints (для документации, использовать в @media) */
  --bp-mobile: 768px;
  --bp-tablet: 1024px;
  --bp-narrow: 480px;

  /* Минимальная touch-цель (Apple HIG / Material) */
  --touch-min: 44px;
}

/* ── Dark theme (default — premium dark) ───────────────────── */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Base canvas — deep, slightly warm graphite */
  --bg-0: #0a0a0c;
  --bg-1: #131317;
  --bg-2: #1c1c22;
  --bg-3: #26262e;

  /* Wallpaper accents — quiet graphite with cool blue hint */
  --mesh-a: #15181d;
  --mesh-b: #11141a;
  --mesh-c: #0d1016;
  --mesh-d: #161a20;
  --mesh-e: #0a0a0c;

  /* Text */
  --fg:        rgba(255, 255, 255, 0.95);
  --fg-muted:  rgba(255, 255, 255, 0.66);
  --fg-faint:  rgba(255, 255, 255, 0.42);
  --fg-ghost:  rgba(255, 255, 255, 0.18);

  /* Glass surfaces — translucent, blurred over wallpaper */
  --glass-1: rgba(28, 28, 34, calc(0.55 + (1 - var(--glass)) * 0.4));
  --glass-2: rgba(38, 38, 46, calc(0.7 + (1 - var(--glass)) * 0.28));
  --glass-3: rgba(48, 48, 58, calc(0.82 + (1 - var(--glass)) * 0.16));

  /* Strokes (very thin, often hairline) */
  --stroke-1: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --stroke-3: rgba(255, 255, 255, 0.22);

  /* Inner highlight (top edge sheen) */
  --sheen: rgba(255, 255, 255, 0.10);

  /* Shadows */
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh-2: 0 4px 16px rgba(0, 0, 0, 0.35);
  --sh-3: 0 12px 40px rgba(0, 0, 0, 0.55);
  --sh-glow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 20px 60px rgba(0, 0, 0, 0.6);

  /* Blur strength */
  --blur-1: calc(12px * var(--glass));
  --blur-2: calc(24px * var(--glass));
  --blur-3: calc(40px * var(--glass));
}

/* ── Light theme ────────────────────────────────────────────── */
[data-theme="light"] {
  color-scheme: light;

  --bg-0: #f5f5f7;
  --bg-1: #ffffff;
  --bg-2: #fafafa;
  --bg-3: #f0f0f3;

  --mesh-a: #ededee;
  --mesh-b: #e4e4e7;
  --mesh-c: #dcdce0;
  --mesh-d: #ebe9e6;
  --mesh-e: #f5f5f7;

  --fg:        rgba(20, 20, 24, 0.96);
  --fg-muted:  rgba(20, 20, 24, 0.66);
  --fg-faint:  rgba(20, 20, 24, 0.44);
  --fg-ghost:  rgba(20, 20, 24, 0.18);

  --glass-1: rgba(255, 255, 255, calc(0.55 + (1 - var(--glass)) * 0.4));
  --glass-2: rgba(255, 255, 255, calc(0.72 + (1 - var(--glass)) * 0.26));
  --glass-3: rgba(255, 255, 255, calc(0.85 + (1 - var(--glass)) * 0.14));

  --stroke-1: rgba(20, 20, 24, 0.08);
  --stroke-2: rgba(20, 20, 24, 0.14);
  --stroke-3: rgba(20, 20, 24, 0.22);

  --sheen: rgba(255, 255, 255, 0.85);

  --sh-1: 0 1px 2px rgba(20, 20, 24, 0.05);
  --sh-2: 0 4px 16px rgba(20, 20, 24, 0.08);
  --sh-3: 0 12px 40px rgba(20, 20, 24, 0.14);
  --sh-glow: 0 0 0 1px rgba(20, 20, 24, 0.04), 0 20px 60px rgba(20, 20, 24, 0.16);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  /* Smooth theme switch (best-effort). */
  transition: background-color 420ms cubic-bezier(0.2, 0.8, 0.2, 1), color 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
body {
  font-family: var(--font-text);
  font-size: 14px;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg-0);
  transition: background-color 420ms cubic-bezier(0.2, 0.8, 0.2, 1), color 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--brand-500); color: #fff; }

/* Scrollbars (subtle) */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--fg-ghost);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); background-clip: content-box; border: 2px solid transparent; }

/* ── Wallpaper (Tahoe-style mesh) ──────────────────────────── */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-attachment: fixed;
  filter: saturate(0.85);
}

[data-theme="dark"] .wallpaper {
  background-color: #0a0a0c;
  background-image:
    radial-gradient(80% 60% at 50% -10%, #15181d 0%, transparent 65%),
    radial-gradient(70% 60% at 100% 50%, #161a20 0%, transparent 70%),
    radial-gradient(70% 60% at 0% 100%, #0d1016 0%, transparent 70%),
    linear-gradient(180deg, #0a0a0c 0%, #0a0a0c 100%);
}
[data-theme="light"] .wallpaper {
  background-color: #f5f5f7;
  background-image:
    radial-gradient(80% 60% at 50% -10%, #ededee 0%, transparent 65%),
    radial-gradient(70% 60% at 100% 50%, #ebe9e6 0%, transparent 70%),
    radial-gradient(70% 60% at 0% 100%, #dcdce0 0%, transparent 70%),
    linear-gradient(180deg, #f5f5f7 0%, #f5f5f7 100%);
}
.wallpaper::after {
  /* Grain to keep the gradient from looking AI-flat */
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.18;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* ── Glass primitive ───────────────────────────────────────── */
.glass {
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(var(--blur-2)) saturate(180%);
  backdrop-filter: blur(var(--blur-2)) saturate(180%);
  border: 0.5px solid var(--stroke-2);
  box-shadow:
    inset 0 0.5px 0 var(--sheen),
    var(--sh-2);
  border-radius: var(--r-lg);
}
.glass-lite {
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(var(--blur-1)) saturate(160%);
  backdrop-filter: blur(var(--blur-1)) saturate(160%);
  border: 0.5px solid var(--stroke-1);
  border-radius: var(--r-md);
}
.glass-heavy {
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(var(--blur-3)) saturate(200%);
  backdrop-filter: blur(var(--blur-3)) saturate(200%);
  border: 0.5px solid var(--stroke-2);
  box-shadow:
    inset 0 0.5px 0 var(--sheen),
    var(--sh-3);
  border-radius: var(--r-xl);
}
.glass-pill {
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(var(--blur-2)) saturate(180%);
  backdrop-filter: blur(var(--blur-2)) saturate(180%);
  border: 0.5px solid var(--stroke-2);
  border-radius: var(--r-pill);
  box-shadow: inset 0 0.5px 0 var(--sheen);
}

/* ── Type ──────────────────────────────────────────────────── */
.h-display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}
.h-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.1;
}
.h-section {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.2;
}
.t-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.t-tnum { font-variant-numeric: tabular-nums; }
.t-mute { color: var(--fg-muted); }
.t-faint { color: var(--fg-faint); }
.t-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 0.5px solid var(--stroke-2);
  background: var(--glass-2);
  color: var(--fg);
  font-weight: 500;
  font-size: 13px;
  -webkit-backdrop-filter: blur(var(--blur-1)) saturate(180%);
  backdrop-filter: blur(var(--blur-1)) saturate(180%);
  box-shadow: inset 0 0.5px 0 var(--sheen);
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--glass-3); border-color: var(--stroke-3); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border: 0.5px solid var(--brand-700);
  color: #fff;
  box-shadow:
    inset 0 0.5px 0 rgba(255,255,255,0.35),
    0 4px 14px rgba(79, 101, 128, 0.32);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand-400), var(--brand-500));
  border-color: var(--brand-600);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover { background: var(--glass-1); border-color: var(--stroke-1); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 14px; border-radius: var(--r-pill); }

/* ── Form controls ─────────────────────────────────────────── */
.input, .select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 0.5px solid var(--stroke-2);
  background: var(--glass-1);
  color: var(--fg);
  -webkit-backdrop-filter: blur(var(--blur-1));
  backdrop-filter: blur(var(--blur-1));
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.input::placeholder { color: var(--fg-faint); }
.input:focus, .select:focus {
  border-color: var(--brand-500);
  background: var(--glass-2);
  box-shadow: 0 0 0 3px rgba(79, 101, 128, 0.20);
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='rgba(255,255,255,0.55)' d='M0 0h12L6 8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
[data-theme="light"] .select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='rgba(20,20,24,0.55)' d='M0 0h12L6 8z'/></svg>");
}

/* ── Chip ──────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--glass-1);
  border: 0.5px solid var(--stroke-1);
  font-size: 12px;
  color: var(--fg-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.chip[data-on="true"] {
  background: var(--brand-500);
  border-color: var(--brand-600);
  color: #fff;
}

/* ── BYN sign — кириллическая Б с перечёркиванием ниже центра ─ */
/*  Используется для отображения цен в белорусских рублях (PKmotors).  */
/*  Combining U+0336 рендерится шрифтами по x-height — для заглавной Б */
/*  это даёт черту визуально выше середины тела буквы. CSS-overlay     */
/*  через ::after позволяет точно опустить черту в нижнюю половину Б.  */
.byn {
  display: inline-block;
  position: relative;
  font-style: normal;
}
.byn::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 62%;
  border-top: 0.075em solid currentColor;
  pointer-events: none;
}

/* ── Utilities ─────────────────────────────────────────────── */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.elide { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
.fade-up { animation: fadeUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
