:root {
  --bg: #0f0f0f;
  --bg-soft: #181818;
  --bg-muted: #202020;
  --border: #2b2b2b;
  --text: #ffffff;
  --text-soft: #b7b7b7;
  --text-muted: #8d8d8d;
  --input: #121212;
  --danger: #ff0000;
  --chip: #272727;
  --shadow: rgba(0,0,0,.25);
}

body.theme-light {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --bg-muted: #f1f3f8;
  --border: #dde2ee;
  --text: #16181d;
  --text-soft: #465063;
  --text-muted: #6f7b90;
  --input: #ffffff;
  --danger: #ff0000;
  --chip: #eef1f7;
  --shadow: rgba(16,24,40,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button, input, textarea, select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: bold;
  font-size: 22px;
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ff0000, #cc0000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(255,0,0,.25);
}
.search-box {
  width: 42%;
  display: flex;
  align-items: center;
}
.search-box input {
  flex: 1;
  height: 42px;
  background: var(--input);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text);
  padding: 0 14px;
  border-radius: 999px 0 0 999px;
  outline: none;
}
.search-box button {
  width: 62px;
  height: 42px;
  background: var(--chip);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0 999px 999px 0;
  cursor: pointer;
}
.profile-group { display: flex; align-items: center; gap: 10px; }
.profile-chip, .theme-toggle {
  background: var(--chip);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.theme-toggle { cursor: pointer; }
.page {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  padding: 24px;
  max-width: 1500px;
  margin: auto;
}
.main-card, .side-card, .post-card, .admin-card, .form-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 30px var(--shadow);
}
.player-wrap {
  aspect-ratio: 16/9;
  width: 100%;
  background: linear-gradient(135deg, #1e1e1e, #101010);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.theme-light .player-wrap {
  background: linear-gradient(135deg, #dde6f7, #bccae7);
}
#liveVideo {
  width: 100%;
  height: 100%;
  background: #000;
}
.live-badge {
  position: absolute;
  top: 18px;
  left: 18px;
  background: var(--danger);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .5px;
  z-index: 5;
}
.play-circle {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  backdrop-filter: blur(4px);
  position: absolute;
  z-index: 4;
  pointer-events: none;
}
.channel-info { padding: 22px; }
.title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.title-row h1 { font-size: 28px; line-height: 1.25; margin-bottom: 8px; }
.meta, .muted { color: var(--text-muted); font-size: 14px; }
.watch-btn, .btn-primary, .btn-danger, .btn-secondary, .btn-success {
  border: none;
  display: inline-block;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: bold;
  white-space: nowrap;
  cursor: pointer;
}
.watch-btn, .btn-primary { background: #fff; color: #000; }
.btn-danger { background: #f04438; color: #fff; }
.btn-secondary { background: var(--chip); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: #12b76a; color: #fff; }
.channel-box {
  margin-top: 16px;
  background: var(--bg-muted);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
.channel-left { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff4d4d, #8b0000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
.subscribe { background: #ff0000; color: #fff; border-radius: 999px; padding: 12px 18px; font-weight: bold; }
.posts-section { margin-top: 24px; }
.section-title { font-size: 22px; margin-bottom: 16px; }
.posts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.post-thumb {
  height: 180px;
  background: linear-gradient(135deg, #363636, #1b1b1b);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 14px;
  overflow: hidden;
}
body.theme-light .post-thumb,
body.theme-light .video-thumb { background: linear-gradient(135deg, #e6edf8, #cad7ec); color: #52607a; }
.post-thumb img, .logo-preview { width: 100%; height: 100%; object-fit: cover; }
.post-content { padding: 16px; }
.post-content h3 { font-size: 18px; margin-bottom: 10px; line-height: 1.35; }
.post-content p { color: var(--text-soft); font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.post-meta { font-size: 13px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
}
.badge-paid { background: rgba(255,174,0,.15); color: #ffb020; border-color: rgba(255,174,0,.3); }
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.side-card { padding: 14px; }
.side-title { font-size: 18px; margin-bottom: 14px; }
.video-item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  margin-bottom: 14px;
  align-items: start;
}
.video-thumb {
  height: 74px;
  border-radius: 12px;
  background: linear-gradient(135deg, #393939, #1c1c1c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #aaa;
  overflow: hidden;
}
.video-text h4 { font-size: 14px; line-height: 1.35; margin-bottom: 6px; }
.video-text span { display: block; color: var(--text-muted); font-size: 12px; line-height: 1.4; }
.note-box {
  background: var(--bg-muted);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 14px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}
.container-admin { max-width: 1250px; margin: 24px auto; padding: 0 20px; }
.admin-grid { display: grid; grid-template-columns: 240px 1fr; gap: 20px; }
.admin-sidebar, .admin-main { min-width: 0; }
.admin-menu { padding: 18px; display: grid; gap: 10px; }
.admin-menu a {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text-soft);
}
.admin-menu a.active, .admin-menu a:hover { background: var(--bg-muted); border-color: var(--border); color: var(--text); }
.admin-card { padding: 20px; }
.admin-card h2 { margin-bottom: 12px; font-size: 24px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.stat-box { background: var(--bg-muted); border: 1px solid var(--border); padding: 16px; border-radius: 16px; }
.stat-box strong { font-size: 28px; display: block; margin-top: 8px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 700; }
input[type="text"], input[type="url"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
textarea { min-height: 140px; resize: vertical; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.alert-success { background: rgba(18,183,106,.12); color: #63d89a; }
.alert-error { background: rgba(240,68,56,.12); color: #ff8b84; }
.login-wrap { max-width: 460px; margin: 70px auto; padding: 0 16px; }
.login-card { padding: 24px; }
.footer-space { height: 24px; }
.single-post { max-width: 980px; margin: 24px auto; padding: 0 20px; }
.single-post .post-card { overflow: visible; }
.single-post .post-content { padding: 22px; }
.content-html p { margin-bottom: 16px; color: var(--text-soft); line-height: 1.8; }
.content-html h2, .content-html h3 { margin: 18px 0 12px; }

@media (max-width: 1100px) {
  .page { grid-template-columns: 1fr; }
  .search-box { width: 50%; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; height: auto; gap: 12px; padding: 14px; }
  .search-box, .profile-group { width: 100%; }
  .profile-group { justify-content: space-between; }
  .page { padding: 14px; }
  .posts-grid, .stats, .form-grid { grid-template-columns: 1fr; }
  .title-row, .channel-box { flex-direction: column; align-items: flex-start; }
  .container-admin { padding: 0 14px; }
}

.header-spacer { flex: 1; }
.sponsor-slot { min-width: 300px; max-width: 360px; width: 100%; }
.sponsor-panel {
  display: grid;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.sponsor-panel strong { font-size: 16px; line-height: 1.35; }
.sponsor-panel small { color: var(--text-soft); line-height: 1.5; }
.sponsor-empty { opacity: .95; }
.badge-red { background: rgba(255,59,48,.14); color: #ff6258; border-color: rgba(255,59,48,.35); }
.badge-blue { background: rgba(10,132,255,.14); color: #4ea0ff; border-color: rgba(10,132,255,.35); }
.badge-green { background: rgba(52,199,89,.14); color: #3fd96d; border-color: rgba(52,199,89,.35); }
.badge-orange { background: rgba(255,159,10,.14); color: #ffb547; border-color: rgba(255,159,10,.35); }
.badge-purple { background: rgba(191,90,242,.14); color: #d07bff; border-color: rgba(191,90,242,.35); }
.badge-pink { background: rgba(255,55,95,.14); color: #ff6d93; border-color: rgba(255,55,95,.35); }
.site-footer {
  margin-top: 26px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.site-footer-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 26px 24px 36px;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 22px;
}
.site-footer h3 { font-size: 22px; margin-bottom: 12px; }
.site-footer p { color: var(--text-soft); line-height: 1.7; }
.footer-contact-block {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.footer-contact { font-weight: 700; }
.footer-note { color: var(--text-muted); }
.content-html { line-height: 1.8; color: var(--text); }
.content-html p { margin-bottom: 12px; }
@media (max-width: 1100px) {
  .search-box { width: 50%; }
}
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    gap: 12px;
    padding: 14px;
  }
  .search-box { width: 100%; }
  .header-spacer { display: none; }
  .page { grid-template-columns: 1fr; padding: 14px; }
  .posts-grid { grid-template-columns: 1fr; }
  .title-row { flex-direction: column; align-items: flex-start; }
  .channel-box { flex-direction: column; align-items: stretch; }
  .sponsor-slot { min-width: 100%; max-width: none; }
  .admin-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .site-footer-inner { grid-template-columns: 1fr; padding: 20px 14px 28px; }
}

.stats-four { grid-template-columns: repeat(4, 1fr); }
.vod-section { margin-bottom: 24px; }
@media (max-width: 768px) { .stats-four { grid-template-columns: 1fr; } }

.no-sidebar { grid-template-columns: 1fr; }
.groupbox {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
  background: var(--bg-muted);
}
.groupbox legend {
  padding: 0 10px;
  font-weight: 700;
  color: var(--text);
}
.checkbox-field { align-content: end; }
.read-box {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 48px;
  word-break: break-all;
}
.compact-grid .field { margin-bottom: 0; }
.tips-list { display: grid; gap: 12px; margin-top: 14px; }
.tip-item {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text-soft);
  line-height: 1.6;
}
.avatar {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  flex: 0 0 64px;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
}
.mini-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.sponsor-empty { min-height: 128px; background: #000; border-color: #111; box-shadow: inset 0 0 0 1px rgba(255,255,255,.02); }
body.theme-light .sponsor-empty { background: var(--bg-muted); border-color: var(--border); }
@media (max-width: 768px) {
  .avatar {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    flex-basis: 56px;
  }
}

.player-notice {
  position: absolute;
  inset: 18px auto auto 18px;
  max-width: 440px;
  z-index: 8;
  background: rgba(0,0,0,.86);
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 10px;
}
.player-notice p { color: rgba(255,255,255,.82); line-height: 1.6; }
.player-notice[hidden] { display: none !important; }
.player-reconnect-btn { width: fit-content; }
.ad-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.56);
  padding: 22px;
}
.ad-overlay-card {
  width: min(100%, 760px);
  background: rgba(15,15,15,.96);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  position: relative;
}
.ad-media-link { display:block; }
.ad-media {
  display:block;
  width:100%;
  max-height:60vh;
  object-fit:cover;
  background:#000;
}
.ad-caption-row {
  display:flex;
  gap:16px;
  justify-content:space-between;
  align-items:center;
  padding:16px;
}
.ad-caption-row p { color: var(--text-soft); margin-top: 6px; line-height: 1.6; }
.ad-timer, .ad-skip {
  position:absolute;
  top:12px;
  padding:8px 12px;
  border-radius:999px;
  background: rgba(0,0,0,.74);
  color:#fff;
  border:1px solid rgba(255,255,255,.12);
  z-index:2;
}
.ad-timer { left:12px; }
.ad-skip { right:12px; cursor:pointer; }
@media (max-width:768px) {
  .ad-overlay { padding: 12px; }
  .ad-caption-row { flex-direction: column; align-items: stretch; }
  .player-notice { right: 18px; max-width: none; }
}

/* Mobile hardening for admin panel */
.admin-main,
.admin-card,
.form-card,
.groupbox,
.form-grid,
.field,
.table-wrap,
.actions,
.profile-group,
.search-box,
.single-post,
.page,
.container-admin {
  min-width: 0;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
  max-width: 100%;
  min-width: 0;
}

.field input,
.field textarea,
.field select,
.groupbox .field,
.groupbox .read-box {
  width: 100%;
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .admin-card,
  .form-card {
    padding: 14px;
  }

  .groupbox {
    padding: 14px;
    margin-bottom: 14px;
  }

  .groupbox legend {
    font-size: 15px;
    padding: 0 6px;
  }

  .field {
    margin-bottom: 12px;
  }

  label {
    font-size: 14px;
    line-height: 1.4;
  }

  input[type="text"],
  input[type="url"],
  input[type="password"],
  input[type="number"],
  input[type="datetime-local"],
  input[type="file"],
  textarea,
  select {
    padding: 11px 12px;
    font-size: 16px;
  }

  th, td {
    white-space: normal;
    word-break: break-word;
  }

  .actions > a,
  .actions > button,
  .actions > input {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .profile-group {
    flex-wrap: wrap;
  }

  .profile-group .profile-chip,
  .profile-group .theme-toggle {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }
}
