.avf-studio {
  background: rgba(14, 16, 25, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.avf-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.avf-sources {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.avf-demo-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
}
.avf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.avf-btn:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(167, 139, 250, 0.45); color: #ffffff; }
.avf-btn.is-active { background: rgba(139, 92, 246, 0.24); border-color: rgba(167, 139, 250, 0.65); color: #ffffff; }
.avf-btn-amber {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #09090b;
  font-weight: 600;
}
.avf-btn-amber:hover { background: #d97706; border-color: #d97706; color: #09090b; }
.avf-btn-violet {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #ffffff;
  font-weight: 600;
}
.avf-btn-violet:hover { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }
.avf-btn-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  font-weight: 600;
}
.avf-btn-sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.avf-pill-btn {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.avf-pill-btn:hover { color: #f8fafc; background: rgba(255, 255, 255, 0.06); }
.avf-pill-btn.is-active { color: #fde68a; background: rgba(245, 158, 11, 0.16); }
.avf-view-actions { display: flex; align-items: center; gap: 8px; }

/* Stage */
.avf-stage-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: #05060a;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  overflow: hidden;
  min-height: 380px;
  padding: 10px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.avf-stage-wrap.is-dragover {
  border-color: #f59e0b;
  box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.45);
}
.avf-stage-wrap.is-transparent {
  background-image:
    linear-gradient(45deg, #161823 25%, transparent 25%),
    linear-gradient(-45deg, #161823 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #161823 75%),
    linear-gradient(-45deg, transparent 75%, #161823 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-color: #0e1018;
}
.avf-canvas {
  display: block;
  width: 100%;
  max-height: 540px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 10px;
}
.avf-stage-wrap[data-aspect="9:16"] .avf-canvas {
  width: auto;
  height: 520px;
  max-width: 100%;
  aspect-ratio: 9 / 16;
}
.avf-stage-wrap[data-aspect="1:1"] .avf-canvas {
  width: auto;
  height: 500px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
}
.avf-stage-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  gap: 10px;
}
.avf-hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e2e8f0;
}
.avf-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8b5cf6;
  box-shadow: 0 0 10px #8b5cf6;
}
.avf-dot.is-live { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.avf-dot.is-rec { background: #ef4444; box-shadow: 0 0 12px #ef4444; }
.avf-meters {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #94a3b8;
}
.avf-meter-bar {
  display: inline-block;
  width: 34px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-left: 4px;
}
.avf-meter-fill { display: block; height: 100%; width: 12%; background: linear-gradient(90deg, #8b5cf6, #f59e0b); border-radius: 999px; }

.avf-stage-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(8, 9, 13, 0.52), rgba(8, 9, 13, 0.15));
  transition: opacity 0.25s ease;
}
.avf-stage-overlay.is-hidden { opacity: 0; pointer-events: none; }
.avf-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 26px;
  border-radius: 16px;
  background: rgba(12, 14, 22, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  text-align: center;
  max-width: 460px;
}
.avf-overlay-title { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #f8fafc; }
.avf-overlay-sub { margin: 0; font-size: 13px; color: #cbd5e1; }
.avf-overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.avf-restore-ui {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 120;
}
.avf-studio.is-ui-hidden .avf-topbar,
.avf-studio.is-ui-hidden .avf-transport,
.avf-studio.is-ui-hidden .avf-presets-section,
.avf-studio.is-ui-hidden .avf-dock,
.avf-studio.is-ui-hidden .avf-stage-hud { display: none; }
.avf-studio.is-ui-hidden .avf-stage-wrap { border: 0; border-radius: 0; padding: 0; min-height: 75vh; }
.avf-studio.is-ui-hidden .avf-canvas { max-height: 85vh; }
.avf-stage-wrap:fullscreen { background: #05060a; padding: 0; border: 0; border-radius: 0; }
.avf-stage-wrap:fullscreen .avf-canvas { max-height: 100vh; height: 100vh; width: 100vw; }

/* Transport */
.avf-transport {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
}
.avf-seek-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avf-time { font-family: var(--font-mono); font-size: 12px; color: #94a3b8; white-space: nowrap; }
.avf-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}
.avf-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid #08090d;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.55);
}
.avf-vol-wrap { display: flex; align-items: center; gap: 8px; width: 120px; }

/* Visual Preset Cards */
.avf-presets-section { margin-top: 18px; }
.avf-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
}
.avf-section-label span { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: #94a3b8; }
.avf-presets-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.avf-preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.avf-preset-card svg { width: 100%; height: 36px; display: block; }
.avf-preset-card:hover { background: rgba(139, 92, 246, 0.1); border-color: rgba(167, 139, 250, 0.45); color: #ffffff; transform: translateY(-1px); }
.avf-preset-card.is-active {
  background: rgba(139, 92, 246, 0.2);
  border-color: #f59e0b;
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35);
}

/* Studio Dock */
.avf-dock {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
.avf-panel {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  padding: 16px;
}
.avf-panel-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.avf-panel-title small { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: #fde68a; }

.avf-palettes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.avf-palette-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
}
.avf-palette-chip.is-active { border-color: #f59e0b; background: rgba(245, 158, 11, 0.14); color: #ffffff; }
.avf-swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.avf-color-pickers { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.avf-color-input {
  width: 30px;
  height: 30px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #10121c;
  cursor: pointer;
}

.avf-sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 14px;
}
.avf-field label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #cbd5e1;
  margin-bottom: 6px;
}
.avf-field label output { font-family: var(--font-mono); color: #a78bfa; font-size: 12px; }

.avf-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.avf-input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 9, 13, 0.7);
  color: #f8fafc;
  font-family: var(--font-body);
  font-size: 13px;
}
.avf-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.avf-seg-btn {
  flex: 1 1 auto;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.avf-seg-btn.is-active { background: rgba(139, 92, 246, 0.24); border-color: #a78bfa; color: #ffffff; }

.avf-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.24);
  margin-bottom: 12px;
  font-size: 13px;
  color: #cffafe;
  cursor: pointer;
}
.avf-check-row input { width: 16px; height: 16px; accent-color: #22d3ee; }

.avf-export-actions { display: grid; gap: 9px; }
.avf-export-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.avf-status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(8, 9, 13, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.45;
}
.avf-status.is-accent { border-color: rgba(245, 158, 11, 0.45); color: #fde68a; }
.avf-upload-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

@media (max-width: 960px) {
  .avf-presets-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .avf-dock { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .avf-studio { padding: 12px; }
  .avf-stage-wrap { min-height: 240px; padding: 6px; }
  .avf-stage-wrap[data-aspect="9:16"] .avf-canvas,
  .avf-stage-wrap[data-aspect="1:1"] .avf-canvas { height: 340px; }
  .avf-transport { grid-template-columns: auto 1fr; }
  .avf-vol-wrap { grid-column: 1 / -1; width: 100%; }
  .avf-presets-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .avf-sliders, .avf-subgrid, .avf-export-row { grid-template-columns: 1fr; }
  .avf-meters { display: none; }
}