:root {
  --bg: #f6f1ea;
  --card: #fffaf4;
  --ink: #2a1f2d;
  --muted: #7a6e77;
  --line: #e7ddd1;
  --accent: #d9482b;
  --accent-2: #f2a341;
  --accent-soft: #fbe7dc;
  --warm: #f0b453;
  --cool: #8fb4c4;
  --radius: 20px;
  --display: "Fraunces", Georgia, serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
body[data-theme="rap"]    { --accent: #6a3fd6; --accent-2: #8a5cf0; --accent-soft: #ece4fd; }
body[data-theme="techno"] { --accent: #0e7f8c; --accent-2: #19b3a6; --accent-soft: #dcf3f1; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.5;
  transition: background .3s;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.top {
  max-width: 760px; margin: 0 auto; padding: 18px 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .01em; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand circle { fill: var(--accent); transition: fill .3s; }
.brand path { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; }
.account { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-width: 0; }
.account .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.account .dot { width: 8px; height: 8px; border-radius: 50%; background: #1db954; flex: none; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; }

.hero { padding: 34px 2px 22px; }
.hero h1 {
  font-family: var(--display); font-weight: 500; font-size: clamp(28px, 6.4vw, 44px);
  line-height: 1.08; letter-spacing: -.02em; margin: 0 0 12px; max-width: 16em; text-wrap: balance;
}
.hero p { margin: 0; color: var(--muted); max-width: 34em; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 18px; margin-bottom: 16px;
}
@media (min-width: 600px) { .card { padding: 26px 26px; } }
h2 { white-space: nowrap;
  font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0 0 18px;
  display: flex; align-items: center; gap: 10px; letter-spacing: -.01em;
}
.step {
  width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--card);
  font-family: var(--body); font-size: 13px; font-weight: 600; display: grid; place-items: center; flex: none;
}

.field { margin-bottom: 22px; }
.field.two { display: grid; gap: 20px; }
@media (min-width: 600px) { .field.two { grid-template-columns: 1fr 1fr; } }
.label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; display: block; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; }
.big { font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

.themes { display: grid; gap: 10px; }
@media (min-width: 600px) { .themes { grid-template-columns: repeat(3, 1fr); } }
.theme {
  text-align: left; border: 1.5px solid var(--line); background: transparent; border-radius: 16px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px; transition: border-color .2s, background .2s;
}
@media (min-width: 600px) { .theme { flex-direction: column; align-items: flex-start; padding: 14px; } }
.theme .sw { width: 38px; height: 38px; border-radius: 12px; flex: none; }
.theme b { display: block; font-weight: 600; }
.theme small { display: block; color: var(--muted); font-size: 13px; line-height: 1.3; }
.theme[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }

input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; margin: 4px 0 0; }
.ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 4px; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button { width: 46px; height: 44px; border: 0; background: transparent; font-size: 20px; }
.stepper button:active { background: var(--accent-soft); }
.stepper output { width: 34px; text-align: center; font-weight: 600; font-size: 18px; }

.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ink); outline-offset: 2px; }

.primary {
  width: 100%; border: 0; border-radius: 999px; padding: 15px 22px; font-weight: 600; font-size: 17px;
  background: var(--accent); color: #fff; transition: background .3s, transform .1s, opacity .2s;
}
.primary:active { transform: scale(.985); }
.primary:disabled { opacity: .55; cursor: default; }
.ghost { border: 1.5px solid var(--line); background: transparent; border-radius: 999px; padding: 9px 16px; font-weight: 500; font-size: 14px; white-space: nowrap; }
.ghost.spotify { border-color: var(--ink); background: var(--ink); color: var(--card); }
.link { border: 0; background: none; padding: 6px 0; color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.status { margin: 12px 0 0; font-size: 14px; color: var(--muted); min-height: 1.5em; text-align: center; }

.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.summary b { color: var(--ink); font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-right: 6px; }
.summary span { display: inline-flex; align-items: baseline; }

.curve svg { display: block; width: 100%; height: auto; }
.curve rect { transition: opacity .2s; }
.b-warm { fill: var(--warm); }
.b-main { fill: var(--accent-2); }
.b-boost { fill: var(--accent); }
.b-cool { fill: var(--cool); }
.phases { display: flex; gap: 4px; margin: 8px 0 18px; font-size: 12px; color: var(--muted); }
.phases div { min-width: 0; border-top: 2px solid var(--line); padding-top: 6px; }
.phases b { display: block; color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phases .p-warm { border-color: var(--warm); }
.phases .p-main { border-color: var(--accent-2); }
.phases .p-cool { border-color: var(--cool); }

.list { list-style: none; margin: 0; padding: 0; }
.list .group { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 0 6px; display: flex; justify-content: space-between; }
.list .group:first-child { padding-top: 0; }
.trk { display: grid; grid-template-columns: 22px 44px 1fr auto 36px 36px; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.trk .num { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.trk .art { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--accent-soft); display: block; }
.trk .meta { min-width: 0; }
.trk .t, .trk .a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trk .t { font-weight: 500; }
.trk .a { font-size: 13px; color: var(--muted); }
.trk .side { text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.35; }
.trk .side b { display: block; color: var(--ink); font-weight: 500; }
.badge { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: #fff; margin-left: 6px; vertical-align: 2px; }
.badge.fav { background: var(--ink); }
.icon { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font-size: 17px; display: grid; place-items: center; }
.icon:hover, .icon:active { background: var(--accent-soft); color: var(--ink); }
@media (max-width: 480px) {
  .trk { grid-template-columns: 40px 1fr auto 32px 32px; gap: 8px; }
  .trk .num { display: none; }
  .trk .art { width: 40px; height: 40px; }
  .icon { width: 32px; height: 32px; }
}

.finish { display: grid; gap: 18px; }
@media (min-width: 600px) { .finish { grid-template-columns: 200px 1fr; align-items: start; } }
#cover { width: 100%; max-width: 200px; height: auto; border-radius: 14px; box-shadow: 0 10px 30px rgba(42,31,45,.18); display: block; }
input[type="text"], input[type="search"] {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; outline: none;
}
input[type="text"]:focus, input[type="search"]:focus { border-color: var(--accent); }
.finish-form .primary { margin-top: 14px; }
.done { margin-top: 14px; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); }
.done a { color: var(--accent); font-weight: 600; }

#mine summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 2px; }
#mine summary::-webkit-details-marker { display: none; }
#mine summary span { font-family: var(--display); font-weight: 600; font-size: 20px; }
#mine summary span::after { content: "+"; float: right; font-family: var(--body); font-weight: 400; color: var(--muted); }
#mine details[open] summary span::after { content: "−"; }
#mine summary small { color: var(--muted); font-size: 14px; }
.mine-body { padding-top: 18px; }
.search { display: flex; gap: 8px; }
.results, .favlist { list-style: none; margin: 10px 0 0; padding: 0; }
.results li { padding: 10px 0; border-top: 1px solid var(--line); }
.results .r-top { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.results img, .results .art { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft); object-fit: cover; }
.results .t, .results .a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .a, .results .d { font-size: 13px; color: var(--muted); }
.roles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-left: 50px; }
.roles button { border: 1.5px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.roles button:active { background: var(--accent-soft); border-color: var(--accent); }
.favs h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.favlist li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; }
.favlist .tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); width: 92px; flex: none; }
.favlist .n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); font-size: 14px; margin: 10px 0 0; }

footer { max-width: 760px; margin: 0 auto; padding: 0 18px 40px; color: var(--muted); font-size: 12px; }
footer p { margin: 0; }

#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--card); padding: 12px 18px; border-radius: 14px;
  max-width: calc(100vw - 32px); font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 10;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.sources { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; }
.badge.pref { background: transparent; color: var(--accent); padding: 0; font-size: 13px; letter-spacing: 0; }
.results .more { text-align: center; }
