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

html, body, #root { height: 100%; }

body {
  font-family: "Montserrat", "Gotham", "Helvetica Neue", Arial, sans-serif;
  background: #ffffff;
  color: #111;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-top: 2px solid #3a3a3a;
}

/* ---------- Header ---------- */
.header {
  flex: 0 0 auto;
  text-align: center;
  padding: 30px 16px 0;
  background: #fff;
  box-shadow: 0 6px 10px -8px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 3;
}

.title {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: #1a1a1a;
  margin-bottom: 26px;
}

.tabs {
  display: inline-flex;
  gap: 6px;
  padding-bottom: 28px;
}

.tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 12px 20px 11px;
  border: 0;
  background: transparent;
  color: #111;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: background 0.2s, color 0.2s;
}

.tab.active { border-bottom-color: #111; }
.tab:not(.active) {
  background: #f1f1f1;
  color: #9a9a9a;
  font-weight: 500;
}
.tab:not(.active):hover { color: #444; }

/* ---------- Stage ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  min-height: 420px;
  overflow: hidden;
}

.panel {
  position: relative;
  flex: 0 0 210px;
  width: 210px;
  background: #fff;
  border-right: 1px solid #e3e3e3;
  padding: 18px 15px 20px;
  overflow-y: auto;
  transition: margin-left 0.35s ease;
  z-index: 2;
}
.panel.collapsed { margin-left: -210px; }

.section { margin-bottom: 22px; }

.section h4 {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 14px;
  color: #111;
}

.swatches { display: flex; gap: 16px; }

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  color: #222;
}

.swatch .dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #9c9c9c;
  box-shadow: inset 0 0 0 0 #fff;
  transition: box-shadow 0.2s, transform 0.2s;
}
.swatch:hover .dot { transform: scale(1.06); }
.swatch.active .dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #c9c9c9; }

.variant-btn {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 6px 4px;
  margin-bottom: 7px;
  background: #fff;
  color: #111;
  border: 1.5px solid #333;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.variant-btn:hover { background: #f3f3f3; }
.variant-btn.active { background: #000; color: #fff; border-color: #000; }

.toggle { display: flex; gap: 5px; }
.toggle button {
  flex: 1;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 4px;
  background: #fff;
  color: #111;
  border: 1.5px solid #333;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.toggle button.active { background: #000; color: #fff; border-color: #000; }
.toggle button:disabled { opacity: 0.45; cursor: default; }

.collapse-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 210px;
  width: 24px;
  height: 32px;
  border: 0;
  background: #fff;
  border-radius: 0 2px 2px 0;
  box-shadow: 1px 0 3px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.35s ease;
}
.collapse-btn.collapsed { left: 0; }
.collapse-btn svg { transition: transform 0.35s ease; }
.collapse-btn.collapsed svg { transform: rotate(180deg); }

.viewport { position: relative; flex: 1 1 auto; min-width: 0; }

#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
  cursor: grab;
}
#renderCanvas:active { cursor: grabbing; }

/* ---------- URBANIA loader ---------- */
.urb-loader {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 10;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.urb-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.urb-loader-inner {
  position: absolute;
  left: 0;
  right: 0;
  top: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.urb-logo { width: 212px; max-width: 60vw; height: auto; display: block; }

.urb-track {
  --van-w: 101px;
  position: relative;
  width: 100%;
  height: 43px;
  margin-top: 13px;
}

/* Line runs from the left edge to under the van's middle */
.urb-line {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: #111;
  width: calc((100% - var(--van-w)) * var(--p) / 100 + var(--van-w) * 0.4);
  transition: width 0.6s ease-out;
}

.urb-van {
  position: absolute;
  bottom: 1px;
  width: var(--van-w);
  height: auto;
  left: calc((100% - var(--van-w)) * var(--p) / 100);
  transition: left 0.6s ease-out;
  animation: urb-bob 0.5s ease-in-out infinite alternate;
}

@keyframes urb-bob {
  from { transform: translateY(0); }
  to { transform: translateY(-1px); }
}

.urb-error {
  margin-top: 22px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #333;
}

.hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .title { font-size: 20px; margin-bottom: 16px; }
  .header { padding-top: 18px; }
  .tabs { padding-bottom: 14px; }
  .stage { flex-direction: column-reverse; }
  .panel, .panel.collapsed {
    margin-left: 0;
    width: 100%;
    flex: 0 0 auto;
    border-right: 0;
    border-top: 1px solid #e3e3e3;
    padding: 14px 16px;
    max-height: 42%;
  }
  .collapse-btn { display: none; }
  .viewport { min-height: 300px; }
}
