:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #111722;
  --panel-strong: #171f2e;
  --line: #2a3445;
  --text: #eef4ff;
  --muted: #9aa9bd;
  --primary: #00e5ff;
  --accent: #ff2f92;
  --danger: #ff4b5c;
  --ok: #2ee59d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0b0b0b;
  color: var(--text);
  font-family: Raleway, Arial, Helvetica, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

header {
  background: rgba(0, 0, 0, 0.9);
  padding: 15px 20px;
  position: sticky;
  width: 100%;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #222;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  color: #ff8800;
  font-size: 1.8em;
  font-weight: 700;
}

.tagline {
  color: #aaa;
  font-size: 0.9em;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 15px;
  margin: 0;
  padding: 0;
}

nav ul li a {
  color: inherit;
  padding: 8px 10px;
  text-decoration: none;
  transition: color 0.3s ease;
}

nav ul li a:hover {
  color: #ff8800;
}

.dropdown {
  position: relative;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #000;
  border: 1px solid #222;
  padding: 10px;
  z-index: 1000;
  min-width: 180px;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content ul {
  display: block;
  list-style: none;
  margin: 0;
  padding: 0;
}

.dropdown-content ul li {
  margin-bottom: 5px;
}

.dropdown-content ul li a {
  display: block;
  padding: 6px 10px;
}

.mobile-menu {
  display: none;
  position: relative;
}

.hamburger {
  color: #ff8800;
  cursor: pointer;
  display: none;
  font-size: 1.5em;
}

.app-shell {
  width: min(100%, 1040px);
  margin: 12px auto 48px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stage-panel {
  background: #000;
  border: 2px solid #444;
  border-radius: 8px;
  box-shadow: none;
}

.stage-panel {
  width: 90%;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
}

.visualizer-titlebar {
  padding: 9px 12px;
  background: linear-gradient(90deg, #111, #171717);
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.visualizer-title {
  color: #ff8800;
  font-size: 16px;
  font-weight: 700;
}

.titlebar-export {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.titlebar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  position: relative;
}

.titlebar-export__label {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.titlebar-presets {
  flex: 0 0 auto;
  position: relative;
}

.titlebar-presets summary {
  align-items: center;
  background: #0c0c0c;
  border: 1px solid #333;
  border-radius: 6px;
  color: #ff8800;
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  height: 28px;
  appearance: none;
  -webkit-appearance: none;
  list-style: none;
  list-style-type: none;
  padding: 0 10px;
  white-space: nowrap;
}

.titlebar-presets summary::-webkit-details-marker {
  display: none;
}

.titlebar-presets summary::marker {
  content: "";
  display: none;
}

.titlebar-presets[open] summary,
.titlebar-presets summary:hover {
  border-color: #ff8800;
  color: #fff;
}

.titlebar-presets__menu {
  background: rgba(5, 5, 5, 0.98);
  border: 1px solid rgba(255, 136, 0, 0.42);
  border-radius: 8px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.48);
  min-width: 285px;
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
}

.titlebar-presets__row,
.titlebar-presets__actions {
  display: grid;
  gap: 8px;
}

.titlebar-presets__row {
  grid-template-columns: minmax(86px, 0.8fr) minmax(0, 1.2fr);
  margin-bottom: 8px;
}

.titlebar-presets__actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.titlebar-presets select,
.titlebar-presets input[type="text"],
.titlebar-button {
  font-size: 12px;
  min-height: 30px;
  padding: 5px 8px;
}

.titlebar-button {
  min-height: 30px;
  width: 100%;
}

.titlebar-presets__status {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin: 8px 0 0;
}

.stage-toolbar,
.timeline,
.export-panel {
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #333;
}

.timeline {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  padding: 10px;
}

.timeline span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: center;
}

.timeline input {
  width: 100%;
}

.timeline-play {
  min-width: 64px;
  padding: 7px 10px;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.stage:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}

.stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}

.stage.is-bg-move-mode {
  cursor: grab;
  touch-action: none;
}

.stage.is-bg-dragging {
  cursor: grabbing;
}

#visualizerCanvas,
#backgroundVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#backgroundVideo {
  display: none;
}

.stage-fullscreen-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 8;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
  padding: 0;
  transition: opacity 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.stage-fullscreen-toggle:hover,
.stage-fullscreen-toggle.is-active {
  background: rgba(0, 0, 0, 0.34);
  border-color: rgba(255, 136, 0, 0.82);
  opacity: 1;
}

.fullscreen-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
}

.fullscreen-icon::before,
.fullscreen-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-color: currentColor;
  border-style: solid;
}

.fullscreen-icon::before {
  border-width: 2px 0 0 2px;
}

.fullscreen-icon::after {
  border-width: 0 2px 2px 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.control-section-title {
  color: #ff8800;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 16px 0 10px;
  padding-top: 12px;
  border-top: 1px solid #2a2a2a;
}

.control-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.control-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: -4px 0 14px;
}

.check-control {
  min-height: 36px;
  background: #090909;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.check-control input {
  accent-color: #ff8800;
}

.settings-drawer {
  border-top: 1px solid #2a2a2a;
  margin-top: 14px;
  padding-top: 10px;
}

.settings-drawer summary {
  color: #ff8800;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.settings-bar {
  width: 100%;
  height: 40px;
  background: #111;
  border-top: 1px solid #333;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

.settings-icon {
  min-width: 44px;
  min-height: 30px;
  background: transparent;
  border: 0;
  color: #ff8800;
  cursor: pointer;
  font-weight: 700;
}

.settings-icon:hover,
.settings-icon.active {
  color: #fff;
}

.settings-panel-dock {
  background: #050505;
}

.settings-panel {
  display: none;
  position: static;
  width: 100%;
  background: rgba(0, 0, 0, 0.72);
  border-bottom: 1px solid rgba(255, 136, 0, 0.38);
  max-height: 320px;
  padding: 12px;
  overflow-y: auto;
}

.settings-panel.active {
  display: block;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
select {
  width: 100%;
  min-height: 40px;
  background: #090909;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.toolbar-select {
  width: auto;
  min-width: 170px;
}

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

.position-slider-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 22px;
}

.position-slider-wrap .position-slider {
  position: relative;
  z-index: 1;
}

.position-slider-reset {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 22px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  padding: 0;
}

.position-slider-reset::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  bottom: 3px;
  width: 2px;
  transform: translateX(-50%);
  background: #ff8800;
  box-shadow: 0 0 6px rgba(255, 136, 0, 0.75);
}

.position-slider-reset:hover::before {
  background: #fff;
}

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a0f17;
}

.button,
.file-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #111;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
.file-button:hover {
  border-color: #ff8800;
}

.button.is-active {
  border-color: #ff8800;
  color: #ff8800;
  box-shadow: inset 0 0 0 1px rgba(255, 136, 0, 0.28);
}

.button--primary {
  background: #ff8800;
  border-color: transparent;
  color: #140900;
  font-weight: 700;
}

.button.is-recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.file-button input {
  display: none;
}

.file-button--quiet {
  width: 100%;
  background: #090909;
}

.status-text {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-panel {
  display: block;
  border-bottom: 0;
}

.export-panel[hidden] {
  display: none;
}

.export-panel__title {
  font-weight: 700;
  margin-bottom: 8px;
}

.export-message {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.export-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.export-links a {
  color: var(--primary);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  text-decoration: none;
}

.export-links a:hover {
  border-color: var(--primary);
}

@media (max-width: 980px) {
  .app-shell {
    margin-top: 12px;
  }
}

@media (max-width: 760px) {
  .top-header,
  .stage-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .visualizer-titlebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 7px 8px;
  }

  .visualizer-title {
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .visualizer-titlebar .status-text {
    display: none;
  }

  .visualizer-titlebar .titlebar-actions {
    align-items: center;
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    justify-content: flex-end;
    margin-left: auto;
    min-width: 0;
    text-align: right;
  }

  .visualizer-titlebar .titlebar-export {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
    text-align: right;
  }

  .visualizer-titlebar .titlebar-export__label {
    font-size: 11px;
    line-height: 1;
  }

  .visualizer-titlebar .titlebar-presets summary {
    font-size: 0;
    height: 26px;
    justify-content: center;
    overflow: hidden;
    padding: 0 8px;
    width: 50px;
  }

  .visualizer-titlebar .titlebar-presets summary::after {
    content: "Save";
    font-size: 11px;
    line-height: 1;
  }

  .titlebar-presets__menu {
    left: auto;
    min-width: min(310px, 90vw);
    right: 0;
    transform: none;
  }

  .stage-toolbar .button,
  .stage-toolbar .file-button,
  .stage-toolbar .toolbar-select {
    width: 100%;
    text-align: center;
    text-align-last: center;
  }

  .nav-container > nav.desktop-menu {
    display: none;
  }

  .mobile-menu {
    display: block;
  }

  .hamburger {
    display: block;
  }

  .mobile-menu nav ul {
    display: none;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.95);
    position: static;
    width: 100%;
    border-radius: 8px;
    padding: 10px 0;
  }

  .mobile-menu nav ul.show {
    display: flex;
  }

  .dropdown-content {
    position: static;
    background: #000;
    border: none;
    padding: 0;
    min-width: 0;
  }

  .dropdown-content ul {
    display: none;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    width: 95%;
  }

  .settings-panel {
    max-height: 360px;
  }
}

@media (max-width: 900px) {
  .stage-fullscreen-toggle {
    display: none;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  body {
    padding-top: 0;
    background: #000;
  }

  header,
  .visualizer-titlebar,
  .settings-bar,
  .settings-panel-dock,
  .timeline,
  .stage-toolbar,
  .export-panel {
    display: none !important;
  }

  .app-shell {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .stage-panel {
    position: fixed;
    inset: 0;
    z-index: 3000;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .stage {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
  }

  .stage-fullscreen-toggle {
    display: none;
  }
}
