:root {
  --bg-1: #1c1526;
  --bg-2: #2a1f3a;
  --panel: #3a2a4a;
  --panel-strong: #342444;
  --accent: #b79cf3;
  --accent-2: #d7baf7;
  --accent-dark: #8d74d8;
  --text: #f2eafb;
  --muted: #c4b3d6;
  --border: #4b3561;
  --shadow: 0 22px 50px rgba(15, 9, 22, 0.5);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Poppins", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% -10%, #3a2a4a 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  padding: 40px 22px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer {
  display: flex;
  justify-content: center;
  text-align: center;
  font-size: 0.6em;
  color: var(--muted);
  padding: 0.5em 16px 20px;
}

.footer .footer-line {
  letter-spacing: 0.03em;
  width: 100%;
  max-width: 96vw;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.footer a:hover {
  color: var(--text);
}

@media (max-width: 480px) {
  .footer {
    font-size: 0.52em;
  }

  .footer .footer-line {
    max-width: 98vw;
  }
}

.hero, .user, .admin {
  width: min(880px, 100%);
  background: linear-gradient(180deg, #4a365f 0%, var(--panel) 100%);
  border-radius: 28px;
  padding: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero::before, .user::before, .admin::before {
  content: "";
  position: absolute;
  top: -55px;
  left: -70px;
  width: 190px;
  height: 190px;
  background: radial-gradient(circle, rgba(215, 186, 247, 0.35), rgba(215, 186, 247, 0));
  border-radius: 50%;
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
}

.hero-top h1 {
  margin: 0;
  min-width: 0;
}

.hero-top .btn {
  margin: 0;
  flex: 0 0 auto;
}

h1 {
  margin: 0 0 12px;
  font-size: 2.6rem;
  letter-spacing: 0.2px;
}

h2 {
  margin: 0;
  font-size: 1.4rem;
}

.lead {
  font-size: 1.15rem;
  margin: 0 0 10px;
}

.note {
  color: var(--muted);
  margin: 0;
}


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

.user-header h1 {
  margin-top: 12px;
  margin-left: 8px;
}

.tracklist {
  margin-top: 8px;
  padding: 8px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid #5a3e76;
  width: 100%;
}

.usage {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 12px 0 6px;
  font-size: 0.9rem;
  color: var(--muted);
  padding-left: 8px;
}

.usage strong {
  color: var(--text);
}

.track-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-direction: column;
  position: relative;
}

.drag-handle {
  position: absolute;
  top: 2px;
  right: 2px;
  cursor: grab;
  color: var(--muted);
  font-size: 1rem;
  user-select: none;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  border-radius: 8px;
  background: transparent;
}

.track-row.dragging {
  opacity: 0.6;
}

.reorder-buttons {
  display: flex;
  gap: 8px;
}

.track-row + .track-row {
  margin-top: 8px;
}

.track-title {
  font-weight: 600;
  font-size: 1.05rem;
}

@media (max-width: 520px) {
  .user.private .track-title {
    max-width: 18ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.track-main {
  flex: 1;
  width: 100%;
}

/* Keep public track rows as two columns even on small screens */
.user.public .track-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user.public .track-info {
  flex: 1 1 auto;
  min-width: 0;
}

.user.public .tracklist .mini-player[data-public="1"] {
  flex: 0 0 auto;
  align-self: center;
  margin-top: 0;
  background: transparent;
}

@media (min-width: 800px) {
  .user.public .mini-player {
    margin-top: 0;
    min-width: 260px;
  }

.user.public .tracklist .mini-player[data-public="1"] {
  min-width: 88px;
  padding: 2px 4px;
}

  .user.public .track-meta {
    align-items: flex-start;
    text-align: left;
  }
}

.track-info {
  width: 100%;
}

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

.track-status {
  flex-shrink: 0;
  margin-right: 16px;
}

.track-meta {
  margin-top: 4px;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.mini-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 6px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.user.public .tracklist .mini-player[data-public="1"] .mini-seek {
  display: none;
}

.user.public .tracklist .mini-player[data-public="1"] .mini-skip,
.user.public .tracklist .mini-player[data-public="1"] .mini-cast,
.user.public .tracklist .mini-player[data-public="1"] .mini-toggle,
.user.public .tracklist .mini-player[data-public="1"] .mini-stop,
.user.public .tracklist .mini-player[data-public="1"] .mini-now {
  display: none;
}

.user.public .tracklist .mini-player[data-public="1"] .mini-time {
  font-size: 0.95rem;
}

.user.public .tracklist .mini-player[data-public="1"] .mini-btn {
  padding: 8px 10px;
  font-size: 0.85rem;
}

.user.public .tracklist .mini-player[data-public="1"] .mini-body {
  order: 0;
}

.user.public .tracklist .mini-player[data-public="1"] .mini-controls {
  order: 1;
}

.mini-player-placeholder {
  height: 58px;
}

.mini-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mini-seek {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0;
}

.mini-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.mini-seek::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.mini-time {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 42px;
  text-align: right;
}

.mini-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-toggle {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.65rem;
  letter-spacing: 0.4px;
  cursor: pointer;
  display: none;
}

.mini-skip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f7f1ff;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  display: none;
}

.mini-toggle.is-on {
  background: linear-gradient(135deg, rgba(183, 156, 243, 0.5), rgba(183, 156, 243, 0.2));
  color: #f7f1ff;
  border-color: rgba(183, 156, 243, 0.6);
}

.mini-stop {
  border: 1px solid rgba(255, 130, 150, 0.5);
  background: rgba(140, 30, 60, 0.5);
  color: #ffe6ee;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.65rem;
  letter-spacing: 0.4px;
  cursor: pointer;
  display: none;
}

.mini-cast {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f7f1ff;
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.7rem;
}

.mini-cast.is-casting {
  border-color: rgba(120, 200, 150, 0.75);
  background: rgba(120, 200, 150, 0.2);
  color: #e9fff0;
  box-shadow: 0 0 0 1px rgba(120, 200, 150, 0.35), 0 0 10px rgba(120, 200, 150, 0.25);
}

.mini-cast.is-casting::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ff0b7;
  box-shadow: 0 0 6px rgba(159, 240, 183, 0.8);
}

.mini-cast svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.mini-body {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.mini-now {
  display: none;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0.04em;
  color: rgba(247, 241, 255, 0.75);
  text-align: center;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.has-sticky-player .sticky-player .mini-now {
  display: block;
}

.track-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  min-width: 0;
  width: 100%;
}

.track-actions .action-main {
  width: 100%;
}

.track-actions .action-secondary {
  width: 100%;
}

.track-actions .inline-form {
  width: 100%;
}

.track-actions .input.small,
.track-actions .btn.small {
  width: 100%;
}


.empty {
  color: var(--muted);
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 10px 18px rgba(141, 116, 216, 0.35);
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.link {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  margin-top: 8px;
}

.input.small {
  padding: 8px 10px;
  border-radius: 10px;
  width: 110px;
}

.btn.small {
  padding: 8px 14px;
  font-size: 0.9rem;
}

.btn.subtle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  box-shadow: none;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.btn.subtle:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.login-corner {
  position: absolute;
  top: 14px;
  right: 14px;
}

.login-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 0.72rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.login-link:hover {
  color: var(--text);
}

.btn.good {
  background: linear-gradient(135deg, rgba(122, 204, 166, 0.55), rgba(122, 204, 166, 0.3));
  color: #e9fff4;
  box-shadow: 0 8px 16px rgba(122, 204, 166, 0.24);
}

.btn.bad {
  background: linear-gradient(135deg, rgba(230, 165, 190, 0.45), rgba(230, 165, 190, 0.2));
  color: #ffe9f1;
  box-shadow: 0 8px 16px rgba(230, 165, 190, 0.18);
}

.btn.danger {
  background: linear-gradient(135deg, rgba(240, 95, 115, 0.9), rgba(200, 45, 80, 0.65));
  color: #fff3f6;
  box-shadow: 0 10px 22px rgba(200, 45, 80, 0.35);
}

.form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.inline-form {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #2c203c;
  color: var(--text);
  font-size: 0.98rem;
  width: 100%;
  max-width: 100%;
}

input:focus {
  outline: 2px solid rgba(183, 156, 243, 0.35);
  border-color: var(--accent);
}

input::placeholder {
  color: rgba(242, 234, 251, 0.6);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0px 1000px #2c203c inset;
  transition: background-color 9999s ease-in-out 0s;
  border: 1px solid var(--border);
}

.banner {
  background: #4a345f;
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  color: var(--muted);
}

.popup {
  background: #4a2e3f;
  border: 1px solid #6b3f56;
  color: #f3d9e2;
  padding: 18px 22px;
  border-radius: 16px;
  width: min(520px, 100%);
  text-align: center;
}

.spacer {
  height: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 8, 20, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.fade-out {
  animation: modalFade 0.4s ease forwards;
}

@keyframes modalFade {
  to {
    opacity: 0;
    transform: scale(0.98);
  }
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  background: linear-gradient(180deg, #4a365f 0%, var(--panel) 100%);
  width: min(420px, 100%);
  padding: 26px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.modal-card-info {
  width: min(680px, 100%);
}

.rules-text {
  display: grid;
  gap: 12px;
  margin: 14px 0 10px;
}

.rules-text p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-card-warn {
  border-color: rgba(255, 120, 140, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 120, 140, 0.2), 0 18px 40px rgba(0, 0, 0, 0.35);
}

.modal-card-warn h2 {
  color: #ff8aa1;
}

.card {
  margin-top: 24px;
  background: var(--panel-strong);
  border: 1px solid #5a3e76;
  border-radius: 18px;
  padding: 18px;
  overflow-x: auto;
}

.form input[type="file"] {
  padding: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.95rem;
  table-layout: fixed;
  min-width: 860px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
  word-break: break-word;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.8rem;
  margin-right: 6px;
}

.badge.ok {
  background: rgba(129, 200, 170, 0.2);
  color: #d7f5e8;
}

.badge.warn {
  background: rgba(230, 165, 190, 0.2);
  color: #f3d1df;
}

.badge.deleted {
  background: rgba(240, 95, 115, 0.2);
  color: #ffd6df;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check.inline {
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.admin .user-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.admin .user-name .muted {
  font-size: 0.8rem;
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 12px 0 18px;
}

.stats-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
}

.stats-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 4px 0 6px;
}

.stats-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.stats-tables > div {
  min-width: 0;
}

.admin .table {
  border-collapse: separate;
  border-spacing: 0 10px;
}

.admin .table tbody tr {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.admin .table tbody td {
  border-bottom: none;
  padding: 12px 10px;
}

.admin .table tbody td:last-child {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin .table tbody td:last-child .inline-form {
  width: 100%;
}

.admin .table tbody td:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

.admin .table tbody td:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

.stats-table {
  table-layout: fixed;
  min-width: 0;
}

@media (min-width: 900px) {
  .stats-users th:nth-child(2),
  .stats-users td:nth-child(2) {
    width: 80px;
  }

  .stats-users th:nth-child(4),
  .stats-users td:nth-child(4) {
    width: 90px;
  }

  .stats-tracks th:nth-child(1),
  .stats-tracks td:nth-child(1) {
    width: 60%;
  }

  .stats-tracks th:nth-child(2),
  .stats-tracks td:nth-child(2) {
    width: 20%;
  }

  .stats-tracks th:nth-child(3),
  .stats-tracks td:nth-child(3) {
    width: 20%;
  }

  .stats-tracks td:nth-child(1) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 820px) {
  .table,
  .table thead,
  .table tbody,
  .table th,
  .table td,
  .table tr {
    display: block;
  }

  .table thead {
    display: none;
  }

  .table {
    min-width: 0;
    table-layout: auto;
  }

  .table tr {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .table td {
    padding: 6px 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
  }

  .table td::before {
    content: attr(data-label);
    flex: 0 0 120px;
    color: var(--muted);
    font-weight: 600;
  }

  .user-table td {
    display: block;
    padding: 8px 0;
  }

  .user-table td::before {
    display: none;
  }

  .user-table tr + tr {
    margin-top: 16px;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .btn.small,
  .input.small {
    width: 100%;
  }
}


@media (max-width: 720px) {
  .page {
    padding: 28px 18px 50px;
  }

  .hero, .user, .admin {
    padding: 8px;
  }

  h1 {
    font-size: 2.1rem;
  }

  .sticky-player {
    left: 12px;
    right: 12px;
    transform: none;
    bottom: 12px;
    width: auto;
    padding: 8px;
  }

  .has-sticky-player .page {
    padding-bottom: 130px;
  }

  .sticky-player .mini-btn,
  .sticky-player .mini-toggle,
  .sticky-player .mini-skip,
  .sticky-player .mini-cast,
  .sticky-player .mini-stop {
    padding: 14px 12px;
    font-size: 0.85rem;
    flex: 0 0 auto;
  }

  .sticky-player .mini-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .sticky-player .mini-controls > * {
    width: 100%;
    justify-content: center;
  }

  .sticky-player .mini-controls [data-auto-next] {
    grid-column: span 2;
  }
}

.sticky-player {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 50;
  width: min(680px, 96vw);
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(34, 25, 48, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.sticky-player:empty {
  display: none;
}

.sticky-player .mini-player {
  flex-direction: column;
  align-items: stretch;
  margin-top: 0;
  background: transparent;
}

.has-sticky-player .page {
  padding-bottom: 140px;
}

.sticky-player .mini-controls {
  width: 100%;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.sticky-player .mini-toggle,
.sticky-player .mini-skip,
.sticky-player .mini-cast,
.sticky-player .mini-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  font-size: 0.8rem;
}

.sticky-player .mini-btn {
  padding: 10px 14px;
  font-size: 0.8rem;
}

@media (max-width: 520px) {
  .user-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-top .btn {
    width: auto;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .card {
    overflow-x: hidden;
  }
}
