/* AutoDL — dark video-site theme */
:root {
  --bg: #0f0f13;
  --bg2: #17171d;
  --bg3: #212129;
  --card: #1b1b22;
  --border: #2c2c36;
  --text: #f1f1f4;
  --muted: #9a9aa8;
  --accent: #ff2d55;
  --accent2: #ff5c7a;
  --live: #ff3b30;
  --new: #34c759;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-y: scroll;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg3);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
::placeholder { color: var(--muted); }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: rgba(15,15,19,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
#logo { font-size: 20px; font-weight: 800; letter-spacing: -.5px; display: flex; align-items: center; gap: 8px; }
#logo span:last-child { color: var(--accent); }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  color: #fff; font-size: 13px; padding-left: 2px;
}
#searchForm { flex: 1; max-width: 560px; margin: 0 auto; display: flex; }
#searchForm input {
  flex: 1; border-radius: 20px 0 0 20px; border-right: 0; background: var(--bg2); padding: 8px 16px;
}
#searchForm .icon-btn {
  border: 1px solid var(--border); border-radius: 0 20px 20px 0;
  background: var(--bg3); padding: 0 18px;
}
#topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.icon-btn { font-size: 16px; padding: 6px 10px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg3); }
.btn {
  padding: 8px 14px; border-radius: 8px; background: var(--bg3);
  border: 1px solid var(--border); font-weight: 600;
}
.btn:hover { background: #2a2a34; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent2); }
.btn.danger { color: #ff6b60; border-color: #5a2622; }
.btn.danger:hover { background: #3a1815; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.rec-badge {
  color: var(--live); font-weight: 700; font-size: 12.5px;
  border: 1px solid rgba(255,59,48,.4); background: rgba(255,59,48,.12);
  padding: 4px 10px; border-radius: 20px; animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- layout ---------- */
#layout { display: flex; min-height: calc(100vh - 56px); }
#sidebar {
  width: 220px; flex-shrink: 0; padding: 12px 8px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
#sidebar a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-radius: 10px; margin-bottom: 2px;
  color: var(--muted); font-weight: 500;
}
#sidebar a:hover { background: var(--bg2); color: var(--text); }
#sidebar a.active { background: var(--bg3); color: var(--text); font-weight: 700; }
.nav-ic { width: 20px; text-align: center; }
.nav-sep { border-top: 1px solid var(--border); margin: 10px 6px; }
.nav-head { padding: 4px 14px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.pill {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}
#main { flex: 1; padding: 20px 24px 60px; min-width: 0; }
body.nav-collapsed #sidebar { display: none; }

.hidden { display: none !important; }

/* ---------- sections & grids ---------- */
.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.section-head .more { color: var(--muted); font-size: 13px; font-weight: 600; }
.section-head .more:hover { color: var(--accent); }
.grid {
  display: grid; gap: 18px 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.empty {
  color: var(--muted); padding: 40px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.page-title { font-size: 24px; font-weight: 800; margin-bottom: 18px; letter-spacing: -.4px; display:flex; align-items:center; gap:12px; flex-wrap: wrap; }

/* ---------- video card ---------- */
.vcard { cursor: pointer; position: relative; }
.vcard .thumb {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius);
  overflow: hidden; background: var(--bg3);
}
.vcard .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.vcard:hover .thumb img { transform: scale(1.05); }
.vcard .no-thumb {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: var(--muted);
}
.dur {
  position: absolute; right: 6px; bottom: 6px;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 600;
  padding: 1px 6px; border-radius: 5px;
}
.badge-new {
  position: absolute; left: 6px; top: 6px;
  background: var(--new); color: #04220d; font-size: 11px; font-weight: 800;
  padding: 2px 8px; border-radius: 5px; letter-spacing: .5px;
}
.badge-live-src {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(255,59,48,.9); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
}
.vcard .vmeta { display: flex; gap: 10px; padding-top: 10px; }
.vcard .vtitle {
  font-weight: 600; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.vcard .vsub { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vcard .vsub a:hover { color: var(--text); }
.vcard .card-menu {
  position: absolute; right: 2px; top: calc(100% - 0px);
}
.vmeta-right { flex: 1; min-width: 0; position: relative; padding-right: 26px; }
.kebab {
  position: absolute; right: 0; top: 6px; color: var(--muted);
  padding: 2px 6px; border-radius: 6px; opacity: 0; font-weight: 700;
}
.vcard:hover .kebab { opacity: 1; }
.kebab:hover { background: var(--bg3); color: var(--text); }

/* service badge */
.svc {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
  font-size: 10px; font-weight: 800; color: #fff; vertical-align: -4px;
}
.svc svg { width: 12px; height: 12px; fill: currentColor; }
.svc.lg { width: 26px; height: 26px; border-radius: 7px; }
.svc.lg svg { width: 16px; height: 16px; }

/* creator avatar */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: linear-gradient(135deg, var(--bg3), #33333f);
  color: var(--text); font-weight: 800; flex-shrink: 0; border: 1px solid var(--border);
}

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  padding: 6px 14px; border-radius: 8px; background: var(--bg3);
  font-weight: 600; font-size: 13px; border: 1px solid transparent; color: var(--text);
}
.chip:hover { background: #2b2b36; }
.chip.active { background: var(--text); color: var(--bg); }

/* ---------- watch page ---------- */
.watch-wrap { display: flex; gap: 24px; align-items: flex-start; }
.watch-main { flex: 1; min-width: 0; }
.watch-side { width: 340px; flex-shrink: 0; }
@media (max-width: 1100px) { .watch-wrap { flex-direction: column; } .watch-side { width: 100%; } }
.player-shell {
  position: relative; background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16/9;
}
.player-shell video { width: 100%; height: 100%; display: block; background: #000; }
.watch-title { font-size: 20px; font-weight: 800; margin: 14px 0 6px; letter-spacing: -.3px; }
.watch-sub { display: flex; align-items: center; gap: 14px; color: var(--muted); flex-wrap: wrap; }
.watch-actions { margin-left: auto; display: flex; gap: 8px; }
.watch-creator {
  display: flex; align-items: center; gap: 12px; margin-top: 16px;
  padding: 12px 14px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
}
.kbd-hints { margin-top: 12px; color: var(--muted); font-size: 12.5px; }
.kbd-hints kbd {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 6px; font-size: 11px; font-family: inherit;
}
.side-list .vcard { display: flex; gap: 10px; margin-bottom: 12px; }
.side-list .vcard .thumb { width: 160px; flex-shrink: 0; }
.side-list .vcard .vmeta { padding-top: 0; flex: 1; min-width: 0; }
.seek-flash {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.7); color: #fff; font-size: 20px; font-weight: 700;
  padding: 14px 20px; border-radius: 50px; pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.seek-flash.left { left: 8%; } .seek-flash.right { right: 8%; }
.seek-flash.show { opacity: 1; }

/* ---------- ads ---------- */
.ad-slot {
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); overflow: hidden;
}
.ad-slot:empty { display: none; }
.ad-banner { margin: 0 0 20px; min-height: 0; }
.ad-side { margin-bottom: 16px; }
.ad-preroll-overlay {
  position: absolute; inset: 0; z-index: 5; background: #000;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
}

/* ---------- tables / rows (channels, activity) ---------- */
.rowcard {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.rowcard .row-main { flex: 1; min-width: 0; }
.rowcard .row-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rowcard .row-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow-wrap: anywhere; }
.rowcard .row-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 5px;
  background: var(--bg3); color: var(--muted);
}
.tag.on { background: rgba(52,199,89,.15); color: var(--new); }
.tag.live { background: rgba(255,59,48,.15); color: var(--live); }
.tag.err { background: rgba(255,159,10,.15); color: #ff9f0a; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.rec { background: var(--live); animation: pulse 1.2s infinite; }
.status-dot.idle { background: var(--muted); }
.progressbar { height: 4px; background: var(--bg3); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progressbar > div { height: 100%; background: var(--accent); transition: width .5s; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 520px; padding: 24px;
}
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal .form-row { margin-bottom: 14px; }
.modal label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.modal input[type=text], .modal input[type=url], .modal input[type=password],
.modal input[type=number], .modal select, .modal textarea { width: 100%; }
.modal .checks { display: flex; flex-direction: column; gap: 8px; }
.modal .checks label { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; font-weight: 500; margin: 0; cursor: pointer; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.check-desc { color: var(--muted); font-size: 12px; margin: -4px 0 0 26px; }

/* ---------- settings ---------- */
.settings-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; max-width: 760px;
}
.settings-card h3 { margin-bottom: 6px; }
.settings-card .desc { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.settings-grid label, .form-col label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.settings-grid input, .settings-grid select { width: 100%; }
.form-col { margin-bottom: 14px; }
.form-col input, .form-col textarea { width: 100%; }
.cred-row { display: grid; grid-template-columns: 140px 1fr 1fr 1fr 34px; gap: 8px; margin-bottom: 8px; align-items: center; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.switch input { width: auto; }

/* ---------- creator page ---------- */
.creator-hero {
  display: flex; align-items: center; gap: 20px; margin-bottom: 24px;
  padding: 24px; background: linear-gradient(120deg, var(--bg2), var(--bg3)); border-radius: 16px;
  border: 1px solid var(--border);
}
.creator-hero .avatar { width: 72px; height: 72px; font-size: 28px; }
.creator-hero h1 { font-size: 26px; letter-spacing: -.5px; }
.creator-hero .csub { color: var(--muted); margin-top: 4px; display: flex; gap: 10px; align-items: center; }

/* toasts */
#toastHost { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg3); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  animation: slidein .2s ease-out; max-width: 340px;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

@media (max-width: 800px) {
  #sidebar { display: none; }
  body.nav-open #sidebar { display: block; position: fixed; z-index: 60; background: var(--bg); border-right: 1px solid var(--border); }
  #searchForm { max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
