:root {
  --bg: #0d0b12;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #1d1730 0%, #0d0b12 62%);
  --surface: #16131f;
  --surface-2: #1e1a2b;
  --line: rgba(255, 255, 255, .09);
  --line-soft: rgba(255, 255, 255, .05);
  --text: #ece9f4;
  --muted: #948ca8;
  --dim: #6d6683;
  --gold: #f0b544;
  --gold-soft: rgba(240, 181, 68, .14);
  --violet: #a58bf5;
  --green: #52d18a;
  --red: #f2707a;
  --radius: 14px;
  --tabh: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  background-image: var(--bg-grad);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom, 0px) + 24px);
}

a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  padding: 18px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  color: var(--gold);
  font-size: 17px;
  animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .brand-mark { animation: none; } }
.brand-sub {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: .01em;
}

/* ---------- tabs ---------- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(15, 12, 22, .93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--tabh);
  color: var(--dim);
  font-size: 10.5px;
  letter-spacing: -.01em;
  border-top: 2px solid transparent;
  transition: color .15s;
}
.tab-ico { display: block; width: 19px; height: 19px; }
.tab-ico svg { width: 100%; height: 100%; display: block; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--gold); border-top-color: var(--gold); background: linear-gradient(180deg, var(--gold-soft), transparent 70%); }

/* ---------- layout ---------- */
main { padding: 14px 14px 0; max-width: 900px; margin: 0 auto; }
.view { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.section-head { margin: 2px 0 12px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.section-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

/* ---------- controls ---------- */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
}
.chip b { font-weight: 700; color: var(--text); }
.chip .n { font-size: 11px; color: var(--dim); margin-left: 5px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--gold-soft); border-color: rgba(240, 181, 68, .5); color: var(--gold); }
.chip.on b, .chip.on .n { color: var(--gold); }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

input[type=search], select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input[type=search]:focus, select:focus { border-color: rgba(240, 181, 68, .5); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23948ca8' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field-label { font-size: 11px; color: var(--dim); margin: 0 0 5px; letter-spacing: .02em; }

/* ---------- song list ---------- */
.count-line { font-size: 12px; color: var(--dim); margin: 10px 2px; font-variant-numeric: tabular-nums; }
.count-line b { color: var(--gold); font-weight: 700; }

.songs { list-style: none; margin: 0; padding: 0; }
.song {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background .12s;
}
.song:active { background: var(--surface-2); }
.song + .song { border-top: 1px solid var(--line-soft); border-radius: 12px; }
.song-rank {
  flex: 0 0 26px;
  text-align: right;
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.thumb {
  flex: 0 0 62px;
  width: 62px;
  height: 46px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
}
.song-body { min-width: 0; flex: 1 1 auto; }
.thumb.dead { opacity: .3; }
.song-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.song-meta {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-meta .date { color: var(--muted); font-variant-numeric: tabular-nums; }
.song-meta .sep { opacity: .45; margin: 0 5px; }
.pill {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: 1px;
}
.play { flex: 0 0 auto; color: var(--dim); font-size: 16px; padding: 4px; }

.more {
  display: block;
  width: 100%;
  margin: 12px 0 4px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.empty { text-align: center; color: var(--dim); font-size: 13px; padding: 30px 10px; }

/* ---------- chronicle ---------- */
.months { display: flex; flex-direction: column; gap: 2px; }
.month {
  display: grid;
  grid-template-columns: 62px 1fr 34px;
  gap: 9px;
  align-items: center;
  padding: 6px 4px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid transparent;
}
.month.on { background: var(--surface-2); border-color: var(--line); }
.month-label { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.month.on .month-label { color: var(--gold); font-weight: 700; }
.bar-track { display: block; height: 15px; background: rgba(255, 255, 255, .04); border-radius: 5px; overflow: hidden; }
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, rgba(240, 181, 68, .85), rgba(165, 139, 245, .8));
  min-width: 3px;
  transition: filter .15s;
}
.month.on .bar-fill { filter: brightness(1.25); }
.month-n { font-size: 12px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.month.on .month-n { color: var(--text); font-weight: 700; }

/* ---------- artists ---------- */
.rank-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.rank-row:last-child { border-bottom: 0; }
.rank-no { font-size: 12px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.rank-row.top .rank-no { color: var(--gold); font-weight: 700; }
.rank-name { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { display: block; height: 4px; margin-top: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--gold), var(--violet)); }
.rank-n { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-n span { color: var(--dim); font-size: 11px; }

/* ---------- diff ---------- */
.diff-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 9px;
  text-align: center;
}
.stat-n { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-l { font-size: 10.5px; color: var(--dim); margin-top: 2px; }
.stat.added .stat-n { color: var(--green); }
.stat.removed .stat-n { color: var(--red); }
.stat.kept .stat-n { color: var(--muted); }

.diff-head { display: flex; align-items: center; gap: 7px; margin: 16px 2px 6px; font-size: 13px; font-weight: 700; }
.diff-head .dot { width: 7px; height: 7px; border-radius: 50%; }
.diff-head.added .dot { background: var(--green); }
.diff-head.removed .dot { background: var(--red); }
.diff-head .c { color: var(--dim); font-weight: 500; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.song.added { border-left: 2px solid rgba(82, 209, 138, .55); }
.song.removed { border-left: 2px solid rgba(242, 112, 122, .5); }
.song.removed .thumb, .song.removed .song-title { opacity: .62; }

.arrow-row { display: grid; grid-template-columns: 1fr 22px 1fr; gap: 7px; align-items: end; }
.arrow { text-align: center; color: var(--dim); padding-bottom: 11px; font-size: 14px; }

/* ---------- elo ---------- */
.elo-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.elo-row:last-child { border-bottom: 0; }
.elo-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  border: 1px solid transparent;
}
.elo-row.medal .elo-rank {
  color: var(--gold);
  font-weight: 700;
  background: var(--gold-soft);
  border-color: rgba(240, 181, 68, .45);
}
.elo-name { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.elo-sub { display: block; font-size: 11px; color: var(--dim); margin-top: 3px; }
.elo-rating { text-align: right; }
.elo-rating b { font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.elo-row.medal .elo-rating b { color: var(--gold); }
.elo-rating span { display: block; font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

.note {
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 2px solid rgba(165, 139, 245, .45);
  border-radius: 0 10px 10px 0;
  padding: 10px 12px;
  margin: 12px 0;
}

/* ---------- misc ---------- */
.loading { text-align: center; padding: 70px 20px; color: var(--dim); font-size: 13px; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 14px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.foot {
  max-width: 900px;
  margin: 26px auto 0;
  padding: 16px 16px 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--dim);
  line-height: 1.7;
}

@media (min-width: 720px) {
  body { padding-bottom: 30px; }
  .tabs {
    position: sticky;
    top: 0;
    bottom: auto;
    max-width: 900px;
    margin: 12px auto 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0;
  }
  .tab { height: 52px; font-size: 12px; flex-direction: row; gap: 7px; border-top: 0; border-bottom: 2px solid transparent; }
  .tab.on { border-bottom-color: var(--gold); }
  .topbar { padding: 24px 16px 4px; }
  .brand { font-size: 22px; }
  main { padding-top: 18px; }
  .song-title { font-size: 14px; }
}
