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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
}

body {
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #1a1a1a;
  background: #0a0a0a;
  flex-shrink: 0;
}

#url-form {
  display: flex;
  flex: 1;
  gap: 8px;
}

#url-input {
  flex: 1;
  background: #141414;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 9px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

#url-input:focus {
  border-color: #444;
}

#url-input::placeholder {
  color: #555;
}

#url-form button {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

#url-form button:hover {
  opacity: 0.85;
}

#api-key-wrap {
  flex-shrink: 0;
}

#api-key-input {
  background: #141414;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 9px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  width: 160px;
  transition: border-color 0.15s;
}

#api-key-input:focus {
  border-color: #444;
}

#api-key-input::placeholder {
  color: #444;
}

/* Main */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#empty-state p {
  color: #444;
  font-size: 0.9rem;
}

/* Player */
#player-wrap {
  flex: 1;
  display: flex;
  background: #000;
  min-width: 0;
}

#player {
  width: 100%;
  height: 100%;
}

/* Sidebar */
#sidebar {
  width: 380px;
  flex-shrink: 0;
  background: #0f0f0f;
  border-left: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

/* Sidebar collapsed */
#sidebar.collapsed {
  width: 40px;
}

#sidebar.collapsed #sidebar-tabs .tab,
#sidebar.collapsed .panel {
  display: none;
}

#sidebar.collapsed #sidebar-tabs {
  flex-direction: column;
  border-bottom: none;
  height: 100%;
  align-items: center;
  justify-content: flex-start;
  padding-top: 8px;
}

/* Tabs */
#sidebar-tabs {
  display: flex;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 11px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #666;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: #aaa;
}

.tab.active {
  color: #fff;
  border-bottom-color: #fff;
}

#collapse-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}

#collapse-btn:hover {
  color: #fff;
}

#collapse-btn svg {
  transition: transform 0.2s;
}

/* Panels */
.panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.panel.active {
  display: flex;
}

.muted {
  color: #555;
  font-size: 0.8rem;
  padding: 16px;
}

/* Playlist meta */
.playlist-meta {
  padding: 14px 16px;
  border-bottom: 1px solid #1a1a1a;
}

.playlist-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #eee;
  margin-bottom: 3px;
}

.playlist-channel {
  font-size: 0.75rem;
  color: #777;
}

/* Playlist items */
#playlist-list {
  flex: 1;
  overflow-y: auto;
}

.pl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.pl-item:hover {
  background: #1a1a1a;
}

.pl-item.active {
  background: #1a1a1a;
}

.pl-index {
  font-size: 0.7rem;
  color: #555;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.pl-item.active .pl-index {
  color: #fff;
}

.pl-thumb {
  width: 80px;
  height: 45px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: #1a1a1a;
}

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

.pl-title {
  font-size: 0.78rem;
  font-weight: 500;
  color: #ddd;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pl-channel {
  font-size: 0.7rem;
  color: #666;
  margin-top: 2px;
}

/* Comments */
#comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.comment {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
}

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.comment-body {
  min-width: 0;
}

.comment-author {
  font-size: 0.72rem;
  font-weight: 500;
  color: #aaa;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.comment-likes {
  font-size: 0.68rem;
  color: #666;
  font-weight: 400;
}

.comment-likes::before {
  content: "\2191 ";
}

.comment-text {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #ccc;
  word-break: break-word;
}

/* Notes */
#panel-notes {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#panel-notes.active {
  display: flex;
}

#notes-entries {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.note-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #141414;
}

.note-timestamp {
  font-size: 0.75rem;
  font-weight: 500;
  color: #4ea8ff;
  cursor: pointer;
  white-space: nowrap;
  padding-top: 1px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.note-timestamp:hover {
  color: #7dc0ff;
}

.note-content {
  flex: 1;
  min-width: 0;
}

.note-content {
  cursor: pointer;
}

.note-preview {
  font-size: 0.82rem;
  color: #aaa;
  line-height: 1.4;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.note-full {
  display: block;
}

.note-item.collapsed .note-full {
  display: none;
}

.note-item.collapsed .note-preview {
  display: block;
}

.note-item:not(.collapsed) .note-preview {
  display: none;
}

.note-text {
  font-size: 0.82rem;
  line-height: 1.5;
  color: #ddd;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.note-date {
  font-size: 0.68rem;
  color: #555;
}

.note-delete {
  background: none;
  border: none;
  color: #444;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.note-delete:hover {
  color: #e55;
}

#notes-input-wrap {
  padding: 10px 12px;
  border-top: 1px solid #1a1a1a;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#notes-input {
  flex: 1;
  background: #141414;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}

#notes-input:focus {
  border-color: #444;
}

#notes-input::placeholder {
  color: #444;
}

#notes-add-btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

#notes-add-btn:hover {
  opacity: 0.85;
}

/* Scrollbars */
#playlist-list::-webkit-scrollbar,
#comments-list::-webkit-scrollbar,
#notes-entries::-webkit-scrollbar {
  width: 5px;
}

#playlist-list::-webkit-scrollbar-track,
#comments-list::-webkit-scrollbar-track,
#notes-entries::-webkit-scrollbar-track {
  background: transparent;
}

#playlist-list::-webkit-scrollbar-thumb,
#comments-list::-webkit-scrollbar-thumb,
#notes-entries::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 3px;
}

/* Mobile */
@media (max-width: 700px) {
  main {
    flex-direction: column;
  }

  #player-wrap {
    height: 40vh;
    flex: none;
  }

  #sidebar {
    width: 100%;
    flex: 1;
  }

  #api-key-input {
    width: 120px;
  }
}