:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #ecedf0;
  --line-strong: #e3e5e9;
  --text: #1b1d21;
  --muted: #8b929c;
  --muted-2: #6b7280;
  --gold: #f5a623;
  --gold-hi: #f6b340;
  --gold-ink: #4a3100;
  --green: #1db954;
  --green-hi: #21d662;
  --red: #e0314b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 28px rgba(16, 24, 40, 0.06);
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ===================== PAGE + INPUT (top) ===================== */
.page {
  max-width: 960px; margin: 0 auto; padding: 0 20px 60px;
  background:
    radial-gradient(900px 360px at 50% -120px, rgba(29, 185, 84, 0.10), transparent 70%);
}
.top { text-align: center; padding: 28px 0 4px; }
.logo {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 600; color: var(--muted-2); letter-spacing: 0.01em;
  margin-bottom: 22px;
}
.logo-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(29,185,84,.15); }
.top h1 { font-size: clamp(26px, 4.4vw, 40px); line-height: 1.08; letter-spacing: -0.02em; font-weight: 700; }
.lede { color: var(--muted-2); margin: 16px auto 0; max-width: 480px; line-height: 1.6; }
/* mode toggle */
.mode-tabs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 26px auto 0; }
.mtab {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--muted-2);
  font-family: inherit; font-weight: 600; font-size: 13.5px;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mtab:hover { background: #f6f7f9; }
.mtab.active { background: #e7f8ee; color: var(--green); border-color: #bfe9cf; }

/* input pill */
.entry {
  margin: 16px auto 0; max-width: 740px;
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 7px 7px 7px 10px; box-shadow: var(--shadow);
}
.entry:focus-within { border-color: var(--green); box-shadow: 0 0 0 4px rgba(29,185,84,.12); }
#url {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 15px; line-height: 1.4; color: var(--text);
  padding: 12px 6px 12px 12px; resize: none; max-height: 140px; overflow-y: auto;
}
#url::placeholder { color: #aab0ba; }
.paste-btn {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.paste-btn svg { width: 19px; height: 19px; }
.paste-btn:hover { background: #f1f3f5; color: var(--text); }
.paste-btn.is-clear:hover { color: var(--red); }
.paste-btn.ok { color: var(--green); }
.btn-green.big { flex-shrink: 0; height: 50px; padding: 0 24px; border-radius: 999px; font-size: 15px; }
.btn-green.big .ico { width: 18px; height: 18px; }
.supports { margin: 16px auto 0; font-size: 13px; color: var(--muted); }
.landing-hint { margin-top: 12px; min-height: 20px; font-size: 13.5px; color: var(--muted-2); }
.landing-hint.error { color: var(--red); }

/* search sub-tabs */
.subtabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 16px auto 0; }
.subtab {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--muted-2);
  font-family: inherit; font-weight: 600; font-size: 13px;
  padding: 7px 16px; border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.subtab:hover { background: #f6f7f9; }
.subtab.active { background: var(--green); color: #fff; border-color: var(--green); }

/* search results — Spotify-style card grid */
.search-results {
  margin-top: 24px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px;
}
.scard {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s, background .15s, transform .06s;
}
.scard:hover { background: #fafbfc; border-color: var(--green); }
.scard:active { transform: scale(.99); }
.scard-art {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 8px;
  overflow: hidden; background: #eceef1; margin-bottom: 10px;
}
.scard.artist .scard-art { border-radius: 50%; }
.scard-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.copybtn {
  position: absolute; bottom: 8px; right: 8px; width: 38px; height: 38px;
  border-radius: 50%; border: none; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 0; transform: translateY(8px); box-shadow: 0 6px 16px rgba(0,0,0,.22);
  transition: opacity .15s, transform .15s, background .15s;
}
.copybtn svg { width: 17px; height: 17px; }
.scard:hover .copybtn { opacity: 1; transform: none; }
.copybtn:hover { background: var(--green-hi); }
.copybtn.copied { background: var(--green); }
.scard-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard-sub { color: var(--muted-2); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 22px; font-size: 14px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: #14171c; color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 11px 18px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; z-index: 50; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===================== RESULT ===================== */
.result { margin-top: 30px; }

.hero-card {
  position: relative;
  display: flex; gap: 22px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.hero-cover { flex-shrink: 0; }
.hero-cover img {
  width: 168px; height: 168px; object-fit: cover; border-radius: 12px;
  background: #eceef1; display: block;
}
.hero-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hero-kind { font-size: 12px; color: var(--muted-2); font-weight: 600; }
.hero-body h2 { font-size: clamp(24px, 3.4vw, 36px); line-height: 1.1; letter-spacing: -0.02em; margin: 3px 0 6px; }
.hero-desc { color: var(--muted-2); font-size: 14px; line-height: 1.5; max-width: 540px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted-2); font-size: 13.5px; font-weight: 500; flex-wrap: wrap; }
.sp-badge { display: inline-flex; align-items: center; gap: 7px; color: var(--text); }
.sp-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--green); }
.dotsep { color: #c7ccd4; }
.hero-actions { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 16px; flex-wrap: wrap; }
.btn-green {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; cursor: pointer; font-weight: 600; font-size: 14px;
  background: var(--green); color: #fff;
  padding: 0 18px; height: 44px; border-radius: 10px;
  transition: background .15s, transform .06s;
}
.btn-green:hover { background: var(--green-hi); }
.btn-green:active { transform: scale(.98); }
.btn-green:disabled { opacity: .6; cursor: progress; }
.btn-green .ico { width: 17px; height: 17px; }
.qpick {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted-2);
  border: 1px solid var(--line-strong); border-radius: 10px; height: 44px; padding: 0 6px 0 14px;
}
.qpick select {
  border: none; outline: none; background: transparent; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; height: 100%;
}
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
  font-weight: 600; font-size: 14px; padding: 0 16px; height: 44px; border-radius: 10px;
  cursor: pointer; transition: background .15s;
}
.btn-ghost:hover { background: #f6f7f9; }
.all-progress { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 160px; }
.bar { flex: 1; height: 7px; background: #eceef1; border-radius: 99px; overflow: hidden; max-width: 280px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--green-hi)); border-radius: 99px; transition: width .4s ease; }
.all-count { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted-2); white-space: nowrap; }
.hero-close {
  position: absolute; top: 16px; right: 16px; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--line-strong); background: var(--card);
  color: var(--muted-2); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.hero-close svg { width: 16px; height: 16px; }
.hero-close:hover { background: #f6f7f9; color: var(--text); }

/* toolbar */
.toolbar { display: flex; gap: 12px; margin: 18px 0 8px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 0 14px; height: 46px; box-shadow: var(--shadow);
}
.search .ico { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
#search { flex: 1; border: none; outline: none; background: transparent; font-size: 14.5px; color: var(--text); }
.sort {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 0 12px; height: 46px; box-shadow: var(--shadow); color: var(--muted-2);
}
.sort .ico { width: 17px; height: 17px; }
#sort { border: none; outline: none; background: transparent; font-family: inherit; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }

/* table */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.thead, .row {
  display: grid;
  grid-template-columns: 46px minmax(200px, 1fr) minmax(110px, 0.7fr) 90px 100px 210px;
  align-items: center; gap: 12px;
}
.thead { padding: 14px 20px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.thead .num { text-align: left; }
.thead .acts-head { text-align: center; }
.tbody { max-height: 70vh; overflow-y: auto; }
.row { padding: 10px 20px; border-bottom: 1px solid var(--line); transition: background .12s; }
.row:last-child { border-bottom: none; }
.row:hover { background: #fafbfc; }
.c-num { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.c-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-title img { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: #eceef1; flex-shrink: 0; }
.t-meta { min-width: 0; }
.t-name { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.t-name .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp { flex-shrink: 0; background: #c2c7cf; color: #fff; font-size: 9px; font-weight: 700; line-height: 1; padding: 3px 4px; border-radius: 3px; }
.t-artist { color: var(--muted-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-album { color: var(--muted-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-dur { color: var(--muted-2); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.c-pop { font-size: 13px; color: var(--muted-2); }
.pop-bar { height: 6px; width: 72px; background: #eceef1; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.pop-fill { height: 100%; background: var(--green); border-radius: 99px; }

.c-act { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.act {
  width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--muted-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  text-decoration: none; transition: background .12s, color .12s, border-color .12s;
}
.act svg { width: 16px; height: 16px; }
.act:hover { background: #f6f7f9; color: var(--text); }
.act.dl { background: var(--green); border-color: var(--green); color: #fff; }
.act.dl:hover { background: var(--green-hi); }
.act.dl.done { background: var(--green); border-color: var(--green); color: #fff; }
.act.err { background: var(--red); border-color: var(--red); color: #fff; }
.act.disabled { opacity: .4; pointer-events: none; }
.act.playing { background: var(--green); border-color: var(--green); color: #fff; }

/* per-row download progress (replaces the action buttons while downloading) */
.c-act .dlbar {
  flex: 1; height: 7px; min-width: 56px; background: #eceef1;
  border-radius: 99px; overflow: hidden;
}
.c-act .dlbar-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--green), var(--green-hi));
  transition: width .25s ease;
}
.dlpct {
  font-size: 12px; font-weight: 600; color: var(--muted-2);
  min-width: 68px; text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.c-act.ok .dlpct { color: var(--green); }
.dlpct.bad { flex: 1; min-width: 0; color: var(--red); overflow: hidden; text-overflow: ellipsis; }

/* per-row quality selector */
.qsel {
  height: 34px; border-radius: 9px; padding: 0 6px;
  border: 1px solid var(--line-strong); background: var(--card);
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted-2);
  cursor: pointer; outline: none; flex-shrink: 0;
}
.qsel:hover { color: var(--text); }
.qsel:focus { border-color: var(--green); }

.spinner { width: 15px; height: 15px; border: 2px solid rgba(0,0,0,.18); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }
.foot { text-align: center; color: #aab0ba; font-size: 12.5px; margin-top: 22px; }

/* tablet */
@media (max-width: 820px) {
  .hero-cover img { width: 132px; height: 132px; }
  .search-results { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* phone */
@media (max-width: 640px) {
  .page { padding: 0 12px 48px; }
  .top { padding: 34px 0 4px; }
  .top h1 { font-size: clamp(21px, 6.4vw, 30px); }
  .lede { font-size: 14px; }

  /* input pill */
  .entry { gap: 2px; padding: 6px 6px 6px 8px; }
  #url { font-size: 14px; padding: 11px 4px 11px 8px; }
  .btn-green.big { height: 46px; padding: 0 15px; font-size: 14px; }
  .paste-btn { width: 38px; height: 38px; }

  /* tabs */
  .mtab { font-size: 12.5px; padding: 9px 14px; }
  .subtab { font-size: 12.5px; padding: 7px 14px; }

  /* hero card stacks vertically */
  .hero-card { flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 16px; }
  .hero-cover img { width: 150px; height: 150px; }
  .hero-body { align-items: center; }
  .hero-desc { max-width: 100%; }
  .hero-meta, .hero-actions { justify-content: center; }
  .hero-actions { width: 100%; }
  .hero-close { top: 10px; right: 10px; }

  /* toolbar stacks */
  .toolbar { flex-direction: column; }
  .search, .sort { width: 100%; }

  /* table: keep only #, Title and Actions (no horizontal scroll) */
  .table-wrap { overflow: hidden; }
  .thead, .row { grid-template-columns: 22px 1fr auto; min-width: 0; gap: 8px; padding-left: 12px; padding-right: 12px; }
  .thead > :nth-child(3), .thead > :nth-child(4), .thead > :nth-child(5),
  .row  > :nth-child(3), .row  > :nth-child(4), .row  > :nth-child(5) { display: none; }
  .c-act { gap: 5px; }

  /* search grid: comfy 2-up, copy button always visible (no hover on touch) */
  .search-results { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .copybtn { opacity: 1; transform: none; width: 34px; height: 34px; }
}
