:root {
  --page-bg: linear-gradient(135deg, #ece0d2 0%, #d9e6e3 100%);
  --card-bg: rgba(252, 248, 243, 0.9);
  --card-border: rgba(109, 90, 80, 0.15);
  --ink: #1d1916;
  --muted: #6c6058;
  --accent: #265f67;
  --accent-strong: #1f5057;
  --accent-soft: rgba(38, 95, 103, 0.16);
  --signal: #d96c54;
  --signal-soft: rgba(217, 108, 84, 0.18);
  --shadow: 0 24px 60px rgba(57, 41, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DejaVu Sans", "Noto Sans", sans-serif;
  color: var(--ink);
  background: var(--page-bg);
}

.page-shell {
  width: min(1520px, calc(100vw - 40px));
  margin: 24px auto 48px;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 14px 24px;
  position: relative;
  overflow: hidden;
}

.hero-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.auth-panel {
  display: grid;
  gap: 10px;
  min-width: min(100%, 320px);
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(38, 95, 103, 0.12);
  background: rgba(255, 255, 255, 0.52);
}

.auth-status-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -24px -58px auto;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(38, 95, 103, 0.18), rgba(38, 95, 103, 0));
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0.08em;
}

.page-footer {
  padding: 4px 8px 0;
  text-align: center;
}

.page-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.context-menu {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  min-width: 220px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(252, 248, 243, 0.98);
  border: 1px solid var(--card-border);
  box-shadow: 0 18px 40px rgba(57, 41, 30, 0.18);
  backdrop-filter: blur(18px);
}

.context-menu[hidden] {
  display: none;
}

.context-menu-item {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  background: rgba(38, 95, 103, 0.1);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.context-menu-item:hover,
.context-menu-item:focus-visible {
  outline: none;
  background: rgba(38, 95, 103, 0.18);
}

.lede {
  margin: 14px 0 0;
  max-width: 64ch;
  color: var(--muted);
  line-height: 1.6;
}

.media-section {
  display: grid;
  grid-template-columns: minmax(320px, 370px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.media-side-column,
.media-main-column {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.upload-card,
.preview-card,
.waveform-card,
.lyrics-card,
.pipeline-card {
  padding: 22px;
}

.upload-card,
.preview-card,
.lyrics-card,
.pipeline-card {
  display: grid;
  gap: 16px;
}

.upload-card .section-heading,
.preview-card .section-heading {
  margin-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-heading p,
.status-row,
#file-name,
#song-file-name {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--accent);
  color: #fffdf9;
  font-weight: 700;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-zone {
  margin-top: 16px;
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  border: 1.5px dashed rgba(38, 95, 103, 0.28);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(38, 95, 103, 0.06));
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.drop-zone.is-active {
  border-color: var(--signal);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(217, 108, 84, 0.12));
  transform: translateY(-1px);
}

.secondary-drop-zone {
  min-height: 120px;
  margin-top: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(38, 95, 103, 0.04));
}

.drop-zone p,
.drop-zone small {
  margin: 0;
}

.drop-zone small {
  color: var(--muted);
}

.working-indicator {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(38, 95, 103, 0.1);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.working-indicator[hidden] {
  display: none;
}

.working-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(31, 80, 87, 0.22);
  border-top-color: var(--accent-strong);
  animation: working-spin 700ms linear infinite;
}

@keyframes working-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.upload-panel {
  margin-top: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(109, 90, 80, 0.05);
  border: 1px solid rgba(109, 90, 80, 0.1);
}

.upload-panel .drop-zone,
.upload-panel .working-indicator {
  margin-top: 0;
}

.upload-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.upload-panel-header label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.secondary-picker {
  background: rgba(38, 95, 103, 0.12);
  color: var(--accent-strong);
}

.lyrics-card {
  display: grid;
  gap: 10px;
}

.lyrics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lyrics-header label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.lyrics-input {
  width: 100%;
  resize: vertical;
  min-height: 260px;
  border: 1px solid rgba(109, 90, 80, 0.18);
  border-radius: 18px;
  padding: 14px 16px;
  font: inherit;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
}

.lyrics-input:focus {
  outline: 2px solid rgba(38, 95, 103, 0.18);
  border-color: rgba(38, 95, 103, 0.38);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.pipeline-card[hidden] {
  display: none;
}

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

.pipeline-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(109, 90, 80, 0.1);
  background: rgba(109, 90, 80, 0.05);
}

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

.pipeline-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.pipeline-panel-header h3,
.pipeline-step-header strong,
.pipeline-step-header span,
.pipeline-step-meta span {
  margin: 0;
}

.pipeline-panel-header h3 {
  font-size: 0.98rem;
}

.pipeline-panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.pipeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.pipeline-step {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(38, 95, 103, 0.12);
  background: rgba(255, 255, 255, 0.66);
  cursor: pointer;
}

.pipeline-step.is-queued {
  border-color: rgba(109, 90, 80, 0.16);
}

.pipeline-step.is-running {
  border-color: rgba(38, 95, 103, 0.28);
  background: rgba(38, 95, 103, 0.08);
}

.pipeline-step.is-succeeded {
  border-color: rgba(38, 95, 103, 0.18);
}

.pipeline-step.is-failed,
.pipeline-step.is-cancelled {
  border-color: rgba(217, 108, 84, 0.3);
  background: rgba(217, 108, 84, 0.08);
}

.pipeline-step-header,
.pipeline-step-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pipeline-step-header strong {
  font-size: 0.92rem;
}

.pipeline-step-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(38, 95, 103, 0.12);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pipeline-step.is-failed .pipeline-step-status,
.pipeline-step.is-cancelled .pipeline-step-status {
  background: rgba(217, 108, 84, 0.16);
  color: #8c3f2d;
}

.pipeline-step-progress {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(38, 95, 103, 0.1);
  overflow: hidden;
}

.pipeline-step-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #4e8f96);
}

.pipeline-step-meta,
.pipeline-step-message,
.pipeline-step-dependency {
  color: var(--muted);
  font-size: 0.82rem;
}

.pipeline-step-message {
  color: var(--ink);
  line-height: 1.45;
}

.pipeline-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(29, 25, 22, 0.18);
  backdrop-filter: blur(3px);
}

.pipeline-drawer-backdrop[hidden] {
  display: none;
}

.pipeline-drawer {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: min(420px, calc(100vw - 32px));
  z-index: 50;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(252, 248, 243, 0.98);
  border: 1px solid var(--card-border);
  box-shadow: 0 24px 60px rgba(57, 41, 30, 0.18);
}

.pipeline-drawer[hidden] {
  display: none;
}

.pipeline-drawer-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.pipeline-drawer-eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pipeline-drawer-header h3,
.pipeline-drawer-summary,
.pipeline-drawer-event-message,
.pipeline-drawer-event-meta,
.pipeline-drawer-empty {
  margin: 0;
}

.pipeline-drawer-summary {
  color: var(--muted);
  line-height: 1.5;
}

.pipeline-drawer-events {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.pipeline-drawer-event {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(109, 90, 80, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

.pipeline-drawer-event-header,
.pipeline-drawer-event-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pipeline-drawer-event-type {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(38, 95, 103, 0.12);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.pipeline-drawer-event-message {
  color: var(--ink);
  line-height: 1.45;
}

.pipeline-drawer-event-meta,
.pipeline-drawer-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.pipeline-drawer-event-meta span:empty {
  display: none;
}

@media (max-width: 960px) {
  .hero-header {
    flex-direction: column;
  }

  .auth-panel {
    width: 100%;
  }

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

  .pipeline-drawer {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    width: auto;
    max-height: min(70vh, 560px);
  }
}

.button-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.mute-toggle {
  border: none;
  border-radius: 14px;
  padding: 11px 16px;
  font: inherit;
}

button {
  background: var(--accent);
  color: #fffdf9;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: rgba(109, 90, 80, 0.12);
  color: var(--ink);
}

.mute-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(109, 90, 80, 0.08);
  color: var(--ink);
}

.timeline-label {
  display: block;
  margin: 20px 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

#timeline {
  width: 100%;
  accent-color: var(--signal);
}

.status-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.preview-timeline {
  display: grid;
  gap: 10px;
}

.preview-timeline .timeline-label {
  margin: 0;
}

.preview-timeline .status-row {
  margin-top: 0;
}

.preview-actions .field-hint {
  flex: 1 1 280px;
}

button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

#video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 22px;
  background: #171311;
  object-fit: contain;
}

.waveform-card {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.waveform-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.waveform-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(109, 90, 80, 0.08);
  color: var(--ink);
}

.waveform-select span {
  font-size: 0.88rem;
  color: var(--muted);
}

.waveform-select select {
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.waveform-select select:focus {
  outline: none;
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(109, 90, 80, 0.08);
  color: var(--ink);
}

.zoom-control span {
  font-size: 0.88rem;
  color: var(--muted);
}

.zoom-control input {
  width: 140px;
  accent-color: var(--signal);
}

.zoom-control strong {
  font-size: 0.88rem;
}

.match-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(38, 95, 103, 0.08);
  border: 1px solid rgba(38, 95, 103, 0.12);
}

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

.match-panel p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.match-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.match-picker[hidden] {
  display: none;
}

.match-picker label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.match-picker select {
  min-width: min(440px, 100%);
  max-width: 100%;
  border: 1px solid rgba(109, 90, 80, 0.18);
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.waveform-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}

.waveform-stage {
  position: relative;
  min-width: 100%;
  height: 320px;
}

.waveform-scroll::-webkit-scrollbar {
  height: 12px;
}

.waveform-scroll::-webkit-scrollbar-thumb {
  background: rgba(109, 90, 80, 0.2);
  border-radius: 999px;
}

#waveform,
#song-waveform {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 250, 245, 0.92), rgba(239, 229, 219, 0.92));
  border: 1px solid rgba(109, 90, 80, 0.15);
  user-select: none;
}

.waveform-overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  user-select: none;
}

.waveform-overlay * {
  pointer-events: none;
}

@media (max-width: 1180px) {
  .media-section {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100vw - 20px, 1520px);
    margin-top: 10px;
  }
}

@media (max-width: 880px) {

  .section-heading,
  .status-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .waveform-toolbar {
    align-items: flex-start;
  }

  .lyrics-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .zoom-control {
    width: 100%;
    justify-content: space-between;
  }

  .hero {
    padding: 14px 18px;
  }

  .hero h1 {
    letter-spacing: 0.05em;
  }
}
