:root {
  --bg: #1B1523;
  --bg-panel: #241A2E;
  --bg-panel-2: #2C2038;
  --brass: #D9A441;
  --brass-soft: #C99A4D;
  --rose: #E8768E;
  --cream: #F3ECDD;
  --muted: #B8A9C4;
  --line: rgba(243, 236, 221, 0.12);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(217, 164, 65, 0.08), transparent),
    radial-gradient(ellipse 50% 40% at 100% 20%, rgba(232, 118, 142, 0.06), transparent);
  color: var(--cream);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ---------- Header / nav ---------- */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 40px;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: 'Fraunces', serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .dot { color: var(--rose); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brass);
  color: #241A2E;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { background: #E5B15A; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--brass); color: var(--brass); background: transparent; }

/* ---------- Home: cassette shelf ---------- */

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state p:first-child {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  color: var(--cream);
  margin-bottom: 8px;
}

.shelf {
  display: grid;
  gap: 14px;
}

.tape-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.tape-card:hover { border-color: var(--brass-soft); transform: translateX(2px); }

.tape-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
}

.tape-card-body { flex: 1; min-width: 0; }
.tape-card-title {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tape-card-meta {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------- New playlist form ---------- */

.field { margin-bottom: 22px; }
.field label {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input[type=text], .field textarea {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--cream);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
}
.field input[type=text]:focus, .field textarea:focus {
  border-color: var(--brass);
}
.field textarea {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.05rem;
  resize: vertical;
  min-height: 70px;
}

.error-banner {
  background: rgba(232, 118, 142, 0.12);
  border: 1px solid rgba(232, 118, 142, 0.4);
  color: var(--rose);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.picker-layout {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 640px) {
  .picker-layout { grid-template-columns: 1fr; }
}

.library-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-panel);
}

.library-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.library-row:last-child { border-bottom: none; }
.library-row:hover { background: var(--bg-panel-2); }

.library-row input[type=checkbox] {
  accent-color: var(--brass);
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.library-row-text { flex: 1; min-width: 0; }
.library-row-title {
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-row-artist {
  font-size: 0.78rem;
  color: var(--muted);
}
.library-row-duration {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.selection-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-panel);
  position: sticky;
  top: 24px;
}
.selection-panel h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 4px;
}
.selection-panel .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 14px;
}
.selection-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.selection-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  background: var(--bg-panel-2);
  border-radius: 8px;
  padding: 8px 10px;
}
.selection-list .sel-num {
  font-family: 'Space Mono', monospace;
  color: var(--brass);
  font-size: 0.78rem;
  width: 20px;
  flex-shrink: 0;
}
.selection-list .sel-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selection-list .sel-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
}
.selection-list .sel-remove:hover { color: var(--rose); }
.selection-empty { color: var(--muted); font-size: 0.85rem; font-style: italic; }

.form-actions { margin-top: 28px; display: flex; gap: 12px; }

/* ---------- Playlist page: cassette liner ---------- */

.cassette-label {
  background: linear-gradient(155deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 30px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.cassette-window {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
  margin-bottom: 26px;
}

.reel {
  width: 64px;
  height: 64px;
  transform-origin: center;
}
.reel.spinning {
  animation: spin 3s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.playlist-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 2rem;
  text-align: center;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.playlist-meta {
  text-align: center;
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.playlist-message {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 1.1rem;
  text-align: center;
  color: var(--brass);
  max-width: 480px;
  margin: 20px auto 0;
  line-height: 1.55;
}

.face-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 34px 0 12px;
  color: var(--muted);
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.face-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.track {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 6px;
  border-bottom: 1px solid var(--line);
}
.track:last-child { border-bottom: none; }

.track-play {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.track-play:hover { border-color: var(--brass); }
.track.playing .track-play {
  background: var(--brass);
  border-color: var(--brass);
  color: #241A2E;
}

.track-info { flex: 1; min-width: 0; }
.track-title {
  font-size: 0.96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track.playing .track-title { color: var(--brass); }
.track-artist {
  font-size: 0.78rem;
  color: var(--muted);
}
.track-duration {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.player-bar {
  position: sticky;
  bottom: 16px;
  margin-top: 30px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.player-bar .now-playing {
  flex: 1;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-bar .now-playing strong { color: var(--cream); font-weight: 500; }
.player-bar audio { height: 32px; }
.player-bar audio { max-width: 180px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}
.back-link:hover { color: var(--brass); }

.danger-zone { margin-top: 40px; text-align: center; }
.danger-zone form { display: inline; }
.danger-zone button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.danger-zone button:hover { color: var(--rose); }

@media (max-width: 480px) {
  .playlist-title { font-size: 1.5rem; }
  .cassette-window { gap: 36px; }
  .reel { width: 50px; height: 50px; }
}
