/* ==========================================================================
   PIXEL.STUDIO — RETRO BRUTALIST DESIGN SYSTEM & STYLESHEET
   100% Fluid 100vh Viewport Layout (Desktop 3-Column & Mobile Adaptation)
   ========================================================================== */

/* --------------------------------------------------------------------------
   DESIGN TOKENS & CSS VARIABLES
   -------------------------------------------------------------------------- */
:root {
  --bg-paper: #EFECE4;
  --bg-card: #F9F7F1;
  --border-dark: #111111;
  --text-main: #111111;
  --text-muted: #555555;
  
  --accent-yellow: #FFE600;
  --accent-green: #00E676;
  --accent-red: #FF3333;
  --accent-cyan: #00E5FF;
  --accent-grey: #E2DFD7;
  
  --font-heading: 'Syne', 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Hind Siliguri', sans-serif;

  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 5px;
  --radius-lg: 6px;

  --shadow-hard: 3px 3px 0px var(--border-dark);
  --shadow-hard-sm: 2px 2px 0px var(--border-dark);
  --shadow-hard-lg: 5px 5px 0px var(--border-dark);
}

/* --------------------------------------------------------------------------
   GLOBAL RESET & 100VH FLUID VIEWPORT CONTAINER
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-paper);
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Technical Grid Overlay */
.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
}

.studio-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-paper);
}

/* --------------------------------------------------------------------------
   DESKTOP HEADER WITH PIXEL.STUDIO BRANDING
   -------------------------------------------------------------------------- */
.studio-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border-dark);
  z-index: 100;
  gap: 16px;
}

.header-brand-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.logo-title {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--border-dark);
  margin: 0;
  line-height: 1;
}

.logo-badge-sub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 230, 118, 0.12);
  border: 1.5px solid var(--border-dark);
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  color: var(--border-dark);
  width: fit-content;
  border-radius: var(--radius-sm);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--border-dark);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

.header-samples {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sample-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
}

.sample-btn, .action-mini-btn {
  background: #fff;
  border: 2px solid var(--border-dark);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 2px 2px 0px var(--border-dark);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.sample-btn:hover, .action-mini-btn:hover {
  background: var(--accent-yellow);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px var(--border-dark);
}

.action-mini-btn.primary-accent {
  background: var(--accent-green);
}

.header-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
}

.quick-save-btn {
  order: 3;
}

.header-nav-drawer {
  display: flex;
  align-items: center;
  gap: 24px;
  order: 2;
}

.sample-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 20px;
  border-left: 2px solid rgba(17, 17, 17, 0.18);
}

/* --------------------------------------------------------------------------
   DESKTOP FLUID 3-COLUMN WORKSPACE LAYOUT
   -------------------------------------------------------------------------- */
.studio-workspace {
  display: grid;
  grid-template-columns: 400px 1fr 360px;
  grid-template-areas: "left center right";
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.mobile-controls-area {
  display: contents;
}

.sidebar-left {
  grid-area: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--bg-paper);
  height: 100%;
  overflow-y: auto;
}

/* --- CANVAS STAGE MONITOR (CENTER COLUMN) --- */
.display-stage-container {
  grid-area: center;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-left: 2px solid var(--border-dark);
  border-right: 2px solid var(--border-dark);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.sidebar-right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--bg-paper);
  height: 100%;
  overflow-y: auto;
}

.stage-bar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--border-dark);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  gap: 8px;
  border-radius: 0;
}

.stage-bar-left, .stage-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stage-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  font-size: 10px;
  margin-right: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
}

.stage-stats-stack {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.stage-stat {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-yellow);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.stage-mini-btn {
  background: #fff;
  color: #000;
  border: none;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: var(--radius-xs);
}

.canvas-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #E5E0D5;
  overflow: hidden;
  position: relative;
  border-radius: 0;
}

.canvas-stage-frame {
  position: relative;
  border: none;
  background: transparent;
  box-shadow: none;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 100%;
  max-width: 100%;
  height: 100%;
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

#studioCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: grab;
  border-radius: var(--radius-xs);
}

#studioCanvas:active {
  cursor: grabbing;
}

/* CRT Scanlines Overlay Layer */
.crt-scanline-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  z-index: 20;
  pointer-events: none;
}

.crt-scanline-layer.hidden {
  display: none;
}

.drop-overlay-banner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 230, 0, 0.92);
  color: var(--border-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 900;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drop-overlay-banner.visible {
  opacity: 1;
}

.stage-footer {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-paper);
  border-top: 2px solid var(--border-dark);
  font-size: 10px;
}

/* --- ACCORDION & CONTROL GROUPS --- */
.accordion-group {
  display: flex;
  flex-direction: column;
}

.group-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px !important;
  background: var(--border-dark) !important;
  color: #ffffff !important;
  border: 2px solid var(--border-dark) !important;
  font-family: var(--font-mono);
  font-size: 12px !important;
  font-weight: 800 !important;
  cursor: default;
  margin-bottom: 0;
  box-shadow: 2px 2px 0px var(--border-dark);
  user-select: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.accordion-group.collapsed .group-title,
.accordion-group.mobile-collapsed .group-title {
  border-radius: var(--radius-md);
  margin-bottom: 2px;
}

.group-title:hover {
  filter: brightness(1.05);
}

.group-content {
  background: var(--bg-card);
  border: 2px solid var(--border-dark);
  border-top: none;
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: 2px 2px 0px var(--border-dark);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.group-content.hidden {
  display: none;
}

.group-content-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   FORM FIELDS & CONTROLS STYLING
   -------------------------------------------------------------------------- */
.drop-zone {
  border: 2px dashed var(--border-dark);
  background: #fff;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.drop-zone:hover {
  background: var(--accent-yellow);
}

.file-input-hidden {
  display: none;
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.drop-icon {
  font-size: 20px;
}

.drop-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}

.drop-sub {
  font-size: 9px;
  color: var(--text-muted);
}

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

.control-field label, .field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;

}

.brutal-select, .brutal-input, .brutal-textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--border-dark);
  background: #fff;
  outline: none;
  border-radius: var(--radius-sm);
}

.brutal-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23111111%22%20stroke-width%3D%223.5%22%20stroke-linecap%3D%22square%22%20stroke-linejoin%3D%22miter%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Custom Brutalist Dropdown Component */
.custom-dropdown-container {
  position: relative;
  width: 100%;
}

.custom-dropdown-trigger {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main, #111111);
  background: #ffffff;
  border: 2px solid var(--border-dark, #111111);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  outline: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.custom-dropdown-trigger:hover,
.custom-dropdown-trigger:focus {
  background: var(--accent-yellow, #FFE600);
}

.custom-dropdown-trigger .dropdown-icon {
  font-size: 10px;
  margin-left: 12px;
  margin-right: 2px;
  transition: transform 0.2s ease;
}

.custom-dropdown-container.open .custom-dropdown-trigger .dropdown-icon {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: #ffffff;
  border: 2px solid var(--border-dark, #111111);
  box-shadow: 4px 4px 0px #111111;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0;
}

.custom-dropdown-menu.hidden {
  display: none !important;
}

.custom-dropdown-option {
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #111111;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed #e0e0e0;
  transition: background 0.1s ease, color 0.1s ease;
  user-select: none;
}

.custom-dropdown-option:last-child {
  border-bottom: none;
}

.custom-dropdown-option:hover {
  background: var(--accent-yellow, #FFE600);
  color: #111111;
}

.custom-dropdown-option.selected {
  background: #111111;
  color: var(--accent-yellow, #FFE600);
  font-weight: 800;
}

.custom-dropdown-option.selected::after {
  content: "✓";
  font-weight: 800;
  font-size: 12px;
}

.hidden-select {
  display: none !important;
}

textarea.brutal-input, .brutal-textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.4;
}

/* Dither Modes Grid */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: #fff;
  border: 2px solid var(--border-dark);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
}

.mode-card:hover,
.mode-card.active {
  background: var(--accent-yellow);
  color: var(--border-dark);
  border-color: var(--border-dark);
}

.mode-card.active .mode-desc {
  color: #222222;
  opacity: 0.85;
}

.mode-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}

.mode-desc {
  font-size: 9px;
  opacity: 0.7;
}

/* Sliders */
.slider-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.slider-item.disabled-control {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(1);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
}

.val-badge {
  background: var(--border-dark);
  color: #fff;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: var(--radius-xs);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #ddd;
  border: 1px solid var(--border-dark);
  outline: none;
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent-yellow);
  border: 2px solid var(--border-dark);
  cursor: pointer;
  border-radius: var(--radius-xs);
}

/* Global Invert Segment Bar */
.global-invert-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: #fff;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-md);
}

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

.seg-btn {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  padding: 8px 6px;
  border: 1.5px solid var(--border-dark);
  background: var(--bg-paper);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
}

.seg-btn:hover,
.seg-btn.active {
  background: var(--accent-yellow);
  color: var(--border-dark);
  border-color: var(--border-dark);
}

/* Palette Grid */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.palette-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: #fff;
  border: 2px solid var(--border-dark);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.palette-card:hover,
.palette-card.active {
  background: var(--accent-yellow);
  border-color: var(--border-dark);
  color: var(--border-dark);
}

.swatch-strip {
  display: flex;
  height: 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.swatch-strip span {
  flex: 1;
}

.palette-name {
  font-size: 10px;
  font-weight: 700;
}

.custom-color-box {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
}

.custom-color-box.hidden {
  display: none;
}

.color-picker-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
}

.color-picker-item input[type="color"] {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border-dark);
  cursor: pointer;
  border-radius: var(--radius-xs);
}

.poster-text-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.poster-text-controls.hidden {
  display: none !important;
}

/* Checkboxes */
.checkbox-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brutal-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.control-note {
  font-size: 9px;
  font-weight: 500;
  opacity: 0.5;
  font-style: italic;
  letter-spacing: 0;
}

/* Export Buttons */
.scale-btn-group {
  display: flex;
  gap: 6px;
}

.scale-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 800;
  border: 1.5px solid var(--border-dark);
  background: #fff;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
}

.scale-btn:hover,
.scale-btn.active {
  background: var(--accent-yellow);
  color: var(--border-dark);
  border-color: var(--border-dark);
}

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-btn {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--border-dark);
  cursor: pointer;
  box-shadow: 3px 3px 0px var(--border-dark);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.export-btn .btn-icon {
  font-size: 18px;
}

.export-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px var(--border-dark);
}

.export-btn.primary-btn {
  background: var(--accent-green);
  color: var(--border-dark);
}

.export-btn.outline-btn {
  background: #fff;
}

.btn-main-text {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.btn-sub-text {
  font-size: 9px;
  opacity: 0.7;
}

/* Sidebar Footer Credits */
.sidebar-footer-credits {
  margin-top: 4px;
  padding: 12px 4px 4px;
  border-top: 1.5px dashed rgba(17, 17, 17, 0.2);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.4;
}

.creator-link {
  color: var(--border-dark);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 1px 4px;
  transition: all 0.15s ease;
}

.creator-link:hover {
  background: var(--accent-yellow);
  color: var(--border-dark);
  text-decoration: none;
}

/* Marquee Ticker (Always Fixed at Bottom of Viewport) */
.studio-marquee {
  flex-shrink: 0;
  border-top: 2px solid var(--border-dark);
  background: var(--border-dark);
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 140s linear infinite;
}

.marquee-content {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-right: 20px;
}

.star {
  color: var(--accent-yellow);
}

@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Desktop-only / Mobile-only visibility helpers */
.mobile-only { display: none; }
.desktop-only { display: block; }

/* --------------------------------------------------------------------------
   MOBILE & TABLET FLUID RESPONSIVE ADAPTATION (max-width: 1024px)
   Desktop CSS is untouched above this point.
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {

  /* --- MOBILE HEADER:
     Row 1: Logo + Badge on Left, Menu ICON ONLY (☰) on Right
     Row 2: ⚡ QUICK SAVE HD Button FULL WIDTH
     Collapsible Drawer below: Samples + Paste/Clear
  --- */
  .studio-header {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px;
    position: relative;
    gap: 8px;
  }

  .header-brand-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .header-brand-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  .logo-title {
    font-size: 16px;
  }

  .logo-badge-sub {
    padding: 2px 6px;
    font-size: 8px;
    white-space: nowrap;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-yellow);
    color: var(--border-dark);
    border: 2px solid var(--border-dark);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 900;
    padding: 0;
    cursor: pointer;
    box-shadow: 2px 2px 0px var(--border-dark);
    user-select: none;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
  }

  .mobile-menu-btn:hover,
  .mobile-menu-btn.active {
    background: var(--border-dark);
    color: var(--accent-yellow);
  }

  .quick-save-btn {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
    text-align: center !important;
    box-shadow: 2px 2px 0px var(--border-dark) !important;
    border-radius: var(--radius-md) !important;
  }

  .header-nav-drawer {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: var(--bg-card);
    border: 2px solid var(--border-dark);
    box-shadow: 3px 3px 0px var(--border-dark);
    border-radius: var(--radius-md);
    margin-top: 2px;
  }

  .header-nav-drawer.open {
    display: flex;
  }

  .header-samples {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
  }

  .header-samples .sample-label {
    font-size: 10px;
    font-weight: 800;
  }

  .sample-btn-group {
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .header-samples .sample-btn {
    flex: 1;
    text-align: center;
    min-width: 0;
    font-size: 10px;
    padding: 6px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    display: flex;
    gap: 6px;
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    border-top: 1.5px dashed rgba(17, 17, 17, 0.2);
    padding-top: 8px;
    margin-top: 2px;
  }

  .header-actions .action-mini-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .stage-bar {
    padding: 6px 10px;
    gap: 8px;
  }

  .stage-bar-left, .stage-bar-right {
    gap: 6px;
  }

  .stage-badge {
    margin-right: 4px !important;
  }

  .stage-stats-stack {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    line-height: 1.1;
  }

  .stage-stats-stack .stage-stat {
    font-size: 9px;
  }

  /* --- WORKSPACE MOBILE & TABLET LAYOUT --- */
  .studio-workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  /* Canvas stage (Middle): claims all remaining major space in the middle */
  .display-stage-container {
    order: 1;
    flex: 1 1 0;
    min-height: 0;
    border-left: none;
    border-right: none;
    border-bottom: 2px solid var(--border-dark);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .canvas-viewport {
    flex: 1;
    min-height: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }

  /* Bottom editing panel: occupies 28vh (~25-30%) at bottom with smooth vertical scroll */
  .mobile-controls-area {
    display: flex;
    flex-direction: column;
    order: 2;
    flex: 0 0 28vh;
    height: 28vh;
    max-height: 30vh;
    overflow-y: auto;
    background: var(--bg-paper);
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    gap: 12px;
    border-top: 2px solid var(--border-dark);
  }

  .sidebar-left,
  .sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    height: auto;
    overflow-y: visible;
  }

  /* Swap: hide drop zone, show upload button */
  .desktop-only { display: none !important; }
  .mobile-only  { display: block; }

  /* Mobile upload button */
  .mobile-upload-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent-yellow);
    border: 2px solid var(--border-dark);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 3px 3px 0px var(--border-dark);
    border-radius: var(--radius-md);
    transition: all 0.12s ease;
  }

  .mobile-upload-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--border-dark);
  }
  /* Accordion [02] dither buttons: horizontal scroll row
     2 buttons fully visible, 3rd peeks at ~20% to signal more */
  .mode-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mode-grid::-webkit-scrollbar { display: none; }
  .mode-card {
    flex: 0 0 calc((100% - 8px) / 2.2);
    min-width: 0;
    scroll-snap-align: start;
  }

  /* Accordion [03] palette cards: horizontal scroll, 2 full + ~20% peek */
  .palette-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .palette-grid::-webkit-scrollbar { display: none; }
  .palette-card {
    flex: 0 0 calc((100% - 8px) / 2.2);
    min-width: 0;
    scroll-snap-align: start;
  }

  /* Accordion [03] invert toggle: side by side, equal width */
  .invert-segment-group {
    display: flex;
    flex-direction: row;
    gap: 6px;
  }
  .seg-btn {
    flex: 1;
    font-size: 10px;
    padding: 8px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Accordion [05] scale buttons: all 4 compact in one row */
  .scale-btn-group {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: visible;
  }
  .scale-btn {
    flex: 1;
    scroll-snap-align: unset;
    white-space: nowrap;
    text-align: center;
    font-size: 10px;
    padding: 8px 4px;
  }

  /* Accordion [05] export action buttons: compact equal-width row, all 3 visible */
  .export-actions {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: visible;
  }
  .export-btn {
    flex: 1;
    min-width: 0;
    padding: 10px 6px;
    scroll-snap-align: unset;
  }
  .btn-main-text {
    font-size: 9px;
  }
  .btn-sub-text {
    display: none; /* hide subtitle on mobile to save height */
  }

  .accordion-group.collapsed .group-content,
  .accordion-group.mobile-collapsed .group-content {
    display: none;
  }

  .group-title {
    padding: 8px 12px !important;
    font-size: 11px !important;
    margin-bottom: 0;
  }

  /* Hide Pro Tip footer on mobile — Cmd+V paste is desktop-only */
  .stage-footer {
    display: none;
  }

}
