:root {
  --bg: #161513;
  --surface: #201e1b;
  --surface-2: #2a2723;
  --border: #36322d;
  --text: #f2ede4;
  --muted: #a69d8e;
  --accent: #d89b52;
  --accent-hover: #e5ac66;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #23201c 0%, var(--bg) 65%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(22, 21, 19, 0.88);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #d89b52, #9b5b2a);
  color: #161513;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

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

.mp4-export-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mp4-duration {
  appearance: none;
  background: var(--panel-2, #23211e);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.mp4-duration:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.btn {
  appearance: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #161513;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--muted);
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.studio {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 340px;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 22px;
  align-items: start;
}

.samples-rail {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

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

.inspector {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

@media (max-width: 1180px) {
  .studio {
    grid-template-columns: minmax(0, 1fr) 330px;
  }
  .samples-rail {
    position: static;
    max-height: none;
    grid-column: 1 / -1;
    padding: 10px 14px;
  }
  .samples-rail h2 {
    margin-bottom: 8px;
  }
  .samples-rail .samples-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .samples-rail .sample-card {
    flex: 0 0 88px;
  }
}

.quick-demo-btn {
  margin-top: 14px;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.finetune-drawer {
  margin: 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 10px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.finetune-drawer summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
  padding: 2px 0;
}

.finetune-drawer[open] summary {
  color: var(--text);
  margin-bottom: 8px;
}

.sticky-cta-bar {
  position: sticky;
  bottom: -14px;
  padding: 10px 0 4px;
  background: linear-gradient(to top, var(--surface) 75%, transparent);
  z-index: 4;
  display: flex;
  gap: 8px;
}

.btn-danger {
  background: rgba(196, 62, 54, 0.90);
  border: 1px solid rgba(235, 96, 86, 0.75);
  color: #fff8f4;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(214, 70, 62, 1);
  border-color: #ff8a80;
}

.btn.btn-active {
  background: rgba(216, 155, 82, 0.20);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.frame.manual-painting canvas {
  cursor: crosshair;
  touch-action: none;
}

.manual-studio {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(36, 33, 29, 0.96), rgba(24, 22, 19, 0.96));
  border: 1px solid rgba(216, 155, 82, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 244, 222, 0.06), 0 8px 22px rgba(0, 0, 0, 0.28);
}

.manual-studio-top,
.manual-studio-mid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.manual-studio-mid {
  justify-content: flex-start;
  padding-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.manual-sub-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.manual-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.studio-pill {
  appearance: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.studio-pill:hover {
  color: var(--text);
  border-color: rgba(216, 155, 82, 0.45);
}

.studio-pill.active,
.studio-pill.btn-active {
  background: rgba(216, 155, 82, 0.22);
  border-color: var(--accent);
  color: #f8e5c4;
}

.manual-color-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.manual-swatch-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
}

.manual-swatch-btn:hover {
  border-color: var(--accent);
}

.manual-swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d89b52;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.manual-dynamics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px 12px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 780px) {
  .manual-dynamics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.manual-dyn-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.manual-dyn-cell span {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.manual-dyn-cell strong {
  color: var(--text);
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.manual-dyn-cell input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0;
}

.frame.loupe-active canvas {
  cursor: none;
}

.loupe-lens {
  position: absolute;
  width: 184px;
  height: 184px;
  margin-left: -92px;
  margin-top: -92px;
  border-radius: 50%;
  border: 2.5px solid #d89b52;
  box-shadow:
    0 0 0 2px rgba(18, 16, 14, 0.85),
    0 14px 36px rgba(0, 0, 0, 0.65),
    inset 0 0 14px rgba(255, 245, 220, 0.18);
  pointer-events: none;
  z-index: 8;
  background: #161513;
}

@media (max-width: 820px) {
  .studio {
    grid-template-columns: 1fr;
  }
  .inspector {
    position: static;
    max-height: none;
  }
}

.canvas-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.frame {
  position: relative;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  max-width: 100%;
}

.canvas-stage.dragover .frame {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 155, 82, 0.3);
}

#paint-canvas {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  width: auto;
  height: auto;
  border-radius: 6px;
  background: #f4efe4;
}

.ref-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface);
  pointer-events: none;
}

.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.75);
  cursor: ew-resize;
  z-index: 6;
  transform: translateX(-1px);
  user-select: none;
  touch-action: none;
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #161412;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

.btn.active-toggle {
  border-color: var(--accent);
  background: rgba(216, 155, 82, 0.22);
  color: var(--text);
}

.brush-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 0 8px rgba(216, 155, 82, 0.4);
  pointer-events: none;
  z-index: 6;
  transform: translate(-50%, -50%);
}

.brush-cursor .tool-nib {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  transform: translate(-3px, -39px);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.65));
  pointer-events: none;
}

.frame.manual-painting .brush-cursor {
  transition: width 0.06s ease, height 0.06s ease;
}

.frame.manual-painting .brush-cursor .tool-nib {
  display: none;
}

.pipeline-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.pipe-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 3px 5px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.pipe-card:hover {
  transform: translateY(-1px);
  border-color: var(--muted);
  color: var(--text);
}

.pipe-card.active {
  border-color: var(--accent);
  background: rgba(216, 155, 82, 0.16);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(216, 155, 82, 0.45);
}

.pipe-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #1a1816;
  flex-shrink: 0;
}

.pipe-icon svg {
  width: 30px;
  height: 30px;
  display: block;
}

.pipe-card span {
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.empty-overlay,
.busy-overlay {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  border-radius: 6px;
}

.empty-overlay {
  background: rgba(244, 239, 228, 0.92);
  color: #2c2824;
}

.busy-overlay {
  background: rgba(22, 21, 19, 0.78);
  backdrop-filter: blur(4px);
  color: var(--text);
  gap: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(242, 237, 228, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.empty-hint {
  margin: 0;
  font-size: 13px;
  color: #5e564d;
  max-width: 420px;
}

.stage-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.stage-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.stage-pill:hover {
  border-color: var(--muted);
  color: var(--text);
}

.stage-pill.active {
  background: rgba(216, 155, 82, 0.18);
  border-color: var(--accent);
  color: var(--text);
}

.playback-bar {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.playback-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.tool-deck {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-well {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.tool-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.09);
  margin: 0 2px;
}

.play-toggle {
  gap: 6px;
  height: 34px;
  padding: 0 14px 0 11px;
  border-radius: 9px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.play-toggle .btn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.play-toggle .icon-pause {
  display: none;
}

.play-toggle.is-playing .icon-play {
  display: none;
}

.play-toggle.is-playing .icon-pause {
  display: block;
}

.tool-icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}

.tool-group .tool-icon-btn {
  background: var(--surface-2);
  border-color: var(--border);
}

.tool-icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.tool-icon-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.tool-icon-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.tool-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tool-icon-btn.btn-active,
.tool-icon-btn.active-toggle {
  background: rgba(216, 155, 82, 0.22);
  border-color: rgba(216, 155, 82, 0.65);
  color: var(--accent-hover);
}

#sound-btn .icon-sound-on {
  display: none;
}

#sound-btn.btn-active .icon-sound-off {
  display: none;
}

#sound-btn.btn-active .icon-sound-on {
  display: block;
}

.tool-mode-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}

.tool-mode-btn .btn-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.14s ease;
}

.tool-mode-btn:hover:not(:disabled) {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.tool-mode-btn:hover:not(:disabled) .btn-icon {
  color: var(--text);
}

.tool-mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-mode-btn.btn-active {
  background: rgba(216, 155, 82, 0.22);
  border-color: var(--accent);
  color: #f8e5c4;
}

.tool-mode-btn.btn-active .btn-icon {
  color: var(--accent-hover);
}

.playback-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.meta-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.meta-badge.muted {
  color: var(--muted);
  text-transform: capitalize;
}

.playback-sliders {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 16px;
  align-items: end;
}

.playback-sliders .control-row {
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .playback-sliders {
    grid-template-columns: 1fr;
  }
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.field select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  min-width: 170px;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 10px;
}

.preset-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--muted);
  color: var(--text);
}

.preset-chip.active {
  background: rgba(216, 155, 82, 0.2);
  border-color: var(--accent);
  color: var(--text);
}

.style-sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 8px;
  min-width: 0;
}

.style-sliders .control-row {
  margin-bottom: 0;
  font-size: 11.5px;
  gap: 4px;
  min-width: 0;
}

.style-sliders .control-row strong {
  font-size: 11px;
}

.style-sliders .control-check,
.style-sliders .seed-row {
  grid-column: 1 / -1;
  min-width: 0;
}

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

.sample-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  padding: 0;
  cursor: pointer;
  color: var(--text);
  text-align: center;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.sample-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.sample-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(216, 155, 82, 0.35);
}

.sample-card.active span {
  color: var(--text);
}

.sample-card img {
  display: block;
  width: 100%;
  height: 62px;
  object-fit: cover;
}

.sample-card span {
  display: block;
  font-size: 11px;
  padding: 4px 2px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transport {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.transport .btn {
  flex: 1;
  padding: 7px 10px;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.control-row strong {
  color: var(--text);
  float: right;
  font-weight: 500;
}

.control-row input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.control-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding-top: 4px;
}

.control-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.control-check em {
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
}

.seed-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

.seed-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 34px;
}

.seed-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn-xs {
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 13px;
  margin-top: 6px;
}

.meta-key {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

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

.panel-header-row h2 {
  margin: 0;
}

.active-brush-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px 2px 4px;
}

.active-brush-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.swatch {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  opacity: 0.38;
  transform: scale(0.94);
  transition: transform 0.14s ease, opacity 0.18s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.swatch.used {
  opacity: 1;
  transform: scale(1);
}

.swatch.active {
  opacity: 1;
  transform: scale(1.22);
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent), 0 0 12px rgba(216, 155, 82, 0.75);
  z-index: 2;
  position: relative;
}

/* === Pipeline, Stage & Style Pill Explainers === */
.guide-btn {
  appearance: none;
  background: rgba(216, 155, 82, 0.14);
  color: var(--accent-hover);
  border: 1px solid rgba(216, 155, 82, 0.42);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.guide-btn:hover {
  background: rgba(216, 155, 82, 0.24);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.preset-explainer {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 10px;
  margin: 8px 0 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(216, 155, 82, 0.05));
  border: 1px solid rgba(216, 155, 82, 0.24);
}

.pe-thumb {
  width: 60px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pe-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.pe-body {
  min-width: 0;
  flex: 1;
}

.pe-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.pe-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.pe-badge {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(216, 155, 82, 0.16);
  color: var(--accent-hover);
  border: 1px solid rgba(216, 155, 82, 0.35);
}

.pe-desc {
  margin: 0 0 5px;
  font-size: 11px;
  line-height: 1.38;
  color: var(--muted);
}

.pe-link {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.pe-link:hover {
  text-decoration: underline;
}

/* Floating Stage Pill Popover */
.stage-popover {
  position: fixed;
  z-index: 40;
  width: 280px;
  padding: 11px 12px;
  border-radius: 11px;
  background: rgba(24, 22, 19, 0.96);
  border: 1px solid rgba(216, 155, 82, 0.45);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.sp-top {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 7px;
}

.sp-thumb {
  width: 66px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sp-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sp-step {
  font-size: 10px;
  color: var(--accent-hover);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.sp-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sp-count {
  font-size: 10.5px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.sp-desc {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: #d6cfc2;
}

/* Full Process & Technique Guide Modal */
.explainer-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 11, 10, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.explainer-dialog {
  width: min(980px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.explainer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(22, 21, 19, 0.7);
}

.explainer-header h2 {
  margin: 0 0 2px;
  font-size: 17px;
  font-family: Georgia, serif;
  color: var(--text);
}

.explainer-header p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.explainer-pipe-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.ex-pipe-tab {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}

.ex-pipe-tab:hover {
  color: var(--text);
  border-color: var(--muted);
}

.ex-pipe-tab.active {
  background: rgba(216, 155, 82, 0.2);
  border-color: var(--accent);
  color: var(--text);
}

.ex-pipe-tab-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.ex-pipe-tab-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.explainer-modal-body {
  padding: 20px 22px 26px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.ex-hero {
  background: linear-gradient(135deg, rgba(216, 155, 82, 0.1), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(216, 155, 82, 0.28);
  border-radius: 12px;
  padding: 16px 18px;
}

.ex-tradition {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-hover);
  font-weight: 600;
  margin-bottom: 4px;
}

.ex-hero h3 {
  margin: 0 0 8px;
  font-size: 22px;
  font-family: Georgia, serif;
  color: var(--text);
}

.ex-overview {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.55;
  color: #dfd8cc;
}

.ex-physics-bar {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ex-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ex-section-head h4 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text);
}

.ex-section-head span {
  font-size: 11.5px;
  color: var(--muted);
}

.ex-diagram-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  overflow-x: auto;
}

.process-diagram-svg {
  width: 100%;
  min-width: 480px;
  height: auto;
  display: block;
}

.ex-stages-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .ex-stages-grid {
    grid-template-columns: 1fr;
  }
}

.ex-stage-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.ex-stage-visual {
  width: 82px;
  height: 50px;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ex-stage-visual svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ex-stage-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.ex-stage-num {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-hover);
}

.ex-stage-tool {
  font-size: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ex-stage-info h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  color: var(--text);
}

.ex-stage-info p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.ex-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .ex-presets-grid {
    grid-template-columns: 1fr;
  }
}

.ex-preset-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.ex-preset-top {
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.ex-preset-thumb {
  width: 68px;
  height: 42px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ex-preset-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ex-preset-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}

.ex-preset-title-row h4 {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.ex-preset-card p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.42;
  color: var(--muted);
}

.ex-preset-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ex-preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ex-preset-tags span {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* === Brand About Trigger, About Dialog, Colophon & Footer === */
.brand-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.about-open {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.5px;
  transition: color 0.15s ease;
}

.about-open:hover {
  color: var(--accent-hover);
}

.about-dialog {
  margin: auto;
  padding: 0;
  border: 1px solid rgba(216, 155, 82, 0.32);
  border-radius: 12px;
  background: transparent;
  max-width: min(37rem, calc(100vw - 1.5rem));
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72);
}

.about-dialog::backdrop {
  background:
    radial-gradient(800px 420px at 20% 10%, rgba(216, 155, 82, 0.16), transparent 60%),
    rgba(12, 11, 10, 0.72);
  backdrop-filter: blur(4px);
}

.about-sheet {
  padding: 1.6rem 1.75rem 1.35rem;
  background:
    linear-gradient(165deg, rgba(36, 33, 29, 0.98), rgba(24, 22, 19, 0.98)),
    var(--surface);
  border-radius: 12px;
}

.about-kicker {
  margin: 0 0 0.35rem;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.about-title {
  margin: 0 0 1.05rem;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: clamp(1.85rem, 4vw, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
}

.about-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.about-body p {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
  font-weight: 400;
  line-height: 1.55;
  color: #d6cfc2;
}

.about-body em {
  font-style: italic;
  color: var(--text);
}

.about-colophon {
  margin: 1.2rem 0 0;
  padding-top: 0.95rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.about-colophon p {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--muted);
}

.about-colophon strong {
  font-weight: 600;
  color: var(--text);
}

.about-actions {
  margin-top: 1.15rem;
  display: flex;
  justify-content: flex-end;
}

.bmc-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.5rem 0.16rem;
  border-radius: 999px;
  background: #1a2332;
  color: #f0c14a;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: baseline;
  line-height: 1.2;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-weight: 500;
  box-shadow: 0 0 0 1px rgba(240, 193, 74, 0.24);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.bmc-link:hover {
  color: #ffd666;
  background: #121821;
  text-decoration: none;
  box-shadow: 0 0 0 1px rgba(255, 214, 102, 0.45);
}

.bmc-logo {
  width: 0.85em;
  height: 0.85em;
  display: inline-block;
  flex: 0 0 auto;
}

.studio-footer {
  max-width: 1600px;
  margin: 4px auto 0;
  padding: 12px 24px 22px;
  border-top: 1px solid rgba(54, 50, 45, 0.6);
  text-align: center;
}

.studio-footer p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.studio-footer strong {
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 600px) {
  .about-sheet {
    padding: 1.25rem 1.2rem 1.1rem;
  }
  .about-body p {
    font-size: 0.92rem;
  }
}
