[hidden] { display: none !important; }

:root {
  --accent: #2fa84f;
  --bg: #ffffff;
  --bg-elevated: #f5f5f7;
  --bg-sidebar: #f0f0f3;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: #d9d9de;
  --row-hover: #e8e8ed;
  --row-playing: #e3f7e9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1e;
    --bg-elevated: #252527;
    --bg-sidebar: #19191b;
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --border: #3a3a3c;
    --row-hover: #2c2c2e;
    --row-playing: #123a21;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
}

/* ---------- Auth screens ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border-radius: 16px;
  padding: 32px;
  border: 1px solid var(--border);
}

.auth-logo {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-logo-img {
  height: 32px;
  width: auto;
  border-radius: 4px;
}

.auth-tagline {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.auth-field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.auth-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.auth-btn {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  margin-top: 6px;
}

.auth-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.auth-error {
  background: rgba(255, 59, 48, 0.12);
  color: #ff3b30;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-success {
  background: rgba(52, 199, 89, 0.12);
  color: #34c759;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  flex: 0 0 auto;
  width: 240px;
  min-width: 190px;
  max-width: 440px;
  background: var(--bg-sidebar);
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: padding-bottom 0.15s ease;
}

.sidebar-resizer {
  flex: 0 0 6px;
  width: 6px;
  cursor: col-resize;
  background: var(--border);
  position: relative;
}

.sidebar-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1px;
  right: 1px;
  background: transparent;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: var(--accent);
}

.main {
  flex: 1 1 auto;
  min-width: 0;
}

body.player-active .sidebar {
  padding-bottom: 92px;
}

.sidebar-logo {
  padding: 0 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-img {
  display: block;
  height: 28px;
  width: auto;
  flex-shrink: 0;
  border-radius: 4px;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.sidebar-nav li {
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-nav li.active {
  background: var(--row-playing);
  color: var(--accent);
  font-weight: 600;
}

.nav-add-btn {
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 0 8px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-section-label button {
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
}

.sidebar-playlists {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-playlists li {
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-playlists li.active {
  background: var(--row-playing);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.admin-link {
  display: block;
  width: 100%;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  box-sizing: border-box;
}

.admin-link:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.upload-btn {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.logout-btn {
  width: 100%;
  padding: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.main {
  overflow-y: auto;
  padding: 24px 32px 120px;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}

.main-header h1 {
  font-size: 24px;
  margin: 0;
}

.main-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.main-header-actions {
  display: flex;
  gap: 8px;
}

.search-box {
  position: relative;
}

.search-box::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 13px;
  height: 13px;
  transform: translateY(-50%);
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  pointer-events: none;
}

.search-box::after {
  content: '';
  position: absolute;
  left: 20px;
  top: 50%;
  width: 6px;
  height: 2px;
  margin-top: 6px;
  background: var(--text-secondary);
  transform: rotate(45deg);
  transform-origin: left center;
  pointer-events: none;
}

.search-box input {
  width: 220px;
  padding: 7px 12px 7px 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
}

.search-box input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.search-results {
  padding-top: 4px;
}

.search-section {
  margin-bottom: 28px;
}

.search-section.empty {
  display: none;
}

.search-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.search-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 14px;
}

.header-btn {
  display: inline-block;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.public-header .header-btn {
  margin-top: 12px;
}

.header-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- Track list ---------- */
.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

:root {
  /* Every column except the title is a fixed px width, so this template
     computes to the exact same pixel widths in every independent grid
     instance (the header, plus each track row is its own grid) — a
     content-driven track (like minmax(_, auto)) would size differently
     per row and throw columns out of alignment. */
  --track-grid: 28px minmax(160px, 2.4fr) minmax(110px, 1.3fr) minmax(110px, 1.3fr) 110px 56px 96px;
}

.track-list-header {
  display: grid;
  grid-template-columns: var(--track-grid);
  align-items: center;
  gap: 14px;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.th-date, .th-duration {
  text-align: right;
}

.th-sort {
  cursor: pointer;
  user-select: none;
}

.th-sort:hover {
  color: var(--text);
}

.th-sort.sort-active {
  color: var(--text);
}

.th-sort.sort-active.sort-asc::after {
  content: ' \25B2';
  font-size: 9px;
}

.th-sort.sort-active.sort-desc::after {
  content: ' \25BC';
  font-size: 9px;
}

.track-row {
  display: grid;
  grid-template-columns: var(--track-grid);
  align-items: center;
  gap: 14px;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}

.track-row.album-row {
  display: flex;
}

.track-row:hover {
  background: var(--row-hover);
}

.track-row.playing {
  background: var(--row-playing);
}

.track-row.playing .track-title {
  color: var(--accent);
}

.track-num {
  width: 22px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 13px;
  flex-shrink: 0;
}

.track-art {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: var(--bg-elevated);
  flex-shrink: 0;
  object-fit: cover;
}

.track-info {
  flex: 1;
  min-width: 0;
  margin-left: 14px;
}

.track-title-cell {
  min-width: 0;
}

.track-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub-mobile {
  display: none;
}

.track-col {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-date {
  text-align: right;
}

.track-duration {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  text-align: right;
}

.track-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--row-hover);
  padding: 4px 8px;
  border-radius: 6px;
  z-index: 1;
}

.track-row:hover .track-actions {
  opacity: 1;
  pointer-events: auto;
}

.track-row.playing .track-actions {
  background: var(--row-playing);
}

.track-actions button {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.track-actions button:hover {
  color: var(--accent);
}

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

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 60px 20px;
  font-size: 14px;
}

/* ---------- Now playing bar ---------- */
.now-playing-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 76px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 220px 1fr 160px;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  z-index: 10;
}

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

.np-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-artist {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.np-btn {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
}

.np-btn svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  display: block;
}

.np-btn:hover {
  color: var(--text);
}

.np-btn-play {
  color: var(--text);
}

.np-btn-play svg {
  width: 38px;
  height: 38px;
}

.np-btn-small svg {
  width: 20px;
  height: 20px;
}

.np-btn-small {
  opacity: 0.45;
}

.np-btn-small.active {
  opacity: 1;
  color: var(--accent);
}

.np-btn-small.repeat-one {
  position: relative;
}

.np-btn-small.repeat-one::after {
  content: '1';
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.np-scrub {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  order: 3;
}

.np-time {
  font-size: 11px;
  color: var(--text-secondary);
  width: 36px;
}

.np-seek {
  flex: 1;
}

.np-volume {
  display: flex;
  justify-content: flex-end;
}

.np-vol-slider {
  width: 90px;
}

@media (max-width: 720px) {
  .now-playing-bar {
    grid-template-columns: 1fr auto;
    height: auto;
    padding: 10px 14px;
    row-gap: 6px;
  }
  .np-volume { display: none; }
  .np-scrub { order: 2; }
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-topbar button {
    font-size: 20px;
    line-height: 1;
  }

  .mobile-title {
    font-weight: 700;
    font-size: 15px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 260px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,0.35);
  }

  .sidebar-resizer {
    display: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .main {
    padding: 16px 16px 140px;
  }

  .main-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .main-header h1 {
    font-size: 20px;
  }

  .main-header-right {
    width: 100%;
  }

  .search-box {
    flex: 1;
  }

  .search-box input {
    width: 100%;
  }

  .track-list-header {
    display: none;
  }

  .track-row {
    grid-template-columns: 22px 1fr 44px auto;
    gap: 10px;
  }

  .track-col {
    display: none;
  }

  .track-sub-mobile {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .track-actions {
    opacity: 1;
    pointer-events: auto;
    background: none;
    padding: 0;
  }

  .track-actions > button {
    display: none;
  }

  .btn-more {
    display: inline-flex !important;
    font-size: 20px;
    line-height: 1;
    padding: 4px 10px;
    color: var(--text-secondary);
  }

  body.player-active .sidebar {
    padding-bottom: 16px;
  }
}

.modal-card {
  background: var(--bg-elevated);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 17px;
}

.add-songs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.add-songs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.add-songs-row:last-child {
  border-bottom: none;
}

.add-songs-row:hover {
  background: var(--row-hover);
}

.add-songs-row input {
  flex-shrink: 0;
}

.add-songs-row .track-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-songs-row .track-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.add-songs-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.action-sheet-buttons {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}

.action-sheet-buttons button {
  text-align: left;
  padding: 13px 12px;
  border-radius: 8px;
  font-size: 15px;
}

.action-sheet-buttons button:hover,
.action-sheet-buttons button:active {
  background: var(--row-hover);
}

.action-sheet-buttons button.danger {
  color: #ff3b30;
}

.btn-more {
  display: none;
}

.upload-progress {
  margin: 4px 0 2px;
}

.upload-progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

.upload-progress-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 132, 255, 0.15);
  border: 3px dashed var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay-text {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 20px 32px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
}

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

.modal-actions button {
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
}

.modal-cancel {
  background: var(--bg);
  border: 1px solid var(--border);
}

.modal-confirm {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- Public share page ---------- */
.public-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 140px;
}

.public-header {
  text-align: center;
  margin-bottom: 28px;
}

.public-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.public-header h1 {
  font-size: 26px;
  margin: 0 0 4px;
}

.public-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
}

.public-track-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.public-track-list .track-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.public-track-list .track-row:last-child {
  border-bottom: none;
}

.public-download-btn {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.public-download-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}
