/* Phase 4 functionality, scoped to interior pages. */
.section-main:has(.functional-content) .section-content {
  margin-top: 0;
  min-height: 0;
  padding-top: 12px;
  padding-bottom: 0;
}
.functional-content {
  padding: 32px;
  background: rgba(4, 8, 12, 0.94);
  border: 1px solid #596168;
  margin-top: 24px;
  width: 100%;
  scroll-margin-top: 110px;
}
.functional-content h2 {
  font-size: 20px;
}
.functional-content p {
  line-height: 1.7;
}
.functional-content button,
.functional-content select,
.functional-content input,
.admin-shell button,
.admin-shell input,
.admin-shell select,
.admin-shell textarea {
  font: inherit;
  color: #fff;
  background: #10161c;
  border: 1px solid #78858e;
  border-radius: 2px;
  min-height: 44px;
  padding: 10px;
}
.functional-content button,
.admin-shell button {
  cursor: pointer;
}
.functional-content button:hover,
.admin-shell button:hover {
  border-color: var(--section-cyan);
}
.functional-content button[aria-pressed="true"] {
  color: #080a0c;
  background: var(--section-cyan);
}
.functional-content :focus-visible,
.admin-shell :focus-visible {
  outline: 3px solid var(--section-yellow);
  outline-offset: 3px;
}
.functional-content [hidden],
.admin-shell [hidden] {
  display: none !important;
}
.experience-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-left: 24px;
}
.toolbar,
.module-tabs,
.source-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
  align-items: end;
}
.toolbar label {
  display: grid;
  gap: 8px;
  max-width: 100%;
}
.toolbar input,
.toolbar select {
  max-width: 100%;
}
.status-line {
  color: #dedede;
}
.content-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.media-card,
.wire-post {
  min-width: 0;
  padding: 16px;
  border: 1px solid #596168;
  background: #0b1117;
}
.media-card img,
.wire-post img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  margin-bottom: 16px;
}
.media-card h3,
.wire-post h3 {
  font-size: 18px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  margin: 0 0 12px;
}
.media-card p {
  font-size: 14px;
}
.media-card a,
.wire-post a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}
.media-card button {
  width: 100%;
}
.media-viewer {
  margin: 24px 0;
}
.media-viewer iframe,
[data-player] iframe {
  display: block;
  border: 0;
  width: 100%;
  height: 400px;
  background: #10161c;
}
.wire-post {
  margin: 20px 0;
}
.wire-post p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wire-post img {
  max-width: 640px;
  aspect-ratio: auto;
}
.social-mount iframe {
  max-width: 100%;
  border: 0;
}
.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin: 24px 0;
}
.control-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
  line-height: 1.5;
}
.control-grid output {
  color: var(--section-cyan);
}
.control-grid input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: var(--section-cyan);
}
.keyboard {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  margin: 28px 0;
}
.keyboard button {
  height: 120px;
  background: #eee;
  color: #080a0c;
  padding: 8px 2px;
  touch-action: none;
  user-select: none;
}
.keyboard button.accidental {
  background: #171a20;
  color: #fff;
}
.keyboard button[aria-pressed="true"] {
  background: var(--section-cyan);
}
.drum-row {
  margin: 20px 0;
}
.drum-row > label {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.step-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
}
.step-grid button {
  padding: 4px;
  min-width: 0;
}
.step-grid button[data-accent="true"] {
  background: var(--section-yellow);
  color: #080a0c;
}
.step-grid button.playhead {
  outline: 2px solid var(--section-magenta);
  outline-offset: -2px;
}
.admin-shell {
  max-width: 1100px;
  padding: 32px;
  margin: auto;
  color: #eee;
  font-size: 16px;
  line-height: 1.6;
}
.admin-shell h1 {
  font-size: 32px;
}
.admin-shell form,
.admin-shell details {
  border: 1px solid #596168;
  padding: 24px;
  margin: 24px 0;
}
.admin-shell label {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.admin-shell textarea {
  width: 100%;
  min-height: 120px;
}
.admin-shell pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.admin-shell .record {
  padding: 20px 0;
  border-bottom: 1px solid #596168;
}
@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .step-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .functional-content {
    padding: 16px;
  }
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .control-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .keyboard {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .keyboard button {
    height: 80px;
  }
  .step-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .experience-link {
    margin-left: 0;
    display: flex;
  }
  .admin-shell {
    padding: 16px;
  }
  .admin-shell form {
    padding: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
.admin-shell {
  padding-top: 100px;
}
#preview-surface {
  max-width: 100%;
}
#preview-surface.mobile-preview {
  width: 375px;
}
.keyboard small {
  display: block;
  font-size: 12px;
  margin-top: 12px;
}
.section-stage:has(.functional-content) .section-environment,
.section-stage:has(.functional-content)::after {
  height: 100svh;
  bottom: auto;
}
.section-main:has(.functional-content) .section-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.section-main:has(.functional-content) .return-home,
.section-main:has(.functional-content) .experience-link {
  align-self: flex-start;
  margin-left: 0;
}
.official-player {
  display: block;
  width: 100%;
  border: 0;
  background: #10161c;
}
.media-viewer .official-player[data-provider="youtube"],
[data-player] .official-player[data-provider="youtube"] {
  aspect-ratio: 16 / 9;
  height: auto;
}

/* Active sections enter the first viewport; the approved background and header remain. */
.section-main:has(.functional-content) .section-label {
  margin-bottom: 12px;
}
.section-main:has(.functional-content) .signal-divider {
  margin: 16px 0;
  padding-top: 8px;
}
.section-main:has(.functional-content) .experience-link {
  margin-top: 16px;
  padding: 8px 12px;
  border: 1px solid var(--section-cyan);
  text-decoration: none;
}
.sound-lab > p {
  margin: 12px 0;
}
.sound-lab .module-tabs,
.sound-lab .audio-transport {
  margin: 8px 0;
}
.sound-lab .keyboard {
  margin: 16px 0;
}
.tone-controls {
  margin-top: 20px;
  border-top: 1px solid #596168;
  padding-top: 12px;
}
.tone-controls summary {
  min-height: 44px;
  cursor: pointer;
  padding: 10px 0;
}
@media (max-width: 600px) {
  .audio-transport {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .audio-transport button {
    padding: 8px;
  }
}
.section-main:has(.functional-content) {
  padding-top: calc(max(16px, env(safe-area-inset-top)) + 136px);
}
@media (max-width: 600px) {
  .sound-lab .module-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sound-lab .module-tabs button {
    font-size: 14px;
  }
}
@media (max-width: 768px) {
  .sound-lab .keyboard {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
@media (max-width: 350px) {
  .sound-lab .keyboard {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 350px) {
  .sound-lab {
    padding-top: 12px;
  }
}
