:root {
  --bg: #fbf7ef;
  --surface: #fff;
  --surface-2: #fffaf1;
  --line: rgba(18,25,49,.11);
  --text: #101526;
  --muted: #697085;
  --navy: #121931;
  --navy-2: #202a4d;
  --gold: #d79a2d;
  --gold-soft: rgba(215,154,45,.14);
  --green: #15845a;
  --green-soft: rgba(21,132,90,.12);
  --danger: #b83232;
  --shadow: 0 20px 70px rgba(18,25,49,.10);
  --radius: 26px;
  --max: 1200px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(215,154,45,.22), transparent 32rem),
    radial-gradient(circle at 95% 8%, rgba(117,87,246,.14), transparent 34rem),
    linear-gradient(180deg, var(--bg), #fff 78%);
}

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

.app {
  width: min(var(--max), calc(100% - 28px));
  margin: 0 auto;
  padding-bottom: 56px;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 50;
  margin: 18px 0 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 34px rgba(18,25,49,.08);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  width: 184px;
  height: 48px;
  overflow: hidden;
  display: flex;
  align-items: center;
  border-radius: 999px;
}

.brand img {
  width: 205px;
  height: 58px;
  object-fit: contain;
  object-position: left center;
  mix-blend-mode: multiply;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-weight: 850;
}

.playlist-btn {
  border: 0;
  display: inline-flex;
  gap: 9px;
  align-items: center;
  border-radius: 999px;
  padding: 11px 15px;
  color: white;
  background: var(--navy);
  font-weight: 950;
}

.playlist-btn span {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 7px;
  background: var(--gold);
  color: var(--navy);
  font-size: .82rem;
}

.hero {
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  gap: 28px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow, .kicker {
  margin: 0 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #956217;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  font-weight: 950;
}

.eyebrow span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 8px rgba(215,154,45,.15);
}

.kicker { margin: 0; font-size: .7rem; }

.hero h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(3rem, 6.4vw, 5.7rem);
  line-height: .9;
  letter-spacing: -.075em;
}

.hero p, .section-head p, .selected p, .hint {
  color: var(--muted);
  line-height: 1.65;
}

.seed-card, .section, .selected, .analysis {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.seed-card, .section {
  padding: 18px;
  margin-top: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  border-radius: 999px;
  background: #f3eee4;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  border: 0;
  border-radius: 999px;
  min-height: 40px;
  color: var(--muted);
  background: transparent;
  font-weight: 950;
}

.tab.active {
  color: white;
  background: var(--navy);
}

.hidden { display: none !important; }

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 950;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input[type="search"], input[type="text"], .file-input, .filters input, .settings input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 0 15px;
  color: var(--text);
  outline: none;
  font-weight: 650;
}

.file-input {
  padding: 14px;
  height: auto;
}

input:focus {
  border-color: rgba(215,154,45,.65);
  box-shadow: 0 0 0 5px rgba(215,154,45,.12);
}

.upload-fields {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.btn {
  min-height: 45px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-weight: 950;
}

.btn.primary { color: white; background: linear-gradient(135deg, var(--navy), var(--navy-2)); }
.btn.secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.btn.danger { color: var(--danger); background: rgba(184,50,50,.09); border-color: rgba(184,50,50,.12); }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.full { width: 100%; }

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-row button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 9px 12px;
  font-weight: 850;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

.section-head h2, .selected h2, .drawer h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  letter-spacing: -.04em;
}

.count {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(117,87,246,.12);
  color: #7557f6;
  font-weight: 950;
}

.list {
  display: grid;
  gap: 10px;
}

.search-row {
  display: grid;
  grid-template-columns: 56px minmax(0,1fr) 160px 110px;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 11px;
}

.cover {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--gold), #7557f6);
}

.title {
  margin: 0;
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview audio {
  width: 100%;
  max-width: 160px;
  height: 32px;
}

.no-preview {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 850;
}

.row-btn {
  border: 0;
  border-radius: 999px;
  min-height: 38px;
  padding: 0 13px;
  color: white;
  background: var(--navy);
  font-weight: 950;
}

.empty-box {
  min-height: 170px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255,250,241,.6);
  padding: 22px;
}

.empty-box.in-table {
  min-height: 180px;
  border: 0;
}

.empty-box.small { min-height: 150px; }

.empty-box h3 { margin: 10px 0 4px; }
.empty-box p { max-width: 380px; margin: 0; color: var(--muted); line-height: 1.55; }

.empty-icon, .avatar {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: var(--gold);
  background: var(--gold-soft);
  font-size: 1.3rem;
  font-weight: 950;
}

.selected {
  display: grid;
  grid-template-columns: 58px minmax(0,1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-top: 18px;
}

.selected.empty { grid-template-columns: 58px minmax(0,1fr); }

.selected-preview {
  margin-top: 10px;
}

.selected-preview audio {
  width: min(100%, 360px);
  height: 34px;
}

.analysis {
  padding: 14px;
  margin-top: 12px;
  background: #fffdf8;
}

.analysis-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.analysis-top span, .analysis p {
  color: var(--muted);
  font-size: .88rem;
}

.bar {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(18,25,49,.08);
  margin-top: 10px;
}

.bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #7557f6);
  transition: width .25s ease;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filters input {
  width: 190px;
  min-height: 40px;
  border-radius: 999px;
}

.filter {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 900;
}

.filter.active {
  color: white;
  background: var(--navy);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.match-table {
  min-width: 930px;
}

.table-head, .match-row {
  display: grid;
  grid-template-columns: 78px minmax(230px,1fr) minmax(190px,.8fr) minmax(220px,.9fr) minmax(170px,.7fr) 100px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}

.table-head {
  color: var(--muted);
  background: #faf7f0;
  border-bottom: 1px solid var(--line);
  font-size: .78rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.match-row {
  border-bottom: 1px solid var(--line);
}

.match-row:last-child { border-bottom: 0; }

.score {
  width: 58px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #875911;
  background: var(--gold-soft);
  font-weight: 950;
}

.score.audio {
  color: var(--green);
  background: var(--green-soft);
}

.track-cell {
  display: grid;
  grid-template-columns: 52px minmax(0,1fr);
  gap: 11px;
  align-items: center;
  min-width: 0;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border-radius: 999px;
  padding: 6px 8px;
  color: var(--muted);
  background: rgba(18,25,49,.055);
  font-size: .78rem;
  font-weight: 830;
}

.chip.green {
  color: var(--green);
  background: var(--green-soft);
}

.drawer {
  position: fixed;
  z-index: 90;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100vh;
  padding: 20px;
  background: var(--surface);
  box-shadow: -24px 0 90px rgba(18,25,49,.22);
  transform: translateX(105%);
  transition: transform .22s ease;
}

.drawer.open { transform: translateX(0); }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(18,25,49,.46);
  backdrop-filter: blur(4px);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--danger);
  background: rgba(184,50,50,.09);
  font-size: 1.2rem;
  font-weight: 950;
}

.playlist-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  margin-top: 16px;
}

.playlist-item {
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) 34px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: var(--surface);
}

.playlist-preview {
  grid-column: 1 / -1;
}

.playlist-preview audio {
  width: 100%;
  height: 32px;
}

.drawer-actions {
  display: grid;
  gap: 9px;
  margin-top: 15px;
}

.settings-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 60;
  border: 1px solid var(--line);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255,255,255,.68);
  color: var(--muted);
  opacity: .22;
}

.settings-btn:hover { opacity: 1; }

.settings {
  border: 0;
  border-radius: 24px;
  width: min(520px, calc(100% - 28px));
  box-shadow: 0 30px 90px rgba(18,25,49,.28);
}

.settings form { padding: 22px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translateX(-50%) translateY(120px);
  border-radius: 999px;
  padding: 12px 16px;
  color: white;
  background: var(--navy);
  box-shadow: 0 18px 45px rgba(18,25,49,.22);
  font-weight: 850;
  transition: transform .22s ease;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.skeleton {
  position: relative;
  overflow: hidden;
  color: transparent !important;
  background: #eee8dd !important;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer { 100% { transform: translateX(100%); } }

@media (max-width: 900px) {
  .app { width: min(100% - 20px, var(--max)); }
  .topbar { top: 8px; margin-bottom: 34px; border-radius: 24px; }
  .brand { width: 146px; }
  .brand img { width: 168px; }
  .topnav a { display: none; }

  .hero { grid-template-columns: 1fr; }
  .hero h1 { font-size: 3rem; }
  .input-row { grid-template-columns: 1fr; }

  .section-head.stack-on-mobile, .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters { width: 100%; justify-content: flex-start; }
  .filters input { width: 100%; }
  .filter { flex: 1; }

  .search-row {
    grid-template-columns: 56px minmax(0,1fr);
  }

  .search-row .preview, .search-row .row-btn {
    grid-column: 1 / -1;
  }

  .match-table { min-width: 0; }
  .table-head { display: none; }

  .match-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .match-row::before {
    content: attr(data-label);
    color: #956217;
    font-size: .72rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .1em;
  }

  .preview audio { max-width: none; }

  .selected {
    grid-template-columns: 54px minmax(0,1fr);
  }

  .selected .btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .hero h1 { font-size: 2.55rem; }
  .seed-card, .section { border-radius: 22px; padding: 15px; }
}
