/* ==========================================================================
   OROGRAFO — Atelier d'Incisione & Cartografia Alpina
   Design System: Warm Obsidian Slate · Antique Brass · Museum Printmaking
   ========================================================================== */

:root {
  --bg-deep: #0e0d0b;
  --bg-panel: #151310;
  --bg-elev: #1d1a16;
  --bg-hover: #27231e;
  --border: rgba(212, 168, 90, 0.16);
  --border-strong: rgba(212, 168, 90, 0.36);
  --gold: #d4a85a;
  --gold-bright: #ecd095;
  --gold-dim: rgba(212, 168, 90, 0.14);
  --text: #eee7da;
  --text-muted: #a39a8c;
  --text-soft: #756e62;
  --sheet-bg: #f4ecdc;
  --sheet-ink: #171513;
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 58px;
  --panel-w: 348px;
  --font-display: 'Cinzel', Georgia, serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.flex-1 { flex: 1; }

/* ---- Top Bar ---- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(180deg, #181612 0%, #12100d 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-strong);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.18em;
  color: var(--gold-bright);
  line-height: 1.1;
}

.brand-text span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  background: #0d0c0a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.active {
  background: linear-gradient(180deg, #2a251e 0%, #1e1a15 100%);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.seg-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
.seg-btn.active .seg-dot { opacity: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Buttons ---- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-sm { padding: 6px 10px; font-size: 11.5px; }
.btn-full { width: 100%; padding: 10px 14px; font-weight: 600; }

.btn-outline {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--gold);
  color: var(--gold-bright);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-elev);
}
.btn-ghost.active {
  color: var(--gold-bright);
  background: var(--gold-dim);
  border-color: var(--gold);
}

.btn-gold {
  background: linear-gradient(180deg, #e0b76d 0%, #bd8f42 100%);
  color: #13100b;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(212, 168, 90, 0.25);
}
.btn-gold:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
}
.btn-gold:active { transform: translateY(0); }

.btn-row { display: flex; gap: 8px; }
.link-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.85;
}
.link-btn:hover { opacity: 1; text-decoration: underline; }

.mobile-only { display: none; }

/* ---- Workspace Layout ---- */
.workspace {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}

/* ---- Stage Area ---- */
.stage-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px 26px 46px;
  background:
    radial-gradient(circle at 50% 42%, rgba(212, 168, 90, 0.05) 0%, transparent 58%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 28px),
    #0e0d0b;
}

.plate-mount {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  transition: all 0.22s ease;
}

.plate-sheet {
  background: var(--sheet-bg);
  color: var(--sheet-ink);
  padding: 18px 20px 14px;
  border-radius: 3px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.72),
    0 4px 16px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition: background 0.25s ease, color 0.25s ease, padding 0.22s ease;
  max-width: 100%;
  max-height: calc(100vh - var(--topbar-h) - 72px);
  display: flex;
  flex-direction: column;
}

.plate-inner-frame {
  border: 1.5px solid currentColor;
  padding: 8px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.plate-inner-frame::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 0.5px solid currentColor;
  opacity: 0.45;
  pointer-events: none;
}

/* Frame Variants */
.plate-mount[data-frame="gallery"] .plate-sheet { padding: 24px 24px 18px; }
.plate-mount[data-frame="gallery"] .plate-inner-frame { border: none; padding: 0; }
.plate-mount[data-frame="gallery"] .plate-inner-frame::before { display: none; }

.plate-mount[data-frame="poster"] .plate-sheet { padding: 14px 14px 16px; }
.plate-mount[data-frame="poster"] .plate-inner-frame { border: 3px solid currentColor; padding: 0; }
.plate-mount[data-frame="poster"] .plate-inner-frame::before { display: none; }
.plate-mount[data-frame="poster"] .cartouche {
  padding: 10px 12px;
  border-top: 2px solid currentColor;
  margin-top: 0;
}

.plate-mount[data-frame="none"] .plate-sheet {
  padding: 0;
  background: transparent;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.72);
}
.plate-mount[data-frame="none"] .plate-inner-frame { border: none; padding: 0; }
.plate-mount[data-frame="none"] .plate-inner-frame::before { display: none; }
.plate-mount[data-frame="none"] .cartouche { display: none; }

.canvas-wrap {
  position: relative;
  overflow: hidden;
  line-height: 0;
  user-select: none;
  touch-action: none;
  background: #141210;
}

#glCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: grab;
}
#glCanvas:active { cursor: grabbing; }

/* Cartouche Preview */
.cartouche {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 4px 2px;
  margin-top: 4px;
  color: inherit;
}

.cartouche-eyebrow {
  display: block;
  font-family: var(--font-sans);
  font-size: 8.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 2px;
}

.cartouche-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.15;
}

.cartouche-right {
  text-align: right;
  flex-shrink: 0;
}

.cartouche-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  opacity: 0.78;
}

.cartouche-sig {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  opacity: 0.72;
  margin-top: 1px;
}

/* Split Comparison Handle */
.split-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  z-index: 12;
  pointer-events: none;
}

.split-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--gold-bright);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.85);
}

.split-knob {
  position: absolute;
  top: 50%;
  left: -18px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(18, 16, 13, 0.92);
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  cursor: ew-resize;
}

.split-tag {
  position: absolute;
  top: 12px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(15, 13, 11, 0.78);
  color: var(--gold-bright);
  border: 1px solid rgba(212, 168, 90, 0.35);
  white-space: nowrap;
}
.split-tag-left { right: 12px; }
.split-tag-right { left: 12px; }

/* Processing Pill */
.processing-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 13, 11, 0.9);
  border: 1px solid var(--border-strong);
  color: var(--gold-bright);
  padding: 7px 14px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(212, 168, 90, 0.28);
  border-top-color: var(--gold-bright);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Stage Bottom Info Bar */
.stage-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-soft);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(14, 13, 11, 0.85);
}

.stage-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}
.stage-meta .sep { opacity: 0.35; }
.stage-hint strong { color: var(--gold); font-weight: 500; }

/* ---- Right Atelier Panel ---- */
.atelier-panel {
  width: var(--panel-w);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 25;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 15px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 168, 90, 0.25) transparent;
}

.panel-section {
  padding: 12px 0 14px;
  border-bottom: 1px solid rgba(212, 168, 90, 0.1);
}
.panel-section:first-child { padding-top: 4px; }
.panel-section:last-child { border-bottom: none; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--gold-dim);
  color: var(--gold-bright);
  border: 1px solid var(--border-strong);
}

.muted-tiny { font-size: 10.5px; color: var(--text-soft); }
.mono-val { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }

.mini-label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin: 10px 0 6px;
  letter-spacing: 0.03em;
}

/* Dropzone Button */
.upload-dropzone {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: linear-gradient(135deg, rgba(212, 168, 90, 0.11), rgba(212, 168, 90, 0.03));
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
}
.upload-dropzone:hover {
  background: linear-gradient(135deg, rgba(212, 168, 90, 0.19), rgba(212, 168, 90, 0.06));
  border-style: solid;
}

.dz-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(212, 168, 90, 0.14);
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dz-text strong {
  display: block;
  font-size: 12.5px;
  color: var(--gold-bright);
}
.dz-text span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Chips */
.chip-grid {
  display: grid;
  gap: 6px;
}
.chip-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.chip-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  font-size: 11.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.14s ease;
  text-align: center;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold-bright);
  font-weight: 500;
}

/* Recipes */
.preset-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.recipe-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}
.recipe-btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.recipe-btn.active {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold-bright);
}

.recipe-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

/* Techniques */
.technique-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tech-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.14s ease;
}
.tech-btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.tech-btn.active {
  background: linear-gradient(90deg, rgba(212, 168, 90, 0.17), rgba(212, 168, 90, 0.05));
  border-color: var(--gold);
}
.tech-btn strong {
  display: block;
  font-size: 12px;
  color: var(--text);
}
.tech-btn.active strong { color: var(--gold-bright); }
.tech-btn span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Sliders */
.slider-group { margin-bottom: 10px; }
.slider-group:last-child { margin-bottom: 0; }

.slider-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.slider-row label { font-size: 11.5px; color: var(--text); }
.slider-row output {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--gold);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: #2b2620;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid #151310;
  box-shadow: 0 0 0 1px var(--gold);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid #151310;
  box-shadow: 0 0 0 1px var(--gold);
  cursor: pointer;
}

/* Solar Compass */
.compass-layout {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sun-compass {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at center, #25211a 0%, #12100d 78%);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.compass-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(212, 168, 90, 0.22);
  pointer-events: none;
}
.compass-ring.r1 { inset: 18px; }
.compass-ring.r2 { inset: 35px; }

.cardinal {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-soft);
  pointer-events: none;
}
.c-n { top: 4px; left: 50%; transform: translateX(-50%); color: var(--gold); }
.c-s { bottom: 4px; left: 50%; transform: translateX(-50%); }
.c-e { right: 5px; top: 50%; transform: translateY(-50%); }
.c-w { left: 5px; top: 50%; transform: translateY(-50%); }

.sun-ray {
  position: absolute;
  top: 50%;
  left: 50%;
  height: 1.5px;
  background: linear-gradient(90deg, rgba(212, 168, 90, 0.15), var(--gold-bright));
  transform-origin: 0 50%;
  pointer-events: none;
}

.sun-orb {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff9e6, #e6b85c);
  box-shadow: 0 0 12px rgba(236, 208, 149, 0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.compass-sliders { flex: 1; min-width: 0; }

/* Paper & Ink Swatches */
.swatch-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.swatch {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 2px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 10px;
  transition: all 0.14s ease;
}
.swatch::before {
  content: '';
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sw);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}
.swatch:hover { border-color: var(--border-strong); color: var(--text); }
.swatch.active {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold-bright);
}

/* Text Fields & Select */
.field-group { margin-bottom: 9px; }
.field-group label {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.field-group input[type="text"],
.field-group select {
  width: 100%;
  background: #100e0c;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 7px 9px;
  outline: none;
  transition: border-color 0.15s ease;
}
.field-group input[type="text"]:focus,
.field-group select:focus {
  border-color: var(--gold);
}

.export-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(212, 168, 90, 0.12);
}

/* Drag Overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.86);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.drop-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.drop-card {
  border: 2px dashed var(--gold-bright);
  border-radius: 16px;
  padding: 44px 56px;
  text-align: center;
  background: rgba(24, 21, 17, 0.92);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}
.drop-icon { font-size: 44px; margin-bottom: 10px; color: var(--gold-bright); }
.drop-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.1em;
  color: var(--gold-bright);
}
.drop-card p { margin: 0; color: var(--text-muted); }

/* Toast */
.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1d1a15;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 120;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Responsive Tablet / Mobile ---- */
@media (max-width: 1040px) {
  .brand-text span { display: none; }
  .stage-hint { display: none; }
  :root { --panel-w: 312px; }
}

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .topbar-center { order: 3; width: 100%; justify-content: space-between; }
  .topbar-actions .btn span { display: none; }
  #exportHeaderBtn span { display: inline; }
  .mobile-only { display: inline-flex; }

  .workspace { height: calc(100dvh - 96px); position: relative; }
  .stage-area { padding: 12px 12px 42px; }

  .atelier-panel {
    position: fixed;
    top: 96px;
    right: 0;
    bottom: 0;
    width: min(90vw, 350px);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.7);
  }
  .atelier-panel.open { transform: translateX(0); }
}
