:root {
  --bg: #121212;
  --bg2: #1d1d1d;
  --bg3: #2a2a2a;
  --fg: #eaeaea;
  --fg2: #9a9a9a;
  --accent: #fa2d48;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

.hidden { display: none !important; }

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

input[type="text"], input[type="password"] {
  font: inherit;
  color: var(--fg);
  background: var(--bg3);
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
}

input:focus { border-color: var(--accent); }

/* ---------- login ---------- */

#login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 85vw);
}

#login-form h1 {
  text-align: center;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

#login-form button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  padding: 12px;
}

#login-error { color: #f55; font-size: 0.85rem; text-align: center; min-height: 1.2em; }

/* ---------- header ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #262626;
}

#brand { font-weight: 800; letter-spacing: 2px; }
.spacer { flex: 1; }
#whoami { color: var(--fg2); font-size: 0.85rem; }
header button { color: var(--fg2); font-size: 0.85rem; }
header button:hover { color: var(--fg); }

/* ---------- album grid ---------- */

.view { padding: 20px; padding-bottom: 120px; max-width: 1100px; margin: 0 auto; }

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

.album-card { cursor: pointer; }

.album-card .cover {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--bg3) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #555;
  transition: transform 0.15s;
}

.album-card:hover .cover { transform: scale(1.03); }

.album-card .name {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-card .artist {
  font-size: 0.8rem;
  color: var(--fg2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#albums .empty { color: var(--fg2); grid-column: 1/-1; text-align: center; padding: 60px 0; }

/* ---------- album detail (Apple Music style) ---------- */

#album { max-width: 640px; }

#album-top { display: flex; align-items: center; margin-bottom: 8px; }
#album-top button { color: var(--accent); font-size: 0.95rem; }

#album-hero { text-align: center; margin-bottom: 18px; }

#album-cover {
  width: min(64vw, 280px);
  aspect-ratio: 1;
  margin: 8px auto 18px;
  border-radius: 12px;
  background: var(--bg3) center/cover no-repeat;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: #555;
}

#album-title { font-size: 1.35rem; font-weight: 700; }
#album-artist { color: var(--accent); font-size: 1.05rem; margin-top: 2px; }

#album-meta-line {
  color: var(--fg2);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-top: 6px;
}

#album-actions { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }

#album-actions button {
  background: var(--bg3);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: 999px;
  padding: 11px 28px;
}

#album-actions #play-all { background: var(--accent); color: #fff; }

/* track list */

#tracks { list-style: none; border-top: 1px solid #2c2c2c; }

#tracks li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-bottom: 1px solid #2c2c2c;
  cursor: pointer;
}

#tracks li:hover { background: var(--bg2); }
#tracks li.playing .t-title { color: var(--accent); }

#tracks .num {
  width: 26px;
  text-align: center;
  color: var(--fg2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

#tracks .t-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { display: block; font-size: 0.75rem; color: var(--fg2); }
#tracks .t-dur { color: var(--fg2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* animated equalizer bars on the playing track */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq span { width: 3px; background: var(--accent); animation: eq 0.9s ease-in-out infinite; }
.eq span:nth-child(1) { animation-delay: 0s; }
.eq span:nth-child(2) { animation-delay: 0.25s; }
.eq span:nth-child(3) { animation-delay: 0.5s; }
.eq.paused span { animation-play-state: paused; height: 4px !important; }

@keyframes eq {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

#album-footer { color: var(--fg2); font-size: 0.85rem; padding: 14px 8px; }

/* ---------- player bar ---------- */

#player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(29, 29, 29, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid #2e2e2e;
  z-index: 20;
}

#p-cover {
  width: 52px; height: 52px;
  border-radius: 6px;
  background: var(--bg3) center/cover no-repeat;
  flex-shrink: 0;
}

#p-meta { width: 180px; flex-shrink: 0; overflow: hidden; }
#p-title { font-size: 0.9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#p-album { font-size: 0.78rem; color: var(--fg2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#p-center { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }

#p-buttons { display: flex; justify-content: center; gap: 18px; }
#p-buttons button { font-size: 1.1rem; color: var(--fg); }
#p-play { font-size: 1.4rem !important; }

#p-seek-row { display: flex; align-items: center; gap: 10px; font-size: 0.75rem; color: var(--fg2); font-variant-numeric: tabular-nums; }
#p-seek { flex: 1; }

input[type="range"] { accent-color: var(--accent); height: 4px; }
#p-vol { width: 90px; flex-shrink: 0; }

@media (max-width: 640px) {
  #p-meta { width: auto; flex: 1; }
  #p-vol { display: none; }
  #player { flex-wrap: wrap; }
  #p-center { width: 100%; flex-basis: 100%; }
}

/* ---------- dialogs ---------- */

dialog {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid #333;
  border-radius: 14px;
  padding: 22px;
  width: min(420px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

dialog h3 { margin-bottom: 4px; }

dialog form, .dlg-body { display: flex; flex-direction: column; gap: 10px; }

.dlg-hint { color: var(--fg2); font-size: 0.8rem; }
.dlg-error { color: #f55; font-size: 0.82rem; min-height: 1em; }

.row { display: flex; gap: 8px; }

.file-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--fg2);
}

.file-label input[type="file"] { font-size: 0.8rem; }

.check-label { font-size: 0.85rem; color: var(--fg2); display: flex; gap: 6px; align-items: center; }

.dlg-buttons { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 6px; }

.dlg-buttons .primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
  padding: 9px 18px;
}

.dlg-buttons .dlg-cancel { color: var(--fg2); }
.dlg-buttons .danger { color: #f55; font-size: 0.85rem; }

#up-progress {
  background: var(--bg3);
  border-radius: 6px;
  height: 18px;
  position: relative;
  overflow: hidden;
}

#up-bar { background: var(--accent); height: 100%; width: 0; transition: width 0.2s; }

#up-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: #fff;
}

/* edit dialog track list */

#ed-track-list { display: flex; flex-direction: column; max-height: 180px; overflow-y: auto; }

.ed-track {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.85rem;
  border-bottom: 1px solid #2c2c2c;
}

.ed-track .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-track button { color: #f55; font-size: 0.8rem; flex-shrink: 0; }

/* user list */

#user-list { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; }

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  font-size: 0.9rem;
  border-bottom: 1px solid #2c2c2c;
}

.user-row .u { flex: 1; }
.user-row .badge {
  font-size: 0.7rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
}
.user-row button { color: #f55; font-size: 0.8rem; }
