/* ============ Chooosy — dark minimal theme ============ */

:root {
  --bg: #0e1014;
  --panel: #161a21;
  --panel-2: #1d222c;
  --border: #2a3140;
  --text: #e8eaf0;
  --muted: #98a1b3;
  --accent: #8b5cf6;
  --accent-2: #6d3ff0;
  --green: #2ecc8f;
  --green-dim: #123528;
  --red: #ff5c72;
  --red-dim: #3a1a20;
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.modal-open { overflow: hidden; }

a { color: var(--accent); }

img { display: block; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  transition: background .15s, transform .05s, opacity .15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .8rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
strong { font-weight: 600; }

/* ============ Topbar ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 16, 20, .9);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.brand-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  background: linear-gradient(90deg, #c4b5fd, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-tag { font-size: .8rem; color: var(--muted); }

/* ============ Buttons ============ */

.primary {
  background: var(--accent);
  color: #fff;
  padding: .65rem 1.2rem;
  font-weight: 600;
}
.primary:hover { background: var(--accent-2); }

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: .5rem .9rem;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }

.danger {
  background: var(--red-dim);
  color: var(--red);
  padding: .55rem .9rem;
  border: 1px solid rgba(255, 92, 114, .35);
}
.danger:hover { background: #4a2028; }

.block { width: 100%; }

/* ============ Layout ============ */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.6rem 1.4rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 1.8rem;
  align-items: start;
}

.stage { min-width: 0; }

/* ============ Search ============ */

#search-form {
  display: flex;
  gap: .6rem;
  margin-bottom: .8rem;
}
#search-input { flex: 1; min-width: 0; font-size: 1.05rem; }
#search-hint { margin: .4rem 0 1.2rem; }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: .9rem;
}

.result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.result:hover { border-color: var(--accent); background: var(--panel-2); }

.result img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--panel-2);
}

.result-info { padding: .6rem .7rem .75rem; }
.result-title {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-artist {
  display: block;
  font-size: .82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-genre {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  opacity: .75;
  margin-top: .15rem;
}

/* ============ Judge ============ */

.judge-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  min-height: 2.2rem;
}

.loading {
  font-size: .9rem;
  color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
}

.card-art {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}

.card-meta { min-width: 0; }

.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  color: #c4b5fd;
  background: rgba(139, 92, 246, .16);
  border: 1px solid rgba(139, 92, 246, .4);
  padding: .18rem .55rem;
  border-radius: 999px;
  margin-bottom: .6rem;
}

.card-meta h2 {
  margin: 0 0 .2rem;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.card-artist { margin: 0; font-size: 1.05rem; color: var(--text); }
.card-info { margin: .3rem 0 1.1rem; font-size: .88rem; }

/* ============ Player ============ */

.player {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem;
  margin-bottom: 1.2rem;
}

.play-btn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  padding: .45rem .9rem;
  white-space: nowrap;
}
.play-btn:hover { background: var(--accent-2); }

.progress {
  flex: 1;
  height: 8px;
  background: #10131a;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #c4b5fd);
  border-radius: 999px;
}
.time { font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ============ Verdict ============ */

.verdict { display: flex; gap: .8rem; }

.verdict button {
  flex: 1;
  padding: .85rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.like {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(46, 204, 143, .4) !important;
}
.like:hover { background: #174533; }

.dislike {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(255, 92, 114, .4) !important;
}
.dislike:hover { background: #4a2028; }

.verdict button:disabled { opacity: .5; }

.shortcut-hint {
  font-size: .78rem;
  text-align: center;
  margin-top: 1rem;
}

/* ============ Sidebar / liked list ============ */

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  position: sticky;
  top: 5rem;
}

.sidebar-title {
  margin: 0 0 .8rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.count {
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 .45rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.liked-list {
  list-style: none;
  margin: 0 0 .9rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  max-height: 55vh;
  overflow-y: auto;
}

.liked-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .5rem;
}

.liked-list img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: #10131a;
  flex-shrink: 0;
}

.liked-track { flex: 1; min-width: 0; }
.liked-title {
  display: block;
  font-size: .86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.liked-artist {
  display: block;
  font-size: .76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remove-btn {
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  padding: .3rem .45rem;
  border-radius: 6px;
  flex-shrink: 0;
}
.remove-btn:hover { color: var(--red); background: var(--red-dim); }

.liked-empty { font-size: .86rem; margin: 0 0 .9rem; }
.liked-empty[hidden] { display: none; }

/* ============ Overlays / dialogs ============ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }

.dialog {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}
.dialog h2 { margin: 0 0 .5rem; font-size: 1.25rem; }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: .7rem;
  margin-top: 1.2rem;
}

.share-preview {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem .9rem;
  font-family: inherit;
  font-size: .88rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  margin: .6rem 0 1rem;
}

.share-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

.share-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: .6rem .95rem;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}
.share-btn:hover { border-color: var(--accent); color: #fff; }
.share-btn.ok { border-color: var(--green); color: var(--green); }

/* ============ Settings ============ */

.field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
  font-size: .92rem;
}
.field.check { flex-direction: row; align-items: center; gap: .6rem; }
.field.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.danger-zone {
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
  margin-top: .4rem;
}

/* ============ Ended screen ============ */

.ended {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 40;
  overflow-y: auto;
  padding: 2rem 1.2rem 3rem;
}
.ended[hidden] { display: none; }

.ended-inner {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}
.ended-inner h1 {
  margin: 0 0 .4rem;
  font-size: 1.8rem;
  letter-spacing: -.02em;
  background: linear-gradient(90deg, #c4b5fd, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ended-inner .sidebar-title { justify-content: center; margin-top: 1.6rem; }
.ended-inner .liked-list { max-height: 40vh; text-align: left; }
.ended-inner .share-panel { margin: 1.2rem 0; }
.ended-inner .share-actions { justify-content: center; }

/* ============ Toast ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: .65rem 1.1rem;
  border-radius: 999px;
  font-size: .9rem;
  z-index: 60;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  animation: toast-in .18s ease-out;
}
.toast[hidden] { display: none; }
.toast.warn { border-color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

/* ============ Responsive ============ */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar { position: static; }
  .card {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }
  .card-art { max-width: 260px; }
  .card-meta { width: 100%; }
  .verdict { width: 100%; }
  .player { width: 100%; }
}

@media (max-width: 520px) {
  .topbar { padding: .8rem 1rem; }
  .brand-tag { display: none; }
  .layout { padding: 1rem .9rem 2.5rem; }
  #search-form { flex-direction: column; }
  .verdict { flex-direction: column-reverse; }
  .shortcut-hint { display: none; }
}
