/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #F7F7F5;
  --surface:    #FFFFFF;
  --border:     #E4E4DF;
  --border2:    #D0CFC9;
  --text:       #1A1A1A;
  --text2:      #6B6B6B;
  --text3:      #9B9B9B;
  --accent:     #1D4ED8;
  --accent-dk:  #1E3A8A;
  --accent-lt:  #EFF6FF;
  --red:        #DC2626;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.logo-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.header-nav { display: flex; align-items: center; gap: 20px; }
.header-nav a { font-size: 13px; color: var(--text2); text-decoration: none; }
.header-nav a:hover { color: var(--text); }
.nav-cta {
  padding: 6px 14px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text) !important;
  font-weight: 500;
}

/* ── Configurator Layout ── */
.configurator {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* ── 3D Viewer ── */
.viewer-panel { display: flex; flex-direction: column; gap: 8px; }

.canvas-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
  min-height: 380px;
  box-shadow: var(--shadow);
}
.canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.viewer-hint {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text2);
  background: rgba(255,255,255,.85);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  pointer-events: none;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition: opacity .5s;
}
.viewer-hint.hidden { opacity: 0; }

.view-btns {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 6px;
}
.vbtn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: rgba(255,255,255,.9);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  color: var(--text2);
  backdrop-filter: blur(4px);
  transition: all .15s;
}
.vbtn:hover { background: #fff; color: var(--text); }
.vbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Loader */
.loader-overlay {
  position: absolute; inset: 0;
  background: var(--surface);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  z-index: 10;
  transition: opacity .4s;
}
.loader-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 13px; color: var(--text2); }

.model-credit { font-size: 11px; color: var(--text3); padding-left: 2px; }
.model-credit a { color: var(--text3); }
.model-credit a:hover { color: var(--text2); }

/* ── Controls Panel ── */
.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}

.ctrl-section { padding: 14px 16px; }
.ctrl-head {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
}
.divider { height: 1px; background: var(--border); }

/* Zones */
.zones-list { display: flex; flex-direction: column; gap: 5px; }
.zone-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .13s;
  background: transparent;
  width: 100%;
  text-align: left;
}
.zone-btn:hover { background: var(--bg); }
.zone-btn.active { border-color: var(--accent); background: var(--accent-lt); }
.zone-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.12);
  flex-shrink: 0;
  transition: background .15s;
}
.zone-label { font-size: 13px; color: var(--text); }

/* Swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: all .12s;
  flex-shrink: 0;
}
.swatch:hover { transform: scale(1.2); }
.swatch.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); transform: scale(1.15); }

.hex-row { display: flex; align-items: center; gap: 6px; }
.hex-label { font-size: 11px; color: var(--text3); white-space: nowrap; }
.hex-input {
  flex: 1;
  height: 30px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0 8px;
  font-size: 12px;
  font-family: monospace;
  color: var(--text);
  min-width: 0;
}
.hex-input:focus { outline: none; border-color: var(--accent); }
.hex-apply {
  padding: 0 10px; height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg);
  font-size: 12px; cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.hex-apply:hover { background: var(--border); }

/* Size Grid */
.size-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.size-btn {
  padding: 6px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text2);
  background: transparent;
  transition: all .12s;
}
.size-btn:hover { background: var(--bg); color: var(--text); }
.size-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-lt);
  font-weight: 600;
}

/* Quantity */
.qty-row { display: flex; align-items: center; gap: 8px; }
.qty-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  cursor: pointer;
  font-size: 18px; font-weight: 300;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.qty-btn:hover { background: var(--bg); }
.qty-val { font-size: 15px; font-weight: 600; min-width: 28px; text-align: center; }
.qty-unit { font-size: 12px; color: var(--text3); }

/* CTA Block */
.cta-block { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.btn-primary {
  width: 100%; padding: 11px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dk); }
.cta-row-2 { display: flex; gap: 6px; }
.btn-secondary {
  flex: 1; padding: 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text);
  font-size: 13px; cursor: pointer;
  transition: background .12s;
}
.btn-secondary:hover { background: var(--bg); }

/* ── Modal ── */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-bg.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-md);
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-bg.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 16px; cursor: pointer;
  color: var(--text2); padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 0; }
.modal-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.modal-row:last-child { border: none; }
.modal-row-label { color: var(--text2); }
.modal-row-value { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.modal-swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.1);
  flex-shrink: 0;
}
.modal-footer {
  display: flex; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.btn-ghost {
  flex: 1; padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text);
  font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { background: var(--bg); }
.modal-footer .btn-primary { flex: 1.5; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111;
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 300;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .configurator {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
  .controls-panel { order: -1; }
  .canvas-wrap { aspect-ratio: 16/10; min-height: 300px; }
}
@media (max-width: 480px) {
  .header-nav a:not(.nav-cta) { display: none; }
  .canvas-wrap { min-height: 260px; }
}
