:root {
  --bg: #0c0e14;
  --sidebar: #11141c;
  --panel: #171b26;
  --panel-2: #1e2331;
  --line: #2a3040;
  --text: #f0f2f8;
  --muted: #98a1b5;
  --accent: #7c8cff;
  --accent-2: #ffb45c;
  --danger: #ff6b6b;
  --shadow: 0 14px 40px rgba(0, 0, 0, .38);
  --radius: 14px;
}

html[data-theme="light"] {
  --bg: #f5f6fa;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f2f8;
  --line: #dde2ec;
  --text: #1d2433;
  --muted: #6c768b;
  --accent: #4f5fd6;
  --accent-2: #d98324;
  --danger: #d64545;
  --shadow: 0 12px 32px rgba(30, 40, 70, .1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-size: 17px; letter-spacing: .3px; }
.brand b { color: var(--accent); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 16px; }

.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sidebar-foot .version { display: block; margin-top: 6px; opacity: .65; font-size: 11px; }

/* ---------- 主区域 ---------- */
.content { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 32px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px);
}
.search-box { display: flex; align-items: center; gap: 8px; width: min(380px, 60vw); padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.search-ico { color: var(--muted); font-size: 18px; line-height: 1; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 12px; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: #38c172; }
.status-dot.bad { background: var(--danger); }

.view { padding: 26px 32px 70px; }

/* ---------- 首页横幅 ---------- */
.hero {
  position: relative; border-radius: 18px; overflow: hidden;
  min-height: 300px; margin-bottom: 34px;
  background: linear-gradient(120deg, var(--panel-2), var(--panel));
  display: flex; align-items: flex-end;
  border: 1px solid var(--line);
}
.hero-bg { position: absolute; inset: -20px; background-size: cover; background-position: center; filter: blur(22px) brightness(.55); transform: scale(1.06); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8,10,16,.92), rgba(8,10,16,.35) 65%, transparent); }
html[data-theme="light"] .hero::after { background: linear-gradient(90deg, rgba(255,255,255,.94), rgba(255,255,255,.55) 65%, transparent); }
.hero-inner { position: relative; z-index: 2; padding: 34px; max-width: 620px; }
.hero-label { font-size: 11px; letter-spacing: 2px; color: var(--accent-2); text-transform: uppercase; }
.hero h1 { margin: 8px 0 10px; font-size: 30px; line-height: 1.25; }
.hero p { margin: 0 0 18px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-meta { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 18px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 17px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-weight: 600; text-decoration: none; transition: filter .15s, transform .08s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 6px 11px; font-size: 12px; font-weight: 500; }
.btn.danger { color: var(--danger); }

/* ---------- 行与卡片 ---------- */
.section { margin-bottom: 34px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head .more { color: var(--muted); font-size: 12px; background: none; border: 0; }

.row-cards { display: grid; grid-auto-flow: column; grid-auto-columns: 230px; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.poster { position: relative; aspect-ratio: 16 / 9; background: var(--panel-2); overflow: hidden; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-poster { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 12px; }
.chip { position: absolute; padding: 2px 7px; border-radius: 5px; background: rgba(8,10,16,.78); color: #fff; font-size: 11px; }
.chip.duration { right: 8px; bottom: 8px; }
.chip.fav { left: 8px; top: 8px; background: var(--accent-2); color: #1b1305; font-weight: 700; }
.play-btn { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); color: #1b1f2b; font-size: 17px; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.card:hover .play-btn { opacity: 1; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.22); }
.progress i { display: block; height: 100%; background: var(--accent); }
.card-body { padding: 10px 12px 12px; }
.card-title { margin: 0; font-size: 13.5px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.card-sub { margin-top: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { padding: 60px 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--text); margin: 0 0 8px; }

/* ---------- 媒体库页 ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.lib-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.lib-card h3 { margin: 0 0 4px; font-size: 17px; }
.lib-card .channel { color: var(--accent); font-size: 12px; }
.lib-card .numbers { display: flex; gap: 16px; margin: 14px 0; font-size: 12px; color: var(--muted); }
.lib-card .numbers b { display: block; color: var(--text); font-size: 18px; }
.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-chip { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 设置页 ---------- */
.settings-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1.2fr); gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-row label { font-size: 12px; color: var(--muted); }
.form-row input, .form-row textarea, .form-row select { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); outline: 0; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--accent); }
.form-row input[readonly] { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.diag { margin-top: 12px; padding: 12px; background: #11151f; color: #b9c2d6; border: 1px solid var(--line); border-radius: 8px; font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; max-height: 320px; overflow: auto; text-align: left; }
.lib-line { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.lib-line:last-child { border-bottom: 0; }

/* ---------- 详情弹层 ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(4,6,12,.72); display: grid; place-items: center; padding: 24px; backdrop-filter: blur(4px); }
.modal-inner { width: min(760px, 100%); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.modal-backdrop { height: 240px; background-size: cover; background-position: center; position: relative; }
.modal-backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent, var(--panel)); }
.modal-content { padding: 0 26px 26px; margin-top: -42px; position: relative; z-index: 2; }
.modal-content h2 { margin: 0 0 8px; font-size: 24px; }
.modal-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.modal-desc { color: var(--muted); line-height: 1.75; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.modal-close { position: absolute; right: 16px; top: 16px; z-index: 3; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(8,10,16,.65); color: #fff; font-size: 18px; }

/* ---------- 播放器 ---------- */
.player-overlay { position: fixed; inset: 0; z-index: 80; background: #05070b; display: flex; flex-direction: column; padding: 18px 24px 24px; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: #e8ebf5; margin-bottom: 14px; }
.player-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mode-tag { flex: none; font-size: 11px; padding: 3px 8px; border: 1px solid #3b4258; border-radius: 999px; color: #9fb0d0; }
.player-actions { display: flex; gap: 12px; align-items: center; }
.player-actions a, .player-actions button { background: #202535; color: #e8ebf5; border: 1px solid #333a4d; border-radius: 8px; padding: 7px 12px; text-decoration: none; font-size: 12px; cursor: pointer; }
.player-actions button:hover, .player-actions a:hover { border-color: #6f8fd0; }
#video { flex: 1; width: 100%; min-height: 0; background: #000; border-radius: 10px; }

.toast { position: fixed; z-index: 100; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 820px) {
  .sidebar { width: 64px; flex-basis: 64px; padding: 16px 8px; }
  .brand span:last-child, .nav-item span:not(.ico), .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .topbar, .view { padding-left: 16px; padding-right: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 23px; }
}
