* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
}


/* Sticky header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.5rem;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(51, 51, 51, 0.5);
}

@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.input-section {
  margin-bottom: 1rem;
}

.context-section {
  background: rgba(26, 26, 26, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(51, 51, 51, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

.context-section.hidden {
  display: none;
}

.context-header {
  padding: 0.5rem 1rem;
  background: rgba(42, 42, 58, 0.9);
  border-bottom: 1px solid rgba(51, 51, 51, 0.5);
  font-size: 0.75rem;
  color: var(--color-tertiary-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.context-header:hover {
  background: rgba(52, 52, 68, 0.9);
}

.context-arrow {
  transition: transform 0.2s;
}

.context-arrow.collapsed {
  transform: rotate(-90deg);
}

#context-display.collapsed {
  display: none;
}

#context-display {
  margin: 0;
  padding: 0.75rem 1rem;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  color: var(--color-tertiary-lighter);
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

#prompt-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid rgba(51, 51, 51, 0.5);
  border-radius: 6px;
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
}

#prompt-input:focus {
  outline: none;
  border-color: #4a9eff;
}

#genre-select,
#bank-select {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid rgba(51, 51, 51, 0.5);
  border-radius: 6px;
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  min-width: 180px;
}

#genre-select:focus,
#bank-select:focus {
  outline: none;
  border-color: #4a9eff;
}

#genre-select option,
#bank-select option {
  background: #1a1a1a;
  color: #fff;
}

button {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

#generate-btn {
  background: #4a9eff;
  color: #fff;
}

#generate-btn:hover {
  background: #3a8eef;
}

#generate-btn:disabled {
  background: #333;
  cursor: not-allowed;
}

/* Generate panel */
.generate-panel {
  margin-bottom: 1.5rem;
}
.generate-panel,
.code-section {
  transition: opacity 0.2s, max-height 0.3s;
  max-height: calc(100vh - 200px);
  overflow: hidden;
}

.generate-panel.hidden,
.code-section.hidden {
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  pointer-events: none;
  position: absolute;
}

#ai-btn,
#code-btn,
#alter-toggle-btn,
#play-btn,
#stop-btn,
#share-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  padding: 0;
}

#ai-btn,
#code-btn {
  background: #6b7280;
  color: #fff;
}

#ai-btn:hover,
#code-btn:hover {
  background: #4b5563;
}

#ai-btn.active {
  background: var(--color-tertiary);
}

#ai-btn.active:hover {
  background: var(--color-tertiary-dark);
}

#code-btn.active {
  background: #3b82f6;
}

#code-btn.active:hover {
  background: #2563eb;
}

#play-btn {
  background: #22c55e;
  color: #fff;
}

#play-btn:hover {
  background: #16a34a;
}

#play-btn.playing {
  background: #f59e0b;
}

#play-btn.playing:hover {
  background: #d97706;
}

#play-btn.paused {
  background: #22c55e;
}

#play-btn.paused:hover {
  background: #16a34a;
}

#stop-btn {
  background: transparent;
  color: #7d8799;
  font-size: 1.6rem;
  width: auto;
  height: auto;
}

#stop-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#share-btn {
  background: #6b7280;
  color: #fff;
}

#share-btn:hover {
  background: #4b5563;
}

#share-btn:active {
  background: #22c55e;
}

#share-btn svg {
  width: 14px;
  height: 14px;
}

/* Full-page visualization background */
.viz-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* RIFF vis canvases (liveVis.js): background style, audio visualizers on top. */
.live-vis-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#live-vis-canvas {
  z-index: 1;
}

#audio-vis-canvas {
  z-index: 2;
  opacity: 0.8;
}

/* Neither WebGPU nor WebGL2: a static note instead of the visuals. */
.vis-fallback {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 6px 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

/* The code's vis did not compile and never drew: the default stands in (liveVis.js). */
.vis-note {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 65;
  padding: 4px 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  pointer-events: none;
  animation: vis-note-fade 8s ease-in forwards;
}
@keyframes vis-note-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .vis-note { animation: none; } }

.live-vis-picker {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
}

/* Header divider */
.header-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 0.25rem;
}

/* Audio visualizer toggle button (now in dropdown) */
#audio-viz-btn {
  /* Inherits dropdown button styles */
}

#audio-viz-btn.active {
  background: rgba(6, 182, 212, 0.3);
  color: var(--color-primary-light);
}

/* Visualizer selector - in header */
.viz-selector {
  position: relative;
}

#viz-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: #6b7280;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-sizing: border-box;
}

#viz-btn:hover {
  background: #4b5563;
}

#viz-btn.active {
  background: var(--color-primary);
  color: #fff;
}

#viz-btn.active:hover {
  background: var(--color-primary-dark);
}

.viz-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(51, 51, 51, 0.5);
  border-radius: 8px;
  overflow: hidden;
  min-width: 140px;
  z-index: 200;
}

.viz-dropdown.hidden {
  display: none;
}

.viz-dropdown button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: #ccc;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.viz-dropdown button:hover {
  background: rgba(6, 182, 212, 0.2);
  color: #fff;
}

.viz-dropdown button.active {
  background: rgba(6, 182, 212, 0.3);
  color: var(--color-primary-light);
}

.viz-dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.25rem 0;
}

.code-section {
  background: rgba(26, 26, 26, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(51, 51, 51, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

.code-header {
  padding: 0.75rem 1rem;
  background: rgba(37, 37, 37, 0.9);
  border-bottom: 1px solid rgba(51, 51, 51, 0.5);
  font-size: 0.875rem;
  color: #888;
}

/* Code editor container (RIFF's editor sits inside, see below) */
#code-editor-container {
  position: relative;
  min-height: 200px;
  background: transparent;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#code-editor-container.error {
  border-color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4), 0 0 30px rgba(239, 68, 68, 0.2);
}

#code-editor-container #play-btn {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
}

#code-editor-container #stop-btn {
  position: absolute;
  top: 0.2rem;
  right: 0.3rem;
  z-index: 10;
  width: 30px;
  height: 30px;
}

.alter-section {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(30, 30, 40, 0.9);
  border-top: 1px solid rgba(51, 51, 51, 0.5);
  transition: opacity 0.2s, max-height 0.2s, padding 0.2s;
  max-height: 100px;
  overflow: hidden;
  margin-top: 1.5rem;
}

.alter-section.hidden {
  opacity: 0;
  max-height: 0;
  padding: 0 0.75rem;
  pointer-events: none;
}

/* Only-alter mode: alter section becomes fixed top bar (desktop only) */
@media (min-width: 769px) {
  body.only-alter .container {
    position: unset;
  }

  body.only-alter .alter-section {
    position: fixed;
    top: 0;
    left: 100px;
    display: flex;
    z-index: 1000;
    margin-top: 0;
    padding: 7px 24px 7px 7px;
    width: calc(100% - 363px);
  }
}

.alter-play-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  max-width: 32px;
  min-height: 32px;
  max-height: 32px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: #22c55e;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-left: auto;
  flex-shrink: 0;
}

.alter-play-btn:hover {
  background: #16a34a;
}

.alter-play-btn.playing {
  background: #f59e0b;
}

.alter-play-btn.playing:hover {
  background: #d97706;
}

.alter-play-btn.paused {
  background: #22c55e;
}

.alter-play-btn.paused:hover {
  background: #16a34a;
}

.alter-play-btn.hidden {
  display: none;
}

#alter-toggle-btn {
  background: #6b7280;
  color: #fff;
}

#alter-toggle-btn:hover {
  background: #4b5563;
}

#alter-toggle-btn.active {
  background: var(--color-tertiary);
}

#alter-toggle-btn.active:hover {
  background: var(--color-tertiary-dark);
}

#alter-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid rgba(51, 51, 51, 0.5);
  border-radius: 4px;
  background: rgba(20, 20, 25, 0.9);
  color: #fff;
}

#alter-input:focus {
  outline: none;
  border-color: var(--color-tertiary);
}

#alter-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  background: var(--color-tertiary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#alter-btn:hover {
  background: var(--color-tertiary-dark);
}

#alter-btn:disabled {
  background: #4b5563;
  cursor: not-allowed;
}

#evolve-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 1rem;
  background: #6b7280;
  color: #fff;
  border: 2px solid #4b5563;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

#evolve-btn:hover {
  background: #4b5563;
  border-color: #374151;
}

#evolve-btn.active {
  background: transparent;
  border: none;
}

#evolve-btn.active::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #ff0000,
    #ff8000,
    #ffff00,
    #00ff00,
    #00ffff,
    #0080ff,
    #8000ff,
    #ff00ff,
    #ff0000
  );
  animation: rotate-rainbow 1.5s linear infinite;
  z-index: 0;
}

#evolve-btn.active::after {
  content: '✧';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  z-index: 1;
}

#evolve-btn.active:hover::after {
  background: #2a2a2a;
}

@keyframes rotate-rainbow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* RIFF code editor: transparent on the glass panel, 200-400 px tall, scrolls
   inside. Colours are RIFF's --riff-ed-* defaults (SAAI's palette). */
#code-editor-container .riff-ed {
  --riff-ed-min-height: 200px;
  --riff-ed-max-height: 400px;
  --riff-ed-active: rgba(74, 222, 128, 0.4);
  border-radius: 0 0 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a #1a1a1a;
}

#code-editor-container .riff-ed::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#code-editor-container .riff-ed::-webkit-scrollbar-track {
  background: #1a1a1a;
}

#code-editor-container .riff-ed::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 5px;
  border: 2px solid #1a1a1a;
}

#code-editor-container .riff-ed::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4a4a4a 0%, #4a4a4a 40%, var(--color-primary) 50%, #4a4a4a 60%, #4a4a4a 100%);
}

#code-editor-container .riff-ed::-webkit-scrollbar-corner {
  background: #1a1a1a;
}

/* Active note highlighting animation */
#code-editor-container .riff-ed-active {
  background-color: rgba(74, 222, 128, 0.4);
  border-radius: 2px;
  animation: pulse 0.15s ease-out;
}

@keyframes pulse {
  0% { background-color: rgba(74, 222, 128, 0.8); }
  100% { background-color: rgba(74, 222, 128, 0.4); }
}

.loading {
  color: #888;
  font-style: italic;
}

.error {
  color: #ef4444;
}

/* Inline slider() widgets: RIFF puts them in a rail at the editor's right
   edge, one line tall, and sets their width and position. */
#code-editor-container .riff-ed-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

#code-editor-container .riff-ed-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(139, 92, 246, 0.3);
}

#code-editor-container .riff-ed-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(139, 92, 246, 0.3);
}

#code-editor-container .riff-ed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--color-tertiary);
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}

#code-editor-container .riff-ed-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-tertiary);
  border: none;
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}

#code-editor-container .riff-ed-slider:hover::-webkit-slider-thumb {
  background: #a78bfa;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.8);
}

#code-editor-container .riff-ed-slider:hover::-moz-range-thumb {
  background: #a78bfa;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.8);
}

#code-editor-container .riff-ed-slider:focus {
  outline: none;
}

#code-editor-container .riff-ed-slider:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

/* RIFF visualizer panel under the editor (collapsible, mode switcher) */
/* S3: arrange strip between the editor and the visualizer */
.arrange-host .arr-strip {
  position: relative;
  /* tall enough for the label at any root font size (6.0e): 0.7rem text, 1.5 line, 2 px borders */
  height: calc(1.05rem + 4px);
  margin: 4px 0.75rem;
}
.arrange-host .arr-track { position: absolute; inset: 0; }
.arrange-host .arr-block {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.03);
  color: #777;
  font: 0.7rem/calc(1.05rem + 2px) ui-monospace, Menlo, Consolas, monospace;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.arrange-host .arr-block:hover { color: #bbb; border-color: rgba(255, 255, 255, 0.2); }
.arrange-host .arr-block.on { background: rgba(74, 158, 255, 0.18); border-color: rgba(74, 158, 255, 0.55); color: #e6f0ff; }
.arrange-host .arr-block.arr-guessed { border-style: dashed; }
.arrange-host .arr-block.arr-muted { opacity: 0.45; }
.arrange-host .arr-head {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: #4a9eff;
  box-shadow: 0 0 5px rgba(74, 158, 255, 0.8);
  pointer-events: none;
}

.riff-viz-panel {
  border-top: 1px solid rgba(51, 51, 51, 0.5);
  --riff-viz-scope: #4a9eff;
}

.riff-viz-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
}

.riff-viz-toggle,
.riff-viz-modes button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #888;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.riff-viz-toggle:hover,
.riff-viz-modes button:hover {
  color: #ccc;
}

.riff-viz-modes {
  display: flex;
  gap: 0.25rem;
}

.riff-viz-modes button.active {
  color: #a5d6ff;
  border-color: rgba(74, 158, 255, 0.4);
}

.riff-viz-arrow {
  display: inline-block;
  font-size: 0.6rem;
  transition: transform 0.2s;
}

.riff-viz-host {
  height: 140px;
  padding: 0 0.5rem 0.5rem;
}

.riff-viz-panel.collapsed .riff-viz-host,
.riff-viz-panel.collapsed .riff-viz-modes {
  display: none;
}

.riff-viz-panel.collapsed .riff-viz-arrow {
  transform: rotate(-90deg);
}

/* Info button (bottom-left corner) */
/* Bottom-left button container */
.bottom-left-btns {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 1000;
}

.info-btn,
.stats-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.info-btn {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 14px;
  font-style: italic;
}

.info-btn:hover,
.stats-btn:hover {
  border-color: rgba(255, 255, 255, 0.9);
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.info-btn span {
  line-height: 1;
  margin-top: -1px;
}

.stats-btn svg {
  width: 14px;
  height: 14px;
}

/* Shortcuts popup */
.shortcuts-popup {
  position: fixed;
  bottom: 3.5rem;
  left: 1rem;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0;
  min-width: 200px;
  z-index: 1001;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.token-popup.hidden,
.shortcuts-popup.hidden {
  display: none;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.shortcuts-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

.shortcuts-close:hover {
  color: #fff;
}

.shortcuts-list {
  padding: 0.5rem 0;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
}

.shortcut-item kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary-light);
  min-width: 24px;
  text-align: center;
}

.shortcut-item span {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.shortcuts-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.app-version {
  flex-basis: 100%;
  text-align: center;
  color: var(--color-primary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.github-link {
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

.github-link:hover {
  color: #fff;
}

/* Token usage popup */
.token-popup {
  position: fixed;
  bottom: 3.5rem;
  left: 3rem;
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0;
  min-width: 180px;
  z-index: 1001;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.token-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
}

.token-popup-content {
  padding: 0.75rem 1rem;
}

.token-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
}

.token-stat-row.total {
  display:block;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 0.35rem;
  padding-top: 0.5rem;
}

.token-stat-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.2rem;
}

.token-stat-value {
  display: block;
  font-size: 0.85rem;
  color: var(--color-primary-light);
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-weight: 500;
}

.token-popup-footer {
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.reset-tokens-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-tokens-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Ko-fi button in header */
.kofi-btn {
  background: cyan;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0 0 0;
  transition: background 0.2s ease;
}

.kofi-btn:hover,
.kofi-btn:active {
  background: #7fffff;
}

.kofi-btn img {
  width: 14px;
  height: 14px;
}

/* Ko-fi popup overlay */
.kofi-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1001;
}

.kofi-overlay.hidden {
  display: none;
}

/* Ko-fi popup */
.kofi-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(20, 20, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0;
  width: 400px;
  max-width: 400px;
  height: 75vh;
  max-height: 700px;
  z-index: 1002;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.kofi-popup.hidden {
  display: none;
}

.kofi-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
}

.kofi-popup-content {
  flex: 1;
  overflow: hidden;
}

.kofi-popup-content iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: toast-in 0.3s ease-out;
}

.toast.hidden {
  display: none;
}

.toast.fade-out {
  animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(1rem);
  }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  .input-group {
    flex-direction: column;
  }

  .input-group > * {
    width: 100%;
  }

  #genre-select,
  #bank-select {
    min-width: unset;
  }

  #prompt-input {
    flex: unset;
  }

  #generate-btn {
    width: 100%;
  }

  .alter-section {
    flex-direction: column;
    max-height: 300px;
  }

  .alter-section > * {
    width: 100%;
  }

  #alter-input {
    flex: unset;
  }

  #alter-btn {
    width: 100%;
    height: 44px;
    font-size: 0;
  }

  #alter-btn::after {
    content: 'Send';
    font-size: 0.875rem;
  }

  #evolve-btn,
  .alter-play-btn {
    width: 100%;
    height: 44px;
    min-width: unset;
    max-width: unset;
    min-height: 44px;
    border-radius: 6px;
  }

  #evolve-btn {
    font-size: 0;
  }

  #evolve-btn::after {
    content: 'Auto ✧';
    font-size: 0.875rem;
  }

  #evolve-btn.active::after {
    content: 'Auto ✧';
    font-size: 0.875rem;
    inset: unset;
    position: static;
    /* background: transparent; */
    width: 99%;
    height: 95%;
    border-radius: 6px;
    opacity:95%
  }

  #evolve-btn.active::before {
    width: 800px;
    height: 800px;
    left: -70%;
    top: -100%;
  }

  .shortcuts-popup,
  .token-popup {
    max-width: calc(100vw - 2rem);
  }

  .kofi-popup {
    width: calc(100vw - 2rem);
    max-width: none;
    height: 75vh;
    max-height: 700px;
  }

  .shortcuts-list {
    display: none;
  }

  /* Larger touch targets for play/stop buttons on mobile */
  #play-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 1.2rem;
  }

  #code-editor-container #play-btn {
    bottom: 0.75rem;
    right: 0.75rem;
  }

  #stop-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.8rem;
  }

}

/* ---- Splash (js/splash.js): neon glass panel over a RIFF vis on a synthetic beat ---- */
html.splash-open, html.splash-open body { overflow: hidden; }
.nosplash .splash { display: none; }
.splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  overflow-y: auto;
  color: #f5f3ff;
  font-family: system-ui, -apple-system, sans-serif;
  /* The fallback glow (no WebGPU/WebGL2, reduced motion), also seen while the vis starts. */
  background:
    radial-gradient(circle at 50% 42%, rgba(168, 85, 247, 0.38), transparent 55%),
    radial-gradient(circle at 15% 85%, rgba(255, 79, 243, 0.28), transparent 50%),
    radial-gradient(circle at 88% 15%, rgba(34, 230, 255, 0.24), transparent 45%),
    #07030f;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.splash-leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-vis { position: fixed; inset: 0; pointer-events: none; }
.splash-canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s ease; }
.splash-live .splash-canvas { opacity: 1; }
.splash-vis::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(7, 3, 15, 0.1), rgba(7, 3, 15, 0.6));
}
.splash-panel {
  position: relative;
  margin: auto;
  width: min(960px, calc(100% - 32px));
  padding: clamp(20px, 4vw, 44px);
  text-align: center;
  background: rgba(12, 6, 28, 0.5);
  border: 1px solid rgba(190, 140, 255, 0.3);
  border-radius: 24px;
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 0 48px rgba(168, 85, 247, 0.28), inset 0 0 32px rgba(34, 230, 255, 0.07);
}
.splash-logo { display: block; width: min(460px, 82vw); height: auto; margin: 0 auto; overflow: visible; }
.splash-tagline {
  margin: 8px 0 0;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  color: #ede9fe;
  text-shadow: 0 0 14px rgba(167, 139, 250, 0.7);
}
.splash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 28px 0;
  text-align: left;
}
.splash-col {
  padding: 18px 22px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.splash-col h2 { margin: 0 0 10px; font-size: 1.1rem; letter-spacing: 0.02em; }
.splash-col-music h2 { color: #ff8af6; text-shadow: 0 0 12px rgba(255, 79, 243, 0.65); }
.splash-col-vis h2 { color: #7df3ff; text-shadow: 0 0 12px rgba(34, 230, 255, 0.65); }
.splash-col ul { margin: 0; padding-left: 1.1em; line-height: 1.55; font-size: 0.95rem; color: #e9e3ff; }
.splash-col li + li { margin-top: 4px; }
.splash-enter {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 14px 52px 14px calc(52px + 0.25em);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, rgba(255, 79, 243, 0.28), rgba(34, 230, 255, 0.28));
  border: 2px solid #e879f9;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 18px rgba(232, 121, 249, 0.6), inset 0 0 14px rgba(34, 230, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: splash-pulse 1.875s ease-in-out infinite; /* four beats at 128 bpm */
}
.splash-enter:hover, .splash-enter:focus-visible {
  transform: scale(1.04);
  border-color: #7df3ff;
  box-shadow: 0 0 28px rgba(232, 121, 249, 0.85), 0 0 56px rgba(34, 230, 255, 0.45), inset 0 0 18px rgba(34, 230, 255, 0.5);
}
.splash-enter:focus-visible { outline: 3px solid #7df3ff; outline-offset: 5px; }
@keyframes splash-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(232, 121, 249, 0.6), inset 0 0 14px rgba(34, 230, 255, 0.35); }
  50% { box-shadow: 0 0 30px rgba(232, 121, 249, 0.9), inset 0 0 18px rgba(34, 230, 255, 0.5); }
}
@media (max-width: 768px) {
  .splash-columns { grid-template-columns: 1fr; gap: 14px; margin: 20px 0; }
  .splash-panel { margin: 16px auto; }
}
@media (prefers-reduced-motion: reduce) {
  .splash, .splash-canvas, .splash-enter { transition: none; animation: none; }
  .splash-enter:hover, .splash-enter:focus-visible { transform: none; }
}

/* Vis Studio view (js/views.js): the editor stays underneath, inert; the
   Studio's own rules (studio/studio.css) are scoped to #studio-view. */
.studio-view-error { position: fixed; inset: 0; z-index: 900; margin: 0; padding: 40vh 20px 0; text-align: center; color: #f1ecff; background: #07030f; }
.studio-view-error a { color: #7df3ff; }
.resume-btn {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 12px 26px;
  font: 600 16px/1 system-ui, -apple-system, sans-serif;
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 79, 243, 0.85), rgba(34, 230, 255, 0.85));
  border: 1px solid #e879f9;
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(232, 121, 249, 0.6);
  cursor: pointer;
}
.resume-btn[hidden] { display: none; }
.resume-btn:hover, .resume-btn:focus-visible { box-shadow: 0 0 26px rgba(34, 230, 255, 0.8); }
/* A direct /studio load: the editor stays out of sight until the Studio view is up. */
html.boot-studio body > :not(#studio-view):not(script) { visibility: hidden; }

/* ---- Share player (js/player.js, S6 6.1): full-screen visual, one big play button ---- */
html.boot-player body > :not(#player):not(.viz-background):not(script):not(.toast) { visibility: hidden; }
body.view-player .header, body.view-player .container, body.view-player .app-footer,
body.view-player #resume-btn, body.view-player .shortcuts-popup, body.view-player .token-popup { display: none !important; }
.player { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; color: #f3eeff; pointer-events: none; }
.player[hidden] { display: none; }
.player > * { pointer-events: auto; }
.player-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 22px; background: linear-gradient(rgba(6, 2, 18, 0.7), rgba(6, 2, 18, 0));
}
.player-title { margin: 0; font-size: clamp(1.2rem, 3vw, 2rem); font-weight: 800; letter-spacing: 0.02em; text-shadow: 0 0 14px rgba(255, 79, 243, 0.6); }
.player-sub { margin: 4px 0 0; font-size: 0.95rem; color: #d9d0ff; }
.player-kind { margin-left: 8px; padding: 1px 8px; border: 1px solid rgba(125, 243, 255, 0.5); border-radius: 999px; font-size: 0.75rem; color: #7df3ff; }
.player-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.player-actions button {
  padding: 8px 14px; border: 1px solid rgba(167, 139, 250, 0.55); border-radius: 10px; background: rgba(20, 8, 40, 0.6);
  color: #f3eeff; font: 600 0.9rem system-ui, sans-serif; cursor: pointer; backdrop-filter: blur(6px);
}
.player-actions button:hover, .player-actions button:focus-visible { border-color: #7df3ff; box-shadow: 0 0 12px rgba(34, 230, 255, 0.5); }
.player-actions button[aria-pressed="true"] { background: rgba(34, 230, 255, 0.2); }
.player-actions .player-remix { background: linear-gradient(90deg, #ff4ff3, #a78bfa 50%, #22e6ff); border-color: transparent; color: #12041f; }
.player-play {
  width: clamp(96px, 16vmin, 150px); height: clamp(96px, 16vmin, 150px); border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85); background: rgba(20, 8, 40, 0.45); color: #fff;
  font-size: clamp(2.4rem, 6vmin, 3.6rem); line-height: 1; cursor: pointer; backdrop-filter: blur(4px);
  box-shadow: 0 0 30px rgba(255, 79, 243, 0.55), inset 0 0 20px rgba(34, 230, 255, 0.3); transition: opacity 0.3s, transform 0.15s;
}
.player-play:hover, .player-play:focus-visible { transform: scale(1.05); }
.player-started .player-play { opacity: 0.25; }
.player-started .player-play:hover, .player-started .player-play:focus-visible { opacity: 0.9; }
.player-code {
  position: absolute; left: 22px; bottom: 22px; max-width: min(720px, 60vw); max-height: 55vh; overflow: auto; margin: 0;
  padding: 12px 14px; border-radius: 10px; background: rgba(6, 2, 18, 0.55); color: #e9e3ff;
  font: 0.78rem/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap;
}
.player-code[hidden] { display: none; }
.player-brand { position: absolute; right: 22px; bottom: 18px; color: #d9d0ff; font-weight: 800; letter-spacing: 0.2em; text-decoration: none; opacity: 0.7; }
@media (prefers-reduced-motion: reduce) { .player-play { transition: none; } }
body.view-player .toast { position: fixed; z-index: 70; }

/* ---- Start screen: one Enter row, then the Studio box (Sound, Visualizer) ---- */
.splash-start { display: grid; grid-template-columns: 1fr; margin: 26px 0 16px; }
.splash-opt {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 16px 16px 14px; text-align: left;
  border: 1px solid rgba(190, 140, 255, 0.4); border-radius: 16px; background: rgba(24, 10, 48, 0.55);
  color: #ede9fe; font: inherit; text-decoration: none; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.splash-start .splash-opt { align-items: center; text-align: center; }
.splash-opt b { font-size: 1.1rem; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; text-shadow: 0 0 12px rgba(255, 79, 243, 0.55); }
.splash-opt span { font-size: 0.85rem; color: #cfc6f5; }
.splash-opt:hover, .splash-opt:focus-visible {
  border-color: #7df3ff; box-shadow: 0 0 18px rgba(34, 230, 255, 0.45); transform: translateY(-1px); outline: none;
}
.splash-studios { margin: 0 0 14px; padding: 12px 14px 14px; border: 1px solid rgba(125, 243, 255, 0.3); border-radius: 18px; background: rgba(6, 2, 18, 0.35); }
.splash-studios h2 { margin: 0 0 10px; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #7df3ff; text-align: left; }
.splash-studio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .splash-studio-row { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .splash-opt { transition: none; } .splash-opt:hover { transform: none; } }

/* S8: GUI complexity (html[data-gui]); see js/ui/guiSettings.js */
html[data-gui="basic"] .gui-bar:not(.gui-more-open) [data-gui-min],
html[data-gui="intermediate"] .gui-bar:not(.gui-more-open) [data-gui-min="expert"],
html[data-gui="basic"] [data-gui-hide]:not([data-gui-keep]),
html[data-gui="intermediate"] [data-gui-hide="expert"]:not([data-gui-keep]) { display: none !important; }
.gui-more-btn { display: none; }
html[data-gui="basic"] .gui-more-btn,
html[data-gui="intermediate"] .gui-bar:has([data-gui-min="expert"]) > .gui-more-btn,
html[data-gui="intermediate"] .gui-bar:has([data-gui-min="expert"]) .st-group > .gui-more-btn { display: inline-flex; align-items: center; justify-content: center; }
.gui-bar.gui-more-open .gui-more-btn { outline: 1px solid rgba(255, 255, 255, 0.35); }
.gui-dialog {
  max-width: min(440px, 92vw); padding: 0; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 12px;
  background: #160f26; color: #eee; font: inherit; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.gui-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.gui-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.gui-head { display: flex; align-items: center; justify-content: space-between; }
.gui-head h2 { margin: 0; font-size: 1.05rem; }
.gui-close { background: none; border: 0; color: inherit; font-size: 1.4rem; cursor: pointer; line-height: 1; }
.gui-form fieldset { border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 8px; padding: 8px 10px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.gui-form legend { padding: 0 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; }
.gui-level { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.gui-level.on { background: rgba(160, 100, 255, 0.18); }
.gui-level-text { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; }
.gui-level-text span { opacity: 0.75; }
.gui-flag { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; cursor: pointer; }
.gui-note { margin: 0; font-size: 0.75rem; opacity: 0.6; }
.st-more { margin-top: 10px; border-top: 1px dashed rgba(255, 255, 255, 0.12); padding-top: 6px; }
.st-more > summary { cursor: pointer; font-size: 0.8rem; opacity: 0.8; padding: 4px 0; }
.st-more > summary:hover { opacity: 1; }
/* the editor header's "⋯" and gear: round like the other header buttons */
.header .gui-more-btn, .header .gui-gear {
  width: 32px; height: 32px; border-radius: 50%; padding: 0; border: none; cursor: pointer;
  background: #6b7280; color: #fff; font-size: 0.95rem; align-items: center; justify-content: center;
}
.header .gui-gear { display: flex; }
.header .gui-more-btn:hover, .header .gui-gear:hover { background: #4b5563; }

/* Header right: settings | Ko-fi (top right, every GUI level). */
.header-controls { align-items: center; }

/* One header lead on all three views (js/viewnav.js): the SAAI logo (link to /)
   and the view switch Code · Sound · Visualizer. Same place, look and size on
   the editor (.header), the Sound Studio (.snd-top) and the Vis Studio (.st-bar):
   the three bars share their padding and the lead sits at their top left. */
.header, #studio-view .st-bar, #sound-view .snd-top { padding: 9px 16px; }
.vnav {
  display: inline-flex; align-items: center; gap: 12px; flex: none; align-self: flex-start;
  height: 34px; min-width: 330px; box-sizing: border-box; margin: 0;
  font: 600 12px/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.vnav-logo {
  display: inline-flex; align-items: center; width: 78px; height: 34px; flex: none;
  text-decoration: none; border-radius: 6px;
  filter: drop-shadow(0 0 2px rgba(255, 230, 240, 0.3));
}
.vnav-mark {
  display: inline-block; transform: scaleX(1.75); transform-origin: left center;
  font: 900 24px/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-variant: small-caps; letter-spacing: -4px;
  background: linear-gradient(90deg, var(--color-primary-light, #c084fc), var(--color-secondary, #ec4899), var(--color-primary-light, #c084fc));
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: gradient-shift 8s ease-in-out infinite;
}
.vnav-logo:focus-visible, .vnav-link:focus-visible { outline: 2px solid #7df3ff; outline-offset: 2px; }
.vnav-switch {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; height: 30px; box-sizing: border-box;
  border: 1px solid rgba(168, 85, 247, 0.4); border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 79, 243, 0.1), rgba(34, 230, 255, 0.08));
}
.vnav-link {
  position: relative; display: inline-flex; align-items: center; height: 22px; padding: 0 12px;
  border-radius: 999px; color: rgba(241, 236, 255, 0.78); text-decoration: none;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.vnav-link + .vnav-link::before { content: ''; position: absolute; left: -2px; top: 25%; bottom: 25%; width: 1px; background: rgba(168, 85, 247, 0.5); }
.vnav-link:hover { color: #7df3ff; text-shadow: 0 0 8px rgba(34, 230, 255, 0.55); }
.vnav-link[aria-current="page"] {
  color: #fff; background: linear-gradient(90deg, rgba(255, 79, 243, 0.35), rgba(34, 230, 255, 0.3));
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}
.vnav-docs { margin-left: 10px; padding: 2px 9px; border: 1px solid rgba(168, 85, 247, 0.45); border-radius: 10px; color: #cbbcf5; font-size: 0.8rem; text-decoration: none; }
.vnav-docs:hover, .vnav-docs[aria-current="page"] { color: #7df3ff; border-color: #7df3ff; }
.vnav-docs:focus-visible { outline: 2px solid #7df3ff; outline-offset: 2px; }
.code-docs-host { position: relative; }
.code-docs-link { position: absolute; top: 4px; right: 8px; z-index: 5; padding: 1px 8px; border-radius: 9px; background: rgba(26, 18, 48, 0.92); border: 1px solid rgba(168, 85, 247, 0.5); color: #7df3ff; font-size: 0.75rem; text-decoration: none; }
.code-docs-link[hidden] { display: none; }
.snd-docs { margin-left: 6px; font-size: 0.75rem; color: #7df3ff; text-decoration: none; white-space: nowrap; }
.snd-docs:hover { text-decoration: underline; }
.vnav-link[aria-current="page"]::before, .vnav-link[aria-current="page"] + .vnav-link::before { display: none; }

/* Footer: switches left, NEKOmedia middle, links right. */
body { padding-bottom: 52px; }
.app-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; height: 48px; box-sizing: border-box;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 1rem;
  background: rgba(10, 10, 10, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(51, 51, 51, 0.5); color: rgba(241, 236, 255, 0.8); font-size: 0.8rem;
}
.footer-left { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.footer-left > button, .footer-left .viz-selector > button { width: 30px; height: 30px; }
.footer-left .info-btn, .footer-left .stats-btn { width: 28px; height: 28px; }
.app-footer .viz-dropdown { top: auto; bottom: 100%; right: auto; left: 0; margin: 0 0 0.6rem; }
.footer-mid { justify-self: center; }
.neko-mark { font-weight: 900; letter-spacing: 0.12em; font-size: 0.85rem; color: #f1ecff; }
.neko-mark span { font-weight: 300; letter-spacing: 0.04em; color: #ff8af6; }
.footer-right { justify-self: end; display: flex; align-items: center; gap: 14px; }
.footer-link { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; opacity: 0.8; transition: opacity 0.15s, color 0.15s; }
.footer-link:hover, .footer-link:focus-visible { opacity: 1; color: #7df3ff; }
.npm-badge { padding: 0 4px; border-radius: 2px; background: #cb3837; color: #fff; font: 700 0.7rem/1.4 system-ui, sans-serif; }
.ft-dim { opacity: 0.6; }
.spektrum-mark span:last-child { font-weight: 700; letter-spacing: 0.04em; }
.toast { bottom: 4.5rem; }
@media (max-width: 640px) {
  .ft-label { display: none; }
  .vnav { min-width: 0; gap: 8px; }
  .vnav-logo { width: 64px; }
  .vnav-mark { font-size: 20px; }
  .vnav-link { padding: 0 8px; }
  .app-footer { grid-template-columns: 1fr auto; gap: 8px; padding: 0 0.5rem; }
  .footer-mid { display: none; }
  .footer-left { gap: 0.25rem; overflow-x: auto; }
}
/* The shared footer (js/viewfooter.js): a contextual slot per view, one line on every width. */
.footer-ctx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; color: rgba(241, 236, 255, 0.6); margin-left: 0.4rem; }
.view-footer { position: static; flex: none; height: 36px; }
#studio-view > .view-footer { position: sticky; bottom: 0; margin-top: auto; }
.view-footer .footer-left { gap: 8px; }
.view-footer .footer-left > select { max-width: 9rem; }
@media (max-width: 640px) {
  .view-footer .footer-left > select, .view-footer .snd-cpu { display: none; }
}
/* Bottom-anchored overlays sit above the footer. */
.vis-note { bottom: 62px; }
.live-vis-picker { bottom: 60px; }
.resume-btn { bottom: 64px; }

/* MIDI panel (plan S11, js/midi/panel.js): a wider settings dialog. */
.midi-dialog { max-width: min(720px, 96vw); max-height: 90vh; }
.midi-form { gap: 10px; }
.midi-sec { gap: 8px; }
.midi-btn { align-self: flex-start; padding: 6px 12px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.25); background: #2a1d46; color: inherit; cursor: pointer; font: inherit; }
.midi-btn.on, .midi-btn[aria-pressed="true"] { background: #6b3fd1; border-color: #9a7bff; }
.midi-mini { padding: 1px 7px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.2); background: none; color: inherit; cursor: pointer; font-size: 0.75rem; }
.midi-msg { margin: 0; padding: 8px 10px; border-radius: 6px; background: rgba(255, 120, 80, 0.12); border: 1px solid rgba(255, 120, 80, 0.35); font-size: 0.85rem; }
.midi-portcols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.midi-portlist { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.82rem; }
.midi-portlist li { display: flex; align-items: center; gap: 6px; }
.midi-portlist li.off { opacity: 0.5; }
.midi-portlist small { opacity: 0.65; }
.midi-dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex: none; }
.midi-portlist li.on .midi-dot { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.midi-port, .midi-devport { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.midi-devport { max-width: 140px; font-size: 0.75rem; opacity: 0.7; }
.midi-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); font-size: 0.8rem; }
.midi-dev.unplugged { opacity: 0.6; }
.midi-dev label, .midi-bpc, .midi-tools label { display: flex; align-items: center; gap: 4px; }
.midi-dev label > span, .midi-bpc > span { opacity: 0.65; font-size: 0.72rem; }
.midi-dev input[type="number"], .midi-bpc input { width: 3.4em; }
.midi-dev input, .midi-dev select, .midi-bpc input, .midi-tools select { background: #0f0a1c; color: inherit; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 4px; font: inherit; padding: 2px 4px; }
.midi-lat input { width: 90px; }
.midi-latv { min-width: 3.6em; font-variant-numeric: tabular-nums; }
.midi-err { display: block; color: #ffb08a; }
.midi-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.midi-log { margin: 0; padding: 6px 8px; height: 150px; overflow: auto; background: #0b0716; border-radius: 6px; font: 0.72rem/1.45 ui-monospace, monospace; list-style: none; }
.midi-log .in { color: #9be7ff; }
.midi-log .out { color: #ffd38a; }
.midi-bpm { font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.midi-panic { color: #ffb08a; border-color: rgba(255, 140, 90, 0.5) !important; }
.snd-midi { font-size: 0.72rem; letter-spacing: 0.04em; }

/* S15 Outputs panel (js/outputs/panel.js): status lights per destination */
.out-light { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #555; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset; }
.out-light.ok { background: #3ddc84; box-shadow: 0 0 6px #3ddc84; }
.out-light.wait { background: #f0b429; }
.out-light.bad { background: #ff5c5c; }
.outputs-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.outputs-companion code { user-select: all; background: #0f0a1c; padding: 1px 5px; border-radius: 4px; }
.outputs-dest input[type="url"] { width: 14em; }
