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

* { box-sizing: border-box; }

/* without this, form controls get light-mode chrome: white text on white */
:root { color-scheme: dark; }

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

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

/* fixed so the shorts feed can subtract a known number */
:root { --topbar-h: 58px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--topbar-h);
  padding: 0 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;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text);
  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);
}

.icon-btn-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* empty once signed in, collapse the gap */
.icon-btn-label:not(:empty) { margin-left: 6px; }

.cookie-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.cookie-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(62, 166, 255, 0.12);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

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

.cookie-input::placeholder { color: var(--text-dim); }

.cookie-input:focus { border-color: var(--accent); }

.cookie-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

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;
  /* container context for the cqw subtitle sizes */
  container-type: inline-size;
}

/* the wrapper goes fullscreen, not the video, so our overlays survive */
.player-wrap:fullscreen {
  aspect-ratio: auto;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.player-wrap:fullscreen video {
  object-fit: contain;
}

.player-error {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 4;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.85);
  color: #ff6b6b;
  font-size: 13px;
  text-align: center;
}

.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;
}

.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;
}

/* drawn by js/subtitles.js, not the browser. inert to pointers so captions
   never swallow a click meant for the controls under them. */

.subtitle-layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
  pointer-events: none;
}

/* or the window background sits there as a bar between cues */
.subtitle-layer:empty {
  display: none;
}

.subtitle-cue {
  display: inline-block;
  padding: 0.1em 0.45em;
  border-radius: 3px;
  white-space: pre-wrap;
}

.subtitle-preview {
  position: relative;
  aspect-ratio: 16 / 7;
  margin-bottom: 18px;
  border-radius: 10px;
  overflow: hidden;
  container-type: inline-size;
  /* gradient, so you can see which edge styles survive over light and dark */
  background: linear-gradient(115deg, #1b2a4a 0%, #4a4030 45%, #d8d2c4 100%);
}


.video-detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rating-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: #272727;
  border-radius: 18px;
  overflow: hidden;
}

.rating-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 16px;
  font-size: 14px;
}

.rating-btn:hover:not(:disabled) { background: #3a3a3a; }
.rating-btn:disabled { opacity: 0.6; cursor: default; }
.rating-btn.active { color: var(--accent); }

.rating-count {
  font-size: 13px;
  font-weight: 600;
}

.rating-divider {
  width: 1px;
  align-self: stretch;
  margin: 6px 0;
  background: var(--border);
}

/* a proportion, not a control, so no height of its own */
.rating-ratio {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  background: #666;
}

.rating-ratio-fill {
  height: 100%;
  background: var(--text);
}


.video-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
}

.upload-date-relative { opacity: 0.75; }


.comments-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comments-sort {
  background: #121212;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 10px;
  font-size: 13px;
}

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

.comment-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}

.comment-badge {
  font-size: 11px;
  color: var(--text-dim);
  background: #272727;
  border-radius: 10px;
  padding: 1px 8px;
}

.comment-badge.owner { color: var(--text); background: #3a3a3a; }
.comment-badge.heart { color: var(--accent-strong); }

.comment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 0;
}

.link-btn:hover { color: var(--text); }

.comment-replies {
  margin-top: 10px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.comment.reply { margin-bottom: 12px; }
.comment.reply .comment-avatar { width: 26px; height: 26px; }
.comment.reply .text { font-size: 13px; }

.reply-form { margin: 10px 0 0; }
.reply-form input { font-size: 13px; }


.short-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(204, 0, 0, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}

/* letterbox the 9:16 frame instead of cropping it to nothing */
.thumb-wrap.short img { object-fit: contain; }

/* the feed is its own scroll container, main's column would fight it */
body[data-view="shorts"] main {
  padding: 0;
  max-width: none;
}

.shorts-feed {
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior-y: contain;
  /* always: stops a hard flick skipping several shorts at once */
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  outline: none;
}

.shorts-feed::-webkit-scrollbar { display: none; }

.short-slide {
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 0;
}

.short-stage {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  min-height: 0;
  flex: 1;
}

.short-slide .short-player {
  height: 100%;
  width: auto;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
}

.short-slide .short-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.short-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.short-poster.hidden { display: none; }

.short-play-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  border: none;
  background: rgba(0, 0, 0, 0.35);
}

.short-play-overlay::after {
  content: '▶';
  font-size: 46px;
  color: #fff;
  opacity: 0.9;
}

.short-play-overlay.hidden { display: none; }

.short-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
}

/* vertical, so like/dislike reads as part of the same column */
.short-side .rating-bar {
  flex-direction: column;
  border-radius: 22px;
}

.short-side .rating-btn { padding: 10px 12px; }
.short-side .rating-divider { width: auto; height: 1px; margin: 0 8px; align-self: stretch; }
.short-side .rating-ratio { display: none; }

.short-action {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #272727;
  color: var(--text);
  font-size: 18px;
}

.short-action:hover { background: #3a3a3a; }

.short-meta {
  width: min(460px, 92vw);
}

.short-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.shorts-sentinel { height: 1px; }


.settings-modal {
  max-width: 760px;
  padding: 20px 24px 24px;
}

.settings-title { margin: 0 0 16px; font-size: 18px; }

.settings-body {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
}

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

.settings-tab:hover { background: #232323; color: var(--text); }
.settings-tab.active { background: #2f2f2f; color: var(--text); font-weight: 600; }

.settings-panel {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
}

.setting-group { margin-bottom: 26px; }

.setting-group h4 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.setting-label { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }

.setting-select {
  background: #121212;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 150px;
}

.setting-toggle { width: 18px; height: 18px; accent-color: var(--accent); }

.setting-range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-range input[type="range"] { width: 130px; accent-color: var(--accent); }

.setting-readout {
  min-width: 46px;
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.setting-color {
  width: 38px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
}

.account-summary {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-summary img,
.account-avatar-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #333;
  flex-shrink: 0;
}

.account-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 22px;
}

.account-name { font-weight: 600; }

.account-channel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

.account-active-tag {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 1px 8px;
}

.player-menu-action {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 12px;
  text-align: left;
  padding: 2px 0;
}

@media (max-width: 640px) {
  .settings-body { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; position: static; }
}
