/* Dawwar design kit: Material 3 (Expressive) in plain CSS for server-rendered pages.
   Colors, springs: tokens.css (generated from the brand seed). Icons: icons.svg sprite. No web fonts.
   Right-to-left works everywhere through logical properties (inline-start/end), never left/right. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Sans", Tahoma, "Geeza Pro", sans-serif;
  --shape-xs: 4px; --shape-s: 8px; --shape-m: 12px; --shape-l: 16px; --shape-xl: 28px; --shape-full: 999px;
  --margin: 16px; --page: 1200px; --reading: 840px; --bar-h: 64px; --nav-h: 80px;
  --elev-1: 0 1px 2px rgb(0 0 0 / .3), 0 1px 3px 1px rgb(0 0 0 / .15);
  --elev-2: 0 1px 2px rgb(0 0 0 / .3), 0 2px 6px 2px rgb(0 0 0 / .15);
  --elev-3: 0 4px 8px 3px rgb(0 0 0 / .15), 0 1px 3px rgb(0 0 0 / .3);
}
@media (min-width: 600px) { :root { --margin: 24px; } }

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--bar-h) + 8px); }
/* The page is a column: bar, content that grows, footer. A short page still has its footer at the bottom. */
html { scrollbar-gutter: stable; }
body {
  display: flex; flex-direction: column;
  margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--md-sys-color-background); color: var(--md-sys-color-on-surface);
  font: 400 1rem/1.5 var(--font); -webkit-tap-highlight-color: transparent;
}
:lang(ar) body, body:lang(ar) { line-height: 1.6; }
img, svg { max-width: 100%; }
a { color: var(--md-sys-color-primary); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; border-radius: var(--shape-s); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--md-sys-color-on-surface-variant); }
.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: var(--gap, 8px); flex-wrap: wrap; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---- type scale (M3). Sizes in rem, so the phone's font size setting is respected (U-04). */
.display-small { font-size: 2.25rem; line-height: 2.75rem; font-weight: 700; }
.headline-large { font-size: 2rem; line-height: 2.5rem; font-weight: 700; }
.headline-medium { font-size: 1.75rem; line-height: 2.25rem; font-weight: 700; }
.headline-small { font-size: 1.5rem; line-height: 2rem; font-weight: 700; }
.title-large { font-size: 1.375rem; line-height: 1.75rem; font-weight: 600; }
.title-medium { font-size: 1rem; line-height: 1.5rem; font-weight: 600; }
.title-small { font-size: .875rem; line-height: 1.25rem; font-weight: 600; }
.body-large { font-size: 1rem; line-height: 1.5rem; }
.body-medium { font-size: .875rem; line-height: 1.25rem; }
.body-small { font-size: .75rem; line-height: 1rem; }
.label-large { font-size: .875rem; line-height: 1.25rem; font-weight: 600; }
.label-medium { font-size: .75rem; line-height: 1rem; font-weight: 600; }

/* ---- icons: <svg class="icon"><use href="…icons.svg#i-name"/></svg> */
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; vertical-align: middle; }
.icon.s20 { width: 20px; height: 20px; } .icon.s18 { width: 18px; height: 18px; } .icon.s32 { width: 32px; height: 32px; } .icon.s40 { width: 40px; height: 40px; }
[dir=rtl] .icon.mirror { transform: scaleX(-1); }

/* ---- state layer: hover, focus and press tint every clickable surface */
.state { position: relative; isolation: isolate; overflow: hidden; cursor: pointer; }
.state::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: currentColor; opacity: 0;
  transition: opacity var(--motion-fast-effects-duration) var(--motion-fast-effects);
}
@media (hover: hover) { .state:hover::after { opacity: .08; } }
.state:focus-visible::after { opacity: .1; }
.state:active::after { opacity: .12; }

/* ---- buttons (48 px tall: big enough for any thumb, U-04) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 24px;
  border: 0; border-radius: var(--shape-full); font-size: 1rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); cursor: pointer;
  transition: border-radius var(--motion-fast-spatial-duration) var(--motion-fast-spatial), box-shadow var(--motion-fast-effects-duration) var(--motion-fast-effects);
}
.btn:active { border-radius: var(--shape-m); }
@media (hover: hover) { .btn:not(.btn-text, .btn-outlined, .btn-tonal):hover { box-shadow: var(--elev-1); } }
.btn .icon { width: 20px; height: 20px; margin-inline-start: -6px; }
.btn-tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.btn-outlined { background: transparent; color: var(--md-sys-color-primary); box-shadow: inset 0 0 0 1px var(--md-sys-color-outline); }
.btn-text { background: transparent; color: var(--md-sys-color-primary); padding: 0 12px; }
.btn-danger { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }
.btn-large { min-height: 56px; padding: 0 28px; font-size: 1.0625rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled=true] { opacity: .38; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: var(--shape-full);
  background: transparent; color: var(--md-sys-color-on-surface-variant); cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn.filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.icon-btn.tonal { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
.icon-btn[aria-pressed=true] { color: var(--md-sys-color-primary); }

/* Extended FAB: the one main action on browse pages (Sell your car). */
.fab {
  position: fixed; inset-inline-end: var(--margin); inset-block-end: calc(var(--fab-bottom, 16px) + env(safe-area-inset-bottom));
  z-index: 20; display: inline-flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px; border-radius: var(--shape-l);
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); box-shadow: var(--elev-3);
  font-weight: 700; text-decoration: none;
  transition: border-radius var(--motion-fast-spatial-duration) var(--motion-fast-spatial);
}
.fab:active { border-radius: var(--shape-xl); }

/* ---- top app bar (desktop and phone) */
.top-bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; height: var(--bar-h);
  padding-inline: max(8px, calc((100% - var(--page)) / 2)); background: var(--md-sys-color-surface);
  transition: background-color var(--motion-default-effects-duration) var(--motion-default-effects), box-shadow var(--motion-default-effects-duration);
}
.top-bar.scrolled { background: var(--md-sys-color-surface-container); }
.brand { display: inline-flex; align-items: center; gap: 10px; padding-inline: 8px; color: var(--md-sys-color-on-surface); text-decoration: none; min-height: 48px; }
.brand-mark { width: 36px; height: 36px; }
.brand-name { font-size: 1.375rem; font-weight: 800; letter-spacing: .01em; }
.brand-name .ar { color: var(--md-sys-color-primary); }
.top-nav { display: none; gap: 4px; margin-inline-start: 16px; }
.top-nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--shape-full); color: var(--md-sys-color-on-surface-variant); text-decoration: none; font-weight: 600; font-size: .9375rem; }
.top-nav a[aria-current=page] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--shape-full);
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); font-weight: 700;
}

/* ---- bottom navigation bar: phones only */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--md-sys-color-surface-container);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--md-sys-color-on-surface-variant); text-decoration: none; font-size: .75rem; font-weight: 600; }
.bottom-nav .pill { display: grid; place-items: center; width: 64px; height: 32px; border-radius: var(--shape-full); transition: background-color var(--motion-fast-effects-duration); }
.bottom-nav a[aria-current=page] { color: var(--md-sys-color-on-surface); }
.bottom-nav a[aria-current=page] .pill { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); --fab-bottom: calc(var(--nav-h) + 16px); }
@media (min-width: 840px), (hover: hover) and (pointer: fine) and (min-width: 600px) {
  .top-nav { display: flex; }
  .bottom-nav { display: none; }
  body.has-nav { padding-bottom: 0; --fab-bottom: 24px; }
  .phone-only { display: none !important; }
}
@media not ((min-width: 840px) or ((hover: hover) and (pointer: fine) and (min-width: 600px))) { .desktop-only { display: none !important; } }

/* ---- page */
.page { width: 100%; max-width: calc(var(--page) + 2 * var(--margin)); margin: 0 auto; padding: 8px var(--margin) 48px; }
.page.reading { max-width: calc(var(--reading) + 2 * var(--margin)); }
.page-head { display: flex; flex-direction: column; gap: 4px; margin: 16px 0 20px; }
.page-head p { color: var(--md-sys-color-on-surface-variant); }
.section { margin-top: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
#main { flex: 1 0 auto; }
.footer { flex: none; margin-top: 48px; padding: 32px var(--margin) 40px; background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-on-surface-variant); }
.footer-inner { max-width: var(--page); margin: 0 auto; display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.footer a { color: inherit; display: block; padding: 6px 0; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---- surfaces and cards */
.surface { background: var(--md-sys-color-surface-container-low); border-radius: var(--shape-l); padding: 16px; }
.surface-high { background: var(--md-sys-color-surface-container); border-radius: var(--shape-l); padding: 16px; }
.outlined { border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--shape-l); padding: 16px; background: var(--md-sys-color-surface); }
.hero {
  border-radius: var(--shape-xl); padding: 24px; background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
}
.hero h1 { margin-bottom: 4px; }
@media (min-width: 840px) { .hero { padding: 40px; } }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.car-card {
  display: flex; flex-direction: column; border-radius: var(--shape-l); overflow: hidden; color: inherit; text-decoration: none;
  background: var(--md-sys-color-surface-container-low); position: relative;
  transition: border-radius var(--motion-default-spatial-duration) var(--motion-default-spatial), box-shadow var(--motion-default-effects-duration);
}
@media (hover: hover) { .car-card:hover { box-shadow: var(--elev-1); } }
.car-card:active { border-radius: var(--shape-xl); }
.car-card .ph { aspect-ratio: 3 / 2; width: 100%; height: auto; object-fit: cover; display: block; background: var(--md-sys-color-surface-container-high); }
.car-card .body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.car-card .price { font-size: 1.25rem; font-weight: 800; color: var(--md-sys-color-on-surface); overflow-wrap: anywhere; }
.car-card .title { font-weight: 600; }
.car-card .meta { font-size: .875rem; color: var(--md-sys-color-on-surface-variant); }
.car-card .tags { position: absolute; inset-block-start: 8px; inset-inline-start: 8px; display: flex; gap: 6px; }
.car-card .fav { position: absolute; inset-block-start: 4px; inset-inline-end: 4px; background: rgb(0 0 0 / .32); color: #fff; }
.car-card .fav[aria-pressed=true] { color: #ff8a80; }
.car-card.gone .ph { filter: grayscale(1); opacity: .6; }
/* A list on phones: photo beside text, more cars per screen on 3G. */
@media (max-width: 599px) {
  .cards.list-on-phone { grid-template-columns: 1fr; gap: 12px; }
  .cards.list-on-phone .car-card { flex-direction: row; min-height: 112px; }
  .cards.list-on-phone .car-card .ph { width: 40%; max-width: 168px; aspect-ratio: auto; height: auto; min-height: 112px; }
  .cards.list-on-phone .car-card .body { padding: 10px 12px; padding-inline-end: 52px; min-width: 0; }
  .cards.list-on-phone .car-card .price { font-size: 1.125rem; }
}

/* ---- badges and tags */
.tag {
  display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 2px 8px; border-radius: var(--shape-s);
  font-size: .75rem; font-weight: 700; background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface);
}
.tag .icon { width: 16px; height: 16px; }
.tag.trust { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.tag.sponsored { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.tag.warn { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.tag.sold { background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); }
.count-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); font-size: .75rem; font-weight: 700; }

/* ---- tiles: makes and body types, pictures before words (S-01) */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 104px; padding: 12px 8px;
  border-radius: var(--shape-l); background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-on-surface);
  text-decoration: none; text-align: center; font-weight: 600; font-size: .9375rem;
  transition: border-radius var(--motion-fast-spatial-duration) var(--motion-fast-spatial);
}
.tile:active { border-radius: var(--shape-xl); }
.monogram {
  display: grid; flex: none; place-items: center; width: 48px; height: 48px; border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-primary); font-weight: 800; font-size: 1.125rem;
}
.tile .icon { width: 40px; height: 40px; color: var(--md-sys-color-primary); }

/* ---- form fields (outlined) */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-weight: 600; font-size: .9375rem; }
.field .hint { font-size: .875rem; color: var(--md-sys-color-on-surface-variant); }
.field .error { font-size: .875rem; color: var(--md-sys-color-error); font-weight: 600; }
.input {
  width: 100%; min-height: 56px; padding: 14px 16px; border: 1px solid var(--md-sys-color-outline); border-radius: var(--shape-xs);
  background: var(--md-sys-color-surface); font-size: 1rem; line-height: 1.5;
  transition: border-color var(--motion-fast-effects-duration), box-shadow var(--motion-fast-effects-duration);
}
.input:focus { outline: none; border-color: var(--md-sys-color-primary); box-shadow: inset 0 0 0 1px var(--md-sys-color-primary); }
.input[aria-invalid=true] { border-color: var(--md-sys-color-error); }
textarea.input { min-height: 120px; resize: vertical; }
select.input {
  appearance: none; padding-inline-end: 44px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
}
[dir=rtl] select.input { background-position: 16px 50%, 22px 50%; }
.input-group { display: flex; gap: 8px; }
.input-group > * { flex: 1; min-width: 0; }
.input-group > .narrow { flex: 0 0 auto; width: auto; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }

/* ---- chips: tap choices, never typing (S-04). <label class="chip"><input type=radio …><svg…/>Text</label> */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--shape-s);
  border: 1px solid var(--md-sys-color-outline-variant); background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface-variant);
  font-weight: 600; font-size: .9375rem; cursor: pointer; user-select: none; text-decoration: none;
  transition: background-color var(--motion-fast-effects-duration), border-radius var(--motion-fast-spatial-duration) var(--motion-fast-spatial);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip .icon { width: 20px; height: 20px; }
.chip:has(input:checked), .chip[aria-pressed=true], .chip.selected {
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); border-color: transparent; border-radius: var(--shape-m);
}
.chip:has(input:focus-visible) { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }
.chips.big .chip { min-height: 56px; padding: 0 20px; font-size: 1rem; border-radius: var(--shape-m); }
.chips.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2); flex: none; }

/* ---- lists */
.list { display: flex; flex-direction: column; border-radius: var(--shape-l); overflow: hidden; background: var(--md-sys-color-surface-container-low); }
.list > * + * { border-top: 1px solid var(--md-sys-color-outline-variant); }
.list-item { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 10px 16px; color: inherit; text-decoration: none; }
.list-item .icon { color: var(--md-sys-color-on-surface-variant); }
.list-item .text { flex: 1; min-width: 0; }
.list-item .sub { font-size: .875rem; color: var(--md-sys-color-on-surface-variant); }

/* ---- key facts as icon tiles (L-03) */
.facts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.fact { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--shape-m); background: var(--md-sys-color-surface-container-low); }
.fact .icon { color: var(--md-sys-color-primary); }
.fact .k { font-size: .75rem; color: var(--md-sys-color-on-surface-variant); }
.fact .v { font-weight: 700; }
.fact .src { display: flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--md-sys-color-on-surface-variant); }
.fact .src.checked { color: var(--md-sys-color-tertiary); font-weight: 700; }

/* ---- ad page */
/* ---- car photos: a photo-app gallery (big swipeable photo, thumbnails, full-screen viewer, grid) */
.photos { display: grid; gap: 8px; }
.photo-hero { position: relative; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 4px; border-radius: var(--shape-xl); background: var(--md-sys-color-surface-container-high); scrollbar-width: none; overscroll-behavior-x: contain; }
.gallery::-webkit-scrollbar { display: none; }
.gallery a { flex: 0 0 100%; scroll-snap-align: center; cursor: zoom-in; }
.gallery img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
@media (min-width: 840px) { .gallery a { flex-basis: 100%; } }
.gallery-count { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; background: rgb(0 0 0 / .55); color: #fff; backdrop-filter: blur(8px); }
.gal-nav { position: absolute; inset-block-start: 50%; translate: 0 -50%; background: rgb(255 255 255 / .9); color: #1a110d; box-shadow: 0 1px 3px rgb(0 0 0 / .3); opacity: 0; transition: opacity .2s, scale .2s; }
.gal-nav.prev { inset-inline-start: 12px; } .gal-nav.next { inset-inline-end: 12px; }
.photo-hero:hover .gal-nav { opacity: 1; } .gal-nav:active { scale: .92; }
[dir=rtl] .gal-nav .icon, [dir=rtl] .viewer-nav .icon { transform: scaleX(-1); }
.dots { position: absolute; inset-block-end: 12px; inset-inline: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.dots span { width: 6px; height: 6px; border-radius: 3px; background: rgb(255 255 255 / .6); box-shadow: 0 0 2px rgb(0 0 0 / .4); transition: width var(--motion-fast-spatial-duration) var(--motion-fast-spatial), background .2s; }
.dots span.on { width: 18px; background: #fff; }
.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.thumbs button { position: relative; padding: 0; border: 0; border-radius: var(--shape-m); overflow: hidden; cursor: pointer; background: var(--md-sys-color-surface-container-high); transition: border-radius var(--motion-fast-spatial-duration) var(--motion-fast-spatial); }
.thumbs img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; display: block; transition: scale .3s; }
.thumbs button:hover img { scale: 1.06; }
.thumbs button.on { border-radius: var(--shape-xl); outline: 3px solid var(--md-sys-color-primary); outline-offset: -3px; }
.thumbs .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff; font-weight: 800; font-size: 1.125rem; }
.all-photos { justify-self: start; }

/* Full-screen viewer: always on black, like a photo app, whatever the theme. */
dialog.viewer { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; overflow: hidden;
  background: rgb(0 0 0 / var(--bg, 1)); color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
dialog.viewer::backdrop { background: transparent; }
.viewer-track { display: flex; height: 100%; touch-action: none; will-change: transform; }
/* The whole photo, never cropped, whatever its shape: pinned to the slide's four edges and fitted inside. */
.viewer-track .slide { position: relative; flex: 0 0 100%; min-width: 0; height: 100%; overflow: hidden; }
.viewer-track img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; object-position: center; transform-origin: 0 0; -webkit-user-drag: none; }
.viewer-bar { position: absolute; inset: 0 0 auto; z-index: 2; display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 32px; background: linear-gradient(rgb(0 0 0 / .6), transparent); transition: opacity .2s; }
dialog.viewer .icon-btn { color: #fff; }
dialog.viewer .icon-btn:hover { background: rgb(255 255 255 / .12); }
.viewer-count { font-weight: 600; padding-inline: 8px; }
.viewer-nav { position: absolute; inset-block-start: 50%; translate: 0 -50%; z-index: 2; width: 56px; height: 56px; background: rgb(0 0 0 / .5) !important; backdrop-filter: blur(8px); box-shadow: 0 0 0 1px rgb(255 255 255 / .15); transition: opacity .2s; }
.viewer-nav.prev { inset-inline-start: 16px; } .viewer-nav.next { inset-inline-end: 16px; }
.viewer-nav[disabled] { opacity: 0; pointer-events: none; }
@media (hover: none), (pointer: coarse) { .viewer-nav { display: none; } }
.viewer-strip { position: absolute; inset: auto 0 0; z-index: 2; display: flex; justify-content: safe center; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 32px max(16px, calc(50% - 28px)) calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgb(0 0 0 / .6)); transition: opacity .2s; }
.viewer-strip::-webkit-scrollbar { display: none; }
.viewer-strip button { flex: none; width: 48px; height: 48px; padding: 0; border: 0; border-radius: var(--shape-s); overflow: hidden; opacity: .55; cursor: pointer; background: #222;
  transition: opacity .2s, width var(--motion-fast-spatial-duration) var(--motion-fast-spatial), border-radius var(--motion-fast-spatial-duration) var(--motion-fast-spatial); }
.viewer-strip button.on { opacity: 1; width: 64px; border-radius: var(--shape-m); outline: 2px solid var(--md-sys-color-inverse-primary); outline-offset: -2px; }
.viewer-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
dialog.viewer.bare .viewer-bar, dialog.viewer.bare .viewer-strip, dialog.viewer.bare .viewer-nav { opacity: 0; pointer-events: none; }
dialog.viewer.zoomed .viewer-strip, dialog.viewer.zoomed .viewer-nav { opacity: 0; pointer-events: none; }
.viewer-hint { position: absolute; inset-inline: 0; inset-block-end: calc(96px + env(safe-area-inset-bottom)); z-index: 2; margin: 0 auto; width: fit-content; max-width: 90%;
  padding: 10px 16px; border-radius: var(--shape-full); background: rgb(0 0 0 / .7); font-size: .875rem; text-align: center; opacity: 0; transition: opacity .4s; pointer-events: none; }
.viewer-hint.show { opacity: 1; }

/* All photos as a grid, the photo app's library view. */
dialog.photo-library { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border-radius: 0; background: var(--md-sys-color-surface); overflow-y: auto; overscroll-behavior: contain; }
dialog.photo-library::backdrop { background: var(--md-sys-color-surface); }
dialog.photo-library .viewer-bar { position: sticky; background: var(--md-sys-color-surface); padding-block-end: 8px; color: var(--md-sys-color-on-surface); }
dialog.photo-library .icon-btn { color: var(--md-sys-color-on-surface); }
.grid-title { display: flex; flex-direction: column; line-height: 1.3; } .grid-title span { color: var(--md-sys-color-on-surface-variant); font-size: .875rem; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(30vw, 180px), 1fr)); gap: 3px; padding: 0 3px 24px; max-width: 1200px; margin: 0 auto; }
.pgrid button { padding: 0; border: 0; cursor: pointer; overflow: hidden; background: var(--md-sys-color-surface-container-high); border-radius: var(--shape-xs); }
.pgrid button:first-child { grid-column: span 2; grid-row: span 2; border-radius: var(--shape-l); }
.pgrid img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; display: block; transition: scale .3s; }
.pgrid button:hover img { scale: 1.05; }
dialog.photo-library[open] .pgrid button { animation: grid-in var(--motion-default-spatial-duration) var(--motion-default-spatial) both; }
dialog.photo-library[open] .pgrid button:nth-child(2) { animation-delay: 50ms; }
dialog.photo-library[open] .pgrid button:nth-child(3) { animation-delay: 75ms; }
dialog.photo-library[open] .pgrid button:nth-child(4) { animation-delay: 100ms; }
dialog.photo-library[open] .pgrid button:nth-child(5) { animation-delay: 125ms; }
dialog.photo-library[open] .pgrid button:nth-child(6) { animation-delay: 150ms; }
dialog.photo-library[open] .pgrid button:nth-child(7) { animation-delay: 175ms; }
dialog.photo-library[open] .pgrid button:nth-child(8) { animation-delay: 200ms; }
dialog.photo-library[open] .pgrid button:nth-child(9) { animation-delay: 225ms; }
dialog.photo-library[open] .pgrid button:nth-child(10) { animation-delay: 250ms; }
dialog.photo-library[open] .pgrid button:nth-child(11) { animation-delay: 275ms; }
dialog.photo-library[open] .pgrid button:nth-child(12) { animation-delay: 300ms; }
@keyframes grid-in { from { opacity: 0; scale: .9; } }
dialog.photo-library[open] { animation: fade-in .2s ease-out; }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.photo-library[open], dialog.photo-library[open] .pgrid button { animation: none; } }
.ad-layout { display: grid; gap: 24px; }
@media (min-width: 1000px) { .ad-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } .ad-side { position: sticky; top: calc(var(--bar-h) + 16px); } }
.price-big { font-size: 2rem; line-height: 2.5rem; font-weight: 800; }
.contact-bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40; display: flex; gap: 8px; padding: 12px var(--margin) calc(12px + env(safe-area-inset-bottom));
  background: var(--md-sys-color-surface-container); box-shadow: var(--elev-2);
}
.contact-bar .btn { flex: 1; }
body:has(.contact-bar) { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
@media (min-width: 1000px) {
  .contact-bar { position: static; padding: 0; background: none; box-shadow: none; flex-direction: column; }
  body:has(.contact-bar) { padding-bottom: 0; }
}
.read-more summary { cursor: pointer; color: var(--md-sys-color-primary); font-weight: 600; list-style: none; padding: 8px 0; }
.read-more summary::-webkit-details-marker { display: none; }
.read-more:not([open]) .clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.read-more[open] summary { display: none; }
.description { white-space: pre-line; }
.safety { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--shape-l); background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--shape-l); background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.notice.error { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.ticks { display: grid; gap: 8px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); padding: 0; margin: 0; list-style: none; }
.ticks li { display: flex; align-items: center; gap: 10px; }
.ticks .icon { color: var(--md-sys-color-tertiary); }

/* ---- selling flow: one question per screen with a progress bar (P-01) */
.progress { height: 8px; border-radius: 4px; background: var(--md-sys-color-secondary-container); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 4px; background: var(--md-sys-color-primary); transition: width var(--motion-slow-spatial-duration) var(--motion-slow-spatial); }
.step-actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--md-sys-color-background); }
.step-actions .btn:last-child { flex: 1; }
.photo-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.photo-grid figure { margin: 0; position: relative; border-radius: var(--shape-m); overflow: hidden; background: var(--md-sys-color-surface-container-high); aspect-ratio: 1; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid figure .cover { position: absolute; inset-block-start: 6px; inset-inline-start: 6px; }
.photo-grid figure form { position: absolute; inset-block-start: 2px; inset-inline-end: 2px; }
.photo-grid figure .icon-btn { width: 40px; height: 40px; background: rgb(0 0 0 / .45); color: #fff; }
.photo-grid figure.uploading img { opacity: .5; }
.photo-grid figure.failed { outline: 2px solid var(--md-sys-color-error); }
.photo-grid figure .bar { position: absolute; inset-inline: 8px; bottom: 8px; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .6); overflow: hidden; }
.photo-grid figure .bar span { display: block; height: 100%; background: var(--md-sys-color-primary); width: 0; transition: width .2s; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 160px; padding: 24px; text-align: center;
  border: 2px dashed var(--md-sys-color-outline); border-radius: var(--shape-l); background: var(--md-sys-color-surface-container-low); cursor: pointer;
}
.drop .icon { width: 48px; height: 48px; color: var(--md-sys-color-primary); }
.shot-guide { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); padding: 0; list-style: none; }
.shot-guide li { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: var(--shape-m); background: var(--md-sys-color-surface-container-low); font-size: .8125rem; text-align: center; }

/* ---- tables (dealer dashboard, desktop) */
.table-wrap { overflow-x: auto; border-radius: var(--shape-l); border: 1px solid var(--md-sys-color-outline-variant); }
table.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: start; font-weight: 700; font-size: .8125rem; color: var(--md-sys-color-on-surface-variant); background: var(--md-sys-color-surface-container); padding: 12px 16px; white-space: nowrap; }
.table td { padding: 10px 16px; border-top: 1px solid var(--md-sys-color-outline-variant); vertical-align: middle; }
.table tr:hover td { background: var(--md-sys-color-surface-container-lowest); }
.table img { width: 72px; height: 48px; object-fit: cover; border-radius: var(--shape-s); display: block; }

/* ---- dialogs and bottom sheets (native <dialog>, no script needed to style) */
dialog { border: 0; padding: 0; color: inherit; background: var(--md-sys-color-surface-container-high); }
dialog::backdrop { background: rgb(0 0 0 / .32); }
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 640px; border-radius: var(--shape-xl) var(--shape-xl) 0 0; padding: 8px 24px calc(24px + env(safe-area-inset-bottom)); }
dialog.sheet::before { content: ""; display: block; width: 32px; height: 4px; margin: 8px auto 16px; border-radius: 2px; background: var(--md-sys-color-outline); }
dialog.sheet[open] { animation: sheet-in var(--motion-default-spatial-duration) var(--motion-default-spatial); }
@keyframes sheet-in { from { transform: translateY(100%); } }

/* ---- snackbar (from ?msg=… after a form post, or from script) */
.snackbar {
  position: fixed; inset-inline: var(--margin); bottom: calc(var(--fab-bottom, 16px) + env(safe-area-inset-bottom)); z-index: 60; margin: 0 auto; max-width: 560px;
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 12px 16px; border-radius: var(--shape-xs);
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); box-shadow: var(--elev-3);
  animation: snack-in var(--motion-default-spatial-duration) var(--motion-default-spatial), snack-out .3s ease-in 5s forwards;
}
.snackbar a { color: var(--md-sys-color-inverse-primary); font-weight: 700; }
@keyframes snack-in { from { transform: translateY(24px); opacity: 0; } }
@keyframes snack-out { to { transform: translateY(24px); opacity: 0; visibility: hidden; } }

/* ---- empty and offline states */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 16px; text-align: center; }
.empty .art { width: 160px; height: 120px; }
.empty p { max-width: 420px; color: var(--md-sys-color-on-surface-variant); }

/* ---- filters panel */
.filters { display: flex; flex-direction: column; gap: 20px; }
fieldset.filters, .filters fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.filters legend { font-weight: 700; padding: 0; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.search-layout { display: grid; gap: 24px; }
@media (min-width: 1000px) { .search-layout { grid-template-columns: 300px minmax(0, 1fr); align-items: start; } .search-layout > aside { position: sticky; top: calc(var(--bar-h) + 8px); max-height: calc(100dvh - var(--bar-h) - 16px); overflow: auto; padding-inline-end: 8px; } }
.searchbar {
  display: flex; align-items: center; gap: 4px; min-height: 56px; padding-inline: 8px 4px; border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface);
}
.searchbar input { flex: 1; min-width: 0; border: 0; background: none; height: 56px; font-size: 1rem; padding: 0 8px; }
.searchbar input:focus { outline: none; }
.searchbar .icon { color: var(--md-sys-color-on-surface-variant); margin-inline-start: 8px; }
.suggest { position: absolute; z-index: 35; inset-inline: 0; margin-top: 4px; padding: 8px 0; border-radius: var(--shape-l); background: var(--md-sys-color-surface-container); box-shadow: var(--elev-2); }
.suggest a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; color: inherit; text-decoration: none; }
.suggest a:hover, .suggest a.active { background: var(--md-sys-color-surface-container-highest); }

.pager { display: flex; justify-content: center; margin-top: 24px; }
.steps { counter-reset: step; display: grid; gap: 12px; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; }
.steps li::before { content: counter(step); display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); font-weight: 800; }
.prose { max-width: 70ch; }
.prose h2 { font-size: 1.25rem; margin: 28px 0 8px; }
.prose p, .prose ul { margin: 0 0 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  @view-transition { navigation: none; }
}
@media print { .top-bar, .bottom-nav, .contact-bar, .fab, .footer { display: none; } }
.fav .on { display: none; } .fav[aria-pressed=true] .on { display: inline; } .fav[aria-pressed=true] .off { display: none; }
.car-card .card-link { display: flex; flex-direction: inherit; flex: 1; color: inherit; text-decoration: none; border-radius: inherit; }
.clamp-preview:has(+ .read-more[open]) { display: none; }
fieldset.choice { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
fieldset.choice legend { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 4px; padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset > legend { padding: 0; margin-bottom: 8px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
/* Tick on a filter chip only once it is chosen (M3 filter chip). */
.chip.state > input[type=checkbox] + .icon { display: none; }
.chip.state > input[type=checkbox]:checked + .icon { display: inline-block; }
/* A clear button on the teal trust box: mint fill, deep teal label, the same in light and dark (the box is dark teal in both). */
.safety > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.safety .btn-on-trust { margin-top: 8px; background: var(--md-sys-color-on-tertiary-container); color: #003735; box-shadow: 0 1px 2px rgb(0 0 0 / .25); }
.safety .btn-on-trust:hover { filter: brightness(1.06); }
.gallery-count, .viewer-count { direction: ltr; unicode-bidi: isolate; }

/* ---- back button in the top app bar (Material 3: a leading navigation icon on screens below the top level) */
.top-bar .back { margin-inline-end: -4px; color: var(--md-sys-color-on-surface); }
.top-bar .back:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent); }
.top-bar .back:active { background: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent); }
@media (max-width: 839px) {
  .top-bar.has-back .brand { padding-inline: 4px; }
  .top-bar.has-back .brand-name { display: none; }
}

/* ---- account pages: a Google Account-style home (centred identity, grouped rows) */
.account-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 8px 0 4px; }
.account-head h1 { margin: 12px 0 0; }
.account-head p { margin: 0; color: var(--md-sys-color-on-surface-variant); }
.avatar.xl { width: 88px; height: 88px; font-size: 2.25rem; }
.section-label { margin: 0; padding-inline: 4px; color: var(--md-sys-color-on-surface-variant); }
.list-item form { margin: 0; }
.form-actions { --gap: 8px; margin-top: 4px; }
.btn-text.danger { color: var(--md-sys-color-error); }
.pager a[aria-busy=true] { pointer-events: none; opacity: .7; }
.pager a[aria-busy=true]::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---- filters as Material 3 sheets
   Large screens: a standard side sheet beside the results; the fields scroll and the
   "Show N cars" / "Clear filters" actions stay pinned at the bottom of the sheet.
   Phones and tablets: the Filters button opens a full-screen dialog with a top bar (close) and the
   same pinned actions above the screen edge, on top of the bottom navigation. Pure CSS on <details>,
   so it also works without script. */
.filters-head { cursor: pointer; min-height: 48px; list-style: none; }
.filters-head::-webkit-details-marker { display: none; }
.filters-close { display: none; }
.filter-actions {
  position: sticky; bottom: 0; z-index: 1; display: flex; flex-direction: column; gap: 4px;
  margin: 0 -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--md-sys-color-surface-container-low); border-top: 1px solid var(--md-sys-color-outline-variant);
}
@media (min-width: 1000px) {
  .search-layout > aside { padding-inline-end: 0; overscroll-behavior: contain; }
  .search-layout > aside > #filters-box { padding-bottom: 0; }
  .search-layout > aside .filters-head { cursor: default; pointer-events: none; }
}
@media (max-width: 999px) {
  #filters-box[open] {
    position: fixed; inset: 0; z-index: 60; margin: 0; padding: 0 16px; border-radius: 0; overflow: auto; overscroll-behavior: contain;
    background: var(--md-sys-color-surface-container-low); animation: sheet-in var(--motion-default-spatial-duration) var(--motion-default-spatial);
  }
  #filters-box[open] > .filters-head {
    position: sticky; top: 0; z-index: 2; margin: 0 -16px; padding: 8px 8px 8px 16px; min-height: var(--bar-h);
    background: inherit; border-bottom: 1px solid var(--md-sys-color-outline-variant);
  }
  #filters-box[open] .filters-close { display: inline-grid; }
  #filters-box[open] .filter-actions { margin: 0 -16px; }
  html:has(#filters-box[open]) { overflow: hidden; }
}
@media (max-width: 999px) { #filters-box:not([open]) { padding: 4px 16px; } }
/* Title above the results; the filter sheet runs from the top so it fits the screen from the first view. */
@media (min-width: 1000px) {
  .search-layout { grid-template-areas: "filters head" "filters results"; row-gap: 0; }
  .search-layout > .search-head { grid-area: head; }
  .search-layout > aside { grid-area: filters; grid-row: 1 / span 2; }
  .search-layout > section { grid-area: results; }
}

/* ---- Material 3 basic dialog for confirmations (replaces the browser's confirm popup) */
dialog.confirm { width: min(100% - 48px, 400px); padding: 24px; border-radius: var(--shape-xl); }
dialog.confirm[open] { animation: dialog-in var(--motion-default-spatial-duration) var(--motion-default-spatial); }
dialog.confirm form { display: flex; flex-direction: column; gap: 16px; }
dialog.confirm .confirm-icon { align-self: center; color: var(--md-sys-color-secondary); }
dialog.confirm h2 { margin: 0; text-align: center; }
dialog.confirm p { margin: 0; color: var(--md-sys-color-on-surface-variant); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@keyframes dialog-in { from { opacity: 0; transform: scale(.9); } }
