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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  background: #1a1a2e;
  color: #e0e0e0;
  touch-action: none;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
}

.toolbar-scroll {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.toolbar-scroll::-webkit-scrollbar { display: none; }

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

button {
  padding: 5px 10px;
  border: 1px solid #0f3460;
  background: #1a1a2e;
  color: #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

button:hover { background: #0f3460; }
.tool-btn.active { background: #e94560; border-color: #e94560; }
.btn-primary { background: #e94560; border-color: #e94560; }
.btn-primary:hover { background: #c73e54; }
.btn-secondary { background: #2a2a4a; }
.full-w { width: 100%; }

.sidebar-toggle {
  flex-shrink: 0;
  background: #0f3460;
  font-weight: 600;
  padding: 5px 12px;
}

.sidebar-toggle.active {
  background: #e94560;
  border-color: #e94560;
}

#main { display: flex; flex: 1; overflow: hidden; position: relative; }

#sidebar {
  width: 260px;
  min-width: 260px;
  background: #16213e;
  border-right: 1px solid #0f3460;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#sidebar h3 {
  font-size: 13px;
  margin-bottom: 8px;
  color: #e94560;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#canvas-container {
  flex: 1;
  position: relative;
  background: #1a1a2e;
  overflow: hidden;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 20px;
  min-width: 300px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin-bottom: 16px; font-size: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 12px; margin-bottom: 3px; color: #aaa; }

.form-group input,
.form-group select,
#properties-content select {
  width: 100%;
  padding: 6px 10px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 13px;
}

.form-group input[type="color"] {
  height: 32px;
  padding: 2px;
  cursor: pointer;
}

.form-group input[type="file"] {
  font-size: 11px;
  padding: 4px;
}

/* Furniture list */
.furniture-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #1a1a2e;
  border-radius: 4px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  font-size: 13px;
}

.furniture-item:hover { border-color: #0f3460; }
.furniture-item .name { font-weight: 500; }
.furniture-item .dims { font-size: 10px; color: #777; }
.furniture-item .actions { display: flex; gap: 2px; }
.furniture-item .actions button { padding: 2px 6px; font-size: 11px; }

/* Saved plans */
.save-controls { display: flex; gap: 4px; margin-bottom: 8px; }
.save-controls input {
  flex: 1;
  padding: 5px 8px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 13px;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #1a1a2e;
  border-radius: 4px;
  margin-bottom: 3px;
  font-size: 13px;
}

.saved-item .date { font-size: 10px; color: #666; }
.saved-item .actions { display: flex; gap: 2px; }
.saved-item .actions button { padding: 2px 6px; font-size: 11px; }

.hint { font-size: 12px; color: #555; }

/* Properties */
#properties-content .form-group { margin-bottom: 6px; }
#properties-content input {
  width: 100%;
  padding: 4px 8px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 12px;
}
#properties-content input[readonly] { color: #777; }
#properties-content label { font-size: 11px; color: #888; }
#properties-content select {
  width: 100%;
  padding: 4px 8px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 12px;
}

/* ── Mobile ── */

@media (max-width: 768px) {
  #toolbar {
    padding: 4px 6px;
    gap: 6px;
  }

  button {
    padding: 8px 10px;
    font-size: 13px;
    min-height: 36px;
  }

  .furniture-item .actions button,
  .saved-item .actions button {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 32px;
  }

  #sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    min-width: 0;
    z-index: 100;
    border-right: none;
    border-left: 1px solid #0f3460;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #canvas-container {
    width: 100%;
  }

  .modal {
    min-width: 0;
    padding: 16px;
    margin: 8px;
  }

  .modal-footer button {
    padding: 10px 16px;
    font-size: 14px;
  }

  .form-group input,
  .form-group select,
  #properties-content select {
    padding: 8px 10px;
    font-size: 14px;
  }

  #properties-content input {
    padding: 8px 10px;
    font-size: 13px;
  }
}
