* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #181822;
  --text: #e8e6e3;
  --dim: #5a5a6e;
  --accent: #ff6b35;
  --accent2: #00e5a0;
  --glitch1: #ff0055;
  --glitch2: #00ffcc;
  --error: #ff4d6d;
}

html, body { min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 100;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 99;
}

.noise {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 98;
  animation: drift 8s linear infinite;
}

@keyframes drift {
  0%   { transform: translate(0, 0); }
  100% { transform: translate(50px, 50px); }
}

.container {
  width: 100%;
  max-width: 720px;
  padding: 4rem 1.25rem 2rem;
  z-index: 10;
  position: relative;
}

.title {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  position: relative;
  display: inline-block;
  color: var(--text);
  cursor: default;
  user-select: none;
  margin-bottom: 0.6rem;
}

.title::before,
.title::after {
  content: attr(data-glitch);
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.title::before { color: var(--glitch1); z-index: -1; }
.title::after  { color: var(--glitch2); z-index: -2; }

.title:hover::before { animation: glitch-1 0.4s infinite linear alternate-reverse; }
.title:hover::after  { animation: glitch-2 0.3s infinite linear alternate-reverse; }

@keyframes glitch-1 {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0); }
  25%  { clip-path: inset(20% 0 40% 0); transform: translate(-3px, 2px); }
  50%  { clip-path: inset(60% 0 5% 0); transform: translate(3px, -1px); }
  75%  { clip-path: inset(10% 0 70% 0); transform: translate(-2px, 3px); }
  100% { clip-path: inset(80% 0 0 0); transform: translate(4px, -2px); }
}
@keyframes glitch-2 {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0); }
  25%  { clip-path: inset(50% 0 20% 0); transform: translate(3px, 1px); }
  50%  { clip-path: inset(5% 0 60% 0); transform: translate(-4px, -2px); }
  75%  { clip-path: inset(70% 0 10% 0); transform: translate(2px, 3px); }
  100% { clip-path: inset(15% 0 50% 0); transform: translate(-3px, -1px); }
}

.tagline {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  color: var(--dim);
  margin-bottom: 2.5rem;
  font-weight: 400;
}

.form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.input-wrap {
  position: relative;
}

.input-wrap::before {
  content: '>';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Space Mono', monospace;
  color: var(--accent2);
  pointer-events: none;
  z-index: 1;
}

.input-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Space Mono', monospace;
  font-size: 0.95rem;
  /* right padding leaves room for the inline Magic! button */
  padding: 0.95rem 7.5rem 0.95rem 2.3rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrap input::placeholder { color: var(--dim); }

.input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,107,53,0.15);
}

.btn {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--bg);
  background: var(--accent);
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, filter 0.15s;
  letter-spacing: 0.02em;
}
.btn:hover {
  background: var(--accent2);
  box-shadow: 0 4px 14px rgba(0,229,160,0.22);
}
.btn:active { filter: brightness(0.92); }

.htmx-request .btn,
.htmx-request input { opacity: 0.55; pointer-events: none; }

.spinner {
  font-family: 'Space Mono', monospace;
  color: var(--accent2);
  font-size: 0.85rem;
  display: none;
}
.htmx-request .spinner.htmx-indicator { display: inline-flex; align-items: center; }

.cursor {
  display: inline-block;
  width: 6px;
  height: 0.95em;
  background: var(--accent2);
  margin-left: 4px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.result { margin-top: 1rem; }

.row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 0.8rem 1.2rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.row:hover, .row:focus-visible {
  background: var(--surface2);
  border-color: rgba(0,229,160,0.25);
  outline: none;
}
.row .title-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}
.row .kind {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--accent2);
  background: rgba(0,229,160,0.08);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}
.row .copy-hint {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: var(--dim);
}

.row--flash {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(0,229,160,0.25), 0 0 24px rgba(0,229,160,0.18);
  transform: scale(1.005);
}

/* Persistent "already copied" mark — stays until the result list re-renders. */
.row--copied {
  border-color: rgba(0,229,160,0.35);
  background: linear-gradient(
    to right,
    rgba(0,229,160,0.06),
    var(--surface) 40%
  );
}
.row--copied::before {
  content: '✓';
  font-family: 'Space Mono', monospace;
  color: var(--accent2);
  font-weight: 700;
  margin-right: -0.4rem;
}
.row--copied .kind {
  background: rgba(0,229,160,0.18);
  color: var(--accent2);
}

.row-unresolved {
  cursor: default;
  background: transparent;
  border-style: dashed;
}
.row-unresolved:hover { background: transparent; border-color: rgba(255,255,255,0.06); }
.row-unresolved .title-text { color: var(--dim); }
.row-unresolved .reason {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: var(--error);
}

.playlist-name {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent);
  margin: 0.5rem 0 1rem;
}
.playlist-name .count {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--dim);
  margin-left: 0.5rem;
}
.playlist-name .count-note {
  color: var(--error);
  opacity: 0.85;
}

.error.message-box {
  font-family: 'Space Mono', monospace;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid rgba(255,77,109,0.25);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}

.footer {
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: var(--dim);
  padding: 2rem 1rem 1.5rem;
  opacity: 0.55;
  z-index: 10;
}

.sr-status {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.particle {
  position: fixed;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  animation: float-up linear infinite;
}
@keyframes float-up {
  0%   { opacity: 0; transform: translateY(100vh) scale(0); }
  10%  { opacity: 0.55; }
  90%  { opacity: 0.25; }
  100% { opacity: 0; transform: translateY(-10vh) scale(1.4); }
}

@media (max-width: 480px) {
  .row .copy-hint { display: none; }
  .container { padding-top: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .noise, .particle { display: none !important; }
  .title:hover::before, .title:hover::after { animation: none !important; }
  .row, .btn, .input-wrap input, .row--flash {
    transition: none !important;
    transform: none !important;
  }
}

.playlist-name .handle {
  color: var(--dim);
  font-weight: 400;
  margin-left: 0.4rem;
  font-size: 0.85em;
}
