:root {
  --bg: #0b0d12;
  --bg-elevated: #121621;
  --bg-surface: #181e2c;
  --bg-surface-hover: #1f2738;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f5f8;
  --text-secondary: #98a3b6;
  --text-muted: #667185;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --player-height: 88px;
  --header-height: 68px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: rgba(11, 13, 18, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1100px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.search-form {
  flex: 1;
  max-width: 620px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-form:focus-within {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  padding: 8px 10px;
  font-size: 0.95rem;
  color: var(--text);
}

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

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.search-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.search-clear svg {
  width: 15px;
  height: 15px;
}

.search-submit {
  border: none;
  background: var(--accent);
  color: #06211e;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 7px 15px;
  border-radius: 999px;
  margin-left: 4px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.search-submit:hover {
  background: #5eead4;
}

.search-submit:active {
  transform: scale(0.98);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.status-pill.ok .status-dot {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.status-pill.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
}

/* Main */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px calc(var(--player-height) + 36px);
}

/* Recent searches */
.recent-section {
  margin-bottom: 18px;
}

.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.text-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.chips-row,
.suggested-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.84rem;
  padding: 6px 13px;
  border-radius: 999px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

/* Error banner */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  font-size: 0.9rem;
}

.error-icon {
  width: 18px;
  height: 18px;
  color: var(--danger);
  flex-shrink: 0;
}

.error-message {
  flex: 1;
}

.error-dismiss {
  color: #fecaca;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 16px 40px;
  max-width: 540px;
  margin: 0 auto;
}

.empty-icon-wrap {
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  border-radius: 20px;
  background: var(--accent-soft);
  border: 1px solid rgba(45, 212, 191, 0.25);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon-wrap svg {
  width: 40px;
  height: 40px;
}

.empty-title {
  margin: 0 0 8px;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.empty-subtitle {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.suggested-chips {
  justify-content: center;
}

/* Loading skeleton */
.loading-state {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.skeleton-row {
  height: 76px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-surface) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border: 1px solid var(--border);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Results */
.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.results-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.results-count {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.result-row:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.result-row.active {
  background: rgba(45, 212, 191, 0.09);
  border-color: rgba(45, 212, 191, 0.4);
}

.result-thumb-wrap {
  position: relative;
  width: 96px;
  height: 54px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0d111a;
  flex-shrink: 0;
}

.result-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 16, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.result-row:hover .result-overlay,
.result-row.active .result-overlay {
  opacity: 1;
}

.result-overlay-play {
  width: 24px;
  height: 24px;
  color: #fff;
}

.result-row.active .result-overlay-play {
  display: none;
}

/* Equalizer */
.equalizer {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}

.result-row.active .equalizer {
  display: flex;
}

.equalizer span {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  animation: eq-bounce 0.85s ease-in-out infinite;
  transform-origin: bottom;
}

.equalizer span:nth-child(2) {
  animation-delay: 0.2s;
}

.equalizer span:nth-child(3) {
  animation-delay: 0.4s;
}

.result-row.active.paused .equalizer span {
  animation-play-state: paused;
  transform: scaleY(0.35);
}

@keyframes eq-bounce {
  0%, 100% { transform: scaleY(0.28); }
  50% { transform: scaleY(1); }
}

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

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.result-row.active .result-title {
  color: var(--accent);
}

.result-channel {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-duration {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.queue-add-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.queue-add-btn:hover {
  background: var(--accent-soft);
  border-color: rgba(45, 212, 191, 0.45);
  color: var(--accent);
}

.queue-add-btn.added {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.queue-add-btn svg {
  width: 17px;
  height: 17px;
}

/* Queue Drawer */
.queue-drawer {
  position: fixed;
  right: 20px;
  bottom: calc(var(--player-height) + 14px);
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: min(480px, calc(100vh - var(--header-height) - var(--player-height) - 32px));
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow: hidden;
}

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

.queue-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.queue-count-pill {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.queue-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.queue-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.queue-empty {
  margin: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.14s ease;
}

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

.queue-item-thumb {
  width: 48px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #0d111a;
}

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

.queue-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-channel {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-remove-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.queue-remove-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.queue-remove-btn svg {
  width: 14px;
  height: 14px;
}

/* Player bar */
.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  min-height: var(--player-height);
  background: rgba(16, 20, 30, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(280px, 1.5fr) minmax(180px, 1fr);
  align-items: center;
  gap: 16px;
}

.player-track {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.player-thumb-wrap {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-thumb-placeholder {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-thumb-placeholder svg {
  width: 22px;
  height: 22px;
}

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

.player-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.player-channel {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #06211e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.play-btn:hover:not(:disabled) {
  background: #5eead4;
}

.play-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.play-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.play-btn svg {
  width: 20px;
  height: 20px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(6, 33, 30, 0.25);
  border-top-color: #06211e;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-label {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 38px;
  text-align: center;
}

/* Custom range sliders */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

.seek-slider {
  flex: 1;
}

.volume-slider {
  width: 92px;
}

.range-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  transition: transform 0.1s ease;
}

.range-slider:hover:not(:disabled)::-webkit-slider-thumb {
  transform: scale(1.15);
}

.range-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
}

.player-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.queue-toggle-btn {
  position: relative;
}

.queue-toggle-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.queue-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #06211e;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive */
@media (max-width: 820px) {
  .status-text {
    display: none;
  }

  .status-pill {
    padding: 7px;
  }

  .player-bar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px 12px;
    padding: 10px 14px;
  }

  .player-track {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
  }

  .player-right {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }

  .player-center {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    max-width: none;
  }

  .volume-slider {
    display: none;
  }

  .main-content {
    padding-bottom: 165px;
  }

  .queue-drawer {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 148px;
  }
}

@media (max-width: 520px) {
  .topbar-inner {
    padding: 0 12px;
    gap: 10px;
  }

  .brand-name {
    display: none;
  }

  .search-submit {
    padding: 7px 11px;
    font-size: 0.8rem;
  }

  .result-thumb-wrap {
    width: 76px;
    height: 44px;
  }

  .result-duration {
    display: none;
  }
}
