html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0d0d12;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

main {
  position: absolute;
  left: 280px;
  top: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0;
}

canvas {
  display: block;
}

/* Sidebar - Satisfactory dark theme */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 280px;
  height: 100vh;
  background: #1a1a24;
  color: #eee;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
  z-index: 100;
  overflow: hidden;
}

.sidebar-header {
  padding: 15px;
  background: #12121a;
  border-bottom: 2px solid #fa9549;
}

.sidebar-header h2 {
  margin: 0 0 15px 0;
  font-size: 1.2rem;
  color: #fa9549;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rotation-display {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
}

#rotation-value {
  font-weight: bold;
  color: #fa9549;
  min-width: 40px;
}

.key-hint {
  font-size: 0.75rem;
  color: #666;
  margin-left: 5px;
}

.grid-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  color: #888;
  padding: 5px 0;
  border-top: 1px solid #2a2a35;
  border-bottom: 1px solid #2a2a35;
}

.help-section .note {
  font-size: 0.75rem;
  color: #666;
  margin-top: 10px;
  font-style: italic;
}

.delete-mode label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.delete-mode input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #e94560;
}

.button-row {
  display: flex;
  gap: 8px;
}

.button-row button {
  flex: 1;
  padding: 8px 12px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

#reset-view-btn {
  background: #3a3a4a;
  border: 1px solid #4a4a5a;
}

#reset-view-btn:hover {
  background: #4a4a5a;
  border-color: #fa9549;
}

#clear-all-btn {
  background: #8b2030;
  border: 1px solid #a52840;
}

#clear-all-btn:hover {
  background: #a52840;
}

/* Search bar */
.search-container {
  padding: 10px 15px;
  background: #12121a;
  border-bottom: 1px solid #2a2a35;
}

.search-container input {
  width: 100%;
  padding: 10px 12px;
  background: #0d0d12;
  border: 1px solid #3a3a4a;
  border-radius: 4px;
  color: #eee;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.search-container input::placeholder {
  color: #666;
}

.search-container input:focus {
  border-color: #fa9549;
}

/* Building categories */
.building-categories {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.building-categories::-webkit-scrollbar {
  width: 8px;
}

.building-categories::-webkit-scrollbar-track {
  background: #1a1a24;
}

.building-categories::-webkit-scrollbar-thumb {
  background: #3a3a4a;
  border-radius: 4px;
}

.building-categories::-webkit-scrollbar-thumb:hover {
  background: #4a4a5a;
}

.category {
  margin-bottom: 5px;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: #1a1a24;
  cursor: pointer;
  border-left: 3px solid #fa9549;
  transition: background 0.2s;
  user-select: none;
}

.category-header:hover {
  background: #252530;
}

.category-header span:first-child {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fa9549;
}

.toggle-icon {
  font-weight: bold;
  color: #666;
}

.building-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 10px;
  background: #12121a;
}

.building-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: #1a1a24;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.building-btn:hover {
  background: #252530;
  border-color: #4a4a5a;
}

.building-btn.selected {
  background: #252530;
  border-color: #fa9549;
  box-shadow: 0 0 8px rgba(250, 149, 73, 0.3);
}

.building-btn.hidden {
  display: none;
}

.building-preview {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.building-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.building-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.building-name {
  font-size: 0.85rem;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.building-size {
  font-size: 0.7rem;
  color: #777;
}


/* Mode-specific cursors */
body.select-mode main {
  cursor: default;
}

body.draw-mode main {
  cursor: crosshair;
}

body.copy-mode main {
  cursor: copy;
}

/* Floating Toolbar (Figma-style) */
#floating-toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1a1a24;
  border: 1px solid #3a3a4a;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.toolbar-btn svg {
  width: 22px;
  height: 22px;
  fill: #888;
  transition: fill 0.15s;
}

.toolbar-btn:hover {
  background: #2a2a35;
}

.toolbar-btn:hover svg {
  fill: #ccc;
}

.toolbar-btn.active {
  background: #fa9549;
}

.toolbar-btn.active svg {
  fill: #1a1a24;
}

.toolbar-btn.active:hover {
  background: #ffab6b;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: #3a3a4a;
  margin: 0 8px;
}

.toolbar-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: #0d0d12;
  color: #eee;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  margin-bottom: 8px;
  pointer-events: none;
  border: 1px solid #3a3a4a;
}

/* Keyboard shortcut hints in toolbar */
.toolbar-btn .shortcut {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  color: #666;
  font-weight: bold;
}

/* No results message */
.no-results {
  padding: 15px;
  text-align: center;
  color: #666;
  font-size: 0.85rem;
  display: none;
}

.no-results.visible {
  display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #sidebar {
    width: 240px;
  }

  main {
    left: 240px;
  }

  .building-btn {
    padding: 5px 6px;
  }

  .building-preview {
    width: 30px;
    height: 30px;
  }

  .building-name {
    font-size: 0.8rem;
  }
}

/* Floating help button */
#help-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fa9549;
  border: none;
  color: #1a1a24;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s;
  z-index: 200;
}

#help-button:hover {
  background: #ffab6b;
  transform: scale(1.1);
}

/* Help modal overlay */
#help-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

#help-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* Help modal */
.help-modal {
  background: #1a1a24;
  border: 2px solid #fa9549;
  border-radius: 12px;
  padding: 30px;
  max-width: 450px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.help-modal h2 {
  margin: 0 0 20px 0;
  color: #fa9549;
  font-size: 1.5rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.controls-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 25px;
}

.control-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #2a2a35;
}

.control-item:last-child {
  border-bottom: none;
}

.control-key {
  background: #2a2a35;
  color: #fa9549;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: bold;
}

.control-desc {
  color: #ccc;
  font-size: 0.9rem;
  text-align: right;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid #2a2a35;
}

.dont-show-again {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
}

.dont-show-again input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #fa9549;
}

#got-it-btn {
  background: #fa9549;
  color: #1a1a24;
  border: none;
  padding: 10px 25px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

#got-it-btn:hover {
  background: #ffab6b;
}