:root {
  --bg: #0a0a14;
  --bg-soft: #14141f;
  --card: #1a1a26;
  --line: #2a2a3a;
  --text: #f1f1f5;
  --muted: #8a8a99;
  --accent: #a78bfa;        /* 紫色 */
  --accent-2: #7c3aed;
  --pill: rgba(167,139,250,.15);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
/* 没有顶部栏的页面（热剧/收藏/搜索/设置/详情）把内容下移到状态栏/灵动岛之下 */
body.no-topbar { padding-top: env(safe-area-inset-top); }
button { font-family: inherit; color: inherit; }
input, button { outline: none; }
a { color: inherit; text-decoration: none; }
img { display: block; }

/* 顶部光晕 */
.bg-glow {
  position: fixed; inset: -40% -20% auto -20%;
  height: 60vh;
  background: radial-gradient(60% 60% at 70% 0%, rgba(255,160,80,.55) 0%, rgba(255,90,120,.25) 35%, rgba(120,80,200,.15) 60%, transparent 75%);
  filter: blur(40px);
  z-index: -1;
  pointer-events: none;
}

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  backdrop-filter: blur(8px);
}
.tabs {
  display: flex; gap: 18px; flex: 1;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: transparent; border: 0; padding: 6px 0;
  font-size: 18px; font-weight: 600; color: var(--muted);
  position: relative; white-space: nowrap; cursor: pointer;
}
.tabs button.active { color: var(--text); }
.tabs button.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px;
  height: 3px; background: var(--accent); border-radius: 3px;
}
.search-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--pill); color: var(--accent);
  border: 0; border-radius: 999px; padding: 8px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.search-btn:active { transform: scale(.97); }

/* 搜索条 */
.search-bar {
  display: flex; gap: 8px; padding: 0 16px 12px;
}
.search-bar.hidden { display: none; }
.search-bar input {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; color: var(--text); font-size: 15px;
}
.search-bar button {
  border: 0; border-radius: 12px; padding: 0 14px; cursor: pointer;
  background: var(--accent-2); color: white; font-weight: 600;
}
.search-bar button.ghost { background: transparent; color: var(--muted); }

/* 网格 */
.grid {
  display: grid; gap: 14px 12px;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px 16px 16px;
}
@media (min-width: 720px)  { .grid { grid-template-columns: repeat(4,1fr); } }
@media (min-width: 980px)  { .grid { grid-template-columns: repeat(5,1fr); } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(6,1fr); } }

.card { cursor: pointer; }
.card .poster {
  aspect-ratio: 3/4; border-radius: 14px; overflow: hidden;
  background: var(--card); position: relative;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.card .poster img { width: 100%; height: 100%; object-fit: cover; }
.card .poster .badge {
  position: absolute; left: 8px; top: 8px;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  color: #ffd166; font-size: 11px; padding: 2px 6px; border-radius: 6px;
}
.card .title {
  margin-top: 8px; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .meta { margin-top: 2px; font-size: 12px; color: var(--muted); }
.card .meta .yr { margin-left: 8px; }

/* 页面大标题（无顶栏的页面用） */
.page-title { padding: 16px 16px 8px; margin: 0; font-size: 22px; font-weight: 700; }

/* 搜索页头部（返回 + 输入框 + 搜索） */
.search-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
}
.search-head input {
  flex: 1; min-width: 0;
  background: var(--card); border: 1px solid var(--line);
  color: var(--text); border-radius: 12px;
  padding: 10px 14px; font-size: 15px;
}
.search-head .icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 50%; color: var(--text); cursor: pointer;
}
.search-head .primary-btn {
  background: var(--accent-2); color: white; border: 0;
  border-radius: 12px; padding: 0 16px; height: 38px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}

/* 热剧推荐 —— 横向列表 */
.hotlist { display: flex; flex-direction: column; gap: 12px; padding: 8px 16px 16px; }
.hotlist .item {
  display: flex; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px;
  cursor: pointer; transition: transform .15s ease;
}
.hotlist .item:active { transform: scale(.98); }
.hotlist .item .poster {
  width: 90px; flex: 0 0 90px;
  aspect-ratio: 3/4; border-radius: 10px; overflow: hidden;
  background: var(--bg-soft); position: relative;
}
.hotlist .item .poster img { width: 100%; height: 100%; object-fit: cover; }
.hotlist .item .info { flex: 1; min-width: 0; }
.hotlist .item .info h4 {
  margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hotlist .item .info .row { font-size: 13px; color: var(--muted); margin-bottom: 4px; line-height: 1.5; }
.hotlist .item .info .row b { color: var(--text); font-weight: 500; }
.hotlist .item .info .row.actors {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 加载/空 */
.center { padding: 40px 16px; text-align: center; color: var(--muted); }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 详情 */
.detail-hero {
  display: grid; grid-template-columns: 130px 1fr; gap: 14px;
  padding: 12px 16px;
}
.detail-hero .poster {
  aspect-ratio: 3/4; border-radius: 14px; overflow: hidden; background: var(--card);
}
.detail-hero .poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero h1 { margin: 0 0 6px; font-size: 20px; }
.detail-hero .row { font-size: 13px; color: var(--muted); margin: 4px 0; }
.detail-hero .score { color: #ffd166; font-weight: 700; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 16px; }
.actions button {
  background: var(--pill); color: var(--accent); border: 0;
  padding: 8px 12px; border-radius: 10px; font-size: 13px; cursor: pointer; font-weight: 600;
}
.actions button.primary { background: var(--accent-2); color: #fff; }
.section { padding: 6px 16px 12px; }
.section h3 { margin: 12px 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.episodes { display: flex; flex-wrap: wrap; gap: 8px; }
.episodes button {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; cursor: pointer; min-width: 64px;
}
.episodes button.playing { border-color: var(--accent); color: var(--accent); }
.desc { color: #cfcfd6; font-size: 14px; line-height: 1.7; }
.desc p { margin: 0 0 10px; }
.desc p:last-child { margin-bottom: 0; }
.desc a { color: var(--accent); }

/* 底部 */
.bottom-nav {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  display: grid; grid-template-columns: repeat(4,1fr);
  background: rgba(20,20,31,.85); backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 10px 6px; z-index: 20;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.bottom-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: 0; color: var(--muted);
  font-size: 12px; padding: 4px 0; cursor: pointer;
}
.bottom-nav button.active { color: var(--accent); }

/* 设置 */
.settings { padding: 8px 16px 24px; }
.settings .group {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 12px; overflow: hidden;
}
.settings .group > h3 {
  margin: 0; padding: 14px 16px; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.settings .group > h3::after {
  content: ""; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s;
}
.settings .group.open > h3::after { transform: rotate(45deg); }
.settings .group > .body {
  padding: 0 16px 14px; display: none;
}
.settings .group.open > .body { display: block; }
.settings .group > h3 .badge {
  font-size: 12px; color: var(--muted); font-weight: 500; margin-left: auto; margin-right: 12px;
}
.settings label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.settings input, .settings select, .settings textarea {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit;
}
.settings textarea { min-height: 180px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.settings .row { display: flex; gap: 8px; align-items: center; }
.settings .row > * { flex: 1; }
.settings button.primary {
  background: var(--accent-2); color: #fff; border: 0;
  padding: 10px 14px; border-radius: 10px; font-weight: 600; cursor: pointer;
  margin-top: 10px;
}
.settings .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 110px; background: rgba(0,0,0,.8); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 50;
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px);} to {opacity:1; transform: translate(-50%,0);} }

.fav-toggle {
  background: transparent !important; color: var(--muted) !important;
  border: 1px solid var(--line) !important;
}
.fav-toggle.on { color: #ffd166 !important; border-color: #ffd166 !important; }

/* 技术栈徽章 */
.tech-stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tech-stack .tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1;
  border: 1px solid transparent;
  transition: transform .12s ease, filter .12s ease;
  text-decoration: none;
}
.tech-stack .tag:hover { transform: translateY(-1px); filter: brightness(1.15); }
.tech-stack .tag:active { transform: translateY(0); }
.tech-stack .tag-cf   { background: rgba(243,128,32,.12); color: #f38020; border-color: rgba(243,128,32,.35); }
.tech-stack .tag-hono { background: rgba(255,99,99,.12); color: #ff6363;  border-color: rgba(255,99,99,.35); }
.tech-stack .tag-kv   { background: rgba(124,58,237,.15); color: #a78bfa;  border-color: rgba(124,58,237,.4); }
.tech-stack .tag-art  { background: rgba(0,200,150,.12); color: #00c896;  border-color: rgba(0,200,150,.35); }
.tech-stack .tag-hls  { background: rgba(99,180,255,.12); color: #63b4ff;  border-color: rgba(99,180,255,.35); }

/* 详情底部频道信息 */
.channel-foot {
  text-align: center; padding: 22px 16px 8px;
  font-size: 11.5px; color: var(--muted); line-height: 1.8;
}
.channel-foot a { color: var(--accent); }
