:root {
  --page-bg: #e6ebf2;
  --app-bg: #f8fbff;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;
  --blue-200: #bfdbfe;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --grad: linear-gradient(135deg, #2563eb, #1d4ed8);
  --shadow-soft: 0 0 30px rgba(15, 23, 42, .10);
  --shadow-btn: 0 8px 20px rgba(37, 99, 235, .22);
  --radius: 18px;
}

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

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 22px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 8px rgba(15, 23, 42, .04);
}

.tb-left, .tb-right { display: flex; align-items: center; gap: 6px; }
.tb-left { flex: none; }

.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 5px 16px rgba(37, 99, 235, .35);
}
.brand-name { font-family: Poppins, sans-serif; font-size: 20px; font-weight: 700; letter-spacing: .2px; color: var(--text); }
.brand-name span { color: var(--blue-600); }

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--blue-50); }

/* Search */
.tb-center { flex: 1; display: flex; justify-content: flex-end; padding: 0 0 0 16px; }
.search {
  display: flex;
  width: min(400px, 100%);
  height: 42px;
  border-radius: 21px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search:focus-within {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0 6px 0 18px;
  font-size: 14.5px;
  font-family: Inter, sans-serif;
  outline: none;
}
.search input::placeholder { color: var(--text-muted); }
.search button {
  width: 64px;
  flex: none;
  border: none;
  border-left: 1px solid var(--line-strong);
  background: #f1f5f9;
  color: var(--text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}
.search button:hover { background: var(--blue-50); color: var(--blue-600); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-300), var(--blue-600));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  margin-left: 4px;
}

/* ===== Layout ===== */
.layout {
  max-width: 1080px;
  margin: 18px auto 40px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  display: block;
}

.main-col { min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: 12px; }

/* ===== Player ===== */
.player-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .16);
  cursor: pointer;
}
.player-wrap video { width: 100%; height: 100%; object-fit: contain; background: #000; }

/* Big play — compact & elegant */
.big-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  color: #fff;
  background: rgba(15, 23, 42, .48);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .32), inset 0 0 0 1px rgba(255, 255, 255, .14);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .18s ease, opacity .2s ease, background .2s ease;
  z-index: 5;
}
.big-play svg { margin-left: 3px; }
.big-play:hover { transform: scale(1.06); background: rgba(37, 99, 235, .82); }
.big-play.hidden { opacity: 0; pointer-events: none; }

/* Tap-for-sound pill (shown when autoplay had to start muted) */
.unmute-pill {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: rgba(15, 23, 42, .82);
  color: #fff;
  font-family: Inter, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.unmute-pill:hover { background: var(--blue-600); }
.unmute-pill[hidden] { display: none; }

/* Double-tap seek / hold-to-2x hint */
.gesture-hint {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
  background: rgba(15, 23, 42, .38);
  border-radius: inherit;
  color: #fff;
  font-family: Inter, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
}
.gesture-hint[hidden] { display: none; }

/* Spinner */
.spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 5px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
.spinner.show { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Controls */
.controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 34px 14px 10px;
  background: linear-gradient(180deg, transparent, rgba(4,12,26,.9) 55%);
  opacity: 0;
  transition: opacity .25s ease;
  z-index: 7;
}
.player-wrap.show-controls .controls { opacity: 1; }
.player-wrap.idle .controls,
.player-wrap.idle .big-play { opacity: 0; pointer-events: none; }
.player-wrap.idle { cursor: none; }

.controls-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.ctl {
  border: none;
  background: transparent;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
  flex: none;
}
.ctl:hover { background: rgba(255,255,255,.14); }

.ctl .ic-pause, .player-wrap.playing .ctl .ic-play { display: none; }
.player-wrap.playing .ctl .ic-pause { display: block; }
.ctl .ic-mute, .player-wrap.muted .ctl .ic-vol { display: none; }
.player-wrap.muted .ctl .ic-mute { display: block; }
.ctl .ic-exitfull { display: none; }
.player-wrap.is-full .ctl .ic-full { display: none; }
.player-wrap.is-full .ctl .ic-exitfull { display: block; }

.vol-group { display: flex; align-items: center; gap: 2px; }
.volume {
  width: 0; opacity: 0;
  transition: width .2s ease, opacity .2s ease;
  accent-color: var(--blue-600);
  cursor: pointer;
}
.vol-group:hover .volume { width: 88px; opacity: 1; }

.time { font-size: 13px; color: #e6efff; font-variant-numeric: tabular-nums; margin-left: 6px; white-space: nowrap; }
.spacer { flex: 1; }
.speed-label { font-size: 13px; font-weight: 700; min-width: 30px; }
.quality-label { font-size: 13px; font-weight: 700; padding: 0 6px; }
.quality-label.auto { color: var(--blue-200); }

/* Progress */
.progress { position: relative; height: 14px; cursor: pointer; }
.progress-buffer, .progress-played {
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  height: 4px; border-radius: 2px; pointer-events: none;
  transition: height .15s ease;
}
.progress:hover .progress-buffer, .progress:hover .progress-played { height: 6px; }
.progress-buffer { width: 0; background: rgba(255,255,255,.3); }
.progress-played { width: 0; background: var(--blue-600); }

.progress-scrub {
  position: absolute; left: 0; top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.scrub-dot {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .3);
  opacity: 0; transition: opacity .15s ease;
}
.progress:hover .scrub-dot { opacity: 1; }

.seek {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; margin: 0;
}

/* Menus */
.menu {
  position: absolute;
  right: 10px; bottom: 64px;
  min-width: 150px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .18);
  padding: 6px;
  z-index: 10;
}
.menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  border: none; background: transparent;
  color: var(--text); font-size: 13.5px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--blue-50); }
.menu button.active { color: var(--blue-600); font-weight: 600; }
.menu .check { margin-left: auto; color: var(--blue-600); visibility: hidden; }
.menu button.active .check { visibility: visible; }

/* ===== Video info (below player) ===== */
.video-title {
  font-family: Poppins, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  margin: 16px 2px 6px;
  color: var(--text);
}

.video-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--text-dim);
  margin: 0 2px 12px;
}
.video-meta .views { font-weight: 600; color: var(--text); }
.video-meta .dot { opacity: .7; }

.video-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.owner { display: flex; align-items: center; gap: 12px; }
.owner-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--grad);
  display: grid; place-items: center;
  font-family: Poppins, sans-serif;
  font-weight: 600; color: #fff;
}
.owner-name { font-family: Poppins, sans-serif; font-weight: 600; font-size: 14.5px; color: var(--text); }
.owner-subs { font-size: 12.5px; color: var(--text-dim); }

.subscribe {
  margin-left: 8px;
  border: none;
  background: #fff;
  color: #0a1830;
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease;
}
.subscribe:hover { background: var(--blue-200); }
.subscribe.on { background: var(--surface-3); color: var(--blue-200); }

.actions { display: flex; align-items: center; gap: 4px; }
.action-btn {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text); font-size: 13.5px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.action-btn:hover { background: var(--blue-50); border-color: var(--blue-100); }
.action-btn.liked { color: var(--blue-600); background: var(--blue-50); border-color: var(--blue-100); }
.action-btn.liked svg { color: var(--blue-600); }

.description {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  color: var(--blue-100);
}

/* ===== Sidebar ===== */
.sidebar-title { font-size: 15.5px; font-weight: 700; margin: 4px 2px 2px; }

.suggestion {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  transition: background .15s ease;
}
.suggestion:hover { background: rgba(46, 126, 232, .12); }

.thumb {
  position: relative;
  flex: 0 0 168px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur {
  position: absolute; right: 5px; bottom: 5px;
  background: rgba(0,0,0,.8);
  color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 5px;
}

.sug-info { min-width: 0; }
.sug-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sug-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.empty { color: var(--text-dim); font-size: 13.5px; padding: 8px; }

/* Fullscreen: fill the screen, keep video letterboxed */
.player-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  background: #000;
}
.player-wrap:fullscreen video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ===== Quality suggestion modal ===== */
.quality-modal {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
}
.quality-modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
}
.modal-card {
  position: relative;
  width: min(360px, 84%);
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .35);
  text-align: center;
}
.modal-card h3 {
  font-family: Poppins, sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.modal-card p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
  margin-bottom: 18px;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: Inter, sans-serif;
  transition: filter .15s ease, background .15s ease;
}
.modal-btn.ghost { background: #f1f5f9; color: var(--text); }
.modal-btn.ghost:hover { background: #e2e8f0; }
.modal-btn.primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-btn); }
.modal-btn.primary:hover { filter: brightness(1.08); }

/* ===== Search toast ===== */
.search-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--text);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .28);
  max-width: 90vw;
  text-align: center;
}
.search-toast[hidden] { display: none; }

/* ===== Responsive ===== */
@media (max-width: 1080px) {
  .layout { margin: 12px 12px 32px; padding: 12px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .tb-center { flex: 1; min-width: 0; padding-left: 6px; }
  .search { width: 100%; height: 40px; }
  .search button { width: 48px; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-name { font-size: 16px; }
}

/* ===== Mobile phones ===== */
@media (max-width: 600px) {
  .controls { padding: 24px 6px 6px; }
  .controls-row { gap: 2px; margin-top: 6px; }
  .ctl { width: 44px; height: 44px; }
  .time { font-size: 11.5px; margin-left: 2px; }
  #pipBtn { display: none; }
  .vol-group .volume { display: none; }
  .speed-label, .quality-label { font-size: 12px; }
  .big-play { width: 56px; height: 56px; }
}
