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

/* ==========================================================
   Global theme and base styles
   This file defines the visual language for the full interface:
   - dark default palette
   - white invert mode for the control panel and canvas
   - shared typography and global spacing
   ========================================================== */

html, body {
  width: 100%;
  height: 100%;
  background: #000000;
  color: #ffffff;
  font-family: 'Noto Sans', sans-serif;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.4;
  overflow: hidden;
  transition: background 0.2s ease, color 0.2s ease;
}

body.invert-theme {
  background: #f5f3ef;
  color: #111111;
}

/* ==========================================================
   App shell and main layout
   The control panel sits to the left; the p5 canvas occupies the rest.
   ========================================================== */

.container {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 0;
}

/* ==========================================================
   Control panel styling
   This panel stores the editing interface: text input, sliders, upload,
   action buttons, and footer metadata.
   ========================================================== */

.control-panel {
  width: 250px;
  height: 100%;
  background: #0a0a0a;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

body.invert-theme .control-panel {
  background: #f2f1ee;
  border-right-color: rgba(0, 0, 0, 0.12);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.02);
}

/* ==========================================================
   Header and form typography
   These rules define the compact editorial look of the project title and
   labels.
   ========================================================== */

.panel-header {
  margin-bottom: 10px;
}

.panel-header h1 {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: #ffffff;
  font-family: 'Noto Sans', sans-serif;
}

body.invert-theme .panel-header h1 {
  color: #111111;
  letter-spacing: 2.1px;
}

/* ==========================================================
   Form controls
   Shared styles for inputs, labels, radio-like selectors, and text fields.
   ========================================================== */

.control-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-section label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: #888888;
  font-weight: 400;
  font-family: 'Noto Sans', sans-serif;
}

body.invert-theme .control-section label {
  color: #4b4b4b;
}

.letter-input {
  font-family: 'Noto Sans', sans-serif;
  font-size: 18px;
  font-weight: 300;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-align: center;
  line-height: 1.4;
  border-radius: 2px;
  resize: vertical;
  min-height: 82px;
  transition: all 0.2s ease;
}

body.invert-theme .letter-input {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(17, 17, 17, 0.18);
  color: #111111;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.letter-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

body.invert-theme .letter-input:focus {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.25);
}

.letter-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

body.invert-theme .letter-input::placeholder {
  color: rgba(0, 0, 0, 0.35);
}

/* ==========================================================
   Slider and status widgets
   These controls drive growth speed and typography; the value readout is
   visually aligned next to the active range input.
   ========================================================== */

.mode-buttons {
  display: flex;
  gap: 6px;
}

.mode-btn {
  flex: 1;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #999999;
  font-family: 'Noto Sans', sans-serif;
  font-size: 11px;
  font-weight: 300;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 2px;
}

body.invert-theme .mode-btn {
  background: rgba(17, 17, 17, 0.03);
  border-color: rgba(17, 17, 17, 0.16);
  color: #333333;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.invert-theme .mode-btn:hover {
  background: rgba(17, 17, 17, 0.07);
}

.mode-btn.active {
  background: rgba(0, 255, 100, 0.2);
  border-color: rgba(0, 255, 100, 0.5);
  color: #00ff64;
}

body.invert-theme .mode-btn.active {
  background: #111111;
  border-color: #111111;
  color: #f6f6f4;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

body.invert-theme .slider {
  background: rgba(0, 0, 0, 0.18);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  cursor: pointer;
}

body.invert-theme .slider::-webkit-slider-thumb {
  background: #111111;
}

.slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

body.invert-theme .slider::-moz-range-thumb {
  background: #111111;
}

#fontSizeValue,
#speedValue {
  font-size: 11px;
  color: #888888;
  min-width: 40px;
  text-align: right;
  font-family: 'Noto Sans', sans-serif;
  font-weight: 300;
}

body.invert-theme #fontSizeValue,
body.invert-theme #speedValue {
  color: #444444;
}

.mic-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mic-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #333333;
  transition: all 0.2s ease;
}

.mic-indicator.active {
  background: #00ff64;
  box-shadow: 0 0 8px rgba(0, 255, 100, 0.6);
}

.mic-indicator.off {
  background: #333333;
}

#micStatusText {
  font-size: 11px;
  color: #888888;
  font-family: 'Noto Sans', sans-serif;
  font-weight: 300;
}

/* ==========================================================
   Upload and action controls
   The file browser is intentionally hidden and replaced by a styled button,
   while the main actions remain compact and high-contrast.
   ========================================================== */

.file-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #999999;
  font-family: 'Noto Sans', sans-serif;
  font-size: 11px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
}

body.invert-theme .file-upload {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.18);
  color: #444444;
}

.file-upload:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.invert-theme .file-upload:hover {
  background: rgba(0, 0, 0, 0.06);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-upload-text {
  pointer-events: none;
}

.control-separator {
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  margin: 10px 0;
}

/* ==========================================================
   Button system
   Buttons use a compact, monochrome palette with accent colors only for
   primary and export actions.
   ========================================================== */

.button-group {
  display: flex;
  gap: 6px;
}

.btn {
  flex: 1;
  padding: 10px;
  font-family: 'Noto Sans', sans-serif;
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.invert-theme .btn {
  border-color: rgba(0, 0, 0, 0.18);
}

.btn-primary {
  background: rgba(0, 255, 100, 0.15);
  color: #00ff64;
  border-color: rgba(0, 255, 100, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(0, 255, 100, 0.25);
  border-color: rgba(0, 255, 100, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #999999;
  border-color: rgba(255, 255, 255, 0.15);
}

body.invert-theme .btn-secondary {
  background: rgba(17, 17, 17, 0.03);
  color: #222222;
  border-color: rgba(17, 17, 17, 0.14);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

body.invert-theme .btn-secondary:hover:not(:disabled) {
  background: rgba(17, 17, 17, 0.06);
  color: #111111;
}

.btn-export {
  background: rgba(255, 200, 0, 0.15);
  color: #ffc800;
  border-color: rgba(255, 200, 0, 0.4);
}

.btn-invert {
  background: rgba(255, 255, 255, 0.05);
  color: #d9d9d9;
  border-color: rgba(255, 255, 255, 0.15);
}

body.invert-theme .btn-invert {
  background: rgba(17, 17, 17, 0.03);
  color: #111111;
  border-color: rgba(17, 17, 17, 0.14);
}

.btn-invert.active {
  background: rgba(255, 255, 255, 0.18);
  color: #111111;
  border-color: rgba(255, 255, 255, 0.45);
}

body.invert-theme .btn-invert.active {
  background: #111111;
  color: #f6f6f4;
  border-color: rgba(17, 17, 17, 0.18);
}

.btn-export:hover:not(:disabled) {
  background: rgba(255, 200, 0, 0.25);
  border-color: rgba(255, 200, 0, 0.6);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
}

body.invert-theme .btn:disabled {
  background: rgba(0, 0, 0, 0.03);
}

/* ==========================================================
   Footer and metadata
   The footer stays pinned to the bottom of the sidebar and holds the
   navigation link and version timestamp.
   ========================================================== */

.footer {
  margin-top: auto;
  padding-top: 15px;
  border-top: 2px solid rgba(255, 255, 255, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 10px;
  font-family: 'Noto Sans', sans-serif;
  font-weight: 300;
}

.back-link {
  color: #888888;
  text-decoration: none;
  transition: color 0.2s ease;
  font-family: 'Noto Sans', sans-serif;
  font-weight: 300;
}

body.invert-theme .back-link {
  color: #444444;
}

.back-link:hover {
  color: #ffffff;
}

body.invert-theme .back-link:hover {
  color: #000000;
}

.timestamp {
  color: #555555;
  font-size: 9px;
  font-family: 'Noto Sans', sans-serif;
  font-weight: 300;
}

body.invert-theme .timestamp {
  color: #666666;
}

/* ==========================================================
   Canvas and visual framing
   The sketch area is kept full-size and visually framed to separate it from
   the control interface.
   ========================================================== */

.canvas-container {
  flex: 1;
  background: #000000;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

body.invert-theme .canvas-container {
  background: #f8f8f6;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.05);
}

canvas {
  display: block;
  background: #000000;
}

body.invert-theme canvas {
  background: #f8f8f6;
}

/* ==========================================================
   Scrollbar and responsive tweaks
   Keeps the sidebar usable on smaller screens without changing the core
   composition.
   ========================================================== */

.control-panel::-webkit-scrollbar {
  width: 6px;
}

.control-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.control-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.control-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .control-panel {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 40vh;
    overflow-x: auto;
  }

  .control-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .control-section label {
    min-width: 60px;
  }

  .canvas-container {
    flex: 1;
  }
}
