:root {
  --bg: #0f1220;
  --bg-2: #151a2e;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.10);
  --text: #e8ecf4;
  --muted: #9aa3b8;
  --accent: #7c5cff;
  --accent-2: #4dd0e1;
  --accent-soft: rgba(124, 92, 255, 0.18);
  --danger: #ff5c7a;
  --success: #4ade80;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Prompt', 'Inter', system-ui, sans-serif;
  background: radial-gradient(1200px 800px at 10% 10%, #1a1f3a 0%, #0f1220 50%, #0a0d18 100%);
  color: var(--text);
  overflow-x: hidden;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 30px;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(124,92,255,0.35);
}
.brand-text h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand-text .tagline { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; }

.icon-btn, .ghost-btn, .secondary-btn, .primary-btn, .ctrl-btn {
  border: none; cursor: pointer; font-family: inherit;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255,255,255,0.06); color: var(--text); font-size: 18px;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }

/* Search */
.search-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.search-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.search-input-wrap {
  flex: 1; min-width: 240px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.search-icon { opacity: 0.7; }
#searchInput {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 16px; padding: 8px 4px; font-family: inherit;
}
.clear-btn {
  background: transparent; color: var(--muted); border: none; cursor: pointer; font-size: 16px; padding: 4px 8px;
}
.clear-btn:hover { color: var(--text); }

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #9a7cff);
  color: #fff; padding: 10px 20px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 15px;
  box-shadow: 0 4px 14px rgba(124,92,255,0.35);
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,92,255,0.45); }

.secondary-btn {
  background: rgba(77,208,225,0.15); color: var(--accent-2);
  border: 1px solid rgba(77,208,225,0.3);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 500; font-size: 14px;
}
.secondary-btn:hover { background: rgba(77,208,225,0.25); }

.toggle {
  display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted);
  cursor: pointer; user-select: none;
}
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.search-status { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 18px; }
.search-status.error { color: var(--danger); }
.search-status.success { color: var(--success); }

/* Virtual keyboard */
.virtual-keyboard {
  margin-top: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  user-select: none;
}
.virtual-keyboard.hidden { display: none; }
.kb-toolbar {
  display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.kb-toolbar button {
  background: rgba(255,255,255,0.08); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.kb-toolbar button.active { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.kb-row { display: flex; gap: 6px; margin-bottom: 6px; justify-content: center; flex-wrap: wrap; }
.kb-key {
  min-width: 34px; height: 36px; padding: 0 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px; color: var(--text); font-size: 15px;
  cursor: pointer; display: grid; place-items: center;
  transition: background 0.1s, transform 0.08s;
}
.kb-key:hover { background: rgba(255,255,255,0.14); }
.kb-key:active { transform: translateY(1px); background: var(--accent-soft); }
.kb-key.wide { min-width: 70px; }
.kb-key.space { min-width: 220px; }
.kb-key.special { background: rgba(124,92,255,0.2); }

/* Main layout */
.main {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
}
@media (max-width: 960px) {
  .main { grid-template-columns: 1fr; }
}

.left-pane, .right-pane { display: flex; flex-direction: column; gap: 16px; }

.player-card, .results-card, .queue-card, .add-url-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(12px);
}

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
#player { width: 100%; height: 100%; }
.player-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  background: linear-gradient(135deg, rgba(124,92,255,0.15), rgba(77,208,225,0.1));
  color: var(--muted);
}
.player-placeholder .placeholder-icon { font-size: 60px; opacity: 0.6; }
.player-placeholder p { margin: 8px 0 2px; font-size: 18px; color: var(--text); }
.player-placeholder small { font-size: 13px; }

.now-playing {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.np-title { font-size: 16px; font-weight: 600; }
.np-artist { font-size: 13px; color: var(--muted); margin-top: 2px; }
.np-controls { display: flex; gap: 8px; align-items: center; }
.ctrl-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.08); color: var(--text); font-size: 18px;
}
.ctrl-btn.big {
  width: 54px; height: 54px; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #9a7cff);
  box-shadow: 0 6px 18px rgba(124,92,255,0.4);
}
.ctrl-btn:hover { transform: scale(1.06); }

.progress-row {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
}
.progress-row input[type="range"] { flex: 1; }
.time { font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }

.volume-row {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap;
}
.volume-row input[type="range"] { width: 120px; }
#volumeVal { font-size: 12px; color: var(--muted); min-width: 24px; }
.ghost-btn {
  background: rgba(255,255,255,0.06); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 14px;
}
.ghost-btn:hover { background: rgba(255,255,255,0.12); }
.ghost-btn.active { background: var(--accent-soft); color: #fff; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px;
  background: rgba(255,255,255,0.12);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 0 0 3px rgba(124,92,255,0.25);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
}

/* Cards header */
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.card-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.count { font-size: 12px; color: var(--muted); }

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  max-height: 520px; overflow-y: auto;
  padding-right: 4px;
}
.result-item {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.result-item:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 8px 20px rgba(124,92,255,0.2); }
.result-thumb { position: relative; aspect-ratio: 16/9; background: #000; overflow: hidden; }
.result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.result-dur {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.75); color: #fff;
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
}
.result-body { padding: 8px 10px; }
.result-title { font-size: 13px; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-channel { font-size: 11px; color: var(--muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-actions {
  display: flex; gap: 6px; padding: 0 10px 10px;
}
.result-actions button {
  flex: 1; padding: 6px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 12px; font-family: inherit;
}
.btn-play { background: var(--accent-soft); color: #fff; }
.btn-add { background: rgba(77,208,225,0.15); color: var(--accent-2); }
.result-actions button:hover { filter: brightness(1.2); }

/* Queue */
.queue-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.queue-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 8px;
  transition: background 0.15s;
}
.queue-item.active { border-color: var(--accent); background: var(--accent-soft); }
.queue-item .q-thumb { width: 56px; height: 32px; border-radius: 6px; overflow: hidden; flex-shrink: 0; background: #000; }
.queue-item .q-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-item .q-info { flex: 1; min-width: 0; }
.queue-item .q-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .q-channel { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .q-actions { display: flex; gap: 4px; }
.queue-item .q-actions button {
  width: 28px; height: 28px; border-radius: 6px; border: none;
  background: rgba(255,255,255,0.06); color: var(--text); cursor: pointer; font-size: 12px;
}
.queue-item .q-actions button:hover { background: rgba(255,255,255,0.14); }
.queue-empty { text-align: center; padding: 24px 10px; color: var(--muted); }
.queue-empty div { font-size: 36px; opacity: 0.5; }

/* Add url */
.add-url-card h3 { margin: 0 0 8px; font-size: 14px; }
.url-row { display: flex; gap: 8px; }
.url-row input {
  flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 8px 10px; font-family: inherit;
}
.hint { color: var(--muted); font-size: 11px; margin-top: 6px; display: block; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; z-index: 1;
  background: #1a1f3a; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 20px; width: min(480px, 92vw);
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 18px; }
.close-btn { background: transparent; color: var(--muted); border: none; font-size: 20px; cursor: pointer; }
.close-btn:hover { color: var(--text); }

.hotkeys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hotkeys-grid > div { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
kbd {
  background: rgba(255,255,255,0.1); border: 1px solid var(--card-border);
  border-radius: 6px; padding: 3px 8px; font-size: 12px; color: var(--text);
  min-width: 44px; text-align: center; font-family: 'Inter', monospace;
}

.settings-body { display: flex; flex-direction: column; gap: 8px; }
.settings-body label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.settings-body input {
  background: rgba(0,0,0,0.3); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px; font-family: inherit;
}
.settings-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a1f3a; border: 1px solid var(--card-border);
  padding: 12px 20px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); z-index: 2000; font-size: 14px;
}
.toast.hidden { display: none; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

a { color: var(--accent-2); }

/* Visualizer */
.visualizer {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.55;
  width: 100%; height: 100%;
}

/* FX panel */
.fx-panel {
  margin-top: 12px; padding: 12px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
}
.fx-panel.hidden { display: none; }
.fx-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fx-header h3 { margin: 0; font-size: 14px; }
.fx-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.fx-control { display: flex; flex-direction: column; gap: 4px; }
.fx-control label { font-size: 12px; color: var(--muted); }
.fx-control input[type="range"] { width: 100%; }
.fx-control input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle.small span { font-size: 12px; }

/* np link */
.np-link { font-size: 11px; color: var(--accent-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.np-link a { color: var(--accent-2); text-decoration: none; }
.np-link a:hover { text-decoration: underline; }

/* bulk input */
.bulk-input {
  width: 100%; margin-top: 6px; min-height: 60px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 8px; font-family: inherit; font-size: 12px; resize: vertical;
}

/* Karaoke modal */
.karaoke-modal .km-content { width: min(1100px, 96vw); max-height: 92vh; overflow: auto; }
.km-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.km-topbar h2 { margin: 0; font-size: 18px; }
.km-actions { display: flex; gap: 8px; }
.km-body { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
@media (max-width: 800px) { .km-body { grid-template-columns: 1fr; } }
.km-video { position: relative; }
.km-video .player-wrap { aspect-ratio: 16/9; }
.km-lyrics { display: flex; flex-direction: column; gap: 8px; }
.km-lyrics-header { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.km-lyrics-controls { display: flex; align-items: center; gap: 8px; }
.km-lyrics-input {
  min-height: 80px; background: rgba(0,0,0,0.3); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 8px; font-family: inherit; font-size: 13px; resize: vertical;
}
.km-lyrics-display {
  flex: 1; min-height: 160px; max-height: 260px; overflow-y: auto;
  background: rgba(0,0,0,0.25); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px; font-size: 18px; line-height: 1.8;
  white-space: pre-wrap;
}
.km-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.km-title { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* queue link/copy */
.q-link { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .q-actions button.copy { font-size: 11px; }
