*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding: 0; }

/* ── Root ─────────────────────────────────────────────────────────────────── */
#zb-root {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #f0f0f0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.zb-header {
  background: #2c2c2c;
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  flex-shrink: 0;
}

.zb-back-btn {
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin: -8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.15s;
}
.zb-back-btn:hover { background: rgba(255,255,255,0.12); }
.zb-back-btn svg { display: block; }

.zb-title {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  margin: 0;
  color: white;
}

.zb-view-tabs {
  display: flex;
  gap: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 3px;
}

.zb-view-tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.zb-view-tab.active {
  background: white;
  color: #2c2c2c;
}

/* ── Body ─────────────────────────────────────────────────────────────────── */
.zb-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  .zb-body {
    flex-direction: row;
    align-items: stretch;
  }
}

/* ── Canvas ───────────────────────────────────────────────────────────────── */
#zb-canvas-wrap {
  position: relative;
  height: 60dvh;
  flex-shrink: 0;
  background: #e8e8e8;
  overflow: hidden;
}

@media (min-width: 768px) {
  #zb-canvas-wrap {
    flex: 1;
    height: 100%;
    flex-shrink: 1;
  }
}

#zb-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#zb-empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#zb-empty-hint span {
  background: rgba(0,0,0,0.35);
  color: white;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 20px;
}

#zb-canvas-hint {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.3);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 12px;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.zb-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.zb-sidebar::-webkit-scrollbar { display: none; }

@media (min-width: 768px) {
  .zb-sidebar {
    flex: none;
    width: 300px;
    height: 100%;
    border-left: 1px solid #ddd;
    background: #f0f0f0;
  }
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.zb-card {
  background: white;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.zb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.zb-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
}

/* ── Step card ────────────────────────────────────────────────────────────── */
.zb-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.zb-step-counter {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a1a;
}
.zb-step-progress {
  height: 4px;
  background: #f0f0f0;
  border-radius: 2px;
  overflow: hidden;
}
.zb-step-bar {
  height: 100%;
  background: #2c2c2c;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.zb-step-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zb-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a1a;
  flex-shrink: 0;
  transition: background 0.15s;
}
.zb-icon-btn:hover:not(:disabled) { background: #eaeaea; }
.zb-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.zb-play-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #2c2c2c;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  height: 34px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.zb-play-btn:hover:not(:disabled) { opacity: 0.8; }
.zb-play-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.zb-step-desc {
  font-size: 12px;
  color: #888;
  margin: 0;
  line-height: 1.5;
}

/* ── Seg control ──────────────────────────────────────────────────────────── */
.zb-seg {
  display: flex;
  gap: 2px;
  background: #f0f0f0;
  border-radius: 6px;
  padding: 2px;
}
.zb-seg-btn {
  flex: 1;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: #999;
  padding: 5px 2px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.zb-seg-btn.active {
  background: white;
  color: #1a1a1a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ── Depth legend ─────────────────────────────────────────────────────────── */
.zb-depth-legend { gap: 8px; }
.zb-legend-bar {
  height: 16px;
  border-radius: 6px;
  background: linear-gradient(to right, #fff, #000);
  border: 1px solid #e0e0e0;
}
.zb-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #999;
}
.zb-legend-desc {
  font-size: 12px;
  color: #888;
  margin: 0;
  line-height: 1.5;
}

/* ── Shapes actions ───────────────────────────────────────────────────────── */
.zb-shapes-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.zb-clear-btn {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.zb-clear-btn:hover { color: #e74c3c; border-color: #e74c3c; }

.zb-add-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #2c2c2c;
  color: white;
  border: none;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.zb-add-btn:hover { opacity: 0.8; }

/* ── Shapes card ──────────────────────────────────────────────────────────── */
.zb-shapes-card {
  flex: 1;
  min-height: 160px;
  overflow: hidden;
}
.zb-shapes-card .zb-shapes-list {
  overflow-y: auto;
  scrollbar-width: none;
  max-height: 100%;
}
.zb-shapes-card .zb-shapes-list::-webkit-scrollbar { display: none; }

.zb-empty-shapes {
  font-size: 13px;
  color: #bbb;
  margin: 0;
  text-align: center;
  padding: 8px 0;
}

.zb-shapes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zb-shape-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1.5px solid transparent;
}
.zb-shape-row:hover { background: #f8f8f8; }
.zb-shape-row.selected { background: #f5f5f5; border-color: #e5e5e5; }

.zb-shape-swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.zb-shape-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.zb-shape-name {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}
.zb-shape-depth {
  font-size: 11px;
  color: #999;
  font-variant-numeric: tabular-nums;
}

.zb-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.zb-delete-btn:hover { color: #e74c3c; background: #fff0ee; }

/* ── Edit card ────────────────────────────────────────────────────────────── */
.zb-shape-controls { gap: 12px; }

.zb-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #999;
}

.zb-ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zb-ctrl-label {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.zb-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
}
.zb-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #2c2c2c;
  cursor: pointer;
  flex-shrink: 0;
}

.zb-ctrl-value {
  font-weight: 500;
  color: #999;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ── Custom color swatch (edit card) ──────────────────────────────────────── */
.zb-custom-swatch-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.zb-custom-swatch-wrap .cp-root {
  display: flex;
}

.zb-custom-swatch-wrap .cp-trigger {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid transparent;
  box-shadow: none;
}

.zb-custom-swatch-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e5e5e5;
  pointer-events: none;
  filter: drop-shadow(0 0 1.5px rgba(0,0,0,0.6));
}

/* ── Preset colors ────────────────────────────────────────────────────────── */
.zb-preset-colors {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.zb-preset-swatch {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.12s;
}
.zb-preset-swatch:hover { transform: scale(1.04); }
.zb-preset-swatch.active { 
  transform: scale(1.02);
  border-color: #445;
  border-width: thin;
}

/* ── Slider ───────────────────────────────────────────────────────────────── */
.zb-slider {
  width: 100%;
  accent-color: #2c2c2c;
  cursor: pointer;
}
.zb-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #bbb;
}
