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

:root {
  --bg: #0e0e12;
  --bg2: #16161d;
  --bg3: #1f1f29;
  --fg: #e8e6e3;
  --fg-dim: #8a8794;
  --accent: #c9a15a;
  --accent-dim: #7a6335;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 90px;
}

header {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg) 80%, transparent);
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
}

h1 {
  font-size: 18px; font-weight: 600; letter-spacing: 0.12em;
  color: var(--accent); margin-bottom: 10px;
}

#search {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--bg3); background: var(--bg2); color: var(--fg);
  font-size: 15px; outline: none;
}
#search:focus { border-color: var(--accent-dim); }

#chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.chip {
  padding: 4px 12px; border-radius: 999px; font-size: 13px;
  background: var(--bg2); color: var(--fg-dim);
  border: 1px solid var(--bg3); cursor: pointer;
}
.chip.on { background: var(--accent-dim); color: var(--fg); border-color: var(--accent-dim); }

#meta-line {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--fg-dim); font-size: 13px; padding: 4px 2px;
}
#shuffle-all {
  background: none; border: none; color: var(--accent); font-size: 13px; cursor: pointer;
}

#list { padding: 0 8px; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; border-radius: 10px; cursor: pointer;
}
.row:hover { background: var(--bg2); }
.row.playing { background: var(--bg3); }
.row img {
  width: 44px; height: 44px; border-radius: 6px; object-fit: cover;
  background: var(--bg3); flex-shrink: 0;
}
.row .t { flex: 1; min-width: 0; }
.row .t .title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.playing .title { color: var(--accent); }
.row .t .sub {
  font-size: 12.5px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .info-btn {
  background: none; border: none; color: var(--fg-dim);
  font-size: 17px; padding: 8px; cursor: pointer; flex-shrink: 0;
}
.row .info-btn:hover { color: var(--fg); }

/* detail panel */
#detail {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  background: var(--bg); padding: 20px 20px 120px;
}
#detail-close {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px;
  background: var(--bg3); color: var(--fg); border: none;
  width: 36px; height: 36px; border-radius: 50%; font-size: 15px; cursor: pointer;
}
#detail-cover {
  width: min(70vw, 320px); aspect-ratio: 1; object-fit: cover;
  border-radius: 12px; display: block; margin: 24px auto 18px;
  background: var(--bg3);
}
#detail-title { font-size: 20px; text-align: center; }
#detail-creator { text-align: center; color: var(--accent); margin: 4px 0 8px; }
#detail-tags {
  text-align: center; color: var(--fg-dim); font-size: 12.5px;
  max-width: 560px; margin: 0 auto 14px; font-style: italic;
}
#detail-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
#detail-actions button {
  padding: 8px 18px; border-radius: 999px; border: 1px solid var(--accent-dim);
  background: none; color: var(--accent); font-size: 14px; cursor: pointer;
}
#detail-play { background: var(--accent-dim); color: var(--fg); }
#detail-lyrics {
  white-space: pre-wrap; font: 14px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--fg); max-width: 640px; margin: 0 auto;
  border-top: 1px solid var(--bg3); padding-top: 18px;
}

/* player bar */
#player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--bg2); border-top: 1px solid var(--bg3);
  padding-bottom: env(safe-area-inset-bottom);
}
#progress { height: 3px; background: var(--bg3); cursor: pointer; }
#progress-fill { height: 100%; width: 0; background: var(--accent); }
#player-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
#p-cover { border-radius: 6px; object-fit: cover; background: var(--bg3); }
#p-info { flex: 1; min-width: 0; cursor: pointer; }
#p-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
#p-creator { font-size: 12px; color: var(--fg-dim); }
#p-time { font-size: 11.5px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
#player-row button {
  background: none; border: none; color: var(--fg); font-size: 22px;
  cursor: pointer; padding: 6px;
}
#p-play { font-size: 26px; color: var(--accent); }

/* --- phase 2 --- */
#title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#title-row h1 { margin-bottom: 0; }
#auth-area { display: flex; gap: 8px; align-items: center; font-size: 13px; }
#whoami { color: var(--accent); }
#auth-area button, #btn-upload {
  background: none; border: 1px solid var(--bg3); color: var(--fg-dim);
  padding: 4px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
#auth-area button:hover, #btn-upload:hover { color: var(--fg); border-color: var(--accent-dim); }
#btn-upload { color: var(--accent); border-color: var(--accent-dim); margin-right: 8px; }

.tab { background: none; border: none; color: var(--fg-dim); font-size: 13px; cursor: pointer; padding: 2px 8px; }
.tab.on { color: var(--accent); border-bottom: 1px solid var(--accent); }

.new-playlist {
  display: block; margin: 10px auto; padding: 8px 20px; border-radius: 999px;
  background: none; border: 1px dashed var(--accent-dim); color: var(--accent);
  font-size: 14px; cursor: pointer;
}

dialog {
  background: var(--bg2); color: var(--fg); border: 1px solid var(--bg3);
  border-radius: 14px; padding: 22px; width: min(92vw, 460px);
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h3 { margin-bottom: 14px; color: var(--accent); font-weight: 600; }
dialog label { display: block; font-size: 13px; color: var(--fg-dim); margin-bottom: 10px; }
dialog input[type="text"], dialog input:not([type]), dialog input[type="search"],
dialog textarea, dialog select, dialog input[type="file"] {
  width: 100%; margin-top: 3px; padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--bg3); background: var(--bg); color: var(--fg); font-size: 14px;
}
.dlg-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.dlg-row button {
  padding: 7px 18px; border-radius: 999px; border: 1px solid var(--bg3);
  background: none; color: var(--fg-dim); cursor: pointer; font-size: 14px;
}
.dlg-row button[type="submit"] { background: var(--accent-dim); color: var(--fg); border-color: var(--accent-dim); }
#upload-status { font-size: 13px; color: var(--accent); min-height: 18px; }

#detail-artist { text-align: center; color: var(--fg); font-size: 14px; margin-top: 2px; }
#detail-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0 20px; }
#detail-actions button {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--accent-dim);
  background: none; color: var(--accent); font-size: 13.5px; cursor: pointer;
}
#detail-actions button.primary { background: var(--accent-dim); color: var(--fg); }

#detail-auditions { max-width: 640px; margin: 0 auto 18px; }
#detail-auditions h4 { color: var(--accent); margin-bottom: 8px; font-weight: 600; }
.audition { border-left: 2px solid var(--accent-dim); padding: 6px 12px; margin-bottom: 12px; }
.a-by { font-size: 12px; color: var(--fg-dim); margin-bottom: 3px; }
.a-text { font-size: 14px; white-space: pre-wrap; }
.audition audio { width: 100%; margin-top: 6px; height: 32px; }

#stagewrap { position: fixed; inset: 0; z-index: 40; background: #000; }
#stage-host, #stage-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
#stage-close {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; z-index: 41;
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  width: 36px; height: 36px; border-radius: 50%; font-size: 15px; cursor: pointer;
}
#stagewrap ~ #player, #stagewrap:not([hidden]) ~ footer#player { z-index: 45; }

#karaoke {
  position: absolute; inset: 0; overflow-y: auto; padding: 40vh 24px;
  text-align: center; font-size: clamp(20px, 4vw, 34px); line-height: 1.9;
}
.k-line { margin-bottom: 6px; }
.k-word { color: #555; transition: color 0.15s; }
.k-word.on { color: var(--accent); text-shadow: 0 0 24px rgba(201,161,90,0.5); }
.k-word.on ~ .k-word { color: #3a3a44; }

#detail-meta {
  text-align: center; color: var(--fg-dim); font-size: 12.5px;
  margin: 2px 0 6px; font-variant-numeric: tabular-nums;
}

.cover-wrap { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.cover-wrap img { width: 100%; height: 100%; }
.cover-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); border: none; border-radius: 6px;
  color: #fff; font-size: 18px; cursor: pointer; opacity: 0; transition: opacity 0.12s;
}
.cover-wrap:hover .cover-play, .row.playing .cover-play { opacity: 1; }
@media (hover: none) { .cover-play { opacity: 1; background: rgba(0,0,0,0.25); } }

.a-text .a-h { display: block; color: var(--accent); margin: 10px 0 2px; }
.a-text hr { border: 0; border-top: 1px solid var(--bg3); margin: 8px 0; }

.fchip {
  background: none; border: 1px solid var(--bg3); color: var(--fg-dim);
  padding: 2px 10px; border-radius: 999px; font-size: 12px; cursor: pointer; margin-left: 6px;
}
.fchip.on { background: var(--accent-dim); color: var(--fg); border-color: var(--accent-dim); }
#sort-by {
  background: var(--bg2); border: 1px solid var(--bg3); color: var(--fg-dim);
  border-radius: 7px; font-size: 12px; padding: 2px 6px; margin-left: 6px;
}

details.audition summary {
  cursor: pointer; list-style: none; padding: 4px 0; font-size: 13px;
}
details.audition summary::before { content: "▸ "; color: var(--accent); }
details.audition[open] summary::before { content: "▾ "; }
details.audition .a-text { padding-top: 6px; }

#f-model {
  background: var(--bg2); border: 1px solid var(--bg3); color: var(--fg-dim);
  border-radius: 7px; font-size: 12px; padding: 2px 6px; margin-left: 6px; max-width: 180px;
}

#detail-model { text-align: center; margin: 4px 0 2px; }
#detail-model select.model-quick {
  background: var(--bg2); border: 1px solid var(--bg3); color: var(--accent);
  border-radius: 999px; font-size: 12.5px; padding: 3px 10px;
}
