/* ==========================================================================
   SUITED STUDIO — TOKYO NEO-BRUTALIST ATELIER × ROBINHOOD EMERALD EDITORIAL
   ========================================================================== */

:root {
  --bg-void: #06080D;
  --bg-panel: #0C1018;
  --bg-card: #121824;
  --bg-card-hover: #182132;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --emerald: #00E676;
  --emerald-dim: rgba(0, 230, 118, 0.14);
  --crimson: #FF2A5F;
  --gold: #FFB800;
  --cyan: #00F0FF;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --font-display: 'Syne', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

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

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

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--emerald);
}

/* ==========================================================================
   TOP STUDIO HEADER BAR
   ========================================================================== */
.studio-header {
  height: 64px;
  background: rgba(10, 14, 22, 0.96);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
  z-index: 30;
}

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

.studio-logo-img {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 10px rgba(255, 140, 0, 0.32));
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--emerald), #009E52);
  color: #04120A;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 230, 118, 0.35);
  border: 2px solid #FFFFFF;
}

.brand-titles {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.brand-titles h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16.5px;
  line-height: 1.15;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.brand-titles h1 span.accent {
  color: var(--emerald);
}

.no-wallet-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(0, 230, 118, 0.35);
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  white-space: nowrap;
}

.brand-sub a {
  color: var(--emerald);
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 700;
  white-space: nowrap;
}
.brand-sub a:hover {
  text-decoration: underline;
}

/* Format Switcher */
.format-switcher {
  display: flex;
  align-items: center;
  background: #080B11;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}

.format-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  height: 36px;
  padding: 0 11px;
  border-radius: 7px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.format-btn small {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: 0.72;
  white-space: nowrap;
}

.format-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.format-btn.active {
  background: var(--emerald);
  color: #04120A;
  box-shadow: 0 2px 14px rgba(0, 230, 118, 0.3);
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-secondary, .btn-wall, .btn-export-3d, .btn-primary-export {
  border-radius: 9px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  height: 38px;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.16s ease;
}

.btn-export-3d {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.22), rgba(0, 230, 118, 0.26));
  color: #E2FAFF;
  border: 1.5px solid var(--cyan);
  font-weight: 800;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.28);
}
.btn-export-3d:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.36), rgba(0, 230, 118, 0.4));
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  border-color: var(--emerald);
  background: var(--bg-card-hover);
}

.btn-wall {
  background: linear-gradient(135deg, rgba(255, 42, 95, 0.18), rgba(157, 78, 221, 0.22));
  color: #FFE6F0;
  border: 1px solid rgba(255, 42, 95, 0.5);
}
.btn-wall:hover {
  background: linear-gradient(135deg, rgba(255, 42, 95, 0.32), rgba(157, 78, 221, 0.35));
  transform: translateY(-1px);
}

.btn-primary-export {
  background: var(--emerald);
  color: #031209;
  border: 2px solid #FFFFFF;
  font-weight: 800;
  box-shadow: 0 0 22px rgba(0, 230, 118, 0.35);
}
.btn-primary-export:hover {
  background: #26FF8E;
  transform: translateY(-1px);
}

/* ==========================================================================
   MAIN 3-COLUMN STUDIO WORKSPACE
   ========================================================================== */
.studio-workspace {
  display: grid;
  grid-template-columns: 340px 1fr 390px;
  height: calc(100vh - 64px);
  width: 100%;
}

/* ==========================================================================
   LEFT DOCK: 2,222 SUITED APE VAULT & TRAIT PICKER
   ========================================================================== */
.left-dock {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.dock-section-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.section-title-row h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-dim);
  padding: 2px 8px;
  border-radius: 6px;
}

.search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.studio-input {
  width: 100%;
  background: #070A10;
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-family: var(--font-body);
  outline: none;
}
.studio-input:focus {
  border-color: var(--emerald);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.icon-btn:hover {
  border-color: var(--emerald);
  color: var(--emerald);
}

.filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.studio-select {
  width: 100%;
  background: #070A10;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-family: var(--font-body);
  outline: none;
}
.studio-select:focus {
  border-color: var(--emerald);
  color: var(--text-main);
}

/* Ape Grid */
.ape-grid-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.ape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ape-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: all 0.14s ease;
  display: flex;
  flex-direction: column;
}

.ape-card:hover {
  border-color: rgba(255, 255, 255, 0.32);
  transform: translateY(-2px);
}

.ape-card.selected {
  border-color: var(--emerald);
  box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.32);
}

.ape-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #080B12;
  overflow: hidden;
}

.ape-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ape-rank-tag {
  position: absolute;
  top: 5px;
  right: 5px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(6, 8, 14, 0.85);
  color: #E2E8F0;
  border: 1px solid rgba(255,255,255,0.15);
}
.ape-rank-tag.mythic {
  background: rgba(255, 42, 95, 0.9);
  color: #FFF;
  border-color: #FF85A1;
}
.ape-rank-tag.legendary {
  background: rgba(255, 184, 0, 0.92);
  color: #090A0F;
  border-color: #FFF;
}
.ape-rank-tag.rare {
  background: rgba(0, 230, 118, 0.9);
  color: #04120A;
}

.ape-card-meta {
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ape-id-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-main);
}

.ape-sub-trait {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selected Ape Inspector Card at bottom of Left Dock */
.selected-ape-inspector {
  padding: 12px 14px;
  background: #080B12;
  border-top: 1px solid var(--border-strong);
}

.inspector-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

#inspector-ape-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--emerald);
}

#inspector-ape-rank {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold);
}

.inspector-traits-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 10px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.inspector-traits-grid b {
  color: var(--text-main);
}

.inspector-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.combat-stats-row {
  display: flex;
  gap: 6px;
}

.stat-mini {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  display: flex;
  gap: 4px;
}
.stat-mini span {
  color: var(--text-muted);
}
.stat-mini strong {
  color: var(--emerald);
}

.opensea-mini-link {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 700;
}
.opensea-mini-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   CENTER STAGE: INTERACTIVE LIVE CANVAS & QUICK UNIVERSE RIBBON
   ========================================================================== */
.center-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(circle at 50% 40%, rgba(0, 230, 118, 0.07), transparent 60%),
    linear-gradient(180deg, #07090F 0%, #05070B 100%);
  overflow: hidden;
  position: relative;
}

/* Top Featured Universe Ribbon */
.featured-ribbon {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  background: rgba(10, 14, 22, 0.78);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.ribbon-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
  margin-right: 4px;
}

.quick-universe-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.14s ease;
}
.quick-universe-chip:hover {
  border-color: var(--emerald);
  transform: translateY(-1px);
}
.quick-universe-chip.active {
  background: var(--emerald);
  color: #031209;
  border-color: #FFFFFF;
}

/* Canvas Viewport Area */
.canvas-viewport {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  position: relative;
  overflow: hidden;
  perspective: 1100px;
}

.canvas-frame-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.canvas-3d-rig {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}

.canvas-3d-rig.is-3d-active {
  transform:
    perspective(1100px)
    rotateX(var(--tilt-x, 8deg))
    rotateY(var(--tilt-y, -12deg))
    scale(0.92);
}

.canvas-3d-rig.is-spinning-360 {
  transition: none !important;
}

#studio-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: grab;
  touch-action: none;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.78), 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition: box-shadow 0.18s ease;
}

.canvas-3d-rig.is-3d-active #studio-canvas {
  box-shadow:
    calc(var(--shadow-x, 12px) * 0.28) calc(var(--shadow-y, 10px) * 0.28) 0 var(--emerald),
    calc(var(--shadow-x, 12px) * 0.58) calc(var(--shadow-y, 10px) * 0.58) 0 #091322,
    calc(var(--shadow-x, 12px) * 0.88) calc(var(--shadow-y, 10px) * 0.88) 0 rgba(0, 240, 255, 0.72),
    calc(var(--shadow-x, 12px) * 1.7) calc(var(--shadow-y, 10px) * 1.9) 52px rgba(0, 0, 0, 0.9),
    0 0 0 2px rgba(255, 255, 255, 0.26);
}

/* 3D Refractive Crystal Glass Frame Casing floating over Canvas */
.canvas-glass-casing {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateZ(16px);
  pointer-events: none;
  border-radius: 14px;
  border: 2.5px solid rgba(255, 255, 255, 0.72);
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.12),
    inset 0 0 22px rgba(0, 240, 255, 0.32),
    0 0 24px rgba(0, 240, 255, 0.35),
    0 12px 36px rgba(0, 0, 0, 0.65);
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(0, 240, 255, 0.08) 18%,
      transparent 38%,
      transparent 64%,
      rgba(0, 230, 118, 0.12) 82%,
      rgba(255, 255, 255, 0.24) 100%
    );
  display: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.canvas-glass-casing.active {
  display: block;
}

.glass-bolt {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle, #00E676 32%, #071220 75%);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.7);
}
.glass-bolt.tl { top: 6px; left: 6px; }
.glass-bolt.tr { top: 6px; right: 6px; }
.glass-bolt.bl { bottom: 6px; left: 6px; }
.glass-bolt.br { bottom: 6px; right: 6px; }

.glass-slab-plaque {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) translateZ(8px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(135deg, rgba(8, 16, 28, 0.92), rgba(14, 28, 46, 0.92));
  border: 1.5px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.75), 0 0 12px rgba(0, 240, 255, 0.35);
  color: #E8FBFF;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 11px;
  border-radius: 99px;
  white-space: nowrap;
}

/* 3D Collector Vault Backplate (3D Rear Ape + Banana Backpack + Custom Nameplate) */
.canvas-3d-backplate {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotateY(180deg) translateZ(2px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  pointer-events: none;
  border-radius: 12px;
  background: #060A12;
  border: 2.5px solid rgba(0, 240, 255, 0.78);
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.08),
    inset 0 0 38px rgba(255, 214, 0, 0.22),
    0 24px 60px rgba(0, 0, 0, 0.88);
  padding: 0;
  overflow: hidden;
}

#backplate-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
}

.backplate-3d-float-tag {
  display: none;
}

.bp-float-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: #FFD600;
  letter-spacing: 0.05em;
}

.bp-float-name {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 900;
  color: #FFFFFF;
  letter-spacing: 0.06em;
  text-shadow: 0 0 10px rgba(0, 230, 118, 0.65);
}

.back-name-quick-input {
  width: 205px;
  height: 28px;
  padding: 0 11px;
  border-radius: 99px;
  background: rgba(10, 16, 26, 0.92);
  border: 1.5px solid rgba(255, 214, 0, 0.65);
  color: #FFFDF2;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  outline: none;
  box-shadow: 0 0 12px rgba(255, 214, 0, 0.18);
  transition: all 0.15s ease;
}
.back-name-quick-input::placeholder {
  color: rgba(255, 234, 138, 0.65);
  font-weight: 600;
}
.back-name-quick-input:focus {
  border-color: #FFD600;
  box-shadow: 0 0 16px rgba(255, 214, 0, 0.45);
}

#studio-canvas:active {
  cursor: grabbing;
}

.canvas-holo-glare {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  pointer-events: none;
  border-radius: 10px;
  opacity: 0;
  mix-blend-mode: screen;
  background:
    linear-gradient(
      125deg,
      transparent 18%,
      rgba(255, 255, 255, 0.22) 36%,
      rgba(0, 240, 255, 0.18) 48%,
      rgba(0, 230, 118, 0.16) 56%,
      transparent 74%
    ),
    radial-gradient(
      circle at var(--glare-x, 32%) var(--glare-y, 28%),
      rgba(255, 255, 255, 0.28) 0%,
      transparent 58%
    );
  transition: opacity 0.2s ease;
}

.canvas-3d-rig.is-3d-active .canvas-holo-glare {
  opacity: 1;
}

.canvas-3d-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(6, 10, 18, 0.88);
  border: 1.5px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 99px;
  letter-spacing: 0.04em;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.65), 0 0 12px rgba(0, 240, 255, 0.32);
  transform: translateZ(26px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: none;
}

.canvas-3d-rig.is-3d-active .canvas-3d-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-3d-pill {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(0, 230, 118, 0.22));
  border: 1.5px solid var(--cyan);
  color: #E2FAFF;
  padding: 4px 11px;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.22);
}
.btn-3d-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.4);
}
.btn-3d-pill strong {
  color: var(--emerald);
  font-family: var(--font-mono);
}
.btn-3d-pill.off {
  background: var(--bg-card);
  border-color: var(--border-strong);
  box-shadow: none;
  color: var(--text-muted);
}
.btn-3d-pill.off strong {
  color: var(--text-muted);
}

.canvas-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 13, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--emerald);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.canvas-loading-overlay.visible {
  opacity: 1;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0, 230, 118, 0.2);
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Bottom Canvas Control Bar */
.canvas-bottom-bar {
  min-height: 54px;
  padding: 8px 18px;
  background: rgba(10, 14, 22, 0.92);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.active-style-pill {
  display: flex;
  flex-direction: column;
}
#active-style-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--emerald);
}
#active-style-franchise {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.canvas-toggles {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.toggle-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle-chip input {
  accent-color: var(--emerald);
  cursor: pointer;
}
.toggle-chip:hover {
  color: var(--text-main);
}

.res-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: #070A10;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   RIGHT DOCK: 142 ANIME/MANGA DECK, SHADERS, PROPS & HUD CUSTOMIZER
   ========================================================================== */
.right-dock {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.dock-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #080B12;
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px;
  gap: 4px;
}

.dock-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock-tab:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.04);
}
.dock-tab.active {
  background: var(--bg-card-hover);
  color: var(--emerald);
  border: 1px solid rgba(0, 230, 118, 0.35);
}

.dock-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.dock-panel.active {
  display: flex;
}

.panel-header-controls {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.cat-pill {
  background: #070A10;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}
.cat-pill:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}
.cat-pill.active {
  background: var(--emerald);
  color: #04120A;
  border-color: var(--emerald);
}

.style-deck-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.style-deck-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.style-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
}

.style-card:hover {
  border-color: var(--st-primary, var(--emerald));
  transform: translateY(-2px);
}

.style-card.active {
  border-color: var(--emerald);
  box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.3);
}

.style-swatch {
  height: 46px;
  background: linear-gradient(135deg, var(--st-primary), var(--st-secondary), var(--st-dark));
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.style-badge-pill {
  background: rgba(6, 8, 14, 0.85);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
}

.style-shader-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.2);
  color: #FFF;
  padding: 2px 5px;
  border-radius: 4px;
}

.style-card-body {
  padding: 8px 9px;
}

.style-card-title {
  font-weight: 800;
  font-size: 12px;
  color: var(--text-main);
  margin-bottom: 2px;
  line-height: 1.25;
}

.style-card-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Controls & Sliders inside Panels */
.panel-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-group-3d {
  background: linear-gradient(160deg, rgba(0, 240, 255, 0.07) 0%, rgba(18, 24, 36, 0.95) 55%, rgba(0, 230, 118, 0.07) 100%);
  border: 1.5px solid rgba(0, 240, 255, 0.35);
}

.mode-3d-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.mode-3d-btn {
  background: #080C14;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 9px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.14s ease;
  color: var(--text-main);
}
.mode-3d-btn span {
  font-size: 11.5px;
  font-weight: 800;
}
.mode-3d-btn small {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
}
.mode-3d-btn:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
}
.mode-3d-btn.active {
  background: rgba(0, 230, 118, 0.15);
  border-color: var(--emerald);
  box-shadow: 0 0 0 1px rgba(0, 230, 118, 0.3);
}
.mode-3d-btn.active span {
  color: var(--emerald);
}

.control-group.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.group-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--emerald);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-label-line {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.slider-label-line strong {
  font-family: var(--font-mono);
  color: var(--text-main);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--emerald);
  cursor: pointer;
}

/* Props Grid */
.props-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.prop-item-btn {
  background: #080B12;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  transition: all 0.14s ease;
}
.prop-item-btn:hover {
  border-color: var(--emerald);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}
.prop-icon {
  font-size: 18px;
}
.prop-label {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
}

.btn-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-danger {
  background: rgba(255, 42, 95, 0.15);
  border: 1px solid rgba(255, 42, 95, 0.45);
  color: #FF85A1;
  padding: 8px 10px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 11.5px;
  cursor: pointer;
}
.btn-danger:hover {
  background: rgba(255, 42, 95, 0.3);
}

/* ==========================================================================
   FULL-SCREEN 142-UNIVERSE MATRIX MODAL
   ========================================================================== */
.universe-wall-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.92);
  backdrop-filter: blur(14px);
  z-index: 100;
  display: none;
  flex-direction: column;
  padding: 28px 36px;
}
.universe-wall-modal.open {
  display: flex;
}

.wall-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-strong);
}

.wall-modal-header h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
}

.wall-modal-grid {
  flex: 1;
  overflow-y: auto;
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  align-content: start;
}

.wall-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-left: 5px solid var(--st-primary, var(--emerald));
  border-radius: 9px;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.14s ease;
}
.wall-card:hover {
  transform: translateY(-2px);
  border-color: var(--st-primary, var(--emerald));
  background: var(--bg-card-hover);
}
.wall-card.active {
  border-color: var(--emerald);
  box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.35);
}

.wall-card-top {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.wall-badge {
  color: var(--st-primary, var(--emerald));
  font-weight: 700;
}
.wall-name {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 2px;
}
.wall-fran {
  font-size: 11px;
  color: var(--text-muted);
}

/* Toast Notification */
.studio-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #08120D;
  color: var(--emerald);
  border: 1.5px solid var(--emerald);
  padding: 10px 20px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 200;
}
.studio-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   MOBILE & TABLET THUMB-ZONE BOTTOM NAVIGATION BAR
   Hidden on desktop (> 1024px), active on Tablet & Mobile (<= 1024px)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS: LAPTOP, TABLET (iPad) & MOBILE (iOS / Android)
   ========================================================================== */

/* 1. Compact Laptop & Medium Desktop (1025px – 1520px) */
@media (max-width: 1520px) and (min-width: 1025px) {
  .hide-lg {
    display: none !important;
  }
  .studio-header {
    padding: 0 14px;
    gap: 10px;
  }
  .studio-logo-img {
    height: 32px;
  }
  .brand-titles h1 {
    font-size: 15px;
  }
  .format-btn {
    padding: 0 9px;
    font-size: 11px;
    height: 34px;
  }
  .btn-secondary, .btn-wall, .btn-export-3d, .btn-primary-export {
    padding: 0 11px;
    font-size: 11.5px;
    height: 36px;
  }
}

@media (max-width: 1280px) and (min-width: 1025px) {
  .hide-md {
    display: none !important;
  }
  .studio-workspace {
    grid-template-columns: 280px 1fr 330px;
  }
}

/* 2. Tablet & Mobile Unified Studio Architecture (<= 1024px) */
@media (max-width: 1024px) {
  html, body {
    width: 100%;
    max-width: 100vw;
    height: 100dvh;
    overflow: hidden;
  }

  .hide-lg {
    display: none !important;
  }

  /* Two-row Responsive Header: Brand + Actions on Top, Format Bar Below */
  .studio-header {
    width: 100%;
    max-width: 100vw;
    height: auto;
    min-height: 86px;
    flex-wrap: wrap;
    padding: 7px 12px;
    gap: 7px;
  }

  .brand-cluster {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 16px;
    flex-shrink: 0;
  }

  .studio-logo-img {
    height: 30px;
  }

  .brand-titles {
    min-width: 0;
  }

  .brand-titles h1 {
    font-size: 14px;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .brand-sub {
    font-size: 9.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 6px;
  }

  .btn-wall, .btn-secondary, .btn-export-3d, .btn-primary-export {
    padding: 0 10px;
    font-size: 11px;
    height: 34px;
    min-height: 34px;
    white-space: nowrap;
  }

  .format-switcher {
    order: 3;
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }

  .featured-ribbon,
  .canvas-bottom-bar,
  .category-pills,
  .filters-grid,
  .format-switcher {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .featured-ribbon::-webkit-scrollbar,
  .canvas-bottom-bar::-webkit-scrollbar,
  .category-pills::-webkit-scrollbar,
  .filters-grid::-webkit-scrollbar,
  .format-switcher::-webkit-scrollbar {
    display: none;
  }

  .format-btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 6px 6px;
    font-size: 11px;
    min-height: 34px;
    white-space: nowrap;
  }

  /* Split Studio Workspace:
     Top = Live Interactive Canvas (always visible!)
     Bottom = Active Workbench Panel (Apes OR Styles/Props/Shaders/Text) */
  .studio-workspace {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 150px);
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  /* Center Stage stays pinned at top so user always sees live Ape changes */
  .center-stage {
    order: 1;
    flex: 0 0 45%;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    min-height: 220px;
    max-height: 46dvh;
    border-bottom: 1.5px solid var(--border-strong);
  }

  .featured-ribbon {
    width: 100%;
    max-width: 100vw;
    padding: 6px 10px;
    gap: 6px;
    flex-shrink: 0;
  }

  .quick-universe-chip {
    padding: 4px 9px;
    font-size: 10.5px;
    flex-shrink: 0;
  }

  .canvas-viewport {
    padding: 6px 10px;
    width: 100%;
    min-height: 0;
  }

  #studio-canvas {
    max-width: 100%;
    max-height: 100%;
  }

  .canvas-bottom-bar {
    width: 100%;
    max-width: 100vw;
    min-height: 36px;
    padding: 4px 10px;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .active-style-pill {
    flex-shrink: 0;
  }

  #active-style-name {
    font-size: 11.5px;
  }

  #active-style-franchise {
    display: none;
  }

  .canvas-toggles {
    flex-wrap: nowrap;
    gap: 10px;
    flex-shrink: 0;
  }

  .res-badge {
    display: none;
  }

  /* Bottom Half Workbench: Swaps between Left Dock (Apes) & Right Dock (Inspector) */
  .left-dock,
  .right-dock {
    order: 2;
    flex: 1 1 55%;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    height: auto;
    min-height: 0;
    border: none;
  }

  .dock-panel {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
  }

  .ape-card,
  .style-card,
  .prop-item-btn {
    min-width: 0;
  }

  .studio-workspace[data-mob-view="inspector"] .left-dock {
    display: none;
  }

  .studio-workspace[data-mob-view="apes"] .right-dock {
    display: none;
  }

  /* Hide redundant desktop right-dock tab bar when controlled by bottom thumb bar */
  .right-dock .dock-tabs {
    display: none;
  }

  /* Tablet grids (4 columns on iPad / Tablet) */
  .ape-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }

  .style-deck-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .props-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Compact Selected Ape Inspector on Mobile/Tablet */
  .selected-ape-inspector {
    padding: 8px 12px;
    flex-shrink: 0;
  }

  .inspector-traits-grid {
    grid-template-columns: repeat(4, 1fr);
    font-size: 10px;
    margin-bottom: 4px;
  }

  /* Thumb-Zone Fixed Bottom Bar */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 58px;
    width: 100%;
    max-width: 100vw;
    background: rgba(8, 11, 18, 0.98);
    border-top: 1px solid var(--border-strong);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }

  .mob-nav-btn {
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.14s ease;
  }

  .mob-nav-icon {
    font-size: 15px;
    line-height: 1;
  }

  .mob-nav-label {
    font-size: 9.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .mob-nav-btn.active {
    background: var(--emerald-dim);
    color: var(--emerald);
    border-color: rgba(0, 230, 118, 0.4);
  }

  .studio-toast {
    bottom: 70px;
    font-size: 11.5px;
    padding: 8px 16px;
    max-width: 92vw;
    text-align: center;
  }

  /* Full-Screen 142-Universe Matrix Modal on Tablet */
  .universe-wall-modal {
    padding: 16px;
  }
  .wall-modal-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}

/* 3. Smartphone Viewport (< 640px: iPhone, Galaxy, Pixel) */
@media (max-width: 640px) {
  .hide-lg,
  .hide-md,
  .hide-xs,
  .no-wallet-pill,
  .brand-sub {
    display: none !important;
  }

  .studio-header {
    padding: 6px 10px;
    gap: 6px;
    min-height: 76px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 14px;
    border-radius: 7px;
  }

  .studio-logo-img {
    height: 22px;
  }

  .brand-cluster {
    gap: 5px;
  }

  .brand-titles h1 {
    font-size: 12px;
    letter-spacing: 0.02em;
  }

  .header-actions {
    gap: 4px;
  }

  .btn-wall, .btn-secondary, .btn-export-3d, .btn-primary-export {
    padding: 0 7px;
    font-size: 10px;
    height: 28px;
    min-height: 28px;
    border-radius: 7px;
  }

  .format-btn small {
    display: none;
  }

  .format-btn {
    font-size: 10.5px;
    padding: 0 4px;
    height: 28px;
    min-height: 28px;
  }

  /* Phone Canvas & Workbench Split */
  .studio-workspace {
    height: calc(100dvh - 138px);
  }

  .center-stage {
    flex: 0 0 43%;
    min-height: 200px;
    max-height: 44dvh;
  }

  .dock-section-header,
  .panel-header-controls {
    padding: 7px 10px;
    gap: 6px;
  }

  .section-title-row {
    margin-bottom: 4px;
  }

  .section-title-row h2 {
    font-size: 12px;
  }

  .search-row {
    margin-bottom: 5px;
  }

  .studio-input {
    font-size: 16px; /* Prevents iOS Safari auto-zoom on focus */
    padding: 5px 9px;
    height: 34px;
  }

  /* Single-line horizontal swipeable filters & category pills on mobile */
  .filters-grid {
    display: flex;
    overflow-x: auto;
    gap: 5px;
    padding-bottom: 2px;
  }

  .filters-grid .studio-select {
    flex: 0 0 auto;
    width: auto;
    min-width: 112px;
    padding: 5px 7px;
    font-size: 11px;
  }

  .category-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .cat-pill {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .ape-grid-scroll,
  .style-deck-scroll,
  .panel-scroll-body {
    padding: 8px 10px;
  }

  .ape-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .style-deck-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .style-swatch {
    height: 36px;
    padding: 4px 6px;
  }

  .style-card-body {
    padding: 6px 7px;
  }

  .style-card-title {
    font-size: 11px;
  }

  .props-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Ultra-compact 1-line active Ape bar at bottom of Ape drawer on mobile */
  .selected-ape-inspector {
    padding: 6px 10px;
  }

  .inspector-traits-grid {
    display: none;
  }

  .inspector-top {
    margin-bottom: 4px;
  }

  .inspector-bottom-bar {
    padding-top: 4px;
  }

  .wall-modal-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  #wall-search-input {
    width: 100% !important;
  }
}
