:root {
  --primary:  #5468ff;
  --danger:   #ef4444;
  --bg:       #f4f6fb;
  --card:     #ffffff;
  --text:     #1a1a2e;
  --muted:    #6b7280;
  --border:   #e5e7eb;
  --nav-bg:   #1a1a2e;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── NAVBAR ─────────────────────────────────────────────────── */
.navbar {
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.navbar-brand { color: white; font-size: 1rem; font-weight: 600; margin-right: auto; letter-spacing: -0.2px; }
.nav-btn {
  color: rgba(255,255,255,0.6);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: color 0.15s, background 0.15s;
}
.nav-btn:hover   { color: white; background: #2a2a46; }
.nav-btn.active  { color: white; background: #32325a; }
.nav-btn.logout  { color: rgba(255,255,255,0.35); font-size: 0.8rem; margin-left: 0.5rem; }

/* ── PAGES ──────────────────────────────────────────────────── */
.page        { display: none; padding: 1.75rem 2rem; max-width: 1200px; margin: 0 auto; }
.page.active { display: block; }

/* ── CARD ───────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: 10px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; color: var(--text); }

/* ── TABLE ──────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbff; }
audio { height: 30px; max-width: 200px; vertical-align: middle; }
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; display: block; }
.thumb-placeholder {
  width: 44px; height: 44px; border-radius: 6px;
  background: var(--bg); display: flex;
  align-items: center; justify-content: center;
  font-size: 18px; border: 1px solid var(--border);
}
.muted  { color: var(--muted); }
.badge  { background: #ede9fe; color: #7c3aed; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.empty-cell { text-align: center; color: var(--muted); padding: 2.5rem 0 !important; font-size: 0.9rem; }
.error  { color: var(--danger) !important; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.82rem; font-weight: 500; margin-bottom: 0.35rem; }

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  background: white;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(84,104,255,0.12);
}
input[type="file"] {
  padding: 0.4rem 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  background: white;
}
textarea { resize: vertical; min-height: 80px; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { padding: 0.55rem 1.1rem; border: none; border-radius: 6px; cursor: pointer; font-size: 0.875rem; font-weight: 500; transition: opacity 0.15s, background 0.15s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled)  { background: #4357e8; }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled)   { background: #dc2626; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #eaedf5; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }

/* ── STATUS TEXT ─────────────────────────────────────────────── */
.status-ok  { color: #059669; font-size: 0.875rem; }
.status-err { color: var(--danger); font-size: 0.875rem; }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── TRACK SELECTOR ──────────────────────────────────────────── */
.track-selector {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem;
  background: white;
}
.track-selector label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  font-weight: normal;
  transition: background 0.1s;
}
.track-selector label:hover { background: var(--bg); }
.track-selector input[type="checkbox"] { width: auto; margin-top: 3px; flex-shrink: 0; }
.track-selector em { color: var(--muted); }

/* ── LOGIN OVERLAY ───────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-card {
  background: white;
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.login-card h2  { text-align: center; margin-bottom: 0.4rem; font-size: 1.3rem; }
.login-card .subtitle { color: var(--muted); text-align: center; margin-bottom: 1.5rem; font-size: 0.875rem; }

/* ── TOAST ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  color: white;
  font-size: 0.875rem;
  z-index: 9999;
  pointer-events: none;
  animation: slideUp 0.25s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
.toast-success { background: #059669; }
.toast-error   { background: var(--danger); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HOME FEED ───────────────────────────────────────────────── */
.home-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.home-feed-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.home-section     { margin-bottom: 1.25rem; }
.home-section-sub { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.home-loading     { font-size: 0.875rem; }

.category-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 28px; }
.category-chip  {
  background: #ede9fe;
  color: #7c3aed;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1rem;
}
.media-card { background: var(--bg); border-radius: 8px; overflow: hidden; }
.media-card-cover-wrap {
  position: relative;
  overflow: hidden;
  display: block;
}
.media-play-overlay {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(0,0,0,0.22);
  color: white;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.18s, background 0.18s;
  width: 100%;
  line-height: 1;
}
.media-card-cover-wrap:hover .media-play-overlay { opacity: 1; }
.media-play-overlay.playing                       { opacity: 1; background: rgba(84,104,255,0.5); }
.media-card-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}
.media-card-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ede9fe, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.media-card-body   { padding: 0.55rem 0.65rem 0.65rem; }
.media-card-title  { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card-artist { font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.media-card-meta   { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4rem; }
.media-card-dur    { font-size: 0.72rem; color: var(--muted); }
