/* ═══════════════════════════════════════════════════════════════
   KANDELA FRAME DESIGNER — designer.css
   Fullscreen split layout: 3D viewport left, control panel right
═══════════════════════════════════════════════════════════════ */

/* ── Reset for designer body ──────────────────────────────────── */
.designer-body {
  background: var(--bg);
  overflow: hidden;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── App shell ────────────────────────────────────────────────── */
#designer-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Header bar ────────────────────────────────────────────────── */
.dsgn-header {
  height: 54px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1.5rem;
  z-index: 100;
}
.dsgn-home-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}
.dsgn-home-link .logo-mark { width: 30px; height: 30px; font-size: 1.1rem; }
.dsgn-home-link .logo-name { font-size: 0.95rem; }
.dsgn-home-link .logo-sub  { font-size: 0.46rem; }

/* ── Step indicator ────────────────────────────────────────────── */
.dsgn-steps {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  justify-content: center;
}
.dsgn-step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  opacity: 0.4;
}
.dsgn-step.active, .dsgn-step.done { opacity: 1; }
.dsgn-step.done { cursor: pointer; }
.dsgn-step:not(.done):not(.active) { pointer-events: none; }

.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border-m);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--fg-3);
  transition: all 0.3s;
  flex-shrink: 0;
}
.dsgn-step.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--fg-dark);
}
.dsgn-step.done .step-num {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--fg);
}
.step-lbl {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.step-connector {
  width: 24px; height: 1px;
  background: var(--border-m);
  flex-shrink: 0;
}

.dsgn-header-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

/* ── Main layout ───────────────────────────────────────────────── */
.dsgn-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── 3D Viewport ───────────────────────────────────────────────── */
.dsgn-viewport {
  flex: 1;
  position: relative;
  background: var(--bg);
  overflow: hidden;
  min-width: 0;
}
#dsgnCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#dsgnCanvas:active { cursor: grabbing; }

.viewport-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.vp-btn {
  width: 34px; height: 34px;
  background: rgba(10,10,14,0.82);
  border: 1px solid var(--border-m);
  backdrop-filter: blur(8px);
  color: var(--fg-2);
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.vp-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.vp-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow2); }

.dsgn-dims {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 1rem;
  background: rgba(10,10,14,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  border-radius: 2px;
}
.dim-item { display: flex; flex-direction: column; gap: 0.1rem; align-items: center; }
.dim-lbl { font-family: var(--font-mono); font-size: 0.52rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3); }
.dim-val { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); }

.vp-drag-hint {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  background: rgba(10,10,14,0.7);
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
  border-radius: 2px;
  pointer-events: none;
  transition: opacity 0.8s;
}

/* ── Side panel ────────────────────────────────────────────────── */
.dsgn-panel {
  width: 360px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
/* Scrollbar */
.dsgn-panel::-webkit-scrollbar { width: 4px; }
.dsgn-panel::-webkit-scrollbar-track { background: transparent; }
.dsgn-panel::-webkit-scrollbar-thumb { background: var(--border-m); border-radius: 2px; }

/* ── Panel steps — animated transitions ─────────────────────────── */
.panel-step {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 1.5rem 1.25rem 1rem;
  animation: panelIn 0.35s var(--ease-out) both;
}
.panel-step.active { display: flex; }

@keyframes panelIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes panelOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-24px); }
}

.panel-header { margin-bottom: 1.25rem; }
.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
  color: var(--fg);
}
.panel-header p {
  font-size: 0.82rem;
  color: var(--fg-2);
  line-height: 1.65;
}

.panel-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  border-top: 1px solid var(--border);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.dsgn-btn-primary {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: var(--fg-dark);
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  border: none; border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  white-space: nowrap;
}
.dsgn-btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.dsgn-btn-primary:active { transform: translateY(0); }
.dsgn-btn-primary--submit { flex: 1; justify-content: center; }

.dsgn-btn-ghost {
  display: inline-flex; align-items: center;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--border-m);
  color: var(--fg-2);
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
  background: none; white-space: nowrap;
  text-decoration: none;
}
.dsgn-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.dsgn-btn-outline {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: none; border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.dsgn-btn-outline:hover { background: var(--accent); color: var(--fg-dark); }
.dsgn-btn--xs { padding: 0.35rem 0.7rem; font-size: 0.62rem; }

/* ── Preset grid ───────────────────────────────────────────────── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.preset-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.preset-card:hover { border-color: var(--accent-dim); background: var(--surface-2); }
.preset-card.active { border-color: var(--accent); background: var(--accent-glow2); }
.preset-card:active { transform: scale(0.97); }
.preset-icon {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
}
.preset-icon--blank {
  border: 1.5px dashed var(--border-m);
  border-radius: 2px;
  color: var(--fg-3); font-size: 1.5rem;
}
.preset-canvas { display: block; }
.preset-name {
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--fg-2);
}
.preset-card.active .preset-name { color: var(--accent); }

/* ── Ring list ─────────────────────────────────────────────────── */
.ring-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.2rem;
}
.ring-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s;
  animation: ringItemIn 0.25s var(--ease-out) both;
}
@keyframes ringItemIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ring-item.selected { border-color: var(--accent); }
.ring-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ring-item-label {
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); flex: 1;
}
.ring-item-delete {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-3);
  font-size: 0.9rem;
  border: none; background: none;
  cursor: pointer; border-radius: 2px;
  transition: color 0.2s, background 0.2s;
}
.ring-item-delete:hover { color: #e05050; background: rgba(200,80,80,0.1); }
.ring-item-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.ring-param { display: flex; flex-direction: column; gap: 0.2rem; }
.ring-param label {
  font-family: var(--font-mono); font-size: 0.55rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-3);
}
.ring-param input {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--fg); padding: 0.35rem 0.5rem;
  font-family: var(--font-mono); font-size: 0.75rem;
  border-radius: 2px; width: 100%;
  transition: border-color 0.2s; outline: none;
}
.ring-param input:focus { border-color: var(--accent); }
.angle-row {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.ring-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.ring-count-label {
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3);
}

/* ── Param sections ────────────────────────────────────────────── */
.param-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.param-section:last-child { border-bottom: none; }
.param-section-title {
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-2); margin-bottom: 0.75rem;
  display: flex; align-items: center; justify-content: space-between;
}
.reset-angles-btn {
  font-family: var(--font-mono); font-size: 0.58rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-3); background: none; border: 1px solid var(--border);
  padding: 0.2rem 0.55rem; border-radius: 2px; cursor: pointer;
  transition: all 0.2s;
}
.reset-angles-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.param-hint { font-size: 0.78rem; color: var(--fg-3); margin-bottom: 0.75rem; line-height: 1.55; }

/* ── Sliders ───────────────────────────────────────────────────── */
.slider-row {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.dsgn-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.dsgn-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-2);
  box-shadow: 0 0 0 2px var(--accent-glow);
  cursor: grab;
  transition: box-shadow 0.2s;
}
.dsgn-slider::-webkit-slider-thumb:active { cursor: grabbing; box-shadow: 0 0 0 4px var(--accent-glow); }
.dsgn-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-2);
  cursor: grab;
}
.slider-val {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--accent); min-width: 40px; text-align: right;
}
.slider-labels {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.5rem;
  letter-spacing: 0.06em; color: var(--fg-3);
}

/* Compact slider for rib angles */
.rib-angle-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  animation: ringItemIn 0.2s var(--ease-out) both;
}
.rib-angle-row:last-child { border-bottom: none; }
.rib-angle-num {
  font-family: var(--font-mono); font-size: 0.58rem;
  color: var(--fg-3); min-width: 28px;
}
.rib-angle-row .dsgn-slider { height: 2px; }
.rib-angle-val {
  font-family: var(--font-mono); font-size: 0.62rem;
  color: var(--fg-2); min-width: 36px; text-align: right;
}
.rib-angle-list { max-height: 200px; overflow-y: auto; padding-right: 0.2rem; }

/* ── Rib count picker ──────────────────────────────────────────── */
.rib-count-picker {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.rib-count-opt {
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--fg-2);
  cursor: pointer;
  transition: all 0.15s;
  min-width: 36px; text-align: center;
}
.rib-count-opt:hover { border-color: var(--accent-dim); color: var(--fg); }
.rib-count-opt.active { background: var(--accent); border-color: var(--accent); color: var(--fg-dark); }

/* ── Radio groups ──────────────────────────────────────────────── */
.radio-group {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.radio-card {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.radio-card:hover { border-color: var(--accent-dim); }
.radio-card input { display: none; }
.radio-card:has(input:checked) { background: var(--accent-glow2); border-color: var(--accent); }
.radio-label {
  font-family: var(--font-mono); font-size: 0.64rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2);
}
.radio-card:has(input:checked) .radio-label { color: var(--accent); }

/* ── Inputs ────────────────────────────────────────────────────── */
.dsgn-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.65rem 0.85rem;
  font-family: var(--font-body); font-size: 0.88rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.dsgn-input:focus { border-color: var(--accent); }
.dsgn-input::placeholder { color: var(--fg-3); }
.dsgn-input--hex { width: 100px; font-family: var(--font-mono); font-size: 0.75rem; }
.dsgn-input option { background: var(--surface); }
.input-label {
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2);
  margin-bottom: 0.35rem; display: block;
}
.input-row { display: flex; flex-direction: column; gap: 0.35rem; }

/* ── Coating toggle ────────────────────────────────────────────── */
.coating-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0;
}
.coating-toggle-label {
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg);
}
.toggle-switch { position: relative; cursor: pointer; }
.toggle-switch input { display: none; }
.toggle-track {
  display: block; width: 40px; height: 22px;
  background: var(--surface-2); border: 1px solid var(--border-m);
  border-radius: 11px; position: relative;
  transition: background 0.3s, border-color 0.3s;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent-dim); border-color: var(--accent);
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--fg-3);
  transition: transform 0.3s var(--ease-spring), background 0.3s;
}
.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px); background: var(--accent);
}

.coating-options {
  animation: panelIn 0.3s var(--ease-out) both;
}

/* ── Colour picker ─────────────────────────────────────────────── */
.custom-colour-row {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.colour-picker-native {
  width: 32px; height: 32px;
  border: 1px solid var(--border-m); border-radius: 2px;
  padding: 0; background: none;
  cursor: pointer; flex-shrink: 0;
}
.colour-family-tabs {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  margin-bottom: 0.75rem;
}
.colour-family-tab {
  padding: 0.3rem 0.6rem;
  font-family: var(--font-mono); font-size: 0.58rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--fg-3); border-radius: 2px; cursor: pointer;
  transition: all 0.15s;
}
.colour-family-tab:hover { color: var(--fg); border-color: var(--border-m); }
.colour-family-tab.active { background: var(--accent-glow2); border-color: var(--accent); color: var(--accent); }

.colour-swatch-picker {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 3px; margin-bottom: 0.75rem;
}
.cswatch {
  aspect-ratio: 1; border-radius: 2px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.cswatch:hover { transform: scale(1.15); z-index: 1; }
.cswatch.selected { border-color: var(--fg); transform: scale(1.1); }

.selected-colour-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 2px;
}
.selected-swatch {
  width: 28px; height: 28px; border-radius: 2px;
  border: 1px solid var(--border-m); flex-shrink: 0;
}
.selected-colour-name { display: block; font-size: 0.82rem; color: var(--fg); }
.selected-colour-hex {
  font-family: var(--font-mono); font-size: 0.64rem;
  color: var(--fg-3); letter-spacing: 0.06em;
}

/* ── Quote form ────────────────────────────────────────────────── */
.quote-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  border-radius: 2px;
}
.quote-summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.8rem; line-height: 1.8;
}
.quote-summary-row .qs-label { color: var(--fg-3); font-size: 0.72rem; }
.quote-summary-row .qs-val { color: var(--fg); font-family: var(--font-mono); font-size: 0.72rem; }

.form-section-title {
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin: 1rem 0 0.75rem;
}
.form-row { display: grid; gap: 0.65rem; margin-bottom: 0.65rem; }
.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-footer {
  display: flex; gap: 0.75rem; align-items: center;
  margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Success panel ─────────────────────────────────────────────── */
.success-panel {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2rem 1.5rem;
  animation: successIn 0.5s var(--ease-out) both;
}
@keyframes successIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.success-icon { margin-bottom: 1.25rem; }
.success-check {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: checkDraw 0.6s 0.3s var(--ease-out) forwards;
}
@keyframes checkDraw {
  to { stroke-dashoffset: 0; }
}
.success-panel h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.success-ref {
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.1em; color: var(--accent);
  margin-bottom: 1rem;
}
.success-panel > p { font-size: 0.88rem; color: var(--fg-2); max-width: 280px; line-height: 1.7; margin-bottom: 1.75rem; }
.success-actions { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; max-width: 240px; }
.success-actions .dsgn-btn-primary, .success-actions .dsgn-btn-ghost { justify-content: center; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dsgn-layout { flex-direction: column; }
  .dsgn-viewport { flex: none; height: 45dvh; min-height: 260px; }
  .dsgn-panel {
    width: 100%; flex: 1;
    border-left: none; border-top: 1px solid var(--border);
  }
  .step-lbl { display: none; }
  .step-connector { width: 14px; }
}
@media (max-width: 600px) {
  .dsgn-header { padding: 0 0.75rem; gap: 0.75rem; }
  .dsgn-panel { padding: 0; }
  .panel-step { padding: 1rem; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
  .form-row--2 { grid-template-columns: 1fr; }
  .dsgn-dims { flex-wrap: wrap; gap: 0.5rem; }
}

/* ── Environment panel ─────────────────────────────────────────── */
.env-panel {
  position: absolute;
  top: 0;
  right: 56px; /* sits left of viewport controls */
  width: 240px;
  background: rgba(8, 8, 12, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-m);
  border-radius: 3px;
  padding: 0.9rem;
  z-index: 50;
  animation: envPanelIn 0.2s var(--ease-out) both;
}
@keyframes envPanelIn {
  from { opacity: 0; transform: translateX(8px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0)   scale(1); }
}
.env-panel-title {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.env-section-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 0.4rem;
}

/* Background swatches */
.env-bg-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 0.85rem;
}
.env-swatch {
  width: 26px; height: 26px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}
.env-swatch:hover   { transform: scale(1.12); }
.env-swatch.active  { border-color: var(--accent); transform: scale(1.08); }

/* Mode buttons */
.env-mode-btns {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.env-mode-btn {
  flex: 1;
  padding: 0.38rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-3);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.env-mode-btn:hover  { color: var(--fg); border-color: var(--border-m); }
.env-mode-btn.active { background: var(--accent-glow2); border-color: var(--accent); color: var(--accent); }

/* Fabric swatches */
.env-fabric-options { animation: envPanelIn 0.2s var(--ease-out) both; }
.env-fabric-swatches {
  display: flex;
  gap: 5px;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.env-fswatch {
  width: 30px; height: 30px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}
.env-fswatch:hover  { transform: scale(1.1); }
.env-fswatch.active { border-color: var(--accent); }

/* Auto-rotate button active state — override generic .vp-btn.active colour */
#btnAutoRotate.active { color: var(--accent); border-color: var(--accent); }

/* ════════════════════════════════════════════════════════════════
   DESIGNER LIGHT MODE OVERRIDES
════════════════════════════════════════════════════════════════ */
html[data-theme="light"] .designer-body    { background: var(--bg); }
html[data-theme="light"] .dsgn-header      { background: var(--bg-2); }
html[data-theme="light"] .dsgn-panel       { background: var(--bg-2); }
html[data-theme="light"] .dsgn-viewport    { background: #e0ddd6; }
html[data-theme="light"] .ring-item        { background: var(--surface); }
html[data-theme="light"] .preset-card      { background: var(--surface); }
html[data-theme="light"] .preset-card.active { background: var(--accent-glow2); }
html[data-theme="light"] .service-card,
html[data-theme="light"] .rib-count-opt    { background: var(--surface); }
html[data-theme="light"] .radio-card       { background: var(--surface); }
html[data-theme="light"] .dsgn-input       { background: var(--surface); color: var(--fg); }
html[data-theme="light"] .ring-param input { background: var(--bg-2); color: var(--fg); }
html[data-theme="light"] .quote-summary    { background: var(--surface); }
html[data-theme="light"] .vp-btn           { background: rgba(240,237,232,0.9); color: var(--fg-2); }
html[data-theme="light"] .dsgn-dims        { background: rgba(240,237,232,0.92); }
html[data-theme="light"] .vp-drag-hint     { background: rgba(240,237,232,0.85); }
html[data-theme="light"] .env-panel        { background: rgba(245,244,241,0.96); }

/* Selected vertex panel light mode */
html[data-theme="light"] .vertex-panel     { background: var(--surface); border-color: var(--border-m); }
html[data-theme="light"] .vertex-panel-title { color: var(--fg); }

/* ════════════════════════════════════════════════════════════════
   VERTEX SELECTION PANEL
   Floats over the viewport, bottom-left, slides in on selection
════════════════════════════════════════════════════════════════ */
.vertex-panel {
  position: fixed;
  bottom: 1.25rem;
  left: 1rem;
  width: 300px;
  max-height: calc(100dvh - 80px);
  background: rgba(10, 10, 14, 0.93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-m);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: vertexPanelIn 0.28s var(--ease-out) both;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
@keyframes vertexPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}

.vertex-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.vertex-panel-title {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.vertex-panel-close {
  width: 22px; height: 22px;
  background: none; border: none;
  color: var(--fg-3); font-size: 1rem;
  cursor: pointer; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.vertex-panel-close:hover { color: var(--fg); background: var(--surface-2); }

.vertex-panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 0.75rem 0.85rem;
}
.vertex-panel-body::-webkit-scrollbar { width: 3px; }
.vertex-panel-body::-webkit-scrollbar-thumb { background: var(--border-m); }

.vertex-type-row {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-2);
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: 0.85rem;
}

.vertex-section {
  margin-bottom: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.vertex-section:last-child { border-bottom: none; padding-bottom: 0; }
.vertex-section-label {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 0.55rem;
}
.vertex-ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.vertex-ctrl label {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: block;
  margin-bottom: 0.3rem;
}
.vertex-input-row {
  display: flex;
  gap: 0.3rem;
  align-items: stretch;
}
.vertex-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.4rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.vertex-input:focus { border-color: var(--accent); }
.vertex-nudge-btns {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.vnudge {
  flex: 1;
  padding: 0 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 0.56rem;
  cursor: pointer;
  border-radius: 1px;
  transition: all 0.15s;
  white-space: nowrap;
}
.vnudge:hover { background: var(--accent); color: var(--fg-dark); border-color: var(--accent); }
.vnudge:active { transform: scale(0.95); }

/* Rib angle rows inside vertex panel */
.vertex-rib-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}
.vertex-rib-row:last-child { border-bottom: none; }
.vertex-rib-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--fg-3);
  min-width: 32px;
}
.vertex-rib-row .dsgn-slider { flex: 1; height: 2px; }
.vertex-rib-val {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--accent);
  min-width: 34px;
  text-align: right;
}

/* Strut length rows */
.vertex-strut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.vertex-strut-row:last-child { border-bottom: none; }
.vertex-strut-label { color: var(--fg-2); font-size: 0.75rem; }
.vertex-strut-val   { font-family: var(--font-mono); color: var(--accent); font-size: 0.7rem; }

/* Vertex markers in 3D (visual hint via CSS — actual markers are Three.js meshes) */
/* Selection highlight pulse — applied as a class on the hit mesh via userData */
@keyframes vertexPulse {
  0%, 100% { opacity: 0.9; }
  50%       { opacity: 0.5; }
}

/* ── Selection mode indicator ──────────────────────────────────── */
#btnSelectionMode.active {
  color: #7dd4a0;
  border-color: #3d9e6e;
  background: rgba(61,158,110,0.15);
}
/* Crosshair cursor override when in selection mode */
.selection-mode-active #dsgnCanvas {
  cursor: crosshair !important;
}
/* Pulse ring marker (CSS-level glow complement to JS scale pulse) */
.vp-selection-hint {
  position: absolute;
  top: calc(1rem + 5 * 38px + 5 * 4px + 0.5rem); /* below the 5 buttons */
  right: 1rem;
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3d9e6e;
  background: rgba(10,10,14,0.82);
  border: 1px solid rgba(61,158,110,0.4);
  padding: 0.3rem 0.55rem;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.selection-mode-active .vp-selection-hint { opacity: 1; }

/* ── Fullscreen preview button ─────────────────────────────────── */
.env-fullscreen-btn {
  display: none; /* shown via JS when room mode active */
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(200,169,110,0.12);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.env-fullscreen-btn:hover { background: var(--accent); color: var(--fg-dark); }

/* Fullscreen viewport tweaks */
.dsgn-viewport:fullscreen,
.dsgn-viewport:-webkit-full-screen {
  background: #0a0804;
}
.dsgn-viewport:fullscreen #dsgnCanvas,
.dsgn-viewport:-webkit-full-screen #dsgnCanvas {
  width: 100vw;
  height: 100vh;
}

/* ── Scene preview buttons ─────────────────────────────────────── */
.env-scene-btns {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.env-scene-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}
.env-scene-btn:hover { border-color: var(--accent-dim); color: var(--fg); background: var(--surface-2); }
.env-scene-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow2); }
.env-scene-icon { font-size: 1rem; flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════════
   AI PREVIEW — env panel section + modal
════════════════════════════════════════════════════════════════ */

/* Divider above AI section */
.env-ai-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem -0.9rem;
}

/* AI section in env panel */
.env-ai-section { padding: 0.1rem 0 0.2rem; }
.env-ai-desc {
  font-size: 0.72rem;
  color: var(--fg-3);
  line-height: 1.55;
  margin-bottom: 0.75rem;
}
.env-ai-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  border: none;
  color: var(--fg-dark);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  justify-content: center;
}
.env-ai-btn:hover  { opacity: 0.9; transform: translateY(-1px); }
.env-ai-btn:active { transform: translateY(0); }
.env-ai-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.env-ai-note {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  min-height: 1rem;
  text-align: center;
}

/* ── AI Modal ──────────────────────────────────────────────── */
.ai-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ai-modal-panel {
  position: relative;
  z-index: 1;
  width: min(680px, 96vw);
  max-height: 90dvh;
  background: var(--bg-2);
  border: 1px solid var(--border-m);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  animation: aiModalIn 0.32s var(--ease-out) both;
}
@keyframes aiModalIn {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.ai-modal-header {
  padding: 1rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.ai-modal-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--fg);
  flex: 1;
}
.ai-modal-subtitle {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.ai-modal-close {
  margin-left: auto;
  width: 26px; height: 26px;
  background: none; border: none;
  color: var(--fg-3); font-size: 1.2rem;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  border-radius: 2px; transition: color 0.2s, background 0.2s;
}
.ai-modal-close:hover { color: var(--fg); background: var(--surface-2); }

/* Image area */
.ai-image-area {
  flex: 1;
  min-height: 300px;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Loading */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2.5rem;
  text-align: center;
  max-width: 400px;
}
.ai-spinner svg {
  animation: aiSpin 1.2s linear infinite;
}
@keyframes aiSpin {
  to { transform: rotate(360deg); }
}
.ai-loading-text p { font-size: 0.92rem; color: var(--fg-2); }
.ai-loading-sub {
  font-family: var(--font-mono);
  font-size: 0.6rem !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3) !important;
  margin-top: 0.3rem;
}
.ai-prompt-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--fg-3);
  line-height: 1.6;
  letter-spacing: 0.04em;
  max-height: 80px;
  overflow: hidden;
  text-align: left;
  width: 100%;
  position: relative;
}
.ai-prompt-preview::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 24px;
  background: linear-gradient(transparent, var(--surface));
}

/* Result */
.ai-result {
  width: 100%; height: 100%;
  position: relative;
}
.ai-result-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  animation: aiFadeIn 0.5s ease both;
}
@keyframes aiFadeIn {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: scale(1); }
}
.ai-result-overlay {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
}
.ai-result-badge {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  padding: 0.3rem 0.6rem;
  border-radius: 2px;
}

/* Error */
.ai-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem;
}
.ai-error p { font-size: 0.9rem; color: var(--fg-2); text-align: center; }

/* Footer */
.ai-modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ai-footer-left { display: flex; flex-direction: column; gap: 0.2rem; }
.ai-scene-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.ai-frame-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--fg-3);
}
.ai-footer-right { display: flex; gap: 0.6rem; align-items: center; }

/* Light mode overrides */
html[data-theme="light"] .ai-modal-panel { background: var(--bg-light); }
html[data-theme="light"] .ai-image-area  { background: var(--bg-light-2); }
html[data-theme="light"] .ai-prompt-preview { background: var(--surface); }
html[data-theme="light"] .ai-prompt-preview::after { background: linear-gradient(transparent, var(--surface)); }

/* ── AI disclaimer ─────────────────────────────────────────── */
.ai-disclaimer {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 1.25rem 0.9rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.ai-disclaimer svg {
  flex-shrink: 0;
  color: var(--fg-3);
  margin-top: 0.15rem;
}
.ai-disclaimer p {
  font-size: 0.7rem;
  line-height: 1.55;
  color: var(--fg-3);
  margin: 0;
}
