/**
 * WWW_PAINT — Nothing OS Dark Theme
 * Flat, hairline, monochrome, dot-matrix. Zero blur. Zero shadows. Zero glass.
 *
 * Design: Nothing OS (pure black, dot grid, Doto/Geist/Geist Mono, signal red)
 * Tokens: vibe-nothing-ui-design (dark theme)
 *
 * @version 2026-10-17
 */

@font-face{font-family:'Doto';src:url('../fonts/open/Doto-ROND-wght.ttf') format('truetype');font-style:normal;font-weight:100 900;font-display:swap}
@font-face{font-family:'Geist';src:url('../fonts/open/Geist-Regular.ttf') format('truetype');font-style:normal;font-weight:400;font-display:swap}
@font-face{font-family:'Geist';src:url('../fonts/open/Geist-SemiBold.ttf') format('truetype');font-style:normal;font-weight:600;font-display:swap}
@font-face{font-family:'Geist Mono';src:url('../fonts/open/GeistMono-Regular.ttf') format('truetype');font-style:normal;font-weight:400;font-display:swap}
@font-face{font-family:'Geist Mono';src:url('../fonts/open/GeistMono-Medium.ttf') format('truetype');font-style:normal;font-weight:500;font-display:swap}

:root {
  /* Nothing OS dark palette */
  --bg:                #000000;
  --surface:           #0C0C0C;
  --raised:            #171717;
  --line:              #262626;
  --line-2:            #3A3A3A;
  --muted:             #5A5A5A;
  --secondary:         #8C8C8C;
  --primary:           #EDEDED;
  --display:           #FFFFFF;
  --accent:            #D71921;
  --accent-text:       #FF4438;
  --accent-glow:       rgba(215, 25, 33, 0.35);

  /* Typography — Nothing OS font stack */
  --f-display:         'Doto', monospace;
  --f-ui:              'Geist', -apple-system, sans-serif;
  --f-mono:            'Geist Mono', ui-monospace, monospace;

  /* Spacing */
  --space-1:           2px;
  --space-2:           4px;
  --space-3:           6px;
  --space-4:           8px;
  --space-5:           12px;
  --space-6:           16px;
  --space-7:           20px;
  --space-8:           28px;
  --space-9:           36px;

  /* Dimensions */
  --header-h:          44px;
  --sidebar-w:         280px;
  --layers-w:          260px;
  --status-h:          36px;
  --touch:             32px;
  --touch-sm:          28px;

  /* Radii — Nothing OS uses sharp technical corners */
  --r-sm:              6px;
  --r-md:              8px;
  --r-pill:            999px;

  /* Motion */
  --t-fast:            .12s ease;
  --t-normal:          .22s ease;
  --t-slow:            .32s ease;

  /* Dot matrix */
  --dot-color:         rgba(255, 255, 255, 0.55);
  --dot-size:          1.3px;
  --dot-spacing:       120px;

  /* Z-index */
  --z-header:          100;
  --z-panel:           90;
  --z-canvas:          10;
  --z-overlay:         200;
  --z-modal:           300;
  --z-motion:          80;
}

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

html { -webkit-font-smoothing: antialiased; font-size: 16px; overflow: hidden; }

body {
  font-family: var(--f-ui);
  font-size: 13px;
  background: var(--bg);
  color: var(--primary);
  height: 100dvh;
  overflow: hidden;
}

/* ── Dot Matrix Field — visible on black via difference blend ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(var(--dot-color) var(--dot-size), transparent calc(var(--dot-size) + 0.4px));
  background-size: var(--dot-spacing) var(--dot-spacing);
  background-attachment: fixed;
  mix-blend-mode: difference;
}

::selection { background: var(--accent); color: var(--display); }

/* ── App Layout ── */
.app { display: flex; flex-direction: column; height: 100dvh; }

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--header-h);
  padding: 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: var(--z-header);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--display);
  white-space: nowrap;
}

.logo__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.logo__slash { color: var(--accent); font-size: 16px; line-height: 1; }

.top-bar__center {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-1);
}

.nav-btn {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--secondary);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-5);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: var(--t-fast);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.nav-btn:hover { color: var(--primary); background: var(--line); }
.nav-btn--active { color: var(--bg); background: var(--primary); }
.nav-btn__icon { font-size: 12px; line-height: 1; }

.top-bar__right { display: flex; align-items: center; gap: var(--space-2); }
.mobile-toggle { display: none; }

/* ── Main Layout ── */
.main { display: flex; flex: 1; overflow: hidden; position: relative; }

/* ── Panels — flat surface, hairline border, no glass ── */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: transform var(--t-normal);
}

.panel--controls {
  width: var(--sidebar-w);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel--layers {
  width: var(--layers-w);
  border-left: 1px solid var(--line);
  border-right: none;
  display: none;
}

.panel--layers.panel--active { display: flex; }

@media (max-width: 1024px) {
  .panel--controls.panel--hidden { display: none; }
}

/* ── Canvas Area ── */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: var(--bg);
  z-index: var(--z-canvas);
}

.canvas-frame {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--bg);
  transition: border-color var(--t-normal);
}

.canvas-wrapper.drag-over .canvas-frame { border-color: var(--accent); }

.paint-canvas { display: block; max-width: 100%; max-height: 100%; background: var(--bg); }
.paint-canvas.empty {
  background-image: radial-gradient(circle at 50% 50%, var(--line) 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  color: var(--muted);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  padding: var(--space-4);
}

.canvas-placeholder__icon { font-size: 2rem; opacity: 0.3; }
.canvas-placeholder__title { font-size: 13px; color: var(--secondary); }
.canvas-placeholder__hint { font-size: 9px; color: var(--muted); font-family: var(--f-mono); letter-spacing: 0.05em; }

/* ── Motion Controls — flat, hairline ── */
.motion-controls-root {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-top: 1px solid var(--line);
  gap: var(--space-4);
  z-index: var(--z-motion);
  flex-shrink: 0;
}

.motion-bar { display: flex; align-items: center; gap: var(--space-3); width: 100%; font-family: var(--f-mono); }
.motion-btn-group { display: flex; align-items: center; gap: var(--space-1); }

.motion-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  line-height: 1;
  padding: 0;
}

.motion-btn:hover { background: var(--line); border-color: var(--primary); }
.motion-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.motion-btn.hidden { display: none; }

.motion-scrubber-wrap { position: relative; flex: 1; height: var(--touch); display: flex; align-items: center; }
.motion-progress-fill {
  position: absolute; top: 0; left: 0; height: 100%; width: 0%;
  background: var(--primary);
  border-radius: var(--r-sm);
  opacity: 0.15; transition: width 0.05s linear; pointer-events: none;
}

.motion-scrubber {
  -webkit-appearance: none; width: 100%; height: 3px;
  background: var(--line-2); border-radius: var(--r-sm);
  outline: none; cursor: pointer; transition: var(--t-fast);
}

.motion-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--display); border: 2px solid var(--bg);
  cursor: pointer; transition: var(--t-fast);
}

.motion-scrubber::-webkit-slider-thumb:hover { transform: scale(1.2); }
.motion-scrubber::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--display); border: 2px solid var(--bg); cursor: pointer;
}

.motion-speed { display: flex; align-items: center; gap: var(--space-2); }
.motion-speed-label { font-size: 9px; color: var(--muted); font-family: var(--f-mono); text-transform: uppercase; letter-spacing: 0.05em; }

.motion-speed select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--raised);
  color: var(--primary); font-size: 10px; font-family: var(--f-mono);
  cursor: pointer;
}

.motion-counter { display: flex; align-items: center; font-size: 9px; color: var(--muted); font-family: var(--f-mono); white-space: nowrap; letter-spacing: 0.05em; }
.motion-controls-root.disabled { opacity: 0.5; pointer-events: none; }

/* ── Status Footer — flat, hairline ── */
.status-footer {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--status-h);
  padding: 0 var(--space-5);
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: 9px;
  color: var(--secondary);
  letter-spacing: 0.05em;
  z-index: var(--z-header);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status__msg { font-weight: 500; color: var(--primary); margin-left: auto; }
.status__msg.loading { position: relative; padding-left: calc(var(--space-4) + 12px); }
.status__msg.loading::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border: 2px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }
.status__msg.error { color: var(--accent-text); }

/* ── Buttons — flat, technical radius, no glass ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border: 1px solid var(--line-2); background: var(--raised);
  color: var(--primary); font-family: var(--f-mono);
  font-size: 9px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-5); min-height: var(--touch); line-height: 1;
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent; user-select: none;
}

.btn:hover { background: var(--line); border-color: var(--primary); }
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--primary); color: var(--bg); border-color: var(--primary); }
.btn--primary:hover { background: var(--display); border-color: var(--display); }
.btn--ghost { background: transparent; color: var(--secondary); border-color: var(--line); }
.btn--ghost:hover { color: var(--primary); background: var(--raised); border-color: var(--primary); }
.btn--sm { font-size: 8px; padding: var(--space-2) var(--space-4); min-height: var(--touch-sm); }
.btn--icon { padding: 0; min-width: var(--touch); width: var(--touch); height: var(--touch); font-size: 12px; }
.btn__icon { display: flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; }

/* ── Round Buttons — flat, no glass ── */
.round-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--touch); height: var(--touch); border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--raised);
  color: var(--primary); font-size: 14px; cursor: pointer; flex-shrink: 0;
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent; user-select: none; padding: 0; line-height: 1;
}

.round-btn:hover { border-color: var(--primary); color: var(--primary); transform: scale(1.08); }
.round-btn--primary { background: var(--primary); color: var(--bg); border-color: var(--primary); }
.round-btn--primary:hover { background: var(--display); color: var(--bg); border-color: var(--display); }
.round-btn--ghost { background: transparent; color: var(--secondary); }
.round-btn--ghost:hover { color: var(--primary); }
.round-btn__icon { display: block; }

/* ── Controls Panel ── */
.panel--controls { padding: 0; }
.control-section { padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); }
.control-section:last-child { margin-bottom: 0; }
.control-section__title {
  font-family: var(--f-mono); font-size: 9px; font-weight: 500;
  color: var(--secondary); letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.control-section__body { display: flex; flex-direction: column; gap: var(--space-2); }

/* ── Style Grid — flat, technical ── */
.style-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.style-btn {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  background: var(--raised); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); cursor: pointer; transition: var(--t-fast);
  font-family: var(--f-mono);
  -webkit-tap-highlight-color: transparent; user-select: none;
}

.style-btn:hover { background: var(--line); border-color: var(--primary); }
.style-btn--active {
  background: var(--primary); border-color: var(--primary);
}

.style-btn__label { font-size: 8px; font-weight: 500; color: var(--secondary); text-align: center; letter-spacing: 0.04em; text-transform: uppercase; }
.style-btn--active .style-btn__label { color: var(--bg); }
.style-btn__swatch { width: 28px; height: 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); }
.style-btn--active .style-btn__swatch { border-color: var(--bg); }

/* ── Segmented Controls — flat, technical ── */
.segmented {
  display: flex; gap: var(--space-1); padding: var(--space-1);
  background: var(--raised); border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
}

.segmented__btn {
  flex: 1; border: none; background: transparent;
  padding: var(--space-2) var(--space-4);
  font-family: var(--f-mono); font-size: 9px; font-weight: 500;
  color: var(--secondary); cursor: pointer; transition: var(--t-fast);
  border-radius: var(--r-sm); white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.05em;
  -webkit-tap-highlight-color: transparent; user-select: none;
}

.segmented__btn:hover { color: var(--primary); background: var(--line); }
.segmented__btn--active { background: var(--primary); color: var(--bg); }

/* ── Sliders ── */
.control-slider { display: flex; flex-direction: column; gap: var(--space-2); }
.slider-label {
  font-family: var(--f-mono); font-size: 9px; font-weight: 500;
  color: var(--secondary); letter-spacing: 0.08em; text-transform: uppercase;
}

.slider-row { display: flex; align-items: center; gap: var(--space-3); }
.slider-row input[type="range"] {
  flex: 1; min-width: 0; height: 3px;
  -webkit-appearance: none; background: var(--line-2);
  border-radius: var(--r-sm); outline: none; cursor: pointer;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--display); border: 2px solid var(--bg);
  cursor: pointer; transition: var(--t-fast);
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
.slider-row input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--display); border: 2px solid var(--bg); cursor: pointer;
}

.slider-value { font-family: var(--f-mono); font-size: 9px; font-weight: 500; color: var(--primary); min-width: 32px; text-align: right; }

/* ── Smart Toggle ── */
.smart-toggle-container { display: flex; flex-direction: column; gap: var(--space-1); }
.smart-toggle-label {
  display: flex; align-items: center; gap: var(--space-2); cursor: pointer;
  font-family: var(--f-mono); font-size: 9px; font-weight: 500;
  color: var(--secondary); text-transform: uppercase; letter-spacing: 0.05em;
}

.smart-toggle-input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.smart-toggle-hint { font-family: var(--f-mono); font-size: 8px; color: var(--muted); }

/* ── Generate Button ── */
.generate-btn-container { margin-top: var(--space-3); }
.generate-btn {
  width: 100%; padding: var(--space-3);
  font-size: 10px; font-weight: 600;
  background: var(--primary); color: var(--bg);
  border: 1px solid var(--primary); border-radius: var(--r-sm);
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; font-family: var(--f-mono); transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent; user-select: none; min-height: var(--touch);
}

.generate-btn:hover { background: var(--display); border-color: var(--display); }
.generate-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Layers Panel — flat, hairline ── */
.layers-panel { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.layers-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  flex-shrink: 0;
}

.layers-title {
  font-family: var(--f-mono); font-size: 9px; font-weight: 500;
  color: var(--secondary); letter-spacing: 0.08em; text-transform: uppercase;
}

.layers-body { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-2); }

.layer-row {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-1);
  border-radius: var(--r-sm); transition: var(--t-fast); position: relative;
}

.layer-row:hover { background: var(--raised); }
.layer-row--active {
  background: var(--raised); border: 1px solid var(--line-2);
}

.layer-row__name {
  flex: 1; font-size: 11px; font-weight: 500; color: var(--primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.layer-row__controls { display: flex; align-items: center; gap: var(--space-1); }

.layer-visibility-btn {
  width: var(--touch-sm); height: var(--touch-sm); border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--t-fast);
  font-size: 10px; color: var(--primary);
}

.layer-visibility-btn--hidden { opacity: 0.3; }
.layer-visibility-btn:hover { background: var(--line); }

.layer-blend-select {
  width: 100px; padding: var(--space-1) var(--space-2);
  background: var(--raised);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-family: var(--f-mono); font-size: 8px; color: var(--primary);
  cursor: pointer;
}

.layer-blend-select:focus { outline: 1px solid var(--accent); }

.layer-row__actions { display: flex; gap: var(--space-1); }

.layer-action-btn {
  width: 24px; height: 24px; border-radius: 50%; border: none;
  background: transparent; color: var(--secondary); cursor: pointer;
  font-size: 11px; transition: var(--t-fast);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; user-select: none;
}

.layer-action-btn:hover { color: var(--primary); background: var(--raised); }
.layer-action-btn--danger:hover { color: var(--accent-text); background: var(--accent-glow); }

.layer-opacity-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }
.layer-opacity-label { font-family: var(--f-mono); font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.layer-opacity-input {
  flex: 1; height: 3px; -webkit-appearance: none;
  background: var(--line-2); border-radius: var(--r-sm); outline: none;
}

.layer-opacity-input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--display); border: 1px solid var(--bg); cursor: pointer;
}

.layers-placeholder {
  padding: var(--space-7) var(--space-4); text-align: center; color: var(--muted);
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.05em;
}

.layer-row__drag {
  cursor: grab; padding: var(--space-1) var(--space-2);
  color: var(--muted); font-family: var(--f-mono); font-size: 11px;
  user-select: none; touch-action: none;
}

.layer-row__drag:active { cursor: grabbing; }

/* ── Layer Row — Two-line layout ── */
.layer-row {
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
  border-radius: var(--r-sm);
  transition: var(--t-fast);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.layer-row__main {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.layer-row__name {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.layer-row__controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.layer-visibility-btn {
  width: var(--touch-sm);
  height: var(--touch-sm);
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--t-fast);
  font-size: 10px;
  color: var(--primary);
  flex-shrink: 0;
}

.layer-visibility-btn--hidden { opacity: 0.3; }
.layer-visibility-btn:hover { background: var(--line); }

.layer-blend-select {
  display: none;
  /* hidden in new layout — was causing overflow */
}

.layer-row__actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.layer-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--secondary);
  cursor: pointer;
  font-size: 11px;
  transition: var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.layer-action-btn:hover { color: var(--primary); background: var(--raised); }
.layer-action-btn--danger:hover { color: var(--accent-text); background: var(--accent-glow); }

.layer-opacity-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.layer-opacity-label {
  font-family: var(--f-mono);
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.layer-opacity-input {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  background: var(--line-2);
  border-radius: var(--r-sm);
  outline: none;
  min-width: 0;
}

.layer-opacity-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--display);
  border: 1px solid var(--bg);
  cursor: pointer;
}

.layer-opacity-value {
  font-family: var(--f-mono);
  font-size: 8px;
  color: var(--secondary);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Stop / Reset buttons ── */
.stop-btn {
  margin-top: var(--space-2);
  width: 100%;
}

.btn--danger {
  background: var(--accent);
  color: var(--display);
  border-color: var(--accent);
}

.btn--danger:hover {
  background: var(--accent-text);
  border-color: var(--accent-text);
}

.reset-btn {
  margin-top: var(--space-2);
  width: 100%;
}

/* ── Export Dialog — flat, hairline ── */
.export-dialog {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal); opacity: 0; pointer-events: none; transition: opacity var(--t-normal);
}

.export-dialog--open { opacity: 1; pointer-events: all; }

.export-dialog__overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.export-dialog__content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  width: 480px; max-width: 90vw; max-height: 90vh;
  display: flex; flex-direction: column;
}

.export-dialog__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5); border-bottom: 1px solid var(--line); flex-shrink: 0;
}

.export-dialog__title {
  font-family: var(--f-mono); font-size: 10px; font-weight: 500;
  color: var(--secondary); letter-spacing: 0.08em; text-transform: uppercase;
}

.export-dialog__body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.export-form { display: flex; flex-direction: column; gap: var(--space-3); }

.form-row { display: flex; flex-direction: column; gap: var(--space-2); }
.form-row:last-child { margin-bottom: 0; }

.form-label {
  font-family: var(--f-mono); font-size: 9px; font-weight: 500;
  color: var(--secondary); letter-spacing: 0.08em; text-transform: uppercase;
}

.form-input, .form-select {
  padding: var(--space-2) var(--space-4);
  background: var(--raised);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-family: var(--f-mono); font-size: 11px; color: var(--primary);
  min-height: var(--touch);
}

.form-input:focus, .form-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); }

.form-select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238C8C8C' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.form-range {
  width: 100%; height: 3px; -webkit-appearance: none;
  background: var(--line-2); border-radius: var(--r-sm); outline: none; cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--display); border: 2px solid var(--bg); cursor: pointer;
}

.form-color {
  width: 40px; height: var(--touch); padding: 2px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--raised); cursor: pointer;
}

.form-value { font-family: var(--f-mono); font-size: 9px; font-weight: 500; color: var(--secondary); letter-spacing: 0.05em; }
.form-actions { display: flex; gap: var(--space-2); }
.form-actions .btn { flex: 1; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal); opacity: 0; pointer-events: none; transition: opacity var(--t-normal);
}

.modal--open { opacity: 1; pointer-events: all; }

.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal__content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  width: 480px; max-width: 90vw; max-height: 90vh;
  display: flex; flex-direction: column;
}

.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5); border-bottom: 1px solid var(--line);
  background: var(--raised);
}

.modal__title {
  font-family: var(--f-mono); font-size: 10px; font-weight: 500;
  color: var(--secondary); letter-spacing: 0.08em; text-transform: uppercase;
}

.modal__body { padding: var(--space-5); overflow-y: auto; flex: 1; }

.modal__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: var(--space-2);
}

/* ── Status Bar ── */
.status-item {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--f-mono); font-size: 9px;
  color: var(--secondary); letter-spacing: 0.05em;
}

.status-label { color: var(--muted); }
.status-value { font-weight: 500; color: var(--primary); }
.status-item--spacer { margin-left: auto; }
.status__message { font-weight: 500; color: var(--primary); }

.status__loading { position: relative; padding-left: calc(var(--space-4) + 12px); }
.status__loading::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border: 2px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}

.status__error { color: var(--accent-text); }

/* ── Paint Toolbar — flat, hairline ── */
.paint-toolbar {
  display: none;
  flex-direction: column;
  gap: var(--space-2);
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
}

.paint-toolbar--active { display: flex; }
.paint-toolbar__row { display: flex; align-items: center; gap: var(--space-2); font-size: 11px; }
.paint-toolbar__row--full { justify-content: stretch; }

.paint-toolbar__label {
  flex-shrink: 0; color: var(--secondary);
  font-family: var(--f-mono); font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.05em; min-width: 48px;
}

.paint-toolbar__select {
  flex: 1; background: var(--raised); color: var(--primary);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 4px 8px; font-family: var(--f-ui); font-size: 11px;
  cursor: pointer;
}

.paint-toolbar__select:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.paint-toolbar__color {
  width: 40px; height: 28px; padding: 0;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
}

.paint-toolbar__color::-webkit-color-swatch-wrapper { padding: 2px; }
.paint-toolbar__color::-webkit-color-swatch { border: none; border-radius: var(--r-sm); }

.paint-toolbar__slider {
  flex: 1; height: 20px; -webkit-appearance: none; appearance: none;
  background: var(--raised); border-radius: var(--r-sm);
  outline: none; border: 1px solid var(--line-2);
}

.paint-toolbar__slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--display); border: 1px solid var(--bg);
  cursor: pointer;
}

.paint-toolbar__slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--display); border: 1px solid var(--bg); cursor: pointer;
}

.paint-toolbar__value {
  flex-shrink: 0; color: var(--secondary);
  font-family: var(--f-mono); font-size: 9px;
  min-width: 32px; text-align: right;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--r-sm); transition: background var(--t-fast); }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

/* ── Focus ── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 250px; --layers-w: 250px; }
}

@media (max-width: 768px) {
  :root {
    --header-h: 40px;
    --status-h: 32px;
    --touch: 28px;
    --touch-sm: 24px;
  }

  .top-bar { padding: 0 var(--space-3); gap: var(--space-2); }
  .logo { font-size: 12px; }
  .logo__slash { font-size: 14px; }
  .top-bar__center { display: none; }

  .main { flex-direction: column; gap: 0; }

  .panel--controls, .panel--layers {
    position: fixed; top: var(--header-h); bottom: var(--status-h);
    width: min(320px, 85vw) !important; max-width: none;
    z-index: var(--z-panel);
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  .panel--controls { left: 0; right: auto; }
  .panel--controls.panel--mobile-closed { transform: translateX(-320px); }
  .panel--layers { left: auto; right: 0; }
  .panel--layers.panel--mobile-closed { transform: translateX(320px); }
  .panel--controls.panel--hidden { display: flex; transform: translateX(-320px); }
  .panel--layers.panel--active { display: flex; }

  .canvas-wrapper { flex: 1; overflow: hidden; }
  .paint-canvas { max-width: 100%; max-height: 100%; }

  .mobile-toggle {
    display: flex !important;
    align-items: center; justify-content: center;
    width: var(--touch); height: var(--touch); border-radius: 50%;
    border: 1px solid var(--line-2); background: var(--raised);
    color: var(--secondary); font-size: 14px; cursor: pointer;
    flex-shrink: 0; transition: var(--t-fast);
    -webkit-tap-highlight-color: transparent; user-select: none;
  }

  .mobile-toggle:hover { color: var(--primary); border-color: var(--primary); }
  .mobile-toggle--active { color: var(--bg); background: var(--primary); border-color: var(--primary); }

  .status-footer { padding: 0 var(--space-3); font-size: 8px; overflow-x: auto; }
  .status-item { white-space: nowrap; }

  .modal { width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; }
  .modal__body { padding: var(--space-3); }

  .control-section { padding: var(--space-3); }
  .control-section__title { font-size: 8px; margin-bottom: var(--space-2); }

  .style-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
  .style-btn { padding: var(--space-2) var(--space-1); gap: var(--space-1); }
  .style-btn__label { font-size: 7px; }

  .btn { padding: var(--space-2) var(--space-4); font-size: 9px; }
  .btn--sm { padding: var(--space-1) var(--space-3); font-size: 8px; }

  .motion-controls-root { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  .motion-btn { width: var(--touch); height: var(--touch); font-size: 12px; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ──────────────────────────────────────────────────────────────
   Debug Overlay — monochrome, no green terminal
   ────────────────────────────────────────────────────────────── */

.debug-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.debug-overlay--open {
  opacity: 1;
  pointer-events: all;
}

.debug-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.debug-panel {
  position: relative;
  width: 600px;
  height: 400px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  overflow: hidden;
  z-index: 1;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  flex-shrink: 0;
}

.debug-header__title {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.debug-close-btn {
  width: var(--touch-sm);
  height: var(--touch-sm);
  min-width: var(--touch-sm);
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--raised);
  color: var(--secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.debug-close-btn:hover {
  color: var(--primary);
  background: var(--line);
  border-color: var(--primary);
}

.debug-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  overflow-y: auto;
}

.debug-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.debug-section-title {
  font-family: var(--f-mono);
  font-size: 8px;
  font-weight: 500;
  color: var(--secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.debug-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-height: 200px;
  overflow-y: auto;
}

.debug-log-entry {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--primary);
  line-height: 1.4;
  word-break: break-word;
  padding: 2px 0;
}

.debug-log-entry--error {
  color: var(--accent-text);
}

.debug-log-entry--warn {
  color: var(--secondary);
}

.debug-log-entry .prefix {
  font-weight: 500;
}

.debug-settings {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--primary);
  line-height: 1.4;
  white-space: pre;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--space-3);
  overflow-x: auto;
}

.debug-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--raised);
  flex-shrink: 0;
}

.debug-copy-btn {
  font-family: var(--f-mono);
  font-size: 8px;
  font-weight: 500;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-5);
  cursor: pointer;
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.debug-copy-btn:hover {
  background: var(--line);
  border-color: var(--primary);
  color: var(--accent);
}

.debug-logbook-entry {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.debug-logbook__time {
  font-family: var(--f-mono);
  font-size: 9px;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.debug-logbook__settings,
.debug-logbook__log {
  font-family: var(--f-mono);
  font-size: 9px;
  color: var(--secondary);
  line-height: 1.3;
  white-space: pre;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--space-2);
  overflow-x: auto;
}

/* ──────────────────────────────────────────────────────────────
   UI Settings Modal — flat, hairline
   ────────────────────────────────────────────────────────────── */

.settings-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.settings-overlay--open {
  opacity: 1;
  pointer-events: all;
}

.settings-content {
  position: relative;
  width: 480px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  overflow: hidden;
  z-index: 1;
}

.settings-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  flex-shrink: 0;
}

.settings-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.settings-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
  background: var(--raised);
  flex-shrink: 0;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mode-toggle__track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1);
  background: var(--raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
}

.mode-toggle__fill {
  position: absolute;
  top: var(--space-1);
  bottom: var(--space-1);
  width: 50%;
  border-radius: var(--r-sm);
  background: var(--accent);
  transition: transform var(--t-fast);
  z-index: 0;
}

.mode-toggle__btn {
  position: relative;
  z-index: 1;
  flex: 1;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: none;
  background: transparent;
  padding: var(--space-2);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mode-toggle__btn:hover {
  color: var(--primary);
  background: var(--line);
}

.mode-toggle__btn--active {
  color: var(--bg);
  background: var(--primary);
}

.mode-indicator {
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Color Pickers */
.color-pickers {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.color-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.color-row__label {
  flex-shrink: 0;
  width: 140px;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-row__input {
  width: 40px;
  height: var(--touch-sm);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.color-row__input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-row__input::-webkit-color-swatch {
  border: none;
  border-radius: var(--r-sm);
}

.color-row__hex {
  flex: 1;
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--primary);
  letter-spacing: 0.05em;
  min-width: 60px;
  text-align: left;
}
