/* PcRCTUBE - faithful YouTube dark theme */
:root {
  --bg: #0f0f0f;
  --surface: #212121;
  --surface-2: #303030;
  --hover: #3d3d3d;
  --text: #f1f1f1;
  --text-2: #aaaaaa;
  --accent: #ff0000;
  --chip: #272727;
  --chip-active: #f1f1f1;
  --border: #3f3f3f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  overflow-y: scroll;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Masthead ---------- */
#masthead {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.mh-left { display: flex; align-items: center; gap: 16px; min-width: 170px; }
#btn-guide {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: transparent; color: var(--text); font-size: 18px;
}
#btn-guide:hover { background: var(--hover); }
.logo { display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.logo-icon {
  width: 30px; height: 21px; background: var(--accent); border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
.logo-icon::after {
  content: ""; border-left: 9px solid #fff; border-top: 5px solid transparent;
  border-bottom: 5px solid transparent; margin-left: 2px;
}
.logo-text { font-size: 19px; font-weight: 700; letter-spacing: -1px; }
.logo-text sup { font-size: 9px; color: var(--text-2); font-weight: 400; margin-left: 2px; letter-spacing: 0; }

.mh-center { flex: 0 1 640px; display: flex; align-items: center; }
.searchbox { flex: 1; display: flex; }
.searchbox input {
  flex: 1; height: 40px; padding: 0 16px;
  background: #121212; color: var(--text);
  border: 1px solid var(--border); border-right: none;
  border-radius: 40px 0 0 40px; font-size: 16px; outline: none;
}
.searchbox input:focus { border-color: #1c62b9; }
.searchbox button {
  width: 64px; height: 40px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  border-radius: 0 40px 40px 0; cursor: pointer; font-size: 16px;
}
.searchbox button:hover { background: var(--hover); }

.mh-right { display: flex; align-items: center; gap: 8px; min-width: 120px; justify-content: flex-end; }
.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: #7c4dff; color: #fff; font-weight: 500; font-size: 15px;
}

/* ---------- Sidebar ---------- */
#guide {
  position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 90;
  background: var(--bg); overflow-y: auto; padding: 12px;
  transition: transform .15s ease;
}
#guide.collapsed { width: 72px; padding: 4px; }
body.watch-mode #guide { transform: translateX(-100%); }
.g-item {
  display: flex; align-items: center; gap: 24px;
  padding: 0 12px; height: 40px; border-radius: 10px; cursor: pointer;
  color: var(--text); font-size: 14px; white-space: nowrap; overflow: hidden;
}
.g-item:hover { background: var(--surface); }
.g-item.active { background: var(--surface); font-weight: 500; }
.g-item .gi { font-size: 18px; width: 24px; text-align: center; flex: none; }
#guide.collapsed .g-item {
  flex-direction: column; gap: 6px; height: 74px; justify-content: center;
  font-size: 10px; padding: 0 2px;
}
#guide.collapsed .g-sep, #guide.collapsed .g-head { display: none; }
.g-sep { border-top: 1px solid var(--border); margin: 12px 0; }
.g-head { padding: 6px 12px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.g-item .sub-dot { width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 500; }

/* ---------- Chips ---------- */
#chipbar {
  position: fixed; top: 56px; right: 0; z-index: 80;
  left: 240px; padding: 8px 24px 12px;
  background: var(--bg);
  display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none;
}
#chipbar::-webkit-scrollbar { display: none; }
body.guide-collapsed #chipbar { left: 72px; }
body.watch-mode #chipbar { display: none; }
.chip {
  background: var(--chip); color: var(--text); border: none; cursor: pointer;
  height: 32px; padding: 0 12px; border-radius: 8px; font-size: 14px; white-space: nowrap;
}
.chip:hover { background: var(--hover); }
.chip.active { background: var(--chip-active); color: var(--bg); font-weight: 500; }

/* ---------- Layout ---------- */
#content { margin: 112px 0 0 240px; padding: 8px 24px 48px; }
body.guide-collapsed #content { margin-left: 72px; }
body.watch-mode #content { margin: 80px 0 0 0; }

/* ---------- Video grid ---------- */
.grid {
  display: grid; gap: 40px 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.vcard { cursor: pointer; }
/* Visible focus ring for D-pad / keyboard navigation (Fire TV remote). */
.vcard:focus, .un-item:focus { outline: none; }
.vcard:focus-visible, .vcard:focus { outline: 3px solid #3ea6ff; outline-offset: 3px; border-radius: 12px; }
.un-item:focus-visible, .un-item:focus { outline: 3px solid #3ea6ff; outline-offset: 2px; border-radius: 8px; }
.thumb-wrap { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; background: #000; }
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard:hover .thumb-wrap { border-radius: 0; }
.duration {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 500;
  padding: 2px 5px; border-radius: 4px;
}
.vmeta { display: flex; gap: 12px; margin-top: 12px; }
.ch-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 500; font-size: 15px;
}
.vtitle {
  font-size: 16px; font-weight: 500; line-height: 1.4; max-height: 44px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.vsub { color: var(--text-2); font-size: 14px; margin-top: 4px; line-height: 1.4; }
.section-title { font-size: 20px; font-weight: 700; margin: 8px 0 20px; display: flex; align-items: center; justify-content: space-between; }
.btn-plain {
  background: var(--surface-2); border: none; color: var(--text); cursor: pointer;
  height: 36px; padding: 0 16px; border-radius: 18px; font-size: 14px;
}
.btn-plain:hover { background: var(--hover); }
.empty-note { color: var(--text-2); padding: 40px 0; text-align: center; font-size: 15px; }

/* ---------- Watch page ---------- */
.watch-layout { display: flex; gap: 24px; max-width: 1750px; margin: 0 auto; }
.watch-main { flex: 1; min-width: 0; }
.player-wrap { aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.player-wrap iframe { width: 100%; height: 100%; border: none; display: block; }
.player-shrink {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1;
  display: none;
}
.player-shrink:hover { background: rgba(0,0,0,.85); }
/* Maximized (full-view) player: a big centred 16:9 video on a black backdrop.
   The black margin around the video is a "rest zone" - moving the cursor off
   the video onto it makes YouTube hide its controls instantly (native), the
   same as the small player. Exit via X / Esc / back. */
.player-wrap.maxd {
  position: fixed; inset: 0; z-index: 1500; border-radius: 0; aspect-ratio: auto;
  width: 100vw; height: 100vh; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.player-wrap.maxd iframe {
  width: min(100vw, 177.78vh);
  height: min(56.25vw, 100vh);
}
.player-wrap.maxd .player-shrink { display: block; }
body.player-maxd { overflow: hidden; }
/* Real browser fullscreen: the player-wrap itself becomes the fullscreen root,
   so the iframe fills the screen on black and the X button stays reachable. */
.player-wrap:fullscreen { width: 100vw; height: 100vh; border-radius: 0; aspect-ratio: auto; background: #000; }
.player-wrap:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; background: #000; }
.player-wrap:fullscreen iframe, .player-wrap:-webkit-full-screen iframe { width: 100%; height: 100%; }
.player-wrap:fullscreen .player-shrink, .player-wrap:-webkit-full-screen .player-shrink { display: block; }
.watch-title { font-size: 20px; font-weight: 700; margin: 14px 0 10px; line-height: 1.35; }
.watch-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.watch-ch { display: flex; align-items: center; gap: 12px; }
.watch-ch .ch-avatar { width: 40px; height: 40px; }
.ch-name { font-weight: 500; font-size: 16px; }
.ch-subs { color: var(--text-2); font-size: 12px; }
.btn-sub {
  background: #f1f1f1; color: #0f0f0f; border: none; cursor: pointer;
  height: 36px; padding: 0 16px; border-radius: 18px; font-size: 14px; font-weight: 500; margin-left: 12px;
}
.btn-sub.subbed { background: var(--surface-2); color: var(--text); }
.actions { display: flex; gap: 8px; }
.pillgroup { display: flex; }
.pillgroup .btn-plain:first-child { border-radius: 18px 0 0 18px; border-right: 1px solid var(--border); }
.pillgroup .btn-plain:last-child { border-radius: 0 18px 18px 0; }
.btn-plain.liked { color: #3ea6ff; font-weight: 500; }
.descbox {
  background: var(--surface); border-radius: 12px; padding: 12px; margin-top: 16px;
  font-size: 14px; line-height: 1.5; cursor: pointer;
}
.descbox .d-stats { font-weight: 500; margin-bottom: 6px; }
.descbox .d-tags { color: #3ea6ff; margin-top: 6px; }
.upnext { width: 402px; flex: none; }
.upnext-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.un-item { display: flex; gap: 8px; margin-bottom: 8px; cursor: pointer; border-radius: 10px; padding: 4px; }
.un-item:hover { background: var(--surface); }
.un-thumb { position: relative; width: 168px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; flex: none; background: #000; }
.un-thumb img { width: 100%; height: 100%; object-fit: cover; }
.un-title { font-size: 14px; font-weight: 500; line-height: 1.35; max-height: 38px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.un-sub { color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* ---------- auth screens ---------- */
body.auth-screen #guide,
body.auth-screen #chipbar,
body.auth-screen .mh-center,
body.auth-screen .mh-left,
body.auth-screen .mh-right { display: none; }

.logo-img { height: 32px; width: auto; display: block; border-radius: 6px; }
body.auth-screen #content { margin: 56px 0 0 0; padding: 0; }

.auth-wrap { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.auth-logo { display: flex; align-items: center; gap: 6px; justify-content: center; margin-bottom: 20px; }
.auth-logo .logo-text { font-size: 22px; font-weight: 700; letter-spacing: -1px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab { flex: 1; height: 38px; border: none; border-radius: 8px; background: var(--chip); color: var(--text); cursor: pointer; font-size: 14px; }
.auth-tab.active { background: var(--accent); color: #fff; font-weight: 500; }
.auth-label { display: block; font-size: 12px; color: var(--text-2); margin: 12px 0 6px; }
.auth-input { width: 100%; height: 40px; padding: 0 12px; background: #121212; color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 15px; outline: none; }
.auth-input:focus { border-color: #3ea6ff; }
.auth-submit { width: 100%; height: 42px; margin-top: 20px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 500; cursor: pointer; }
.auth-submit:hover { background: #cc0000; }
.auth-submit:disabled { opacity: .6; cursor: default; }
.auth-err { color: #ff6b6b; font-size: 13px; min-height: 18px; margin-top: 10px; }
.auth-hint { color: var(--text-2); font-size: 12px; margin-top: 14px; line-height: 1.5; }
.auth-title { margin-bottom: 10px; }
.auth-msg { color: var(--text-2); line-height: 1.6; margin-bottom: 20px; }

/* ---------- admin panel ---------- */
.mh-link { background: transparent; border: 1px solid var(--border); color: var(--text); height: 32px; padding: 0 14px; border-radius: 18px; cursor: pointer; font-size: 14px; margin-right: 8px; }
.mh-link:hover { background: var(--hover); }
.admin-h { margin: 24px 0 12px; font-size: 16px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.admin-table th { color: var(--text-2); font-weight: 500; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-act { height: 30px; padding: 0 12px; font-size: 13px; }
.admin-act.danger { color: #ff6b6b; }
.tag-ok { color: #16e08a; } .tag-pending { color: #ffce54; } .tag-admin { color: #3ea6ff; }
.tag-you, .tag-admin, .tag-ok, .tag-pending { font-size: 12px; }
.tag-you { color: var(--text-2); }

@media (max-width: 1100px) {
  .watch-layout { flex-direction: column; }
  .upnext { width: 100%; }
}
@media (max-width: 800px) {
  #guide { display: none; }
  #content, #chipbar { margin-left: 0 !important; left: 0 !important; }
}

/* ---------- Recommendation + Saved ---------- */
.title-note { font-size: 13px; font-weight: 400; color: var(--text-2); }
/* overlay buttons on a card thumbnail (Save floppy, Remove x) */
.card-save, .card-remove {
  position: absolute; top: 8px; width: 32px; height: 32px; border: none; cursor: pointer;
  border-radius: 8px; background: rgba(0,0,0,.72); color: #fff; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0; opacity: .92;
  transition: background .15s, transform .1s;
}
.card-save { right: 8px; }
.card-remove { left: 8px; font-size: 14px; }
.card-save:hover, .card-remove:hover { transform: scale(1.08); }
.card-save:hover { background: rgba(0,0,0,.92); }
.card-save.on { background: #3ea6ff; color: #fff; opacity: 1; }
.card-remove:hover { background: #cc0000; }
.card-save.busy, .card-remove.busy { opacity: .5; cursor: default; }
.rec-by { color: var(--text-2); font-size: 12px; margin-top: 4px; }
/* watch-page Recommend / Save active state */
.btn-plain.rec-on { color: #3ea6ff; font-weight: 500; }
.btn-plain:disabled { opacity: .7; cursor: default; }
/* remember-me checkbox on the sign-in card */
.auth-remember { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--text-2); font-size: 13px; cursor: pointer; user-select: none; }
.auth-remember input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
/* transient toast (used by the in-app self-update gesture) */
.app-toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: #303030; color: #f1f1f1; padding: 12px 20px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 2px 12px rgba(0,0,0,.5); z-index: 9999;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 80%;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
