:root {
  --ink: #0B2436;
  --steel-line: #163A56;
  --paper: #F5F9FB;
  --card: #ffffff;
  --wood: #C89550;
  --wood-dark: #A3763A;
  --water: #17AAB8;
  --line: #DCE7EC;
  --text: #0F1E29;
  --mute: #7C8B96;
  --clay: #A8623F;
  --success: #4F7A5B;
  --radius: 3px;
  --footer-h: 84px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom, 0px));
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 20px 28px;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  font-family: 'Space Grotesk', 'Fraunces', serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.brand span { color: var(--water); }
.brand-sub {
  font-size: 12.5px;
  color: var(--mute);
  margin-top: 2px;
}
.brand-mark {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wood-dark);
}

/* ===== STEPPER ===== */
.stepper-wrap { margin-bottom: 20px; }
.stepper {
  display: flex;
  align-items: center;
  position: relative;
}
.stepper::before {
  content: "";
  position: absolute;
  left: 14px; right: 14px; top: 13px;
  height: 1px;
  background: var(--line);
}
.step-node {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  z-index: 1;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: inherit;
}
.step-node.clickable { cursor: pointer; }
.step-dot {
  width: 27px; height: 27px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 12.5px;
  color: var(--mute);
  transition: all .15s ease;
}
.step-node.done .step-dot {
  background: var(--wood);
  border-color: var(--wood);
  color: #fff;
}
.step-node.active .step-dot {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-style: normal;
}
.step-label {
  font-size: 11px;
  color: var(--mute);
  margin-top: 7px;
  text-align: center;
  max-width: 88px;
  line-height: 1.25;
}
.step-node.active .step-label { color: var(--text); font-weight: 500; }

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(280px, 0.92fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.visual-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: sticky;
  top: 12px;
}

.visual-canvas {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.three-wrap {
  position: relative;
  width: 100%;
  height: 460px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--ink);
  touch-action: none;
}
.three-wrap.night-mode { background: #071018; }
.three-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.view-toolbar {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 3;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 78%;
}
.visual-canvas { position: relative; }
.view-toolbar {
  position: absolute;
}

.viewtoggle-btn, .scene-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(23, 170, 184, 0.55);
  background: rgba(11, 36, 54, 0.82);
  color: #e2e8f0;
  padding: 7px 10px;
  border-radius: 20px;
  cursor: pointer;
  min-height: 34px;
}
.scene-btn.active,
.viewtoggle-btn.active {
  background: var(--water);
  border-color: var(--water);
  color: #072028;
}
.viewtoggle-btn:hover, .scene-btn:hover { background: rgba(23, 170, 184, 0.28); }

.visual-caption {
  font-size: 12px;
  color: var(--mute);
  text-align: center;
  margin-top: 10px;
}

.photo-row {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.photo-zoom-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--line);
}
.photo-zoom-wrap img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
  transition: transform 0.25s;
}
.photo-zoom-wrap:hover img { transform: scale(1.04); }
.photo-zoom-hint {
  position: absolute; inset: auto 0 0 0;
  background: rgba(11,36,54,0.78);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  text-align: center;
  padding: 3px 4px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.photo-zoom-wrap:hover .photo-zoom-hint { opacity: 1; }
.photo-kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wood-dark);
}
.photo-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  margin-top: 2px;
}
.photo-caption {
  font-size: 12px;
  color: var(--mute);
  margin-top: 2px;
}

.options-panel { min-width: 0; }

h2.step-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 19px;
  margin: 0 0 4px;
}
p.step-hint {
  font-size: 13px;
  color: var(--mute);
  margin: 0 0 16px;
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.option-card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
}
.option-card:hover { border-color: var(--water); }
.option-card.selected {
  border-color: var(--ink);
  background: #E8F3F6;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.option-card small {
  display: block;
  color: var(--mute);
  font-size: 11.5px;
  margin-top: 3px;
}
.option-card .price-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  margin-top: 6px;
}

.dims-box {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
  background: var(--paper);
}
.dims-box strong {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
}
.dims-box span { color: var(--mute); }

.color-block { margin-bottom: 18px; }
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px 8px;
}
.swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.color-swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
}
.color-swatch:hover { transform: scale(1.06); }
.color-swatch.active {
  border-color: var(--wood);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wood);
}
.swatch-name {
  font-size: 11px;
  color: var(--mute);
  text-align: center;
  line-height: 1.2;
}
.color-swatch.fixed { cursor: default; pointer-events: none; }
.color-swatch.fixed:hover { transform: none; }
.membrane-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin-top: 10px; }
.membrane-item { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--mute); text-align: center; }
.membrane-item img { width: 100%; height: 40px; object-fit: cover; border-radius: 20px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.switch-row:first-of-type { border-top: none; padding-top: 0; }
.switch-row .switch-label {
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.switch-row .switch-label img {
  width: 38px;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.switch-row small { display: block; color: var(--mute); font-weight: 400; font-size: 12px; }

.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #D8D2C2;
  border-radius: 26px;
  transition: 0.25s;
}
.slider::before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--water); }
.switch input:checked + .slider::before { transform: translateX(20px); }

table.recap-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
table.recap-table td { padding: 10px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.recap-table td.modify { text-align: right; white-space: nowrap; }
table.recap-table a.modify-link { color: var(--water); font-size: 12px; text-decoration: none; }
table.recap-table a.modify-link:hover { text-decoration: underline; }
table.recap-table tr.total-row td {
  border-bottom: none;
  padding-top: 14px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--mute); margin-bottom: 6px; }
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--text);
  min-height: 44px;
}
.field textarea { resize: vertical; min-height: 80px; }
.field.error input { border-color: #a5433a; }
.field-error-msg { font-size: 11.5px; color: #a5433a; margin-top: 4px; display: none; }
.field.error .field-error-msg { display: block; }

.confirmation-box .status {
  display: inline-block;
  background: var(--success);
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

/* ===== FOOTER ===== */
.footer-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.price-live {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
}
.price-live .amount {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.price-live .amount.est::before { content: "≈ "; color: var(--mute); font-size: 14px; }
.price-live .price-notice {
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: none;
  color: var(--mute);
  max-width: 460px;
  margin-top: 3px;
}

.nav-buttons { display: flex; gap: 8px; flex-shrink: 0; }
button.btn {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
button.btn.primary { background: var(--ink); color: #F5F9FB; }
button.btn:disabled { opacity: .4; cursor: not-allowed; }

.photo-reelle {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.photo-reelle-kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wood-dark);
}
.photo-reelle-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  margin: 4px 0 10px;
}
.photo-reelle-shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: #0B2436;
  cursor: zoom-in;
  position: relative;
  text-align: left;
}
.photo-reelle-shot img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  transition: transform 0.25s ease;
}
.photo-reelle-shot:hover img { transform: scale(1.03); }
.photo-reelle-hint {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(11,36,54,0.78);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 7px 8px;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(11,36,54,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 16px;
}
.image-modal[hidden] { display: none !important; }
.modal-frame {
  position: relative;
  display: inline-block;
  max-width: 92vw;
  max-height: 90vh;
}
.modal-frame img,
.image-modal img {
  display: block;
  max-width: 92vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 6px;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: auto;
  height: auto;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: #0B2436;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.modal-close:hover { background: #17AAB8; color: #072028; }

.three-wrap:fullscreen,
.visual-panel:fullscreen,
#visualCanvas:fullscreen {
  background: var(--ink);
  width: 100%;
  height: 100%;
}

.cam-reset-btn {
  display: none;
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  border: 0;
  background: #17AAB8;
  color: #072028;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 20px;
  cursor: pointer;
}
.cam-reset-btn.is-visible { display: block; }

.exit-fs-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  border: 0;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  background: #17AAB8;
  color: #072028;
  font-size: 22px;
  font-weight: 600;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
}
.three-wrap:fullscreen .exit-fs-btn,
.three-wrap:-webkit-full-screen .exit-fs-btn {
  display: block;
}

/* ===== TABLET ===== */
@media (max-width: 960px) {
  .app { padding: 12px 12px 20px; }
  .layout { grid-template-columns: 1fr; gap: 12px; }
  .visual-panel {
    position: static;
    order: 1;
    padding: 10px;
  }
  .options-panel { order: 2; }
  .visual-canvas {
    display: flex;
    flex-direction: column;
  }
  .view-toolbar {
    position: static;
    max-width: 100%;
    width: 100%;
    justify-content: stretch;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 0 0 8px;
  }
  .view-toolbar .viewtoggle-btn,
  .view-toolbar .scene-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 4px;
    font-size: 11px;
    min-height: 40px;
    white-space: nowrap;
  }
  .three-wrap {
    height: 52vw;
    min-height: 220px;
    max-height: 320px;
  }
  .photo-row { display: none; }
}

/* ===== PHONE ===== */
@media (max-width: 640px) {
  .app { padding: 10px 10px 16px; }
  header.top { margin-bottom: 10px; }
  .brand { font-size: 18px; }
  .brand-sub { display: none; }
  .stepper-wrap { margin-bottom: 12px; }
  .step-label { display: none; }
  .step-dot { width: 24px; height: 24px; font-size: 11px; }
  .stepper::before { top: 12px; left: 10px; right: 10px; }
  .three-wrap {
    height: 46vw;
    min-height: 200px;
    max-height: 260px;
  }
  .visual-caption { display: none; }
  .photo-row { display: none; }

  .view-toolbar {
    gap: 3px;
    margin: 0 0 6px;
  }
  .view-toolbar .viewtoggle-btn,
  .view-toolbar .scene-btn {
    padding: 4px 2px;
    font-size: 9px;
    min-height: 28px;
    letter-spacing: 0.02em;
    border-radius: 14px;
    background: rgba(11, 36, 54, 0.82);
    border-color: rgba(23, 170, 184, 0.55);
    color: #e2e8f0;
  }
  .view-toolbar .viewtoggle-btn:hover,
  .view-toolbar .viewtoggle-btn:focus,
  .view-toolbar .scene-btn:hover,
  .view-toolbar .scene-btn:focus {
    background: rgba(11, 36, 54, 0.82);
    color: #e2e8f0;
  }
  .view-toolbar .scene-btn.active {
    background: var(--water);
    border-color: var(--water);
    color: #072028;
  }
  #viewToggleBtn.face-mode {
    color: #ffffff;
    background: #17AAB8;
    border-color: #17AAB8;
    font-weight: 600;
  }

  .options-panel { padding: 12px; }
  .option-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .option-card {
    padding: 8px 8px 7px;
    font-size: 13px;
  }
  .option-card small {
    font-size: 10px;
    margin-top: 2px;
  }
  .option-card .price-tag {
    font-size: 11px;
    margin-top: 4px;
  }

  .photo-reelle {
    margin-top: 12px;
    padding-top: 12px;
  }
  .photo-reelle-shot img { height: 150px; }

  .footer-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .price-live .amount { font-size: 18px; }
  button.btn { padding: 10px 14px; }
}

@media (max-width: 420px) {
  .option-grid { grid-template-columns: 1fr 1fr; }
  .footer-inner { flex-wrap: wrap; }
  .nav-buttons { width: 100%; }
  .nav-buttons .btn { flex: 1; }
  .photo-reelle-shot img { height: 130px; }
}

@media (min-width: 961px) {
  .visual-panel:fullscreen .three-wrap,
  .three-wrap:fullscreen {
    height: 100%;
    max-height: none;
  }
}
