:root {
  --bg: #14110f;
  --bg-2: #1c1815;
  --panel: #221d19;
  --panel-2: #2a241f;
  --line: #3a322b;
  --text: #f3ece4;
  --muted: #a99c8f;
  --dim: #75695e;
  --accent: #e8a547;
  --accent-2: #d9653b;
  --accent-ink: #1d1206;
  --good: #7fbf8a;
  --bad: #e2715f;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --player-h: 76px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #2b1f15 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(var(--player-h) + 24px);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1em; height: 1em; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 800; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 22px; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: rgba(20, 17, 15, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; font-family: Fraunces, serif; font-weight: 800; font-size: 22px; }
.brand svg { width: 30px; height: 30px; }
.brand span { color: var(--text); }
.tabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); padding: 4px; border-radius: 999px; }
.tabs button { border: 0; background: none; padding: 6px 16px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.status { margin-left: auto; font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status.ai::before, .status.off::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.status.ai::before { background: var(--good); }
.status.off::before { background: var(--accent); }

main { max-width: 1240px; margin: 0 auto; padding: 24px; position: relative; }
.view { display: none; }
.view.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

/* ---------- create */
.create-grid { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 20px; align-items: start; }
.composer { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 84px; }
.seg { display: inline-flex; align-self: flex-start; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 16px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.mode-simple, .mode-custom { display: flex; flex-direction: column; gap: 8px; }
.lbl { font-weight: 600; font-size: 13px; color: var(--muted); }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.opt { font-weight: 400; color: var(--dim); }
.hint { font-size: 12px; color: var(--dim); }
textarea, input[type="search"], #title {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; resize: vertical; outline: none; transition: border-color .15s;
}
textarea:focus, input:focus { border-color: var(--accent); }
textarea::placeholder, input::placeholder { color: var(--dim); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.chip:hover { color: var(--text); border-color: var(--dim); }

.switch { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 38px; height: 22px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; position: relative; transition: background .15s; }
.thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 8px 14px; font-weight: 600; }
.btn:hover { border-color: var(--dim); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border: 0; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: 13px; font-size: 16px; border-radius: 12px; }
.btn:disabled { opacity: .55; cursor: progress; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; }
.fineprint { margin: 0; font-size: 12px; color: var(--dim); text-align: center; }

/* ---------- song lists */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.list-head input { max-width: 320px; }
.songs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.song {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center;
  padding: 8px; border-radius: 12px; cursor: pointer; position: relative;
}
.song:hover, .song.selected { background: var(--panel-2); }
.song.playing .s-title { color: var(--accent); }
.cover { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; position: relative; flex: none; background: var(--bg-2); }
.cover img, .cover svg { width: 100%; height: 100%; display: block; }
.cover .ov { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); opacity: 0; transition: opacity .15s; color: #fff; font-size: 22px; border: 0; padding: 0; }
.song:hover .cover .ov, .song.playing .cover .ov { opacity: 1; }
.s-main { min-width: 0; }
.s-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-title .take { font-weight: 500; color: var(--dim); font-size: 12px; margin-left: 6px; }
.s-style { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-side { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; }
.badge { font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.icon { border: 0; background: none; width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted); font-size: 18px; padding: 0; }
.icon:hover { background: var(--panel-2); color: var(--text); }
.song.pending { cursor: default; }
.song.pending .cover { background: linear-gradient(110deg, var(--bg-2) 30%, var(--panel-2) 50%, var(--bg-2) 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.song.pending .s-style { color: var(--accent); }
.song.failed .s-style { color: var(--bad); }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { color: var(--dim); text-align: center; padding: 40px 10px; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.bars i { width: 3px; background: var(--accent); animation: eq 1s ease-in-out infinite; border-radius: 1px; }
.bars i:nth-child(2) { animation-delay: -.3s; } .bars i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- explore grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.card { background: none; border: 0; text-align: left; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.card .cover { width: 100%; height: auto; aspect-ratio: 1; border-radius: 12px; }
.card:hover .cover .ov { opacity: 1; }
.card .s-title { font-size: 14px; }

/* ---------- detail drawer */
.detail {
  position: fixed; top: 64px; right: 0; bottom: var(--player-h); width: min(420px, 100vw);
  background: var(--bg-2); border-left: 1px solid var(--line); padding: 24px; overflow-y: auto; z-index: 15;
  box-shadow: var(--shadow); animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.detail .close { position: absolute; top: 12px; right: 12px; }
.detail-cover { width: 180px; height: 180px; border-radius: 16px; overflow: hidden; margin-bottom: 16px; box-shadow: var(--shadow); }
.detail-cover svg { width: 100%; height: 100%; display: block; }
.d-style { color: var(--muted); margin: 4px 0 14px; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.d-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 20px; }
.d-facts div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.d-facts dt { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.d-facts dd { margin: 0; font-weight: 600; font-size: 13px; text-transform: capitalize; }
.lyrics { font-size: 16px; line-height: 1.7; }
.lyrics h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin: 18px 0 4px; font-weight: 600; }
.lyrics p { margin: 0; color: var(--muted); transition: color .15s; }
.lyrics p.now { color: var(--text); }
.lyrics p .w.sung { color: var(--accent); }
.lyrics .inst { color: var(--dim); font-style: italic; }

/* ---------- player */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--player-h); z-index: 30;
  display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(200px, 2fr) 120px; gap: 20px; align-items: center;
  padding: 0 20px; background: rgba(28, 24, 21, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.p-song { display: flex; gap: 12px; align-items: center; min-width: 0; }
.p-cover { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; flex: none; }
.p-cover svg { width: 100%; height: 100%; display: block; }
.p-meta { min-width: 0; }
.p-title { background: none; border: 0; padding: 0; font-weight: 600; text-align: left; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.p-title:hover { text-decoration: underline; }
.p-style { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-controls { display: flex; align-items: center; gap: 6px; }
.icon.play { width: 44px; height: 44px; background: var(--text); color: var(--bg); font-size: 20px; }
.icon.play:hover { background: #fff; color: var(--bg); }
.p-seek { display: flex; align-items: center; gap: 10px; min-width: 0; }
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.wave { flex: 1; height: 40px; cursor: pointer; position: relative; outline: none; border-radius: 6px; }
.wave:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.wave canvas { width: 100%; height: 100%; display: block; }
.p-extra input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- menu, modal, toast */
.menu { position: fixed; z-index: 50; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 210px; box-shadow: var(--shadow); }
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 8px; }
.menu button:hover, .menu button:focus-visible { background: var(--panel); outline: none; }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(440px, 100%); box-shadow: var(--shadow); }
.modal-card h3 { margin-bottom: 10px; font-size: 20px; }
.modal-card p { color: var(--muted); margin: 0 0 14px; }
.modal-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.toast { position: fixed; left: 50%; bottom: calc(var(--player-h) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 70;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; transition: .2s; max-width: min(520px, calc(100vw - 32px)); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive */
@media (max-width: 900px) {
  .create-grid { grid-template-columns: 1fr; }
  .composer { position: static; }
  .player { grid-template-columns: 1fr auto; grid-template-rows: auto auto; height: auto; padding: 10px 16px; gap: 6px 12px; }
  .p-seek { grid-column: 1 / -1; grid-row: 2; }
  .p-extra { display: none; }
  :root { --player-h: 112px; }
}
@media (max-width: 600px) {
  .top { gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
  .brand span { display: none; }
  .tabs button { padding: 6px 12px; }
  .status { font-size: 11px; }
  main { padding: 16px; }
  .panel { padding: 14px; }
  .song { grid-template-columns: 48px 1fr auto; gap: 10px; }
  .cover { width: 48px; height: 48px; }
  .detail { top: 0; z-index: 40; bottom: var(--player-h); }
  .d-facts { grid-template-columns: repeat(2, 1fr); }
  .p-controls #p-prev, .p-controls #p-next { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
