/* Detail view: single-scroll, non-cropping responsive layout. */
.detail-dialog {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  scrollbar-color: #b7bec8 transparent;
  scrollbar-width: thin;
}

.detail-dialog::-webkit-scrollbar {
  width: 7px;
}

.detail-dialog::-webkit-scrollbar-track {
  background: transparent;
}

.detail-dialog::-webkit-scrollbar-thumb {
  background: #b7bec8;
  border: 2px solid #fff;
  border-radius: 999px;
}

.detail-layout {
  min-height: 0;
  max-height: none;
  align-items: start;
}

.gallery-stage {
  min-width: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,.96), rgba(238,241,244,.96));
}

.gallery-main {
  object-fit: contain;
  object-position: center;
  background: transparent;
}

.detail-info {
  min-width: 0;
}

.detail-info h2,
.detail-model,
.detail-price,
.quick-specs,
.vin,
.detail-section {
  position: relative;
}

.features {
  align-items: flex-start;
}

.feature {
  max-width: 100%;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (min-width: 901px) {
  .detail-dialog {
    width: min(1180px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    border-radius: 24px;
    box-shadow: 0 32px 100px rgba(7, 14, 30, .34);
  }

  .detail-dialog::backdrop {
    background: rgba(8, 15, 29, .76);
  }

  .detail-layout {
    grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr);
  }

  .gallery {
    position: sticky;
    top: 0;
    height: min(820px, calc(100dvh - 24px));
    min-height: 0;
    padding: 18px;
    display: grid;
    grid-template-rows: minmax(0, 1fr) 74px;
    gap: 12px;
    overflow: hidden;
    background: #edf0f3;
  }

  .gallery-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    border: 1px solid rgba(12, 21, 44, .06);
    border-radius: 18px;
  }

  .gallery-main {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 18px;
  }

  .thumbs {
    min-width: 0;
    margin: 0;
    padding: 1px 1px 4px;
    display: flex;
    grid-template-columns: none;
    gap: 9px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .thumb {
    width: 92px;
    min-width: 92px;
    height: 69px;
    flex: 0 0 92px;
    aspect-ratio: 4 / 3;
    scroll-snap-align: center;
    border-radius: 10px;
  }

  .detail-info {
    padding: 32px 34px 38px;
    overflow: visible;
  }

  .detail-info h2 {
    margin: 14px 0 7px;
    font-size: clamp(27px, 2.4vw, 34px);
  }

  .detail-model {
    margin-bottom: 18px;
  }

  .detail-price {
    margin-bottom: 22px;
    font-size: 32px;
  }

  .quick-specs {
    gap: 9px;
    margin-bottom: 24px;
  }

  .quick-spec {
    padding: 12px 11px;
  }

  .vin {
    padding: 12px 14px;
  }

  .detail-section {
    margin-top: 22px;
  }

  .detail-section h3 {
    margin-bottom: 11px;
  }

  .spec-table {
    gap: 0 26px;
  }

  .spec-row {
    padding: 8px 0;
    line-height: 1.35;
  }

  .features {
    gap: 7px;
  }

  .feature {
    padding: 7px 9px;
    font-size: 10.5px;
  }

  .dialog-close {
    top: max(18px, calc((100dvh - min(820px, calc(100dvh - 24px))) / 2 + 13px));
    right: max(18px, calc((100vw - min(1180px, calc(100vw - 24px))) / 2 + 13px));
    width: 43px;
    height: 43px;
    color: var(--ink);
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(12, 21, 44, .12);
  }
}

@media (max-width: 900px) {
  .detail-dialog {
    width: min(760px, calc(100% - 20px));
    height: auto;
    max-height: calc(100dvh - 20px);
    border-radius: 20px;
  }

  .detail-layout {
    display: block;
  }

  .gallery {
    position: relative;
    top: auto;
    height: auto;
    min-height: 0;
    padding: 12px 12px 10px;
    display: block;
    overflow: visible;
  }

  .gallery-stage {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 15px;
  }

  .gallery-main {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 15px;
  }

  .thumbs {
    display: flex;
    grid-template-columns: none;
    margin: 0;
    padding: 10px 0 1px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .detail-info {
    overflow: visible;
  }
}

@media (max-width: 600px) {
  .detail-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .gallery {
    padding: 0 0 10px;
  }

  .gallery-stage,
  .gallery-main {
    border-radius: 0;
  }

  .detail-info {
    padding-top: 22px;
  }

  .features {
    gap: 7px;
  }

  .feature {
    padding: 8px 9px;
    font-size: 11px;
  }
}

@media (min-width: 901px) and (max-height: 740px) {
  .gallery {
    height: calc(100dvh - 16px);
    padding: 12px;
    grid-template-rows: minmax(0, 1fr) 62px;
    gap: 8px;
  }

  .thumb {
    width: 80px;
    min-width: 80px;
    height: 60px;
    flex-basis: 80px;
  }

  .detail-dialog {
    max-height: calc(100dvh - 16px);
  }

  .detail-info {
    padding: 24px 30px 30px;
  }

  .detail-info h2 {
    font-size: 27px;
  }

  .detail-price {
    margin-bottom: 18px;
    font-size: 28px;
  }

  .quick-specs {
    margin-bottom: 18px;
  }

  .detail-section {
    margin-top: 17px;
  }
}
