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

body {
  display: flex;
  height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  overflow: hidden;
  user-select: none;
}

/* ── Library Panel ── */
#library {
  width: 250px;
  min-width: 250px;
  height: 100vh;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #ccc;
  padding: 16px;
  z-index: 100;
}

#library h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  margin-bottom: 12px;
}

.library-category {
  margin-bottom: 24px;
}

.library-category {
  border-top: 1px solid #ddd;
  padding-top: 8px;
}

.library-category h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 8px;
}

/* ── Collapsible sections ── */
.collapsible-header {
  cursor: pointer;
  user-select: none;
}

.collapsible-header:hover {
  color: #666;
}

.collapse-arrow {
  display: inline-block;
  width: 16px;
  font-size: 14px;
  font-weight: 300;
  transition: transform 0.2s ease;
}

.collapsible-content {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.25s ease;
}

.collapsible-content.collapsed {
  max-height: 0;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: grab;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.library-item:hover {
  background: #f0f0f0;
}

.library-item:active {
  cursor: grabbing;
}

.library-item img {
  height: 32px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  pointer-events: none;
}

.library-item .label {
  font-size: 12px;
  color: #333;
  pointer-events: none;
  flex: 1;
}

.library-item .library-price {
  font-size: 11px;
  color: #999;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Canvas Area ── */
#canvas-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #f5f5f5;
  padding: 24px 24px 24px 124px;
}

#canvas {
  position: relative;
  width: 4000px;
  height: 2200px;
  transform-origin: 0 0;
}

/* ── Clear Button ── */
#clear-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 50;
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

#clear-btn:hover {
  background: #f0f0f0;
  color: #333;
}

/* ── Zoom Controls ── */
#zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 4px 8px;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

#zoom-controls button {
  width: 28px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #333;
}

#zoom-controls button:hover {
  background: #f0f0f0;
}

#zoom-level {
  font-size: 12px;
  color: #666;
  min-width: 36px;
  text-align: center;
}

/* ── E-tracks ── */
.track {
  position: absolute;
  z-index: 1;
  top: 0;
  cursor: ew-resize;
}

.track img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.track.dragging {
  opacity: 0.5;
}

/* ── Elements (shelves, cabinets, etc.) ── */
.element {
  position: absolute;
  z-index: 5;
  cursor: grab;
}

.element:active {
  cursor: grabbing;
}

.element {
  color: #000;
  transition: color 0.15s;
}

.element:hover {
  color: #cc0000;
}

.element img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.element svg {
  display: block;
  pointer-events: none;
}

.element.dragging {
  opacity: 0.3;
}

.element.selected {
  color: #cc0000;
}

/* ── Element Dimensions (hover) ── */
.element-dimensions {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform-origin: top center;
  font-size: 16px;
  color: #bbb;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.element:hover .element-dimensions {
  opacity: 1;
}

body.is-dragging .element-dimensions {
  display: none;
}

/* ── Bay & Total Dimension Labels ── */
.bay-label {
  position: absolute;
  font-size: 14px;
  color: #bbb;
  white-space: nowrap;
  pointer-events: none;
  transform-origin: top center;
}

.total-dimensions {
  position: absolute;
  font-size: 14px;
  color: #bbb;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Drop indicators ── */
.pin-guide {
  position: absolute;
  z-index: 3;
  height: 2px;
  background: rgba(0, 120, 255, 0.5);
  pointer-events: none;
  border-radius: 1px;
}

.bay-highlight {
  position: absolute;
  z-index: 2;
  background: rgba(0, 120, 255, 0.06);
  border: 1px dashed rgba(0, 120, 255, 0.25);
  pointer-events: none;
  border-radius: 2px;
}

.snap-guide {
  position: absolute;
  z-index: 1000;
  width: 1px;
  background: rgba(255, 100, 0, 0.6);
  pointer-events: none;
  top: 0;
}

/* ── Drag Ghost ── */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.6;
}

.drag-ghost.hidden {
  display: none;
}

/* ── Context Menu ── */
.context-menu {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 180px;
  padding: 4px 0;
  font-size: 13px;
}

.context-menu.hidden {
  display: none;
}

.menu-item {
  padding: 7px 16px;
  cursor: pointer;
  color: #333;
}

.menu-item:hover {
  background: #0078ff;
  color: #fff;
}

.menu-separator {
  height: 1px;
  background: #e8e8e8;
  margin: 4px 0;
}

.menu-label {
  padding: 5px 16px 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #999;
}

/* ── Cost Panel ── */
#cost-panel {
  border-top: 1px solid #ddd;
  padding-top: 12px;
  margin-bottom: 16px;
}

#cost-panel h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  margin-bottom: 8px;
}

#cost-items {
  font-size: 12px;
  color: #555;
}

.cost-line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #f0f0f0;
}

.cost-line .cost-label {
  flex: 1;
}

.cost-line:last-child {
  border-bottom: none;
}

.cost-line .cost-unit {
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 50px;
  color: #999;
  font-size: 11px;
}

.cost-line .cost-price {
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 60px;
}

#cost-total {
  display: flex;
  justify-content: space-between;
  padding: 8px 0 0;
  margin-top: 4px;
  border-top: 2px solid #333;
  font-weight: 700;
  font-size: 14px;
  color: #111;
}

#cost-total-amount {
  font-variant-numeric: tabular-nums;
}

.cost-empty {
  font-size: 12px;
  color: #999;
  font-style: italic;
  padding: 8px 0;
}

/* ── Export Panel ── */
#export-panel {
  border-top: 1px solid #ddd;
  padding-top: 8px;
  margin-top: 16px;
}

#export-panel h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 8px;
}

#export-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.export-btn {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  text-align: left;
}

.export-btn:hover {
  background: #f0f0f0;
}

.export-option {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #666;
  padding: 2px 0 4px;
  cursor: pointer;
}

.export-option.visible {
  display: flex;
}

.export-option input[type="checkbox"] {
  margin: 0;
}

.hidden {
  display: none;
}
