:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181a20;
  --line: #2b3038;
  --text: #f4f4f5;
  --muted: #a6adbb;
  --accent: #32d583;
  --accent-ink: #07140d;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 96px);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px;
  position: sticky;
  top: 0;
  height: calc(100vh - 96px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand.center {
  justify-content: center;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a,
.button,
.primary,
.danger {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  background: #1d2027;
  color: var(--text);
  cursor: pointer;
}

.nav a.active,
.nav a:hover,
.button:hover {
  border-color: var(--accent);
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}

.danger {
  border-color: rgba(255, 107, 107, .45);
  color: var(--danger);
}

.content,
.admin-layout {
  padding: 28px 28px 124px;
}

.admin-layout {
  max-width: 1180px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

.muted,
.topbar p,
.track-card p,
.track-card small {
  color: var(--muted);
}

.search input,
label input {
  width: 100%;
  border: 1px solid var(--line);
  background: #14161b;
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  outline: none;
}

.search {
  width: min(360px, 100%);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}

.track-card {
  min-width: 0;
}

.cover-button {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  cursor: pointer;
  position: relative;
  padding: 0;
}

.cover-button img,
.player img,
.row img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-button span {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  opacity: 0;
  transform: translateY(4px);
  transition: .18s ease;
}

.track-card:hover .cover-button span,
.track-card.playing .cover-button span {
  opacity: 1;
  transform: translateY(0);
}

.track-card h2 {
  margin: 10px 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-card p,
.track-card small {
  display: block;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 64px minmax(150px, 1fr) auto minmax(180px, 440px) 120px;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(16, 17, 20, .96);
  backdrop-filter: blur(18px);
}

.player img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
}

.player button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #1d2027;
  color: var(--text);
  cursor: pointer;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.player-progress {
  display: grid;
  grid-template-columns: 44px minmax(120px, 1fr) 44px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.player-meta {
  min-width: 0;
}

.player-meta strong,
.player-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta span {
  color: var(--muted);
  font-size: 14px;
}

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

.notice {
  border: 1px solid rgba(50, 213, 131, .35);
  background: rgba(50, 213, 131, .1);
  color: #bdf8d7;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.notice.error {
  border-color: rgba(255, 107, 107, .45);
  background: rgba(255, 107, 107, .1);
  color: #ffd1d1;
}

.empty,
.panel,
.auth-box {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 22px;
}

.panel {
  margin-bottom: 18px;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.split form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  align-items: end;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.table {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 48px 1.5fr 1fr 1fr 70px auto auto;
  gap: 10px;
  align-items: center;
}

.debug-row {
  grid-template-columns: 1px 1.8fr 100px 120px 140px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.row img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-box {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

code {
  color: #d9e7ff;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px;
  }

  .sidebar .brand {
    margin-bottom: 14px;
  }

  .sidebar .muted {
    margin: 12px 0 0;
    font-size: 13px;
  }

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

  .nav a {
    padding: 10px 8px;
    text-align: center;
    font-size: 13px;
  }

  .topbar,
  .split {
    align-items: stretch;
    flex-direction: column;
  }

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

  .content,
  .admin-layout {
    padding: 20px 16px 168px;
  }

  h1 {
    font-size: 28px;
  }

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

  .track-card h2 {
    font-size: 15px;
    margin-top: 8px;
  }

  .track-card p,
  .track-card small {
    font-size: 13px;
  }

  .cover-button span {
    opacity: 1;
    width: 36px;
    height: 36px;
    right: 9px;
    bottom: 9px;
    transform: none;
  }

  .player {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    grid-template-areas:
      "cover meta controls"
      "progress progress progress";
    gap: 10px 12px;
    min-height: 128px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .player img {
    grid-area: cover;
    width: 52px;
    height: 52px;
  }

  .player-meta {
    grid-area: meta;
  }

  .player-controls {
    grid-area: controls;
    gap: 6px;
  }

  .player button {
    width: 38px;
    height: 38px;
    font-size: 12px;
  }

  #playBtn {
    width: 50px;
    border-radius: 999px;
  }

  .player-progress {
    grid-area: progress;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
  }

  .player-volume {
    display: none;
  }

  .panel,
  .empty,
  .auth-box {
    padding: 16px;
  }

  .split form {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .split form .button {
    text-align: center;
  }

  .row {
    position: relative;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #14161b;
  }

  .row img {
    width: 72px;
    height: 72px;
  }

  .row input,
  .row button,
  .row .button,
  .row .danger {
    width: 100%;
  }

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

@media (max-width: 430px) {
  .content,
  .admin-layout {
    padding-left: 12px;
    padding-right: 12px;
  }

  .sidebar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .nav a {
    font-size: 12px;
  }

  .grid {
    gap: 14px 10px;
  }

  .player {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    padding-left: 10px;
    padding-right: 10px;
  }

  .player img {
    width: 48px;
    height: 48px;
  }

  .player button {
    width: 34px;
    height: 34px;
  }

  #playBtn {
    width: 44px;
  }

  .player-meta strong {
    font-size: 14px;
  }

  .player-meta span {
    font-size: 12px;
  }
}
