/* Guided configurator. Desktop retains the existing three-column studio. */
body.configurator-page .mobile-flow-intro,
body.configurator-page [data-flow-preview] {
  display: none;
}

body.configurator-page .mobile-flow-status {
  display: contents;
}

body.configurator-page .flow-next-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

@media screen and (min-width: 901px) {
  body.configurator-page .flow-summary-overview {
    display: none;
  }

  body.configurator-page .flow-details {
    margin: 18px 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 14px;
    background: #111820;
  }

  body.configurator-page .flow-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 12px 0;
    color: var(--accent);
    font: 500 13px/1.5 var(--body);
    list-style: none;
    cursor: pointer;
  }

  body.configurator-page .flow-details > summary::-webkit-details-marker,
  body.configurator-page .flow-details > summary > span[aria-hidden="true"] {
    display: none;
  }

  body.configurator-page .flow-details > summary::after {
    content: '+';
    font-size: 21px;
    font-weight: 400;
  }

  body.configurator-page .flow-details[open] > summary::after {
    content: '−';
  }

  body.configurator-page .flow-details[open] {
    padding-bottom: 14px;
  }
}

@media screen and (max-width: 900px) {
  body.configurator-page {
    --flow-footer-height: 174px;
    --flow-preview-height: clamp(120px, 25svh, 220px);
    background: var(--bg);
    padding-bottom: calc(var(--flow-footer-height) + 18px);
  }

  body.configurator-page .cfg {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: calc(var(--nav-h) + 10px) 10px 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--bg2);
    box-shadow: 0 16px 48px #0003;
    overflow: visible;
    overflow-anchor: none;
  }

  body.configurator-page #stepsRail {
    position: static;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    flex-direction: row;
    height: auto;
    min-height: 58px;
    gap: 2px;
    padding: 6px 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 24px 24px 0 0;
    background: #151b23;
  }

  body.configurator-page .cfg-step {
    min-width: 44px;
    min-height: 44px;
    padding: 2px;
    gap: 3px;
    border-radius: 10px;
    align-content: center;
  }

  body.configurator-page .cfg-step b {
    width: 25px;
    height: 25px;
    font: 600 12px/1 var(--body);
    border-radius: 50%;
  }

  body.configurator-page .cfg-step span.t {
    font: 500 10px/1.3 var(--body);
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
  }

  body.configurator-page .cfg-step.active {
    background: rgba(var(--accent-rgb), .07);
  }

  body.configurator-page .cfg-step.done b {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), .08);
  }

  body.configurator-page .mobile-flow-intro {
    display: grid;
    gap: 4px;
    padding: 13px 16px 5px;
    scroll-margin-top: calc(var(--nav-h) + 10px);
  }

  body.configurator-page .mobile-flow-intro small,
  body.configurator-page .mobile-flow-step {
    color: var(--muted);
    font: 500 10px/1.4 var(--body);
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  body.configurator-page .mobile-flow-intro strong,
  body.configurator-page .mobile-flow-title {
    display: block;
    color: var(--txt);
    font: 500 17px/1.3 var(--body);
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  body.configurator-page .mobile-flow-intro p,
  body.configurator-page .mobile-flow-copy {
    margin: 0;
    color: var(--muted);
    font: 400 12px/1.45 var(--body);
  }

  body.configurator-page .cfg-stage,
  body.configurator-page .cfg-stage.has-vehicle-3d,
  body.configurator-page .cfg-stage.has-vehicle-visual,
  body.configurator-page .cfg-stage.has-wheel-reference {
    position: relative;
    top: auto;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: transparent;
  }

  body.configurator-page #stageHead {
    padding: 8px 14px 0;
    gap: 0;
  }

  body.configurator-page #stageHead h1 {
    display: none;
  }

  body.configurator-page .stage-controls {
    flex-wrap: nowrap;
    gap: 8px;
  }

  body.configurator-page .stage-controls .seg {
    display: flex;
    flex: 1;
    min-width: 0;
    padding: 2px;
    border-radius: 14px;
    background: #171e26;
  }

  body.configurator-page .stage-controls .seg button {
    flex: 1;
    min-height: 44px;
    min-width: 0;
    padding: 8px;
    border-radius: 11px;
    font-size: 12px;
    white-space: normal;
  }

  body.configurator-page .stage-controls .toggle {
    min-height: 44px;
    padding: 6px 2px;
    gap: 5px;
    font-size: 11px;
  }

  body.configurator-page .toggle {
    min-height: 44px;
  }

  body.configurator-page .toggle input,
  body.configurator-page .toggle input:checked {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  body.configurator-page .toggle input::before {
    content: '';
    position: absolute;
    top: 11px;
    left: 2px;
    width: 40px;
    height: 22px;
    border-radius: 22px;
    background: var(--line2);
  }

  body.configurator-page .toggle input:checked::before {
    background: var(--accent);
  }

  body.configurator-page .toggle input::after {
    top: 14px;
    left: 5px;
    width: 16px;
    height: 16px;
  }

  body.configurator-page .toggle input:checked::after {
    transform: translateX(18px);
  }

  body.configurator-page #stageView,
  body.configurator-page #stageView.is-wheel-reference,
  body.configurator-page #stageView.has-vehicle-3d {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 0 14px 12px;
    min-height: 0;
    height: auto;
    overflow: visible;
    scroll-margin-top: calc(var(--nav-h) + 12px);
  }

  body.configurator-page #stageView .webgl-view {
    position: relative;
    inset: auto;
    flex: none;
    width: 100%;
    height: var(--flow-preview-height);
    min-height: 0;
  }

  body.configurator-page #stageView .preview-caption {
    position: static;
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0 2px;
    max-width: none;
    pointer-events: auto;
    text-align: center;
  }

  body.configurator-page #stageView .preview-caption > b {
    font: 500 10px/1.4 var(--body);
    letter-spacing: .04em;
  }

  body.configurator-page #stageView .preview-caption > span {
    max-width: 100%;
    margin: 0;
    font-size: 11px;
    line-height: 1.5;
  }

  body.configurator-page #stageView.has-vehicle-photo {
    min-height: 0;
    padding-top: 12px;
    gap: 10px;
  }

  body.configurator-page .stage-vehicle-frame {
    flex: none;
    height: clamp(180px, 50vw, 230px);
    min-height: 0;
    max-height: none;
    border-radius: 16px;
  }

  body.configurator-page #stageView.has-vehicle-photo .preview-caption {
    text-align: left;
    gap: 5px;
  }

  body.configurator-page #stageView .vehicle-visual-credit {
    font-size: 10px;
    line-height: 1.65;
    overflow-wrap: anywhere;
  }

  body.configurator-page .wheel-photo-toolbar {
    flex-wrap: wrap;
    gap: 7px 12px;
    padding: 0;
  }

  body.configurator-page .wheel-photo-status {
    flex: 1 1 130px;
    font-size: 11px;
  }

  body.configurator-page .wheel-photo-compare,
  body.configurator-page .wheel-photo-retry,
  body.configurator-page .visual-retry,
  body.configurator-page .studio-availability button,
  body.configurator-page .viewer-fallback button {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 12px;
  }

  body.configurator-page .studio-viewpoints {
    position: static;
    order: -1;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 7px;
  }

  body.configurator-page .studio-viewpoints button {
    min-height: 44px;
    padding: 9px 11px;
    font-size: 11px;
  }

  body.configurator-page .studio-credit summary {
    min-height: 44px;
    padding: 12px 2px;
    margin: auto;
  }

  body.configurator-page #stageFoot {
    display: none;
  }

  body.configurator-page .cfg-panel {
    position: static;
    display: block;
    height: auto;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0 0 24px 24px;
    background: #151c24;
    overflow: visible;
  }

  body.configurator-page #panelBody {
    overflow: visible;
    height: auto;
    padding: 17px 16px 24px;
  }

  body.configurator-page #panelBody .panel-kicker {
    display: none;
  }

  body.configurator-page #panelBody > h2 {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  body.configurator-page #panelBody > .sub {
    display: none;
  }

  body.configurator-page #flowHeading:focus,
  body.configurator-page #mobileFlowIntro:focus {
    outline: none;
  }

  body.configurator-page #panelBody .sub {
    font-size: 12px;
    line-height: 1.5;
    margin: 0 0 17px;
  }

  body.configurator-page .flow-guidance {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 11px 12px;
    margin: 12px 0 16px;
    border: 1px solid rgba(var(--accent-rgb), .2);
    border-radius: 12px;
    background: rgba(var(--accent-rgb), .055);
    color: var(--accent);
    font: 400 12px/1.5 var(--body);
  }

  body.configurator-page .field,
  body.configurator-page .flow-details,
  body.configurator-page .form,
  body.configurator-page .flow-summary-edit {
    scroll-margin-top: calc(var(--nav-h) + 18px);
    scroll-margin-bottom: calc(var(--flow-footer-height) + 18px);
  }

  body.configurator-page #panelBody .field {
    margin: 14px 0;
  }

  body.configurator-page #panelBody input:not([type="checkbox"]):not([type="range"]):not([type="color"]),
  body.configurator-page #panelBody select,
  body.configurator-page #panelBody textarea,
  body.configurator-page .nfw-brand-search {
    min-height: 48px;
    font-size: 16px;
    border-radius: 12px;
    scroll-margin-top: calc(var(--nav-h) + 24px);
    scroll-margin-bottom: calc(var(--flow-footer-height) + 24px);
  }

  body.configurator-page .nfw-brand-trigger {
    min-height: 48px;
    font-size: 16px;
    border-radius: 12px;
  }

  body.configurator-page .nfw-brand-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  body.configurator-page .flow-details {
    border: 1px solid var(--line2);
    border-radius: 14px;
    padding: 0 13px;
    margin: 18px 0;
    background: #111820;
  }

  body.configurator-page .flow-details > summary {
    position: relative;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px 12px 0;
    color: var(--accent);
    font: 500 13px/1.5 var(--body);
    cursor: pointer;
    list-style: none;
  }

  body.configurator-page .flow-details > summary::-webkit-details-marker {
    display: none;
  }

  body.configurator-page .flow-details > summary > span[aria-hidden="true"] {
    display: none;
  }

  body.configurator-page .flow-details > summary::after {
    content: '+';
    position: absolute;
    right: 0;
    font-size: 21px;
    font-weight: 400;
  }

  body.configurator-page .flow-details[open] > summary::after {
    content: '−';
  }

  body.configurator-page .flow-details[open] {
    padding-bottom: 12px;
  }

  body.configurator-page .opt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  body.configurator-page .opt,
  body.configurator-page .chip,
  body.configurator-page .check,
  body.configurator-page .note,
  body.configurator-page .generation-info {
    border-radius: 13px;
  }

  body.configurator-page .opt-grid .opt {
    padding: 10px;
  }

  body.configurator-page .opt-grid .wheel-thumb {
    max-height: 155px;
  }

  body.configurator-page .chip,
  body.configurator-page .swatch,
  body.configurator-page .check,
  body.configurator-page .flow-summary-edit {
    min-height: 44px;
    min-width: 44px;
  }

  body.configurator-page .chip {
    padding: 11px 15px;
  }

  body.configurator-page .swatch {
    height: 44px;
    width: 44px;
  }

  body.configurator-page .swatches {
    gap: 11px;
    padding: 4px;
    margin-inline: -4px;
  }

  body.configurator-page .range input[type="range"] {
    min-height: 44px;
  }

  body.configurator-page .flow-summary-overview {
    display: grid;
    gap: 8px;
    margin: 0 0 18px;
  }

  body.configurator-page .flow-summary-edit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-width: 0;
    padding: 12px 13px;
    color: var(--accent);
    background: #111820;
    border: 1px solid var(--line2);
    border-radius: 12px;
    font: 500 12px/1.4 var(--body);
    text-align: left;
  }

  body.configurator-page .flow-summary-edit > span:first-child {
    display: grid;
    gap: 4px;
    min-width: 0;
  }

  body.configurator-page .flow-summary-edit small {
    color: var(--muted);
    font: 400 11px/1.4 var(--body);
  }

  body.configurator-page .flow-summary-edit b {
    color: var(--txt);
    font: 500 13px/1.5 var(--body);
    overflow-wrap: anywhere;
  }

  body.configurator-page .flow-summary-edit > span:last-child {
    flex: none;
    font-size: 11px;
    white-space: nowrap;
  }

  body.configurator-page .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  body.configurator-page #panelFoot {
    position: fixed;
    inset: auto 0 0;
    z-index: 35;
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 9px max(14px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid #627184;
    border-radius: 19px 19px 0 0;
    background: #141c25f5;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -12px 35px #0004;
  }

  body.configurator-page .mobile-flow-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
  }

  body.configurator-page [data-flow-preview] {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px 0 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--accent);
    text-align: left;
    font: 500 11px/1.35 var(--body);
  }

  body.configurator-page [data-flow-preview] img {
    flex: none;
    width: 44px;
    height: 44px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #202936;
  }

  body.configurator-page [data-flow-preview] > span {
    display: block;
    min-width: 0;
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.45;
  }

  body.configurator-page [data-flow-preview] > span > small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font: 400 10px/1.4 var(--body);
  }

  body.configurator-page #panelFoot .price {
    display: block;
    min-width: 0;
    margin: 0;
    text-align: right;
  }

  body.configurator-page #panelFoot .price small {
    margin: 0 0 2px;
    max-width: 190px;
    color: var(--muted);
    font: 400 10px/1.3 var(--body);
    text-transform: none;
    letter-spacing: 0;
  }

  body.configurator-page #panelFoot .price b {
    font: 500 22px/1.15 var(--body);
    letter-spacing: -.03em;
    white-space: nowrap;
  }

  body.configurator-page #panelFoot .price .per {
    display: none;
  }

  body.configurator-page #panelFoot .panel-nav {
    display: grid;
    grid-template-columns: minmax(82px, .7fr) minmax(0, 1.65fr);
    gap: 8px;
  }

  body.configurator-page #panelFoot .panel-nav .btn {
    min-width: 0;
    min-height: 48px;
    padding: 11px 12px;
    border-radius: 14px;
    font: 600 13px/1.35 var(--body);
    text-transform: none;
    letter-spacing: 0;
    white-space: normal;
  }

  body.configurator-page #panelFoot .panel-nav .btn > span {
    justify-content: center;
    gap: 9px;
  }

  body.configurator-page #panelFoot .panel-nav .btn:disabled {
    opacity: .42;
  }

  body.configurator-page .flow-next-hint {
    min-height: 15px;
    margin: 0;
    text-align: center;
    font-size: 11px;
    line-height: 1.4;
    color: var(--muted);
  }

  body.configurator-page.flow-keyboard-open #panelFoot {
    visibility: hidden;
    pointer-events: none;
  }

  body.configurator-page #panelBody .actions .btn {
    min-height: 48px;
    border-radius: 14px;
  }

  body.configurator-page #stageView:fullscreen {
    display: flex;
    padding: 16px;
    justify-content: center;
    overflow: auto;
  }

  body.configurator-page #stageView:fullscreen .webgl-view {
    flex: 1;
    min-height: 200px;
  }
}

@media screen and (max-width: 350px) {
  body.configurator-page .cfg {
    margin-inline: 7px;
  }

  body.configurator-page .cfg-step span.t {
    font-size: 9px;
  }

  body.configurator-page #panelBody {
    padding-inline: 12px;
  }

  body.configurator-page [data-flow-preview] {
    gap: 5px;
  }

  body.configurator-page #panelFoot .price small {
    max-width: 165px;
    font-size: 9px;
  }

  body.configurator-page .two,
  body.configurator-page .vehicle-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Keep both the wheel and the first choice visible on compact portrait phones. */
@media screen and (max-width: 420px) and (max-height: 650px) and (orientation: portrait) {
  body.configurator-page {
    --nav-h: 56px;
    --flow-preview-height: 110px;
    --flow-footer-height: 128px;
  }

  body.configurator-page .cfg {
    margin-top: calc(var(--nav-h) + 6px);
  }

  body.configurator-page #stepsRail {
    min-height: 44px;
    padding: 0 6px;
  }

  body.configurator-page .cfg-step {
    gap: 1px;
  }

  body.configurator-page .cfg-step b {
    width: 23px;
    height: 23px;
  }

  body.configurator-page .mobile-flow-intro {
    padding: 8px 13px 2px;
    gap: 2px;
  }

  body.configurator-page .mobile-flow-title {
    font-size: 15px;
  }

  body.configurator-page .mobile-flow-copy {
    display: none;
  }

  body.configurator-page #stageHead {
    padding: 4px 12px 0;
  }

  body.configurator-page #stageView {
    padding: 0 12px 6px;
  }

  body.configurator-page #stageView:not(.has-vehicle-photo):not(.has-vehicle-3d):not(.is-wheel-reference) > .preview-caption {
    display: none;
  }

  body.configurator-page #panelBody {
    padding-top: 8px;
  }

  body.configurator-page #panelBody .field {
    margin: 8px 0;
  }

  body.configurator-page .vehicle-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 8px;
  }

  body.configurator-page #panelFoot {
    gap: 4px;
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  body.configurator-page #panelFoot .panel-nav .btn {
    min-height: 44px;
    padding-block: 9px;
  }

  body.configurator-page #panelFoot .price b {
    font-size: 20px;
  }

  body.configurator-page .flow-next-hint {
    min-height: 12px;
    font-size: 10px;
    line-height: 1.2;
  }
}

/* On a short landscape screen, the preview and fields share the same card. */
@media screen and (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  body.configurator-page {
    --nav-h: 52px;
    --flow-preview-height: 110px;
    --flow-footer-height: 80px;
  }

  body.configurator-page .cfg {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: 'steps steps' 'intro intro' 'stage panel';
    align-items: start;
    margin-top: calc(var(--nav-h) + 6px);
  }

  body.configurator-page #stepsRail {
    grid-area: steps;
    min-height: 44px;
    padding: 0 8px;
    width: 100%;
  }

  body.configurator-page .cfg-step {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 4px;
  }

  body.configurator-page .mobile-flow-intro {
    grid-area: intro;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
  }

  body.configurator-page .mobile-flow-title {
    font-size: 14px;
  }

  body.configurator-page .mobile-flow-copy {
    display: none;
  }

  body.configurator-page .cfg-stage {
    grid-area: stage;
    min-width: 0;
  }

  body.configurator-page #stageHead {
    padding-top: 0;
  }

  body.configurator-page .stage-controls {
    gap: 6px;
  }

  body.configurator-page .stage-controls .seg button {
    font-size: 11px;
    padding: 6px;
  }

  body.configurator-page #stageView {
    padding-bottom: 8px;
  }

  body.configurator-page #stageView:not(.has-vehicle-photo):not(.has-vehicle-3d) .preview-caption > span {
    display: none;
  }

  body.configurator-page .stage-vehicle-frame {
    height: 120px;
  }

  body.configurator-page .cfg-panel {
    grid-area: panel;
    min-width: 0;
    border-top: 0;
    border-left: 1px solid var(--line);
    border-radius: 0 0 24px 0;
  }

  body.configurator-page #panelBody {
    padding: 0 14px 20px;
  }

  body.configurator-page #panelBody .field {
    margin: 0 0 12px;
  }

  body.configurator-page #panelFoot {
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.2fr);
    align-items: center;
    gap: 18px;
    padding-top: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  body.configurator-page #panelFoot .price b {
    font-size: 20px;
  }

  body.configurator-page #panelFoot .price small {
    font-size: 9px;
  }

  body.configurator-page .flow-next-hint {
    display: none;
  }
}

@media print {
  body.configurator-page .mobile-flow-intro,
  body.configurator-page .flow-guidance,
  body.configurator-page .flow-summary-edit,
  body.configurator-page .flow-next-hint {
    display: none !important;
  }
}
