:root {
  color-scheme: dark;
  --bg: #1b1b1f;
  --panel: #26262c;
  --text: #e8e8ea;
  --accent: #00bcd4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid #000;
}

.toolbar h1 {
  font-size: 1.1rem;
  margin: 0;
}

button {
  cursor: pointer;
  border: 1px solid #444;
  background: #333;
  color: var(--text);
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.workspace {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  width: 14rem;
  flex-shrink: 0;
  padding: 1rem;
  background: var(--panel);
  min-height: calc(100vh - 3.5rem);
  overflow-y: auto;
}

.palette-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9a9aa2;
  margin: 1rem 0 0.5rem;
}

.palette-section:first-child h2 {
  margin-top: 0;
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.palette-item {
  text-align: left;
}

.palette-item.active {
  border-color: var(--accent);
  background: #003c44;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

canvas {
  background: #fff;
  image-rendering: pixelated;
}

.new-maze-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  min-width: 20rem;
}

.new-maze-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.new-maze-form h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.dialog-field select,
.dialog-field input {
  background: #1b1b1f;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.color-swatch {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 1px solid #666;
  cursor: pointer;
  padding: 0;
}

.color-swatch.selected {
  border-color: #00bcd4;
  box-shadow: 0 0 0 2px #00bcd4;
}

.dialog-error {
  color: #e74c3c;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.menu-bar {
  display: flex;
  gap: 0.25rem;
}

.menu {
  position: relative;
}

.menu-button {
  border: 1px solid transparent;
  background: transparent;
}

.menu-button:hover {
  border-color: #444;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 14rem;
  margin-top: 0.25rem;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px solid #444;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Une règle auteur "display" l'emporte toujours sur la règle user-agent [hidden] { display:
   none }, même moins spécifique : sans ce garde, dropdown.hidden = true (JS) ne masque jamais
   visuellement l'élément. */
.menu-dropdown[hidden] {
  display: none;
}

.menu-item {
  border: none;
  background: transparent;
  text-align: left;
  border-radius: 4px;
}

.menu-item:hover:not(:disabled) {
  background: #383840;
  border-color: transparent;
}

.menu-separator {
  border: none;
  border-top: 1px solid #444;
  margin: 0.4rem 0;
  width: 100%;
}

.menu-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
}

.menu-field select,
.menu-field input {
  background: #1b1b1f;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
}

.menu-zoom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.menu-zoom-row button {
  padding: 0.2rem 0.6rem;
}

.menu-zoom-label {
  min-width: 3.5rem;
  text-align: center;
}
