@import './styles/tokens.css';
@import './styles/base.css';
@import './styles/shell.css';
@import './styles/features/sessions.css';
@import './styles/features/taste-profile.css';
@import './styles/components.css';
@import './styles/features/library.css';
@import './styles/features/search.css';
@import './styles/features/now-playing.css';
@import './styles/layout.css';

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

/* ── SF Symbols icon sizing ──────────────────────────────────────────────────
   .sf-icon is the base class for inline SF Symbols SVGs.
   Context-specific overrides control the rendered size.                      */
.sf-icon {
  display: block;
  flex-shrink: 0;
  overflow: visible;
}

/* Nav sidebar: icons sit next to text labels */
.nav-icon {
  height: 15px;
  width: auto;
}

/* Bottom nav: larger tap target */
.bottom-nav-icon {
  height: 22px;
  width: auto;
}

/* Mini player transport buttons */
.mini-btn .sf-icon {
  height: 18px;
  width: auto;
}

/* Art placeholder: centered music note */
.mini-art-placeholder .sf-icon {
  height: 22px;
  width: auto;
  opacity: 0.4;
}

/* Now-playing transport buttons */
.np-transport-btn .sf-icon {
  height: 20px;
  width: auto;
}

/* Skip buttons (prev/next) are smaller than play/pause — Apple Music hierarchy */
#mini-prev .sf-icon,
#mini-next .sf-icon {
  height: 13px;
}

#np-prev .sf-icon,
#np-next .sf-icon {
  height: 15px;
}

/* Track reaction buttons: star + thumbsup */
.track-reaction-btn .sf-icon {
  height: 13px;
  width: auto;
  display: inline-block;
}

:root {
  --bg: #0d0d0d;
  --surface: #1c1c1e;
  --surface2: #2c2c2e;
  --border: #3a3a3c;
  --accent: #00C8FF;
  --accent-soft: rgba(0, 200, 255, 0.15);
  --text: #f2f2f7;
  --text-2: #aeaeb2;
  --text-3: #636366;
  --green: #30d158;
  --yellow: #ffd60a;
  --blue: #0a84ff;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

h1 {
  font-size: 18px;
  font-weight: 600;
}

.back-btn {
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  user-select: none;
}

.back-btn:hover {
  opacity: 0.8;
}

.hidden {
  display: none !important;
}

/* ── Main ── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.loading {
  color: var(--text-3);
  text-align: center;
  padding: 60px 0;
}

.error-msg {
  color: var(--accent);
  text-align: center;
  padding: 60px 0;
}

/* ── Sessions list ── */
.sessions-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sessions-list-title {
  font-size: 20px;
  font-weight: 600;
}

.sessions-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-card:hover {
  background: var(--surface2);
}

.session-card h2 {
  font-size: 16px;
  font-weight: 600;
}

.session-card .context {
  font-size: 13px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.session-meta .badge {
  font-size: 10px;
  padding: 1px 7px;
}

.session-meta .count {
  margin-left: auto;
}

/* ── Status badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-pending,
.badge-new {
  background: rgba(99, 99, 102, 0.3);
  color: var(--text-3);
}

.badge-in_progress {
  background: rgba(255, 214, 10, 0.15);
  color: var(--yellow);
}

.badge-completed {
  background: rgba(48, 209, 88, 0.15);
  color: var(--green);
}

.badge-reviewed {
  background: rgba(48, 209, 88, 0.15);
  color: var(--green);
}

.badge-archived {
  background: rgba(99, 99, 102, 0.18);
  color: var(--text-3);
  opacity: 0.7;
}

/* ── Session list ── */
.session-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.session-card-top h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.session-card-intent {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Session detail ── */
.session-back-nav {
  margin-bottom: 16px;
}

.back-link {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.session-header {
  margin-bottom: 24px;
}

.session-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.session-header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.session-intent {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.5;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-complete {
  background: rgba(10, 132, 255, 0.12);
  color: var(--blue, #0a84ff);
  border: 1px solid rgba(10, 132, 255, 0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}

.btn-complete:hover:not(:disabled) {
  background: rgba(10, 132, 255, 0.2);
}

.btn-complete:disabled,
.btn-complete-loading {
  opacity: 0.6;
  cursor: default;
}

.session-reflection {
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.session-reflection-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.session-reflection p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin: 0;
}

.session-user-feedback {
  margin-bottom: 14px;
}

.session-feedback-input {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  transition: border-color 0.15s, background 0.15s;
}

.session-feedback-input:focus {
  outline: none;
  border-color: var(--blue, #0a84ff);
  background: var(--surface2);
}

.session-feedback-input::placeholder {
  color: var(--text-3);
}

/* ── New Session chat modal ── */
.ns-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.ns-modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow: hidden;
}

.ns-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ns-title {
  font-size: 15px;
  font-weight: 600;
}

.ns-close {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.ns-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.ns-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ns-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.ns-bubble-assistant {
  background: var(--surface2);
  color: var(--text);
  align-self: flex-start;
}

.ns-bubble-user {
  background: var(--accent);
  color: #000;
  align-self: flex-end;
}

.ns-bubble-error {
  background: rgba(255, 59, 48, 0.15);
  color: #ff453a;
  border: 1px solid rgba(255, 59, 48, 0.3);
}

.ns-session-ready {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ns-session-ready-title {
  font-size: 15px;
  font-weight: 600;
}

.ns-session-ready-summary {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.ns-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ns-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  resize: none;
  overflow: hidden;
  line-height: 1.5;
  max-height: 160px;
  overflow-y: auto;
  font-family: inherit;
}

.ns-input:focus {
  border-color: var(--accent);
}

.ns-input::placeholder {
  color: var(--text-3);
}

.ns-input:disabled,
.ns-send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Thinking animation */
.ns-bubble-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.ns-thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: ns-thinking-bounce 1.2s ease-in-out infinite;
}

.ns-thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ns-thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ns-thinking-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.session-library-snapshot {
  margin-bottom: 14px;
}

.session-library-snapshot summary {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  cursor: pointer;
  user-select: none;
}

.session-library-snapshot p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-top: 8px;
  white-space: pre-wrap;
}

.session-taste-signals-container {
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-top: 14px;
}

.session-taste-signals-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 12px;
}

.session-taste-signals-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.taste-signal-item {
  padding: 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--blue, #0a84ff);
}

.signal-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.signal-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  background: rgba(10, 132, 255, 0.1);
  color: var(--blue, #0a84ff);
  border-radius: 3px;
}

.signal-entry {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin: 0;
}

.session-progress-wrap {
  margin-bottom: 8px;
}

.session-progress-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.session-progress-bar {
  height: 3px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.session-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}

/* ── Discovery items ── */
.discovery-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 40px;
}

.discovery-item {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.discovery-item-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.discovery-item-artist {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.discovery-item-rationale {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 0;
}

.discovery-item-rationale .ai-sparkle {
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Add to Library button — overlaid on artwork ────────────────────────────── */
.discovery-item-art-wrap {
  position: relative;
  flex-shrink: 0;
}

.discovery-add-library-btn {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: #000;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
  /* hidden until hover on desktop; always visible on touch */
  opacity: 0;
  pointer-events: none;
}

/* Reveal on card hover (desktop) */
.discovery-item:hover .discovery-add-library-btn,
.discovery-item-child:hover .discovery-add-library-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Always visible on touch devices */
@media (hover: none) {
  .discovery-add-library-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.discovery-add-library-btn:hover:not(:disabled) {
  background: var(--accent);
  opacity: 0.85;
}

.discovery-add-library-btn:disabled {
  cursor: not-allowed;
}

/* Added ✓ */
.discovery-add-library-btn.added {
  background: var(--accent);
  opacity: 1;
  pointer-events: none;
}

/* Error state */
.discovery-add-library-btn.failed {
  background: #e05252;
  color: #fff;
  opacity: 1;
}

/* ── Discovery play button (track items, web playback) ── */
.discovery-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  padding-left: 2px;
  /* optical centering of ▶ */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, background 0.15s, transform 0.15s;
}

.discovery-item:hover .discovery-play-btn,
.discovery-item-child:hover .discovery-play-btn {
  opacity: 1;
  pointer-events: auto;
}

.discovery-play-btn:hover {
  background: var(--accent);
  border-color: transparent;
  transform: translate(-50%, -50%) scale(1.08);
}

@media (hover: none) {
  .discovery-play-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.discovery-item-feedback {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.discovery-thumbs {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.discovery-thumbs-like {
  display: flex;
  gap: 6px;
}

.discovery-thumb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.discovery-thumb-btn .sf-icon {
  width: 14px;
  height: 14px;
}

.discovery-thumb-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.discovery-thumb-btn.active.liked {
  background: rgba(48, 209, 88, 0.15);
  border-color: var(--green);
  color: var(--green);
}

.discovery-thumb-btn.active.disliked {
  background: rgba(252, 60, 68, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.alignment-rating {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
}

.alignment-label {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
}

.alignment-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color 0.15s;
}

.star-icon {
  width: 16px;
  height: 16px;
}

.alignment-star:hover {
  color: var(--text);
}

.alignment-star:hover .star-icon,
.alignment-star.filled .star-icon {
  opacity: 1;
}

.alignment-star .star-icon {
  opacity: 0.3;
}

.alignment-star.filled {
  color: rgba(255, 179, 0, 0.8);
}

.alignment-star.filled .star-icon {
  color: rgba(255, 179, 0, 0.9);
}

.alignment-star.preview {
  color: rgba(255, 179, 0, 0.5);
}

.alignment-star.preview .star-icon {
  opacity: 0.6;
}

.discovery-comment-wrap {
  flex: 1;
  min-width: 140px;
}

.discovery-add-note-btn {
  font-size: 12px;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.discovery-add-note-btn:hover {
  color: var(--text-2);
}

.discovery-comment-input {
  width: 100%;
  min-height: 52px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.discovery-comment-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Artist section ── */
.discovery-artist-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: opacity 0.2s;
}

.discovery-artist-section.item-reviewed {
  opacity: 0.65;
}

.discovery-artist-section.item-reviewed:hover {
  opacity: 1;
}

.discovery-artist-header {
  display: flex;
  gap: 14px;
  padding: 16px;
  align-items: flex-start;
}

.discovery-artist-art {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.discovery-artist-art-placeholder {
  background: var(--surface2);
}

.discovery-artist-meta {
  flex: 1;
  min-width: 0;
}

.discovery-artist-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.discovery-artist-children,
.discovery-album-children {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Album / track item (with artwork) ── */
.discovery-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  grid-template-rows: auto auto;
  overflow: hidden;
  transition: opacity 0.2s;
}

.discovery-item.item-reviewed {
  opacity: 0.65;
}

.discovery-item.item-reviewed:hover {
  opacity: 1;
}

.discovery-item-art {
  grid-column: 1;
  grid-row: 1;
  width: 120px;
  height: 120px;
  object-fit: cover;
  display: block;
}

.discovery-item-art-placeholder {
  grid-column: 1;
  grid-row: 1;
  width: 120px;
  height: 120px;
  background: var(--surface2);
}

.discovery-item-body {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.discovery-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.discovery-item-header .discovery-thumbs {
  flex-shrink: 0;
}

/* Full-width note row */
.discovery-item-note {
  grid-column: 1 / -1;
  grid-row: 2;
  padding: 0 16px 14px;
}

.discovery-item-note .discovery-comment-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  resize: vertical;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}

.discovery-item-note .discovery-comment-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface2);
}

/* Child items — smaller art, tighter grid */
.discovery-item-child {
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  grid-template-columns: 80px 1fr;
}

.discovery-item-child .discovery-item-art,
.discovery-item-child .discovery-item-art-placeholder {
  width: 80px;
  height: 80px;
}

.discovery-item-child .discovery-item-name {
  font-size: 14px;
}

.discovery-item-child .discovery-item-rationale {
  font-size: 12px;
  margin-bottom: 0;
}

/* ── Taste profile ── */
.taste-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.taste-profile-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  flex: 1 1 auto;
}

/* Portrait action buttons (Refresh / Generate first) */
.portrait-action-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(0, 200, 255, 0.25);
  border-radius: 99px;
  padding: 5px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex: 0 0 auto;
}

.portrait-action-btn:hover {
  opacity: 0.8;
}

.portrait-action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.portrait-refresh-stale {
  color: var(--yellow);
  background: rgba(255, 214, 10, 0.12);
  border-color: rgba(255, 214, 10, 0.3);
}

/* Inline status message shown during/after refresh */
.portrait-refresh-status {
  font-size: 13px;
  color: var(--text-2);
  flex: 1 1 100%;
  margin-top: 4px;
}

.portrait-refresh-success {
  color: var(--green);
}

.portrait-refresh-skipped {
  color: var(--text-3);
}

.portrait-refresh-error {
  color: #ff453a;
}

/* Portrait card */
.portrait-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.portrait-card-stale {
  border-color: rgba(255, 214, 10, 0.3);
}

.portrait-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  margin: 0 0 16px;
}

.portrait-focus {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

.portrait-focus-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}

.portrait-focus-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
  margin: 0;
}

.portrait-footer {
  margin-top: 16px;
}

.portrait-date {
  font-size: 12px;
  color: var(--text-3);
}

.portrait-empty {
  font-size: 14px;
  color: var(--text-3);
  padding: 20px 0;
  margin-bottom: 24px;
}

.portrait-empty p {
  margin-bottom: 12px;
}

/* Collapsible observations log */
.taste-log-section {
  margin-bottom: 32px;
}

.taste-log-toggle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  user-select: none;
}

.taste-log-toggle::-webkit-details-marker {
  display: none;
}

.taste-log-toggle::before {
  content: "›";
  font-size: 16px;
  transition: transform 0.15s;
  display: inline-block;
}

details[open] .taste-log-toggle::before {
  transform: rotate(90deg);
}

.taste-log-count {
  background: var(--surface2);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
}

.taste-profile-log {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
}

.taste-entry {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.taste-entry-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.taste-entry-date {
  font-size: 12px;
  color: var(--text-3);
}

.taste-entry-session {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.taste-entry-session:hover {
  text-decoration: underline;
}

.taste-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.taste-tag {
  background: var(--surface2);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
}

.taste-entry-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* ── Session detail (old kept for compat) ── */
.session-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.session-context {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 24px;
  white-space: pre-wrap;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ── Recommendation cards ── */
.rec-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
}

.rec-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Clickable header row */
.rec-header {
  display: flex;
  gap: 16px;
  padding: 14px 16px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  align-items: center;
  color: inherit;
}

.rec-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.rec-artwork {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}

.rec-artwork-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.rec-info {
  flex: 1;
  min-width: 0;
}

.rec-info .rec-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-info .rec-artist {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 1px;
}

.rec-info .rec-album {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 5px;
}

.rec-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  align-self: stretch;
}

.rec-open-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
  padding: 2px 8px;
  text-decoration: none;
  line-height: 1.5;
  white-space: nowrap;
}

.rec-open-link:hover {
  background: rgba(0, 200, 255, 0.28);
}

.rec-reviewed-indicator {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.2s;
  line-height: 1;
}

.rec-card.reviewed .rec-reviewed-indicator {
  opacity: 1;
}

.rec-card.reviewed {
  opacity: 0.6;
}

.rec-card.reviewed:hover {
  opacity: 1;
}

.rec-card.reviewed.expanded {
  opacity: 1;
}

.rec-chevron {
  font-size: 18px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.rec-card.expanded .rec-chevron {
  transform: rotate(180deg);
}

/* Collapsible body */
.rec-body {
  display: none;
  border-top: 1px solid var(--border);
}

.rec-card.expanded .rec-body {
  display: block;
}

.rec-rationale {
  font-size: 13px;
  color: var(--text-2);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.rec-rationale strong {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  text-decoration: none;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary.active {
  background: rgba(48, 209, 88, 0.12);
  color: var(--green);
  border-color: rgba(48, 209, 88, 0.4);
}

.btn-success {
  background: rgba(48, 209, 88, 0.15);
  color: var(--green);
  border: 1px solid rgba(48, 209, 88, 0.3);
}

/* ── AI analysis section (inside expanded track row) ── */
.ai-analysis-section {
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-analysis-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-analysis-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.ai-confidence {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text-3);
}

.ai-confidence--high {
  color: var(--green);
  background: rgba(48, 209, 88, 0.12);
}

.ai-confidence--medium {
  color: var(--yellow);
  background: rgba(255, 214, 10, 0.10);
}

.ai-confidence--low {
  color: var(--text-3);
  background: var(--surface2);
}

.ai-analysis-summary {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  font-style: italic;
  margin: 0;
}

.ai-analysis-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.ai-stat {
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface2);
  border-radius: 6px;
  padding: 2px 8px;
}

.ai-stat-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface2);
  width: 100px;
  padding: 2px 8px;
}

.ai-stat-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  opacity: 0.38;
  border-radius: 6px;
}

.ai-stat-bar-label {
  position: relative;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

.ai-mood {
  font-size: 11px;
  color: var(--text-2);
  background: rgba(0, 200, 255, 0.08);
  border-radius: 6px;
  padding: 2px 8px;
}

/* ── Feedback form ── */
.feedback-form {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.feedback-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.feedback-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 90px;
}

/* Star rating */
.stars {
  display: flex;
  flex-direction: row-reverse;
  gap: 2px;
}

.stars input {
  display: none;
}

.stars label {
  font-size: 22px;
  color: var(--border);
  cursor: pointer;
  transition: color 0.1s;
}

.stars input:checked~label,
.stars label:hover,
.stars label:hover~label {
  color: var(--yellow);
}

/* Loved toggle */
.loved-btn {
  font-size: 22px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: transform 0.15s;
}

.loved-btn:hover {
  transform: scale(1.2);
}

.loved-btn.active {
  filter: none;
}

/* Replay / session-fit buttons */
.replay-group {
  display: flex;
  gap: 6px;
}

.replay-group button {
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.replay-group button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Context tags */
.tag-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-group button {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.tag-group button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Thumbs */
.thumbs-group {
  display: flex;
  gap: 8px;
}

.thumbs-group button {
  font-size: 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.1s;
}

.thumbs-group button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Notes textarea */
.notes-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px;
  resize: vertical;
  min-height: 72px;
  transition: border-color 0.15s;
}

.notes-input:focus {
  outline: none;
  border-color: var(--accent);
}

.save-indicator {
  font-size: 12px;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.3s;
}

.save-indicator.visible {
  opacity: 1;
}

.save-indicator.error {
  color: var(--accent);
  opacity: 1;
}

#save-error-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-soft);
  border: 1px solid rgba(0, 200, 255, 0.4);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius);
  z-index: 100;
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

/* ── Claude's analysis card ── */
.claude-analysis-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 16px 20px;
  margin-bottom: 32px;
}

.claude-analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.claude-analysis-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
}

.claude-analysis-date {
  font-size: 11px;
  color: var(--text-3);
}

.claude-analysis-body {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ── Session feedback ── */
.session-feedback-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
}

.session-feedback-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.complete-btn-row {
  margin-top: 16px;
}

.empty-state {
  color: var(--text-3);
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}

/* ── View tab nav ── */
.view-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab-btn {
  padding: 4px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
}

.tab-btn:hover:not(.active) {
  color: var(--text);
}

/* ── Sync toolbar ── */
.sync-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sync-meta-label {
  font-size: 12px;
  color: var(--text-3);
}

.btn-sync {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.btn-sync:hover {
  background: var(--surface);
  color: var(--text-1);
}

.btn-sync:disabled {
  opacity: 0.5;
  cursor: default;
}

.sync-bridge-unavailable {
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
}

/* ── Sync progress ── */
.sync-progress {
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.sync-progress.error {
  color: #fc3c44;
  border-color: rgba(252, 60, 68, 0.35);
}

/* ── Library controls (search + filter/sort) ── */
.library-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 0;
}

.album-search-input {
  width: 220px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 12px 4px 32px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.album-search-input:focus {
  border-color: var(--accent);
  width: 280px;
}

.album-search-input::placeholder {
  color: var(--text-3);
}

/* ── Filter/sort button & dropdown ── */
.filter-sort-wrap {
  position: relative;
}

.album-filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.album-filter-btn:hover {
  background: var(--surface);
  color: var(--text-1);
}

.album-filter-btn.has-filter {
  border-color: var(--accent);
  color: var(--accent);
}

.album-filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  padding: 4px 0;
}

.afd-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.afd-item:hover {
  background: var(--surface);
}

.afd-check {
  width: 18px;
  font-size: 12px;
  color: var(--accent);
  opacity: 0;
  flex-shrink: 0;
}

.afd-item.active .afd-check {
  opacity: 1;
}

.afd-item.active[data-action="filter-favorites"] {
  color: var(--accent);
}

.afd-divider {
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ── Album grid ── */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px 16px;
}

.album-card {
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: opacity 0.15s;
}

.album-card:hover {
  opacity: 0.75;
}

.album-card-art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  object-fit: cover;
  display: block;
  margin-bottom: 7px;
  background: var(--surface2);
}

.album-card-art-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.album-card-name {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  min-width: 0;
}

.album-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Pin + fav buttons sit side-by-side in the card title row */
.album-card-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Pin button — hidden until hover; always visible when active (pinned) */
.album-card-pin-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
  filter: grayscale(1);
}

.album-card:hover .album-card-pin-btn {
  opacity: 0.6;
}

.album-card-pin-btn.active {
  opacity: 1;
  filter: none;
}

/* Star button — hidden until card hover; always visible when active (favorited) */
.album-card-fav-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--text-2);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.album-card:hover .album-card-fav-btn {
  opacity: 1;
}

.album-card-fav-btn.active {
  opacity: 1;
  color: var(--accent);
}

.album-card-artist {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Track tags (Last.fm) ── */
.track-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.track-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(10, 132, 255, 0.12);
  color: var(--blue);
  border: 1px solid rgba(10, 132, 255, 0.25);
  white-space: nowrap;
}

/* ── Album back nav ── */
.album-back-nav {
  margin-bottom: 12px;
}

.back-link {
  color: var(--text-3);
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--text-2);
}

.album-back-nav .back-link {
  color: var(--text-2);
}

.album-back-nav .back-link:hover {
  color: var(--text);
}

/* ── Album detail header ── */
.album-detail-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.album-detail-art {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}

.album-detail-info {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.album-detail-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 8px;
}

.album-detail-artist {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.album-detail-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.album-detail-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.album-wiki-blurb {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
}

/* ── Album detail title buttons (pin + fav side by side) ── */
.album-detail-title-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.album-detail-pin-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  filter: grayscale(1);
  transition: opacity 0.15s, filter 0.15s;
}

.album-detail-header:hover .album-detail-pin-btn {
  opacity: 0.6;
}

.album-detail-pin-btn.active {
  opacity: 1;
  filter: none;
}

.album-detail-pin-btn:hover {
  opacity: 1 !important;
}

/* ── Album detail inline favorite star ── */
.album-detail-fav-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--border);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.album-detail-header:hover .album-detail-fav-btn {
  opacity: 1;
}

.album-detail-fav-btn.active {
  opacity: 1;
  color: var(--accent);
}

.album-detail-fav-btn:hover {
  color: var(--accent);
}

/* ── Track row (album detail track list) ── */
.track-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.track-row:last-child {
  border-bottom: none;
}

/* Header is a plain div — love btn and stars stop propagation on click */
.track-row-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s;
}

.track-row-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* ── Reaction buttons (★/☆  ▲/△  ▼/▽) ─────────────────────────────────────
   Single source of truth. Use modifiers for context:
     .track-reaction-btns--hover-reveal  — hidden until row hover or has active (album rows)
     .track-reaction-btns--lg            — larger icons (NP current card)
   ────────────────────────────────────────────────────────────────────────── */
.track-reaction-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Album rows: hide until hover or one is active */
.track-reaction-btns--hover-reveal {
  opacity: 0;
  transition: opacity 0.15s;
}

.track-row-header:hover .track-reaction-btns--hover-reveal,
.track-reaction-btns--hover-reveal:has(.active) {
  opacity: 1;
}

/* NP current card: larger icons */
.track-reaction-btns--lg .track-reaction-btn {
  font-size: 18px;
  padding: 2px 5px;
}

.track-reaction-btns--lg .track-reaction-btn.active {
  transform: scale(1.2);
}

/* Base button — works everywhere */
.track-reaction-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--text-3);
  transition: color 0.15s, transform 0.12s;
}

.track-reaction-btn:hover {
  color: var(--text-2);
  transform: scale(1.15);
}

/* Active state colors — defined once, apply everywhere */
.track-reaction-btn.reaction-favorite.active {
  color: var(--accent);
}

.track-reaction-btn.reaction-like.active {
  color: var(--accent);
}

.track-reaction-btn.reaction-dislike.active {
  color: var(--accent);
}

.track-reaction-btn.active {
  transform: scale(1.15);
}

/* Track pin button — hidden until row hover; always visible when pinned */
.track-pin-btn {
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  filter: grayscale(1);
  flex-shrink: 0;
  transition: opacity 0.15s, filter 0.15s;
}

.track-row-header:hover .track-pin-btn {
  opacity: 0.5;
}

.track-pin-btn.active {
  opacity: 1;
  filter: none;
}

.track-pin-btn:hover {
  opacity: 1 !important;
}

.track-row-num {
  font-size: 13px;
  color: var(--text-3);
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.track-row-name {
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* AI sparkle icon — inline indicator for AI-generated content */
.ai-sparkle {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  flex-shrink: 0;
  transition: opacity 0.15s ease, filter 0.15s ease;
  cursor: default;
}

.ai-sparkle-placeholder {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.ai-sparkle:hover {
  opacity: 1 !important;
  filter: drop-shadow(0 0 4px currentColor);
}

.ai-sparkle--high {
  color: #c4b5fd;
  opacity: 1;
}

.ai-sparkle--medium {
  color: #a78bfa;
  opacity: 0.65;
}

.ai-sparkle--low {
  color: #fb923c;
  opacity: 0.6;
}

.track-row-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}


.track-row-dur {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

/* ── Track play button (album page, web playback) ── */
.track-play-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.track-row-header:hover .track-play-btn {
  opacity: 1;
}

.track-play-btn:hover {
  color: var(--accent);
}

.track-play-btn .sf-icon {
  height: 12px;
  width: auto;
}

@media (hover: none) {
  .track-play-btn {
    opacity: 1;
  }
}

/* ── Track menu button (ellipsis) — always visible, muted ── */
.track-menu-btn {
  background: none;
  border: none;
  padding: 2px 5px;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color 0.15s;
}

.track-menu-btn .sf-icon {
  width: 14px;
  height: 14px;
}

.track-menu-btn:hover {
  color: var(--text-1);
}

/* ── Track context menu popup ── */
.track-menu {
  position: fixed;
  z-index: 1000;
  background: rgba(38, 38, 40, 0.96);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  min-width: 180px;
  padding: 5px 0;
  overflow: hidden;
}

.track-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 14px;
  background: none;
  border: none;
  color: var(--text-1);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background 0.08s;
}

.track-menu-item:hover {
  background: rgba(255, 255, 255, 0.09);
}

.track-menu-item.destructive {
  color: #ff453a;
}

.track-menu-item.destructive:hover {
  background: rgba(255, 69, 58, 0.12);
}

.track-menu-icon {
  display: flex;
  align-items: center;
  width: 16px;
  justify-content: center;
}

.track-menu-icon .sf-icon {
  width: 14px;
  height: 14px;
}

/* ── Track highlight (Go to Album pulse) ── */
@keyframes track-highlight-pulse {
  0% {
    background: rgba(229, 60, 82, 0.18);
  }

  100% {
    background: transparent;
  }
}

.track-row--highlight {
  animation: track-highlight-pulse 1.4s ease-out;
}

.track-row-body {
  display: none;
  /* indent: love(16) + gap(10) + num(20) + gap(10) = 56px */
  padding: 2px 4px 14px 56px;
}

.track-row.expanded .track-row-body {
  display: block;
}

/* ── Album actions ── */
.album-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-generate-features {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-generate-features:hover:not(:disabled) {
  background: #e5353f;
}

.btn-generate-features:disabled {
  background: var(--text-3);
  cursor: not-allowed;
}

.btn-generate-features.btn-partial {
  background: #ff9500;
  /* Orange color for partial state */
  border-color: #ff9500;
}

.btn-generate-features.btn-partial:hover:not(:disabled) {
  background: #e6860a;
}

.features-complete {
  color: var(--green);
  font-size: 14px;
  font-weight: 500;
}

.features-status {
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
}

.features-status.visible {
  opacity: 1;
}

.features-status.error {
  color: var(--accent);
}

.features-status.success {
  color: var(--green);
}

/* ── Audio features display ── */
.audio-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.feature-item {
  background: var(--surface2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
}

.feature-summary {
  margin-top: 8px;
  padding: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  border-left: 3px solid var(--accent);
}

/* ── Audio features display ── */
.audio-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.feature-item {
  background: var(--surface2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
}

.feature-summary {
  margin-top: 8px;
  padding: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  font-style: italic;
}

.feature-rationale {
  width: 100%;
  font-size: 12px;
  color: var(--text-2);
  font-style: italic;
  margin-top: 4px;
}

.feature-source {
  font-family: monospace;
  font-size: 11px;
  opacity: 0.6;
}

.feature-confidence--high {
  border: 1px solid var(--green);
  color: var(--green);
}

.feature-confidence--medium {
  border: 1px solid var(--yellow);
  color: var(--yellow);
}

.feature-confidence--low {
  border: 1px solid var(--text-3);
  color: var(--text-3);
}

/* ── Now Playing toggle btn ── */
#np-toggle-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: 6px;
  flex-shrink: 0;
}

#np-toggle-btn:hover,
#np-toggle-btn.active {
  background: var(--surface);
  color: var(--text);
}

#np-toggle-btn.active {
  color: var(--accent);
}

/* ── History sidebar (desktop) / Now Playing overlay (mobile) ── */
.np-panel {
  /* Desktop: fills #history-sidebar via position:absolute */
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.np-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.np-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  flex: 1;
}

.np-clear-btn {
  font-size: 11px;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
  flex-shrink: 0;
}

.np-clear-btn:hover {
  color: var(--text-2);
}

/* ── Device picker button ── */
.np-device-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px 3px 5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.np-device-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--text-3);
}

.np-airplay-icon {
  flex-shrink: 0;
  opacity: 0.6;
}

.np-device-chevron {
  font-size: 9px;
  opacity: 0.5;
  margin-left: 1px;
}

/* ── Device popover (inline, flows between header and body) ── */
.np-device-popover {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.np-device-popover[hidden] {
  display: none;
}

.np-device-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.np-device-option:first-child {
  border-top: none;
}

.np-device-option:hover {
  background: var(--surface2);
}

.np-device-option.active {
  color: var(--text);
  font-weight: 500;
}

.np-device-check {
  width: 14px;
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Track hero — artwork + title/sub */
.np-track-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 6px;
}

.np-artwork {
  width: 48px;
  height: 48px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}

.np-artwork-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 20px;
}

.np-track-details {
  flex: 1;
  min-width: 0;
}

.np-track-name,
.np-track-sub {
  padding-left: 0 !important;
}

/* Transport controls */
.np-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 12px 2px;
}

.np-transport-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-2);
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.np-transport-btn:hover {
  color: var(--text-1);
  background: var(--surface-2);
}

.np-play-pause {
  font-size: 22px;
  color: var(--accent);
}

.np-play-pause:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* History artwork thumbnail */
.np-hist-art {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.np-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.np-idle {
  color: var(--text-3);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
}

/* Current track card */
.np-current-card {
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.np-playing-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.np-playing-indicator {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent);
  flex: 1;
}

.np-track-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 3px;
  word-break: break-word;
}

.np-track-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.np-progress {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  margin-bottom: 5px;
  overflow: hidden;
}

.np-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.6s linear;
}

.np-progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}

.np-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

/* NP current card reaction container spacing */
.track-reaction-btns--lg {
  padding: 10px 0 6px;
}

/* Mood line: sparkle toggle + mood text inline */
.np-mood-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

/* AI summary toggle — wraps the sparkle icon */
.np-summary-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.np-features {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.np-summary {
  font-size: 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.np-impression-form {
  margin-top: 10px;
}

.np-form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.np-notes {
  width: 100%;
  margin-top: 8px;
  min-height: 56px;
}

/* Section dividers */
.np-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.np-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.np-section-name {
  font-weight: 500;
  color: var(--text-2);
  text-transform: none;
  letter-spacing: 0;
}

/* Context track list */
.np-ctx-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.np-ctx-track {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  font-size: 12px;
  color: var(--text-3);
}

.np-ctx-track.current {
  color: var(--text);
  font-weight: 600;
}

.np-ctx-track.played {
  opacity: 0.55;
}

.np-ctx-marker {
  width: 20px;
  text-align: right;
  flex-shrink: 0;
  font-size: 11px;
}

.np-ctx-track.current .np-ctx-marker {
  color: var(--accent);
}

.np-ctx-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-ctx-reaction {
  width: 16px;
  flex-shrink: 0;
  font-size: 11px;
  text-align: center;
}

/* History items */
.np-hist-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.np-hist-item:last-child {
  border-bottom: none;
}

.np-hist-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
}

.np-hist-info {
  flex: 1;
  min-width: 0;
}

.np-hist-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-bottom: 2px;
}

.np-hist-track-text {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-hist-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-hist-album-text,
.np-hist-artist {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-hist-album-text {
  color: var(--text-3);
}

.np-hist-sep {
  color: var(--text-3);
  flex-shrink: 0;
}

.np-hist-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}



/* ── App shell layout ──────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-areas: "sidebar main history";
  grid-template-columns: 200px 1fr 340px;
  grid-template-rows: 1fr;
  height: 100dvh;
  overflow: hidden;
}

#sidebar-nav {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  background: var(--bg);
}

.nav-brand {
  font-size: 16px;
  font-weight: 700;
  padding: 4px 20px 16px;
  color: var(--text);
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-icon {
  flex-shrink: 0;
  opacity: 0.7;
  /* height/width set in .sf-icon block at top */
}

.nav-item.active .nav-icon {
  opacity: 1;
}

/* Coming-soon nav item: visually dimmed, non-interactive */
.nav-item-soon {
  opacity: 0.38;
  pointer-events: none;
}

.nav-soon-badge {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: auto;
}

/* LAN session user footer — compact account menu anchored to the sidebar */
#lan-user-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  position: relative;
  overflow: visible;
}

.user-settings-shell {
  position: relative;
}

.user-menu-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(36, 36, 38, 0.98), rgba(24, 24, 26, 0.98));
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.user-menu-trigger:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--border));
  transform: translateY(-1px);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #0d0d0d;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 70%, white), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.user-menu-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-menu-track-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.15;
}

.user-menu-chevron {
  color: var(--text-3);
  font-size: 13px;
  flex-shrink: 0;
}

.user-settings-popover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 12px);
  z-index: 30;
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(18, 18, 20, 0.98);
  backdrop-filter: blur(24px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  transform-origin: bottom left;
  animation: user-menu-reveal 0.16s ease-out;
}

@keyframes user-menu-reveal {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.user-settings-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.user-settings-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 4px;
}

.user-settings-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.user-settings-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

/* Library sync section */
.lib-sync-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-settings-popover .lib-sync-row,
.user-settings-popover .lib-sync-row--sub {
  width: 100%;
}

.lib-sync-meta {
  font-size: 12px;
  color: var(--text-2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-sync-btn {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, var(--border));
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.user-settings-popover .lib-sync-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
  background: var(--surface);
  color: var(--text);
}

.lib-sync-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.lib-sync-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.lib-sync-btn--secondary {
  color: var(--text);
  border-color: var(--border);
}

.lib-sync-btn--secondary:hover:not(:disabled) {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border));
  background: var(--surface2);
}

.lib-sync-row--sub {
  margin-top: 0;
}

.lib-sync-btn--ghost {
  color: var(--text-3);
  border-color: var(--border);
  font-size: 11px;
  padding: 3px 4px;
}

.user-settings-popover .lib-sync-btn--ghost {
  width: auto;
  align-self: flex-start;
  padding-left: 0;
  padding-right: 0;
  background: transparent;
}

.lib-sync-btn--ghost:hover:not(:disabled) {
  color: var(--text);
  background: none;
  text-decoration: underline;
}

.lib-sync-status {
  font-size: 11px;
  color: var(--text-2);
  padding: 2px 0;
  line-height: 1.4;
}

.lib-sync-auth-row {
  align-items: flex-start;
  gap: 6px;
}

.lib-sync-auth-status {
  flex: 1;
}

.lib-sync-auth-status.is-good {
  color: #7ac08f;
}

.lib-sync-auth-status.is-warn {
  color: #ffb36b;
}

#btn-switch-user,
.user-settings-signout {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 500;
  color: #ff7b7b;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.22);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

#btn-switch-user:hover,
.user-settings-signout:hover {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.34);
  color: #ff9393;
}

#main-col {
  grid-area: main;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#view-root {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 24px; /* top padding removed — controls are rendered above */
  min-height: 0;
}

/* Container for controls rendered above the scrollable view root */
#view-controls {
  padding: 6px 20px; /* reduced vertical padding so albums can scroll higher */
  background: var(--bg);
  border-bottom: none; /* remove thin dividing line under controls */
  z-index: 8;
  position: sticky;
  top: 0; /* stays below the app header (header has higher z-index) */
}

/* Left-align controls when showing album back-link */
.library-controls.back-view {
  justify-content: flex-start;
}

#history-sidebar {
  grid-area: history;
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--border);
}

/* Bottom nav: hidden on desktop */
#bottom-nav {
  display: none;
}

/* ── Mini player (universal) ─────────────────────────────────────────────── */
.mini-player {
  display: none;
  align-items: center;
  padding: 0 16px 0 12px;
  gap: 12px;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body.has-mini-player .mini-player {
  display: flex;
}

/* Thin absolute bar — mobile only; hidden on desktop */
.mini-player-progress {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.mini-player-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 1s linear;
}

/* Inline timeline — desktop only */
.mini-timeline {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}

.mini-player-bar {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  min-width: 0;
}

.mini-player-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.mini-art-img,
.mini-art-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  flex-shrink: 0;
}

.mini-art-img {
  object-fit: cover;
}

.mini-art-placeholder {
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-3);
}

.mini-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mini-track-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-album-link {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: color 0.15s;
}

.mini-album-link:hover {
  color: var(--text-2);
}

.mini-time {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.mini-reaction-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.mini-reaction-btns .track-reaction-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 5px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mini-reaction-btns .track-reaction-btn:hover {
  color: var(--text-2);
}

.mini-reaction-btns .track-reaction-btn.active {
  color: var(--accent);
}

.mini-reaction-btns .track-reaction-btn.reaction-dislike.active {
  color: var(--accent);
}

.mini-menu-btn {
  margin-left: 2px;
  flex-shrink: 0;
}

.mini-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mini-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
}

/* ── Mobile / PWA ─────────────────────────────────────────────────────────── */
.np-dismiss-btn {
  display: none;
}

@media (max-width: 768px) {

  /* ── Mobile grid: single column, bottom nav ── */
  #app {
    grid-template-areas:
      "main"
      "bottom-nav";
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  #sidebar-nav {
    display: none;
  }

  #history-sidebar {
    display: none;
  }

  /* Bottom nav */
  #bottom-nav {
    grid-area: bottom-nav;
    display: flex;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(13, 13, 13, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-3);
    text-decoration: none;
    padding: 8px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item.active {
    color: var(--accent);
  }

  .bottom-nav-icon {
    flex-shrink: 0;
  }

  .bottom-nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }

  /* ── Mobile mini player: visual override (floating pill) ── */
  .mini-player {
    background: rgba(36, 36, 38, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.4);
  }

  /* Mobile: restore thin absolute bar, hide inline timeline */
  .mini-player-progress {
    display: block;
  }

  .mini-timeline {
    display: none;
  }

  /* Mobile: controls back to right side */
  .mini-controls {
    order: 3;
  }

  /* ── NP panel: full-screen overlay on mobile, slides up from bottom ── */
  .np-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    padding-top: env(safe-area-inset-top, 44px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    overflow-x: hidden;
  }

  body.mobile.mobile-fullplayer .np-panel {
    transform: translateY(0);
  }

  /* ── Dismiss button (down chevron) ── */
  .np-dismiss-btn {
    display: flex;
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 28px;
    line-height: 1;
    padding: 2px 8px 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* ── Full player header ── */
  .np-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    gap: 4px;
  }

  /* Centered title between dismiss chevron and device button */
  .np-panel-title {
    flex: 1;
    text-align: center;
    font-size: 12px;
  }

  /* ── Full player current card: stacked, full-width artwork ── */
  #np-current-card {
    padding: 4px 20px 24px;
  }

  .np-playing-state {
    justify-content: flex-end;
    padding: 0 0 8px;
  }

  /* Artwork: stacked column, full-width square */
  .np-track-hero {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 4px;
  }

  .np-artwork {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 14px;
    object-fit: cover;
    max-width: 100%;
  }

  .np-artwork-placeholder {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    background: var(--surface-2);
  }

  .np-track-details {
    width: 100%;
    text-align: center;
    min-width: 0;
  }

  .np-track-name {
    font-size: 20px;
    font-weight: 700;
    white-space: normal;
    line-height: 1.25;
    margin-bottom: 4px;
  }

  .np-track-sub {
    font-size: 15px;
  }

  /* ── Progress bar ── */
  .np-progress {
    height: 4px;
    margin: 14px 0 5px;
  }

  /* ── Transport controls: big touch targets ── */
  .np-transport {
    padding: 12px 12px 8px;
    gap: 24px;
  }

  .np-transport-btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    padding: 8px;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
  }

  .np-play-pause {
    font-size: 28px;
    min-width: 52px;
    min-height: 52px;
  }

  /* ── Reaction buttons ── */
  .track-reaction-btn {
    padding: 8px 12px;
    min-height: 48px;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }

  .track-reaction-btns--lg .track-reaction-btn {
    font-size: 24px;
    padding: 10px 16px;
    min-height: 52px;
  }

  .track-reaction-btns--lg .track-reaction-btn.active {
    transform: scale(1.1);
  }

  .track-reaction-btns--lg {
    gap: 6px;
    padding: 0;
  }

  /* ── Impression form ── */
  .np-impression-form {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  /* ── Context/tag buttons ── */
  .t-tag-btn {
    padding: 7px 12px;
    font-size: 13px;
    min-height: 36px;
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Device picker ── */
  .np-device-btn {
    font-size: 12px;
    padding: 5px 10px 5px 8px;
    flex-shrink: 0;
  }

  .np-device-option {
    padding: 14px 16px;
    font-size: 15px;
    min-height: 52px;
  }

  /* ── Prevent iOS auto-zoom on focus ── */
  .notes-input,
  .np-notes {
    font-size: 16px;
  }

  /* ── History: larger touch target ── */
  .np-hist-header {
    padding: 10px 4px;
    -webkit-tap-highlight-color: transparent;
  }

  /* ── Hide history and context list in mobile full player ── */
  body.mobile #np-history-section,
  body.mobile #np-context-section {
    display: none;
  }
}