:root {
  color-scheme: dark;
  --ink: #ffffff;
  --muted: #c9d4ef;
  --subtle: #8ea1c9;
  --line: rgba(75, 229, 232, 0.2);
  --paper: #001a3a;
  --surface: rgba(10, 22, 47, 0.88);
  --surface-strong: #1c1c28;
  --surface-soft: rgba(255, 255, 255, 0.06);
  --deep-space: #001a3a;
  --night: #020712;
  --galactic-violet: #7a42f4;
  --dream-purple: #b084ff;
  --aurora-teal: #2ad1c9;
  --aqua-nebula: #4be5e8;
  --stellar-white: #ffffff;
  --button-glow: linear-gradient(100deg, #f423b4, #7a42f4 48%, #4be5e8);
  --brand-gradient: linear-gradient(110deg, #7a2ff4, #4be5e8);
  --focus: #4be5e8;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(0, 26, 58, 0.98), rgba(28, 28, 40, 0.98) 48%, rgba(46, 30, 86, 0.96)),
    var(--deep-space);
  font-family:
    "Avenir Next", Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background:
    linear-gradient(100deg, rgba(2, 7, 18, 0.96), rgba(0, 26, 58, 0.94) 48%, rgba(122, 66, 244, 0.32)),
    var(--night);
  border-bottom: 1px solid rgba(75, 229, 232, 0.24);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.3);
}

.topbar h1,
.playlist-name-field input {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar h1 {
  color: white;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow:
    0 0 0 3px rgba(75, 229, 232, 0.15),
    0 0 26px rgba(176, 132, 255, 0.28),
    0 12px 28px rgba(0, 0, 0, 0.34);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--aqua-nebula);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: var(--aqua-nebula);
}

.topbar-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-stats span {
  min-width: 82px;
  padding: 8px 10px;
  border: 1px solid rgba(75, 229, 232, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--stellar-white);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

#quotaStatus {
  min-width: 148px;
}

.sign-out-button {
  min-height: 34px;
}

.upgrade-button {
  min-height: 34px;
  padding: 0 12px;
}

.request-song-button {
  min-height: 34px;
  padding: 0 12px;
}

.pane-toolbar .request-song-button {
  width: 100%;
  min-height: 38px;
}

.member-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 26, 58, 0.98), rgba(28, 28, 40, 0.98) 48%, rgba(122, 66, 244, 0.36)),
    var(--deep-space);
}

.member-panel {
  width: min(420px, 100%);
  border: 1px solid rgba(75, 229, 232, 0.28);
  border-radius: 8px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(4, 14, 34, 0.98), rgba(10, 22, 47, 0.96)),
    var(--surface);
  box-shadow: var(--shadow);
}

.member-logo {
  width: 78px;
  height: 78px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 26px rgba(176, 132, 255, 0.28);
}

.member-panel h2 {
  margin: 4px 0 18px;
  font-size: 24px;
  line-height: 1.15;
}

.member-form {
  display: grid;
  gap: 12px;
}

.member-form label {
  display: grid;
  gap: 6px;
}

.member-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.member-form input,
.request-panel input,
.request-panel textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--stellar-white);
}

.request-panel textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.member-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}

.member-actions button {
  min-width: 0;
}

.member-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 7, 18, 0.72);
  backdrop-filter: blur(10px);
}

.request-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 12px;
  border: 1px solid rgba(75, 229, 232, 0.28);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(4, 14, 34, 0.98), rgba(10, 22, 47, 0.96)),
    var(--surface);
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.request-panel label {
  display: grid;
  gap: 6px;
}

.request-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.request-panel input::placeholder,
.request-panel textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.library-pane,
.playlist-pane {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.library-pane {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(5, 16, 38, 0.96), rgba(10, 22, 47, 0.94)),
    var(--surface);
  display: grid;
  grid-template-rows: auto 1fr;
}

.pane-toolbar {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(5, 16, 38, 0.98), rgba(10, 22, 47, 0.96)),
    var(--surface);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.24);
}

.search-field {
  display: grid;
  gap: 6px;
}

.search-field span,
.settings-band span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.search-field input,
.audio-select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--stellar-white);
}

.search-field input::placeholder {
  color: rgba(255, 255, 255, 0.56);
}

.search-field input {
  padding: 0 12px;
}

.admin-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(132px, auto)) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.admin-row .secondary {
  min-height: 34px;
  padding: 0 12px;
}

.admin-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.analytics-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.analytics-card,
.analytics-region-list {
  display: grid;
  gap: 8px;
}

.analytics-region-list {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.analytics-card div {
  display: grid;
  gap: 2px;
}

.analytics-card span {
  color: var(--aqua-nebula);
  text-transform: uppercase;
}

.analytics-card strong {
  color: var(--stellar-white);
  line-height: 1.25;
}

.search-field input:focus,
.member-form input:focus,
.request-panel input:focus,
.request-panel textarea:focus,
.audio-select:focus,
button:focus-visible {
  outline: 3px solid rgba(75, 229, 232, 0.34);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
}

.segmented button {
  min-height: 34px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 4px;
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented button.active {
  background: var(--brand-gradient);
  color: var(--stellar-white);
}

.era-filter {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.song-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.result-note {
  padding: 10px 6px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.song-pager {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(4, 14, 34, 0.98), rgba(9, 22, 48, 0.96)),
    var(--surface);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.2);
}

.song-pager span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

.song-pager button {
  min-height: 34px;
  padding: 0 12px;
}

.song-row,
.playlist-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.song-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 38px;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.song-title,
.playlist-song {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.song-meta,
.playlist-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.audio-select {
  padding: 0 8px;
  font-size: 12px;
}

.audio-select option {
  background: var(--surface-strong);
  color: var(--stellar-white);
}

.audio-select option:checked {
  background: var(--galactic-violet);
  color: var(--stellar-white);
}

.add-button,
.icon-button,
.remove-button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--stellar-white);
  font-weight: 900;
}

.add-button {
  background: var(--aurora-teal);
  color: #041321;
  font-size: 18px;
}

.playlist-pane {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background:
    linear-gradient(150deg, rgba(0, 26, 58, 0.78), rgba(28, 28, 40, 0.9) 54%, rgba(122, 66, 244, 0.18)),
    var(--deep-space);
}

.playlist-header {
  position: sticky;
  top: 0;
  z-index: 7;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(4, 14, 34, 0.96), rgba(9, 22, 48, 0.94) 58%, rgba(68, 43, 133, 0.42)),
    var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.22);
}

.playlist-fields {
  min-width: min(480px, 100%);
  display: grid;
  gap: 8px;
}

.playlist-name-field {
  display: grid;
  gap: 4px;
}

.playlist-name-field span {
  color: var(--aqua-nebula);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.playlist-name-field input {
  width: min(460px, 100%);
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 8px;
  background: transparent;
  color: var(--stellar-white);
  font-weight: 900;
}

.playlist-name-field input:focus {
  border-color: rgba(75, 229, 232, 0.42);
  background: rgba(255, 255, 255, 0.07);
  outline: 3px solid rgba(75, 229, 232, 0.22);
}

.playlist-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary,
.primary {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 900;
  color: var(--stellar-white);
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.075);
  color: var(--stellar-white);
}

.primary {
  background: var(--button-glow);
  color: var(--stellar-white);
  box-shadow: var(--shadow);
}

.primary:hover,
.add-button:hover {
  filter: brightness(1.08);
}

.secondary:hover,
.lock-button:hover,
.icon-button:hover,
.remove-button:hover {
  border-color: rgba(75, 229, 232, 0.55);
  background: rgba(75, 229, 232, 0.12);
}

.playlist-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.empty-state {
  place-content: center;
  color: var(--muted);
  font-weight: 800;
}

.playlist-row {
  display: grid;
  grid-template-columns: 28px 34px minmax(0, 1fr) 68px 34px;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.playlist-row.dragging {
  opacity: 0.5;
}

.drag-handle,
.playlist-index {
  color: var(--subtle);
  text-align: center;
  font-weight: 900;
}

.drag-handle {
  cursor: grab;
}

.lock-button {
  min-width: 60px;
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.075);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.lock-button.active {
  background: rgba(176, 132, 255, 0.18);
  border-color: rgba(176, 132, 255, 0.52);
  color: var(--dream-purple);
}

.settings-band,
.generate-bar {
  border-top: 1px solid var(--line);
  background: rgba(4, 14, 34, 0.96);
  padding: 12px 20px;
  position: sticky;
  z-index: 5;
  backdrop-filter: blur(14px);
}

.settings-band {
  bottom: 58px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
}

.settings-band label:first-child {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) 38px;
  gap: 10px;
  align-items: center;
}

.settings-band input[type="range"] {
  accent-color: var(--dream-purple);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--aurora-teal);
}

.generate-bar {
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -18px 34px rgba(0, 0, 0, 0.2);
}

.job-status {
  min-height: 34px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.job-status a {
  color: var(--aqua-nebula);
}

@media (max-width: 920px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app-shell {
    height: auto;
    min-height: 100svh;
    overflow: visible;
    grid-template-rows: auto auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .library-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-rows: auto auto;
  }

  .library-pane,
  .playlist-pane {
    min-height: 0;
    overflow: visible;
  }

  .playlist-pane {
    grid-template-rows: auto auto auto auto;
  }

  .pane-toolbar,
  .playlist-header,
  .settings-band {
    position: static;
  }

  .song-list,
  .playlist-list {
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
  }

  .song-pager {
    position: static;
  }

  .settings-band {
    grid-template-columns: 1fr;
    bottom: auto;
  }

  .generate-bar {
    bottom: 0;
  }
}

@media (max-width: 560px) {
  .topbar,
  .playlist-header,
  .generate-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-stats,
  .playlist-actions {
    justify-content: stretch;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
  }

  .topbar-stats span,
  .playlist-actions button {
    flex: 1;
  }

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

  .era-filter {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .member-actions {
    grid-template-columns: 1fr;
  }

  .song-row {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .song-pager {
    grid-template-columns: 1fr 1fr;
  }

  .song-pager span {
    grid-column: 1 / -1;
  }

  .audio-select {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .playlist-row {
    grid-template-columns: 24px 28px minmax(0, 1fr) 34px;
  }

  .lock-button {
    grid-column: 3 / 4;
    justify-self: start;
  }
}
