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

:root {
  --bg: #0f1115;
  --canvas-bg: #0f1115;
  --fg: #e0e0e0;
  --fg-muted: rgba(224, 224, 224, 0.5);
  --accent: #5b9aff;
  --surface: #1a1c22;
  --surface-hover: #24262e;
  --border: #2a2c34;
  --radius: 10px;
  --drawer-height: 48px;
}

body.light {
  --bg: #f0f0f0;
  --fg: #1a1a1a;
  --fg-muted: rgba(26, 26, 26, 0.45);
  --accent: #2b6ed9;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;
  --border: #ddd;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

#canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

/* ===== DRAWER ===== */
#drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  transform: translateY(calc(100% - var(--drawer-height)));
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  max-height: 75vh;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
}

#drawer.open {
  transform: translateY(0);
}

#drawer-toggle {
  width: 100%;
  height: var(--drawer-height);
  border: none;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.03em;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#drawer-toggle:hover {
  background: var(--surface-hover);
}

#drawer-icon {
  display: inline-block;
  transition: transform 0.35s ease;
  font-size: 16px;
}

#drawer-content {
  padding: 4px 20px 28px;
  overflow-y: auto;
  max-height: calc(75vh - var(--drawer-height));
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 4px 32px;
}

/* ===== SETTINGS SECTIONS ===== */
.settings-section {
  padding: 8px 0;
}

.settings-section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  gap: 12px;
}

.settings-row label {
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  min-width: 70px;
}

/* ===== PILL BUTTONS ===== */
.pill-group {
  display: flex;
  gap: 3px;
  background: var(--border);
  border-radius: 8px;
  padding: 2px;
}

.pill-group button {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.pill-group button:hover {
  background: var(--surface-hover);
}

.pill-group button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ===== TOGGLE SWITCH ===== */
.toggle-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  transition: background 0.2s ease;
}

.toggle-btn.active .toggle-track {
  background: var(--accent);
}

.toggle-thumb {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-btn.active .toggle-thumb {
  transform: translateX(16px);
}

/* ===== SLIDER ===== */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 180px;
}

.slider-wrap input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.slider-wrap input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.slider-value {
  font-size: 11px;
  color: var(--fg-muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== SCROLLBAR ===== */
#drawer-content::-webkit-scrollbar {
  width: 4px;
}

#drawer-content::-webkit-scrollbar-track {
  background: transparent;
}

#drawer-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  #drawer-content {
    padding: 4px 16px 24px;
    grid-template-columns: 1fr;
  }
  .pill-group button {
    padding: 4px 8px;
    font-size: 10px;
  }
  .settings-row label {
    font-size: 12px;
  }
}
