:root {
  --bg: #0f0f0f;
  --bg-alt: #181818;
  --card: #212121;
  --text: #f1f1f1;
  --text-dim: #aaaaaa;
  --accent: #3ea6ff;
  --accent-strong: #cc0000;
  --border: #303030;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-strong);
  letter-spacing: 0.5px;
}

.search-form {
  flex: 1;
  max-width: 600px;
  display: flex;
}

.search-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 20px 0 0 20px;
  background: #121212;
  color: var(--text);
  outline: none;
}

.search-form button {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 20px 20px 0;
  background: #222;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 14px;
}

.tab-btn.active {
  background: #2a2a2a;
  color: var(--text);
}

.account-widget button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 18px;
  font-weight: 600;
}

.account-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 18px;
}

.account-pill:hover { background: #2a2a2a; }

.account-pill img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.icon-btn {
  position: relative;
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
}

.icon-btn:hover { background: #2a2a2a; }

.icon-btn.unconfigured::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-strong);
  border: 1.5px solid var(--bg-alt);
}

.cookie-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #121212;
  color: var(--text);
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  outline: none;
}

main {
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

.section-title {
  font-size: 18px;
  margin: 10px 0 16px;
  color: var(--text);
}

.hint {
  color: var(--text-dim);
  padding: 40px;
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.video-card {
  cursor: pointer;
  color: inherit;
}

.thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

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

.duration-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 3px;
}

.live-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}

.video-meta {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.video-meta img.channel-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #333;
}

.video-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-sub {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.3;
}

.channel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 10px;
  background: var(--card);
  border-radius: 10px;
  cursor: pointer;
}

.channel-card img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #333;
  margin-bottom: 12px;
}

.channel-card .name { font-weight: 600; }
.channel-card .sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.channel-strip {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.channel-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 90px;
  flex-shrink: 0;
  cursor: pointer;
  text-align: center;
}

.channel-chip img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #333;
}

.channel-chip .name {
  font-size: 12px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 40px 16px;
}

.overlay.hidden { display: none; }

.overlay-inner {
  background: var(--bg-alt);
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  padding: 20px;
  position: relative;
}

.overlay-inner.small { max-width: 420px; }

.close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}

.watch-main, .watch-sidebar {
  min-width: 0;
}

@media (max-width: 1000px) {
  .watch-layout {
    grid-template-columns: 1fr;
  }
}

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.speed-indicator {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
}

.speed-indicator.hidden {
  display: none;
}

.hotkey-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 8px;
}

.hotkey-hint kbd {
  background: #272727;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 11px;
}

.player-wrap iframe,
.player-wrap video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #000;
}

.player-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
}

.player-menu-btn {
  display: block;
  width: 28px;
  height: 28px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 16px;
  padding: 0;
}

.player-menu-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.player-menu-panel {
  position: absolute;
  top: 34px;
  right: 0;
  min-width: 180px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-menu-panel.hidden {
  display: none;
}

.player-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

.player-menu-select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
  max-width: 130px;
}

.video-detail-title {
  font-size: 18px;
  margin: 16px 0 6px;
}

.video-detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.channel-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-row img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #333;
}

.subscribe-btn {
  background: #fff;
  color: #0f0f0f;
  border: none;
  padding: 8px 18px;
  border-radius: 18px;
  font-weight: 600;
}

.subscribe-btn.subscribed {
  background: #272727;
  color: var(--text);
  border: 1px solid var(--border);
}

.video-description {
  background: #181818;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: pre-wrap;
  margin-bottom: 20px;
  max-height: 140px;
  overflow-y: auto;
}

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

.comments-section h3 {
  font-size: 15px;
  margin: 0;
}

.comments-search {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #121212;
  color: var(--text);
  outline: none;
  font-size: 13px;
  width: 200px;
}

.comment-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.comment-form input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  outline: none;
}

.comment-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 16px;
}

.comment {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.comment img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #333;
  flex-shrink: 0;
}

.comment-body .author {
  font-size: 13px;
  font-weight: 600;
  margin-right: 8px;
}

.comment-body .time {
  font-size: 12px;
  color: var(--text-dim);
}

.comment-body .text {
  font-size: 14px;
  margin: 4px 0;
  white-space: pre-wrap;
}

.comment-body .likes {
  font-size: 12px;
  color: var(--text-dim);
}

.related-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.related-item {
  display: flex;
  gap: 10px;
  cursor: pointer;
}

.related-item .thumb-wrap {
  width: 160px;
  flex-shrink: 0;
}

.related-meta {
  min-width: 0;
  padding-top: 2px;
}

.signin-code {
  text-align: center;
  padding: 10px 0;
}

.signin-code .code {
  font-size: 32px;
  letter-spacing: 4px;
  font-weight: 700;
  background: #121212;
  border-radius: 8px;
  padding: 14px;
  margin: 16px 0;
}

.signin-code a {
  color: var(--accent);
}

.status-msg {
  color: var(--text-dim);
  margin-top: 10px;
  font-size: 13px;
}

.error-msg {
  color: #ff6b6b;
}

.load-more {
  display: block;
  margin: 24px auto;
  background: #272727;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 18px;
}
