* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f5f5f3 0%, #efefe9 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 14px;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: var(--ink-3);
  box-shadow: var(--shadow-focus);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input::file-selector-button {
  display: none;
}

input[type="range"] {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

input[type="color"] {
  min-height: 48px;
  padding: 6px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--ink);
  box-shadow: none;
}

audio {
  width: 100%;
}

.mv-app {
  min-height: 100vh;
  padding: 32px;
}

.mv-header {
  width: min(1200px, 100%);
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.mv-header h1 {
  margin-top: 8px;
}

.mv-light {
  font-weight: 400;
}

.mv-header-text {
  max-width: 620px;
  margin-top: 12px;
}

.mv-header-note {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mv-note-label,
.mv-stage-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.mv-layout {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.mv-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mv-panel,
.mv-stage-panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(229, 229, 224, 0.9);
  border-radius: var(--radius-4);
  box-shadow: 0 18px 50px rgba(17, 17, 17, 0.06);
  backdrop-filter: blur(12px);
}

.mv-panel {
  padding: 20px;
}

.mv-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.mv-panel-head > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mv-panel-body {
  display: block;
}

.mv-panel.is-collapsed .mv-panel-head {
  margin-bottom: 0;
}

.mv-panel-toggle {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
  line-height: 1;
  transition: color var(--dur-1) var(--ease-out);
}

.mv-panel-toggle-icon {
  width: 22px;
  height: 22px;
  transition: transform var(--dur-1) var(--ease-out);
}

.mv-panel-toggle[aria-expanded="true"] .mv-panel-toggle-icon {
  transform: rotate(180deg);
}

.mv-panel-toggle:hover {
  color: var(--ink);
}

.mv-field,
.mv-upload-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mv-field + .mv-field,
.mv-upload-group + .mv-field,
.mv-preset-grid + .mv-upload-group,
.mv-field + .mv-upload-group,
.mv-check-row + .mv-field,
.mv-field + .mv-check-row {
  margin-top: 14px;
}

.mv-field span:first-child {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
}

.mv-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
}

.mv-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius-2);
  border: 1px dashed var(--line-2);
  background: #fafaf8;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
}

.mv-upload:hover {
  border-color: var(--ink-3);
  background: #f2f2ee;
}

.mv-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.mv-inline-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.mv-inline-label {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--ink-3);
}

.mv-inline-value {
  font-size: var(--text-sm);
  color: var(--ink);
  word-break: break-word;
}

.mv-range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
}

.mv-range-row output {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  border-radius: var(--radius-2);
  border: 1px solid var(--line);
  background: #fbfbf9;
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.mv-color-input {
  background: var(--surface);
}

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

.mv-preset {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}

.mv-preset:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.mv-preset.is-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.mv-preset span:last-child {
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
}

.mv-preset-swatch {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
}

.mv-preset-midnight {
  background: radial-gradient(circle at 25% 20%, #38527c 0%, transparent 28%),
    linear-gradient(135deg, #070b18 0%, #0f1b35 45%, #271a4b 100%);
}

.mv-preset-sunset {
  background: radial-gradient(circle at 65% 25%, rgba(255, 213, 143, 0.75) 0%, transparent 22%),
    linear-gradient(135deg, #1f1235 0%, #7a2f4c 45%, #da6a55 100%);
}

.mv-preset-studio {
  background: linear-gradient(145deg, #141414 0%, #323232 100%);
  position: relative;
}

.mv-preset-studio::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}

.mv-preset-aurora {
  background: linear-gradient(145deg, #06111b 0%, #0e2936 55%, #12273b 100%);
  position: relative;
}

.mv-preset-aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, rgba(28, 217, 197, 0.4), rgba(154, 236, 123, 0.18), rgba(255, 255, 255, 0));
  filter: blur(4px);
}

.mv-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.mv-actions-export {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mv-button {
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius-2);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}

.mv-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.mv-button-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.mv-button-icon-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mv-button-icon-mark svg {
  width: 22px;
  height: 22px;
}

.mv-button:hover {
  border-color: var(--ink-3);
  background: #fbfbf8;
}

.mv-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.mv-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.mv-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: rgba(17, 17, 17, 0.08);
}

.mv-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 120ms linear;
}

.mv-button-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.mv-button-dark:hover {
  background: #2a2a2a;
  border-color: #2a2a2a;
}

.mv-stage-panel {
  padding: 20px;
  position: sticky;
  top: 24px;
}

.mv-stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.mv-stage-previews {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.31640625fr);
  gap: 16px;
  align-items: start;
}

.mv-stage-shell {
  border-radius: 20px;
  overflow: hidden;
  background: #080808;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

#visualizer-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

#portrait-visualizer-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
}

.mv-stage-footer {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mv-footer {
  width: min(1200px, 100%);
  margin: 24px auto 0;
  padding-bottom: 12px;
}

.mv-footer-inner {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.mv-footer-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mv-footer-left p {
  margin: 0;
}

.mv-footer-sponsor {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink);
}

.mv-footer-sponsor a,
.mv-footer-coffee {
  color: inherit;
  text-decoration: none;
  border-bottom: 0;
}

.mv-footer-processing {
  font-size: 11px;
  color: var(--ink-3);
}

.mv-footer-coffee {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-2);
}

.mv-footer-coffee:hover {
  color: var(--ink);
}

.mv-footer-coffee svg {
  width: 13px;
  height: 13px;
}

.mv-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mv-footer-sep {
  color: var(--ink-4);
}

@media (max-width: 1040px) {
  .mv-app {
    padding: 20px;
  }

  .mv-layout {
    grid-template-columns: 1fr;
  }

  .mv-sidebar {
    position: static;
  }

  .mv-stage-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .mv-header,
  .mv-stage-head,
  .mv-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .mv-header-note {
    justify-content: flex-start;
  }

  .mv-app {
    padding: 16px;
  }

  .mv-panel,
  .mv-stage-panel {
    padding: 16px;
  }

  .mv-footer-right {
    white-space: normal;
    flex-wrap: wrap;
    padding-top: 0;
  }

  .mv-preset-grid,
  .mv-actions-export,
  .mv-stage-previews,
  .mv-actions {
    grid-template-columns: 1fr;
  }
}
