:root {
  --bg: #f3f6ef;
  --panel: #fffef9;
  --ink: #13201a;
  --muted: #5f6f61;
  --line: #d9e2d4;
  --spotify: #1db954;
  --spotify-dark: #149848;
  --info: #4c84d6;
  --danger: #b63d3d;
  --shadow: 0 12px 24px rgba(19, 32, 26, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(112, 207, 144, 0.2), transparent 42%),
    radial-gradient(circle at 100% 100%, rgba(97, 162, 237, 0.16), transparent 44%),
    var(--bg);
}

/* Dark theme variables */
body.theme-dark {
  --bg: #0f1411;
  --panel: #141a16;
  --ink: #e9eee8;
  --muted: #a7b3a9;
  --line: #273028;
  --spotify: #1db954;
  --spotify-dark: #18a34e;
  --info: #7fb2ff;
  --danger: #e57373;
  --shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  background:
    radial-gradient(circle at 15% 10%, rgba(46, 116, 71, 0.2), transparent 42%),
    radial-gradient(circle at 100% 100%, rgba(34, 74, 128, 0.18), transparent 44%),
    var(--bg);
}

.layout {
  width: min(100%, 980px);
  margin: 1.1rem auto 2rem;
  padding: 0 0.9rem;
  display: grid;
  gap: 0.95rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.hero {
  padding-top: 1.2rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5.2vw, 2.65rem);
  line-height: 1.06;
}

h2 {
  margin: 0 0 0.4rem;
}

h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.lede {
  margin: 0.6rem 0 0.2rem;
  color: var(--muted);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.row {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.35rem;
}

label {
  font-size: 0.92rem;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.68rem 0.76rem;
  font-size: 1rem;
  color: var(--ink);
  background: #ffffff;
}

input[readonly] {
  background: #f5f8f2;
}

input:focus {
  outline: 2px solid rgba(29, 185, 84, 0.22);
  border-color: var(--spotify);
}

.actions {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 650;
  padding: 0.58rem 0.94rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 2px solid rgba(76, 132, 214, 0.28);
  outline-offset: 1px;
}

.btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--spotify);
  border-color: var(--spotify);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--spotify-dark);
}

.btn.ghost {
  border-color: #b9c7ba;
}

.status-row {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.24rem 0.62rem;
}

.chip-neutral {
  background: #e7edf3;
  color: #3d4f65;
}

.chip-success {
  background: #d9f3e2;
  color: #155c34;
}

.chip-error {
  background: #f6d8d8;
  color: #7f2222;
}

.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.split {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

.list {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 0.5rem 0.64rem;
}

.list-item {
  font-size: 0.91rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed #e4ebe0;
}

.list-item:last-child {
  border-bottom: 0;
}

.venn {
  margin-top: 0.75rem;
}

.venn-svg {
  width: 100%;
  height: auto;
  opacity: 0;
  transform: translateY(5px) scale(0.987);
  transition: opacity 320ms ease, transform 320ms ease;
}

.venn-svg.is-ready {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.venn-bg {
  fill: #ffffff;
  stroke: var(--line);
}

.venn-circle {
  transition: transform 340ms ease, opacity 340ms ease;
  opacity: 0.18;
}

.venn-left {
  fill: rgba(76, 132, 214, 0.58);
  transform: translateX(-10px);
}

.venn-right {
  fill: rgba(29, 185, 84, 0.58);
  transform: translateX(10px);
}

.venn-svg.is-ready .venn-left,
.venn-svg.is-ready .venn-right {
  transform: translateX(0);
  opacity: 1;
}

.venn-label {
  font-family: inherit;
}

.venn-user-left,
.venn-user-right {
  font-size: 16px;
  font-weight: 700;
  fill: var(--ink);
}

.venn-pct-left,
.venn-pct-right {
  font-size: 26px;
  font-weight: 800;
  fill: var(--ink);
}

.venn-shared {
  font-size: 20px;
  font-weight: 800;
  fill: var(--ink);
}

.venn-shared-sub {
  font-size: 11px;
  fill: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translate(-50%, 10px);
  background: #17231d;
  color: #ffffff;
  border-radius: 999px;
  padding: 0.52rem 0.85rem;
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: transform 150ms ease, opacity 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.footer {
  padding: 0.25rem 0 1.25rem;
  text-align: center;
}

.footer-inner {
  display: inline-flex;
  justify-content: center;
  width: 100%;
}

/* Dark mode toggle */
.theme-toggle {
  position: fixed;
  right: 14px;
  bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  padding: 0.5rem 0.9rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.theme-toggle:hover { transform: translateY(-1px); }

/* Avatars compare header */
#compare-avatars {
  margin-top: 0.6rem;
  display: none; /* app.js toggles to flex when ready */
  gap: 1.8rem;
  align-items: center;
}

.avatar-col {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
}

.avatar-name {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
}

.avatar {
  box-shadow: 0 6px 14px rgba(19, 32, 26, 0.08);
}

/* Friends list */
.friends-list {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}

.friend-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.friend-item:hover {
  transform: translateY(-1px);
  background: #f8fbf6;
}

.friend-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: var(--panel); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ink); font-size: 0.9rem;
}

.friend-name {
  font-weight: 700; font-size: 0.98rem; color: var(--ink);
}

.friend-sub {
  font-size: 0.85rem; color: var(--muted);
}

.friend-remove {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.friend-remove:hover {
  color: var(--danger);
}

/* Visualization */
.viz {
  margin-top: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  padding: 0.6rem;
  overflow: hidden;
}

.viz-svg { width: 100%; height: auto; }

.artist-node {
  font-size: 11px;
  fill: var(--ink);
  opacity: 0.92;
  transition: opacity 140ms ease;
  animation: drift 6.4s ease-in-out infinite;
  transform-origin: center;
}

.artist-node:hover { opacity: 1; }

@keyframes drift {
  0% { transform: translate(0,0) }
  50% { transform: translate(var(--dx, 2px), var(--dy, -2px)) }
  100% { transform: translate(0,0) }
}

.circle-left { fill: rgba(76, 132, 214, 0.12); stroke: rgba(76, 132, 214, 0.6); }
.circle-right { fill: rgba(29, 185, 84, 0.12); stroke: rgba(29, 185, 84, 0.6); }
.circle-single { fill: rgba(76, 132, 214, 0.1); stroke: rgba(76, 132, 214, 0.55); }

.label { font-size: 14px; fill: var(--ink); font-weight: 700; }

@media (min-width: 720px) {
  .layout {
    margin-top: 1.7rem;
  }

  .panel {
    padding: 1.1rem 1.2rem;
  }

  .split {
    grid-template-columns: 1fr 1fr;
  }
}
