* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
  background: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 7px 12px;
}

button:hover:not(:disabled) { background: #475569; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
}
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #1e293b;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  color: #fcd34d;
  letter-spacing: 0.02em;
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header-controls select {
  margin-left: 6px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 4px 8px;
}

.body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.left {
  flex: 1;
  padding: 14px 16px 8px;
  overflow: auto;
}

.right {
  width: 320px;
  flex-shrink: 0;
  background: #111827;
  border-left: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.mode-row, .search-row, .playlist-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.mode-btn.active {
  background: #b45309;
  border-color: #f59e0b;
}

.label-muted { color: #cbd5e1; font-size: 0.9rem; }

.search-input {
  flex: 1;
  min-width: 180px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 12px;
}

.count-input {
  width: 64px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.section-title {
  margin: 14px 0 8px;
  font-size: 1rem;
  color: #fcd34d;
}

.count-badge {
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.85rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.result-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-card.is-playing {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px #f59e0b;
}

.thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #0f172a;
  overflow: hidden;
  cursor: pointer;
}

.thumb-wrap img,
.thumb-wrap .thumb-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
  display: block;
}

.thumb-wrap .thumb-iframe {
  object-fit: unset;
  background: #000;
}

.thumb-dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 2;
}

.thumb-hint {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(15,23,42,0.8);
  color: #fcd34d;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  z-index: 2;
}

.result-card:hover .thumb-hint {
  opacity: 1;
}

.result-card .meta {
  padding: 8px;
  flex: 1;
}

.result-card .title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-card .channel {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0 0 6px;
}

.result-card .actions {
  display: flex;
  gap: 4px;
  padding: 0 8px 8px;
}

.result-card .actions button {
  flex: 1;
  padding: 5px;
  font-size: 0.8rem;
}

.playlist {
  border: 1px solid #334155;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.pl-item {
  display: grid;
  grid-template-columns: 28px 56px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #1e293b;
  cursor: pointer;
}

.pl-item:last-child { border-bottom: none; }
.pl-item:hover { background: #1e293b; }
.pl-item.active { background: #1e3a5f; }
.pl-item.selected { outline: 1px solid #f59e0b; }

.pl-item img {
  width: 56px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

.pl-item .t {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-item .d {
  font-size: 0.75rem;
  color: #94a3b8;
}

.player-wrap {
  margin: 12px 0 16px;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #334155;
}

.player-wrap.hidden { display: none; }

#yt-player {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  line-height: 0;
}

#yt-player iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
}

.now-playing {
  margin: 0;
  padding: 8px 12px;
  font-size: 0.9rem;
  background: #111827;
}

.lyrics {
  flex: 1;
  margin: 0;
  padding: 10px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #cbd5e1;
  min-height: 200px;
}

.status-bar {
  padding: 8px 16px;
  border-top: 1px solid #1e293b;
  background: #111827;
  font-size: 0.85rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-hint {
  color: #64748b;
  font-size: 0.9rem;
  padding: 16px;
  text-align: center;
}

@media (max-width: 900px) {
  .body { flex-direction: column; }
  .right {
    width: 100%;
    border-left: none;
    border-top: 1px solid #1e293b;
    max-height: 280px;
  }
}
