/* ============================================================
   LynxFlowX 复刻版设计系统 —— 暗色极光影院壳
   性能契约：极光用 filter 模糊（禁 backdrop-filter）；.main-scroll 为唯一滚动容器；
   卡片 content-visibility；滚动期间以 .is-scrolling 抑制悬停重绘；零外部字体。
   ============================================================ */

:root {
  /* 表面与文字 */
  --bg: #070a12;
  --bg-elev: #0b101c;
  --card: #111828;
  --card-hi: #172033;
  --line: #212b45;
  --line-soft: #18213a;
  --text: #eaeefb;
  --text-dim: #9aa6c4;
  --text-faint: #6b7796;

  /* 强调色 */
  --violet: #8b5cf6;
  --violet-hi: #a78bfa;
  --indigo: #6366f1;
  --indigo-hi: #818cf8;
  --cyan: #22d3ee;
  --teal: #2dd4bf;
  --gold: #f59e0b;
  --gold-hi: #fbbf24;
  --danger: #ef4444;
  --ok: #22c55e;

  /* 形状 / 阴影 / 布局 */
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --shadow-lift: 0 16px 36px rgba(0, 0, 0, 0.5);
  --sidebar-w: 252px;
  --topbar-h: 64px;
  --stage-max: 940px;
  --stream-max: 860px;
  --glow: 0 0 0 1px rgba(139, 92, 246, 0.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

html[data-theme='light'] {
  --bg: #f5f6fb;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-hi: #eef1f9;
  --line: #d8deed;
  --line-soft: #e6ebf5;
  --text: #101728;
  --text-dim: #4b5675;
  --text-faint: #7a85a3;
  --shadow: 0 18px 40px rgba(24, 34, 68, 0.12);
  --shadow-lift: 0 16px 30px rgba(24, 34, 68, 0.14);
}

/* ---------------------------- 基础重置 ---------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--violet-hi);
  outline-offset: 2px;
  border-radius: 8px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  background: var(--violet);
  color: #06070d;
  padding: 8px 14px;
  border-radius: 0 0 10px 0;
  font-weight: 600;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------------------------- 极光背景 ---------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}
.aurora-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}
.aurora-blob--gold {
  width: 620px; height: 460px; top: -190px; left: -140px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.55), transparent 68%);
}
.aurora-blob--indigo {
  width: 700px; height: 520px; top: -230px; right: -180px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.42), transparent 68%);
}
.aurora-blob--teal {
  width: 520px; height: 380px; top: 42%; left: 46%;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.22), transparent 70%);
}
html[data-theme='light'] .aurora-blob { opacity: 0.32; }

/* ---------------------------- 滚动条 ---------------------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26314e; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #35426b; }
html[data-theme='light'] ::-webkit-scrollbar-thumb { background: #c6cfe3; }

/* ---------------------------- 应用骨架 ---------------------------- */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns 0.22s ease;
}
.app-shell.sidebar-collapsed { grid-template-columns: 76px minmax(0, 1fr); }

/* ---------------------------- 侧边栏 ---------------------------- */
.chatgpt-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(11, 16, 28, 0.94), rgba(8, 11, 20, 0.97));
  border-right: 1px solid var(--line-soft);
  padding: 14px 12px 0;
  overflow: hidden;
}
html[data-theme='light'] .chatgpt-sidebar {
  background: linear-gradient(180deg, #ffffff, #f7f9fe);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 14px;
  min-height: 44px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16.5px; font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; }
.brand-text strong em {
  font-style: normal;
  background: linear-gradient(120deg, var(--violet-hi), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text small {
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
}
.sidebar-scroll > * { flex-shrink: 0; }

.view-switcher { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.view-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--text-dim);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.view-pill:hover { background: var(--card); color: var(--text); }
.view-pill.is-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(56, 189, 248, 0.16));
  border-color: rgba(139, 92, 246, 0.5);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 18px rgba(139, 92, 246, 0.14);
}
html[data-theme='light'] .view-pill.is-active { color: var(--violet); }
.nav-ico { width: 17px; height: 17px; fill: currentColor; opacity: 0.85; flex-shrink: 0; }

.sidebar-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.sidebar-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-faint);
  font-weight: 700;
  padding: 6px 8px 4px;
}

.channel-list { display: flex; flex-direction: column; gap: 2px; }
.channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-align: left;
  min-width: 0;
}
.channel-row .ico, .channel-row .ch-ico { flex-shrink: 0; font-style: normal; }
.channel-row span.ch-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row:hover { background: var(--card); color: var(--text); }
.channel-row.is-active {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--text);
}
.channel-row-count {
  font-size: 10.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.thread-list { display: flex; flex-direction: column; gap: 2px; max-height: 210px; overflow-y: auto; }
.thread-empty { font-size: 11.5px; color: var(--text-faint); padding: 2px 8px 6px; line-height: 1.6; }
.thread-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  grid-template-areas: "dot title" "dot meta";
  gap: 0 8px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 9px;
  background: transparent;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.thread-row:hover { background: var(--card); }
.thread-row.is-active { background: var(--card-hi); border-color: var(--line); }
.thread-dot { grid-area: dot; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.thread-row.is-active .thread-dot { background: var(--violet-hi); box-shadow: 0 0 8px var(--violet); }
.thread-title {
  grid-area: title;
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-row.is-active .thread-title { color: var(--text); }
.thread-meta { grid-area: meta; font-size: 10.5px; color: var(--text-faint); }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 12px 4px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.sidebar-block { display: flex; flex-direction: column; gap: 6px; }

.net-mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.net-mode-row button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 11px;
  transition: all 0.15s ease;
}
.net-mode-row button:hover { border-color: var(--indigo); color: var(--text); }
.net-mode-row button.is-active {
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(139, 92, 246, 0.5);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(56, 189, 248, 0.1));
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.16s ease;
}
.new-chat-btn:hover { background: linear-gradient(135deg, rgba(139, 92, 246, 0.32), rgba(56, 189, 248, 0.18)); }
.new-chat-btn svg { width: 16px; height: 16px; fill: currentColor; }

.side-quota-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.side-quota-top .sidebar-section-title { padding: 0; }
.side-quota-num { font-size: 10.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.quota-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
html[data-theme='light'] .quota-bar { background: rgba(16, 23, 40, 0.08); }
.quota-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  transition: width 0.35s ease, background 0.25s ease;
}
.quota-bar-fill.low { background: linear-gradient(90deg, var(--gold), var(--gold-hi)); }
.quota-bar-fill.out { background: linear-gradient(90deg, var(--danger), #f87171); }
.side-quota-sub { font-size: 10.5px; color: var(--text-faint); }

.side-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.side-user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side-user-meta strong { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-meta small { font-size: 10.5px; color: var(--text-faint); }
.pro-chip {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #0a0e1a;
  background: linear-gradient(135deg, var(--cyan), var(--violet-hi));
  border-radius: 5px;
  padding: 2px 6px;
}

.sidebar-scrim { display: none; }

/* ---------------------------- 主区顶栏 ---------------------------- */
.chatgpt-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chatgpt-topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 11, 20, 0.72);
  contain: layout style;
  z-index: 20;
  flex-shrink: 0;
}
html[data-theme='light'] .chatgpt-topbar { background: rgba(255, 255, 255, 0.82); }

.quick-search { flex: 1; position: relative; display: flex; align-items: center; }
.quick-search-icon {
  position: absolute;
  left: 15px;
  width: 17px; height: 17px;
  fill: var(--text-faint);
  pointer-events: none;
}
.quick-search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  padding: 11px 84px 11px 42px;
  font-size: 13.5px;
  transition: border-color 0.16s ease, background 0.16s ease;
  appearance: none;
}
.quick-search input::placeholder { color: var(--text-faint); }
.quick-search input:focus { outline: none; border-color: var(--violet); background: var(--card-hi); }
.quick-search input::-webkit-search-cancel-button { display: none; }
.quick-search-kbd {
  position: absolute;
  right: 12px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-faint);
  border-radius: 6px;
  padding: 2px 7px;
  pointer-events: none;
  font-family: inherit;
}

.suggest-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 340px;
  overflow-y: auto;
  padding: 0;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: var(--card-hi); }
.suggest-kind {
  font-size: 10.5px;
  color: var(--violet-hi);
  border: 1px solid rgba(139, 92, 246, 0.38);
  border-radius: 5px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.suggest-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-year { font-size: 11.5px; color: var(--text-faint); flex-shrink: 0; }

.topbar-actions { display: flex; align-items: center; gap: 9px; }
.net-status-pill {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 11.5px;
  color: var(--text-dim);
  border: 1px solid var(--line);
  white-space: nowrap;
  transition: all 0.15s ease;
}
.net-status-pill.is-probing { color: var(--violet-hi); border-color: rgba(139, 92, 246, 0.45); }
.net-status-pill.is-good { color: #6ee7b7; border-color: rgba(45, 212, 191, 0.45); }
.net-status-pill.is-proxy { color: var(--cyan); border-color: rgba(34, 211, 238, 0.4); }
.net-status-pill.is-bad { color: #f87171; border-color: rgba(239, 68, 68, 0.4); }

.icon-btn {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  border-radius: 11px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
html[data-theme='light'] .icon-btn { background: transparent; }
.icon-btn:hover { border-color: var(--violet); color: var(--violet-hi); background: rgba(139, 92, 246, 0.1); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.ico-sun { display: none; }
html[data-theme='light'] .ico-sun { display: block; }
html[data-theme='light'] .ico-moon { display: none; }

/* ---------------------------- 主滚动容器 ---------------------------- */
.main-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
  transform: translateZ(0);
  padding-bottom: 40px;
}

/* ---------------------------- AI 对话舞台 ---------------------------- */
.chatgpt-stage {
  max-width: var(--stage-max);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
}
.chatgpt-stage.is-empty { padding-top: 6vh; }

.chat-hero { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.chat-hero-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--violet-hi);
}
.chat-hero h1 {
  font-size: clamp(26px, 3.6vw, 38px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.9px;
}
.grad-text {
  background: linear-gradient(120deg, var(--violet-hi), var(--indigo-hi) 45%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chat-hero-sub { font-size: 13.5px; color: var(--text-dim); max-width: 660px; line-height: 1.75; }

.chat-messages-stream {
  max-width: var(--stream-max);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-bottom: 8px;
}
.chat-row { display: flex; gap: 12px; }
.chat-row.is-user { justify-content: flex-end; }
.bubble-user {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.26), rgba(56, 189, 248, 0.16));
  border: 1px solid rgba(139, 92, 246, 0.36);
  border-radius: 18px 18px 4px 18px;
  padding: 11px 16px;
  font-size: 14px;
  line-height: 1.65;
  max-width: 78%;
  white-space: pre-wrap;
  word-break: break-word;
}
.assistant-avatar {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 800;
  margin-top: 2px;
  flex-shrink: 0;
}
.assistant-block { display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1; }
.assistant-text { font-size: 14.5px; line-height: 1.8; color: var(--text); word-break: break-word; }
.assistant-text strong { color: var(--violet-hi); }
.assistant-text p { margin: 0 0 6px; }
.assistant-text p:last-child { margin-bottom: 0; }
.assistant-text .err { color: #f87171; }
.md-h { font-size: 15px; font-weight: 700; margin: 12px 0 6px; }
.md-ul { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.md-ul li {
  position: relative;
  padding-left: 16px;
  line-height: 1.7;
}
.md-ul li::before {
  content: '';
  position: absolute;
  left: 2px; top: 11px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--violet-hi);
}
.md-ol { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.md-ol li { padding-left: 22px; position: relative; line-height: 1.7; }
.md-num { position: absolute; left: 0; color: var(--violet-hi); font-weight: 700; }
.assistant-text code {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12.5px;
}
.cursor {
  display: inline-block;
  width: 7px; height: 15px;
  background: var(--violet-hi);
  vertical-align: -2px;
  animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 工作流 trace */
.wf-trace {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.06);
  overflow: hidden;
}
.wf-trace summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  font-size: 12px;
  color: var(--indigo-hi);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.wf-trace summary::-webkit-details-marker { display: none; }
.wf-trace summary .wf-arrow { transition: transform 0.15s ease; display: inline-block; }
.wf-trace[open] summary .wf-arrow { transform: rotate(90deg); }
.wf-nodes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 0 13px 10px; }
.wf-node {
  font-size: 11.5px;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  animation: fadeIn 0.25s ease;
  white-space: nowrap;
}
.wf-node.is-active {
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--violet-hi);
  background: rgba(139, 92, 246, 0.12);
}
.wf-node.is-done { color: #6ee7b7; border-color: rgba(45, 212, 191, 0.35); }
.wf-sep { color: var(--text-faint); font-size: 11px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-3px); } }
.wf-spinner {
  width: 11px; height: 11px;
  border: 1.5px solid var(--indigo);
  border-top-color: var(--violet-hi);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.wf-detail-lines { padding: 0 13px 10px; display: flex; flex-direction: column; gap: 3px; }
.wf-detail-line { font-size: 11px; color: var(--text-faint); }
.wf-detail-stage { color: var(--indigo-hi); font-weight: 600; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.reasoning {
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-left: 3px solid var(--indigo);
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.06);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-faint);
}
.reasoning summary { cursor: pointer; color: var(--indigo-hi); font-size: 11.5px; list-style: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning-body { white-space: pre-wrap; margin-top: 6px; line-height: 1.7; }

.tool-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--violet-hi);
}
.tool-progress .spin {
  width: 12px; height: 12px;
  border: 1.5px solid var(--line);
  border-top-color: var(--violet-hi);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.turn-foot {
  font-size: 11.5px;
  color: var(--text-faint);
  border-top: 1px dashed var(--line-soft);
  padding-top: 9px;
}

/* 追问建议 */
.followup-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.followup-chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  transition: all 0.15s ease;
}
.followup-chip:hover {
  border-color: var(--violet);
  color: var(--violet-hi);
  background: rgba(139, 92, 246, 0.1);
}

/* 聊天内影片卡 */
.chat-movie-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.chat-movie-card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
  display: flex;
  flex-direction: column;
}
.chat-movie-card:hover { transform: translateY(-3px); border-color: rgba(139, 92, 246, 0.6); }
.chat-movie-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--card-hi);
  overflow: hidden;
  width: 100%;
  border: none;
  padding: 0;
  display: block;
}
.chat-movie-year {
  position: absolute;
  top: 6px; left: 6px;
  z-index: 2;
  background: linear-gradient(135deg, var(--violet-hi), var(--cyan));
  color: #0a0e1a;
  font-size: 10px;
  font-weight: 800;
  border-radius: 5px;
  padding: 2px 6px;
}
.chat-movie-body { padding: 8px 9px 10px; display: flex; flex-direction: column; gap: 3px; }
.chat-movie-title {
  font-size: 12.5px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  min-height: 2.6em;
}
.chat-movie-heat { font-size: 10.5px; color: var(--gold-hi); font-weight: 600; }
.chat-movie-card .card-act { padding: 5px 2px; font-size: 11px; }

/* ---------------------------- 输入坞 ---------------------------- */
.composer-dock { padding: 4px 0 0; }
.composer-dock.is-empty-state { padding-bottom: 10px; }
.chatgpt-composer-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(160deg, rgba(23, 32, 51, 0.94), rgba(15, 21, 36, 0.94));
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 20px;
  padding: 14px 16px 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
html[data-theme='light'] .chatgpt-composer-box { background: #ffffff; border-color: var(--line); box-shadow: var(--shadow); }
.chatgpt-composer-box:focus-within {
  border-color: rgba(139, 92, 246, 0.7);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.13), 0 18px 44px rgba(0, 0, 0, 0.42);
}
.chatgpt-composer-box.is-sticky {
  position: sticky;
  bottom: 0;
  z-index: 5;
}
.composer-row { display: flex; align-items: flex-start; gap: 10px; }
.composer-spark { color: var(--violet-hi); margin-top: 12px; flex-shrink: 0; }
.composer-spark svg { width: 20px; height: 20px; fill: currentColor; }
#chat-prompt-input {
  flex: 1;
  min-height: 46px;
  max-height: 200px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  padding: 10px 0;
}
#chat-prompt-input::placeholder { color: var(--text-faint); }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.composer-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.composer-mode {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-faint);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  transition: all 0.15s ease;
}
.composer-mode em { font-style: normal; font-size: 11px; opacity: 0.68; }
.composer-mode:hover { color: var(--text); border-color: var(--indigo); }
.composer-mode.is-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(56, 189, 248, 0.55));
  border-color: var(--violet);
  color: #ddd6fe;
  font-weight: 600;
}
.composer-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(124, 92, 246, 0.4);
  transition: filter 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}
.composer-send svg { width: 19px; height: 19px; fill: currentColor; }
.composer-send:hover { filter: brightness(1.1); }
.composer-send:disabled { opacity: 0.45; box-shadow: none; cursor: not-allowed; }

.starter-prompts-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }
.starter-pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  transition: all 0.15s ease;
}
.starter-pill:hover {
  border-color: var(--violet);
  color: var(--violet-hi);
  background: rgba(139, 92, 246, 0.1);
}
html[data-theme='light'] .starter-pill { background: #fff; }

/* ---------------------------- 能力卡片 ---------------------------- */
.feature-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 26px 0 8px;
}
.feature-card {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.025);
  transition: background 0.15s ease, border-color 0.15s ease;
}
html[data-theme='light'] .feature-card { background: #fff; border-color: var(--line-soft); }
.feature-card:hover {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.35);
}
.feature-ico {
  width: 36px; height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.feature-ico svg { width: 18px; height: 18px; }
.feature-ico--indigo { background: rgba(139, 92, 246, 0.16); color: var(--violet-hi); }
.feature-ico--blue { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
.feature-ico--cyan { background: rgba(34, 211, 238, 0.16); color: var(--cyan); }
.feature-ico--teal { background: rgba(45, 212, 191, 0.16); color: var(--teal); }
.feature-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feature-text strong { font-size: 12.5px; }
.feature-text small { font-size: 10.5px; color: var(--text-faint); line-height: 1.45; }

/* ---------------------------- 精选片单 ---------------------------- */
.home-shelves {
  max-width: 1440px;
  margin: 40px auto 0;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.shelf { display: flex; flex-direction: column; gap: 14px; content-visibility: auto; contain-intrinsic-size: auto 350px; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; }
.shelf-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.shelf-head .shelf-sub { font-size: 11.5px; color: var(--text-faint); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-more { font-size: 12px; color: var(--violet-hi); background: none; border: none; padding: 0; }
.shelf-more:hover { color: var(--cyan); }
.shelf-body { position: relative; }
.shelf-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 158px;
  gap: 15px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  contain: layout style;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.shelf-track::-webkit-scrollbar { display: none; }
.rail-nav {
  position: absolute;
  top: 42%;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(13, 18, 31, 0.94);
  color: var(--text);
  display: none;
  place-items: center;
  z-index: 3;
  font-size: 19px;
  line-height: 1;
}
html[data-theme='light'] .rail-nav { background: #fff; }
.rail-nav:hover { border-color: var(--violet); color: var(--violet-hi); }
.rail-nav--prev { left: -14px; }
.rail-nav--next { right: -14px; }
.shelf-body:hover .rail-nav { display: grid; }

/* ---------------------------- 影片卡 ---------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
  transition: transform 0.16s ease, border-color 0.16s ease;
}
.card:hover { transform: translateY(-4px); border-color: rgba(139, 92, 246, 0.6); box-shadow: var(--shadow-lift); }
.main-scroll.is-scrolling .card:hover { transform: none; box-shadow: none; }
.card-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--card-hi);
  overflow: hidden;
  width: 100%;
  border: none;
  padding: 0;
  display: block;
  cursor: pointer;
}
.poster-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.poster-img.loaded { opacity: 1; }
.card-badges {
  position: absolute;
  top: 8px; left: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(7, 10, 18, 0.86);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.badge.gold { color: #fde68a; border-color: rgba(245, 158, 11, 0.45); }
.badge.indigo { color: var(--violet-hi); border-color: rgba(139, 92, 246, 0.45); }
.badge.new {
  background: linear-gradient(135deg, var(--violet-hi), var(--cyan));
  color: #0a0e1a;
  border: none;
  font-weight: 800;
  letter-spacing: 0.4px;
}
.card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(7, 10, 18, 0.42);
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 1;
  color: #fff;
}
.card:hover .card-play { opacity: 1; }
.card-play svg { width: 26px; height: 26px; fill: currentColor; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6)); }
.continue-card .card-play { opacity: 0.35; }
.continue-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(7, 10, 18, 0.78);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.card-body { padding: 10px 11px 4px; display: flex; flex-direction: column; gap: 4px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { font-size: 11px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.card-stars { font-size: 11px; font-weight: 700; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.card-stars::before { content: '★ '; font-size: 10px; }
.card-remark {
  font-size: 10.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-reason { font-size: 10.5px; color: var(--violet-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; gap: 6px; padding: 8px 11px 12px; }
.card-act {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  border-radius: 9px;
  padding: 6px 4px;
  font-size: 11.5px;
  transition: all 0.15s ease;
}
.card-act:hover { border-color: var(--indigo); color: var(--text); }
.card-act.primary {
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.card-act.primary:hover { filter: brightness(1.08); }
.card-act svg { width: 12px; height: 12px; fill: currentColor; }
.card.is-mini .card-actions { display: none; }

/* ---------------------------- 片库与筛选 ---------------------------- */
.catalog-section {
  max-width: 1440px;
  margin: 26px auto 0;
  padding: 0 24px;
}
.catalog-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.catalog-head h2 { font-size: 20px; font-weight: 700; }
.results-count { font-size: 12.5px; color: var(--text-faint); }

.filters {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(17, 24, 40, 0.62);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
html[data-theme='light'] .filters { background: #fff; }
.filter-row { display: flex; gap: 10px; align-items: flex-start; }
.filter-label {
  width: 40px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  padding-top: 7px;
}
.filter-opts { display: flex; flex-wrap: wrap; gap: 7px; }
.facet-btn {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.facet-btn:hover { border-color: var(--indigo); color: var(--text); }
.facet-btn.is-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.85), rgba(56, 189, 248, 0.5));
  border-color: var(--violet);
  color: var(--violet-hi);
  font-weight: 600;
}
html[data-theme='light'] .facet-btn { background: #f3f5fb; }
.new-badge {
  font-size: 9px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--violet-hi), var(--cyan));
  color: #0a0e1a;
  border-radius: 4px;
  padding: 1px 4px;
  letter-spacing: 0.3px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 16px;
}

.empty-state {
  text-align: center;
  padding: 56px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.empty-title { font-size: 17px; font-weight: 600; }
.empty-hint { font-size: 13.5px; color: var(--text-faint); max-width: 420px; line-height: 1.7; }

.load-more-wrap { display: flex; justify-content: center; padding: 26px 0 10px; }
.load-more-sentinel { height: 1px; }

.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--violet-hi);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------------------------- 按钮 ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn-primary {
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  color: #fff;
  box-shadow: 0 10px 26px rgba(124, 92, 246, 0.34);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { border-color: var(--line); background: transparent; color: var(--text-dim); }
.btn-outline:hover { border-color: var(--violet); color: var(--violet-hi); }
.btn-ghost {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--indigo-hi);
}
.btn-ghost:hover { background: rgba(99, 102, 241, 0.2); }
.btn-block { width: 100%; margin-top: 10px; }

/* ---------------------------- 页脚 ---------------------------- */
.site-footer {
  max-width: 1440px;
  margin: 56px auto 0;
  padding: 22px 24px 10px;
  border-top: 1px solid var(--line-soft);
}
.footer-inner { display: flex; flex-direction: column; gap: 6px; }
.site-footer p { font-size: 12px; color: var(--text-dim); }
.footer-sub { font-size: 11px; color: var(--text-faint); }

/* ---------------------------- 弹窗 ---------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 10, 0.93);
}
html[data-theme='light'] .modal-backdrop { background: rgba(16, 23, 40, 0.55); }
.modal-panel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: min(1340px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  z-index: 8;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(7, 10, 18, 0.85);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.modal-close:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------------------------- 播放器 ---------------------------- */
.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: start;
}
/* 宽屏影院模式：舞台独占整行，右栏隐藏，营造沉浸观影 */
.player-panel.is-theater .player-layout { grid-template-columns: minmax(0, 1fr); }
.player-panel.is-theater .player-right-col { display: none; }
.player-panel.is-theater .player-stage { max-height: min(78vh, 78dvh); }
.player-left-col { min-width: 0; }
.player-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
}
#videoEl {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  transition: object-fit 0.15s ease, transform 0.15s ease;
}
.player-stage[data-aspect='cover'] #videoEl { object-fit: cover; transform: scale(1.04); }
.player-stage[data-aspect='ultrawide'] { aspect-ratio: 21 / 9; }
.player-stage[data-aspect='ultrawide'] #videoEl { object-fit: cover; }
.player-stage[data-aspect='fill'] #videoEl { object-fit: fill; }
.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(3, 5, 10, 0.86);
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 0 24px;
}
.stage-overlay.is-error .spinner { display: none; }
.stage-overlay.is-error #stageOverlayText { color: #ff8095; }
.ai-summary-btn { color: var(--violet-hi); border-color: rgba(167, 139, 250, 0.35); }
.ai-summary-btn:active { transform: scale(0.98); }
.comment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
}
.comment-item {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 4px;
}
.comment-nick { color: var(--violet-hi); font-weight: 600; }
.comment-time { color: var(--text-dim); font-size: 11px; }
.comment-text { font-size: 13px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.comment-empty { font-size: 12px; color: var(--text-dim); text-align: center; padding: 14px 0; }
html[data-theme='light'] .comment-item { background: rgba(15, 23, 42, 0.045); border-color: var(--line-soft); }
.player-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-elev);
}
.ctrl-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ctrl-right { margin-left: auto; }
.ctrl-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
}
.ctrl-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  transition: all 0.15s ease;
}
.ctrl-btn:hover { border-color: var(--indigo); color: var(--text); }
.ctrl-btn.is-active {
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.speed-select { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); }
.speed-select select {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11.5px;
}
.player-work-summary { padding: 16px 18px; }
.player-work-summary h3 { font-size: 16px; line-height: 1.35; }
.player-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.player-overview { font-size: 12.5px; color: var(--text-dim); line-height: 1.75; margin-top: 8px; }

.player-right-col {
  border-left: 1px solid var(--line-soft);
  padding: 18px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  min-width: 0;
}
.player-head { padding-right: 40px; }
.player-head h3 { font-size: 16px; line-height: 1.35; }
.player-block { display: flex; flex-direction: column; gap: 9px; }
.block-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
}
.block-label em { color: var(--violet-hi); font-style: normal; }

.chip-row { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover { border-color: var(--indigo); color: var(--text); }
.chip.active {
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}
.chip.dead { opacity: 0.4; text-decoration: line-through; }

.line-chips { flex-direction: column; overflow: visible; }
.line-chip {
  width: 100%;
  justify-content: space-between;
  border-radius: 9px;
  padding: 7px 11px;
  white-space: normal;
}
.line-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lat-badge {
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
  color: var(--text-faint);
  border: 1px solid var(--line);
}
.lat-badge.is-fast { color: #6ee7b7; border-color: rgba(45, 212, 191, 0.4); background: rgba(45, 212, 191, 0.1); }
.lat-badge.is-mid { color: var(--gold-hi); border-color: rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.08); }
.lat-badge.is-proxy { color: var(--cyan); border-color: rgba(34, 211, 238, 0.4); background: rgba(34, 211, 238, 0.08); }
.lat-badge.is-dead { color: #f87171; border-color: rgba(239, 68, 68, 0.35); }
.line-chip.active .lat-badge {
  background: rgba(7, 9, 14, 0.85);
  color: #fff;
  border-color: transparent;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 7px;
  max-height: 210px;
  overflow-y: auto;
  padding-right: 4px;
}
.ep-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px 4px;
  font-size: 12px;
  transition: all 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ep-btn:hover { border-color: var(--violet); color: var(--violet-hi); }
.ep-btn.active {
  background: linear-gradient(135deg, var(--violet-hi), var(--indigo));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.player-block.companion { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.companion-thread {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 240px;
  overflow-y: auto;
}
.companion-q {
  align-self: flex-end;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.36);
  border-radius: 12px 12px 4px 12px;
  padding: 8px 11px;
  font-size: 12.5px;
  max-width: 92%;
  line-height: 1.6;
}
.companion-a {
  align-self: flex-start;
  background: var(--card-hi);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-dim);
  max-width: 92%;
  white-space: pre-wrap;
  word-break: break-word;
}
.companion-a.is-loading { color: var(--text-faint); font-size: 12px; }
.companion-form { display: flex; gap: 8px; }
.companion-form input {
  flex: 1;
  min-width: 0;
  background: var(--card-hi);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12.5px;
}
.companion-form input:focus { outline: none; border-color: var(--violet); }
.companion-form .btn { padding: 8px 14px; }

/* ---------------------------- 详情弹窗 ---------------------------- */
.detail-panel { width: min(940px, 100%); }
.detail-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.detail-poster-wrap { padding: 24px 0 26px 24px; }
.detail-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  background: var(--card-hi);
  overflow: hidden;
  width: 100%;
}
.detail-body { padding: 24px 24px 26px 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail-body h2 { font-size: 22px; line-height: 1.25; }
.detail-sub { font-size: 12.5px; color: var(--text-faint); }
.detail-overview { font-size: 13.5px; color: var(--text-dim); line-height: 1.8; }
.detail-line { font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.detail-line em { font-style: normal; color: var(--text-faint); font-weight: 600; margin-right: 8px; }
.detail-remark { font-size: 12px; color: var(--violet-hi); }
.detail-actions { display: flex; gap: 10px; margin-top: 6px; }
.detail-recs h4 { font-size: 13px; margin-bottom: 10px; }
.detail-rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 11px;
}
.detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------------------------- Toast ---------------------------- */
.toast-host {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: min(520px, 90vw);
  animation: toastIn 0.2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------------------------- 响应式 ---------------------------- */
@media (max-width: 1240px) {
  .feature-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) {
  .player-layout { grid-template-columns: 1fr; }
  .player-right-col {
    border-left: none;
    border-top: 1px solid var(--line-soft);
    max-height: none;
  }
}

@media (max-width: 900px) {
  .app-shell,
  .app-shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .chatgpt-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(var(--sidebar-w), 84vw);
    z-index: 150;
    transform: translateX(0);
    transition: transform 0.22s ease;
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.6);
  }
  .app-shell.sidebar-collapsed .chatgpt-sidebar { transform: translateX(-100%); }
  .sidebar-collapse { display: none; }
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 140;
    background: rgba(4, 6, 12, 0.6);
    transition: opacity 0.2s ease;
  }
  .app-shell.sidebar-collapsed .sidebar-scrim { opacity: 0; pointer-events: none; }
  /* 移动端抽屉始终完整展示 */
  .app-shell.sidebar-collapsed .brand-text,
  .app-shell.sidebar-collapsed .thread-list,
  .app-shell.sidebar-collapsed .sidebar-section-title,
  .app-shell.sidebar-collapsed .side-quota-num,
  .app-shell.sidebar-collapsed .quota-bar,
  .app-shell.sidebar-collapsed .side-user-meta,
  .app-shell.sidebar-collapsed .pro-chip,
  .app-shell.sidebar-collapsed .channel-row-count,
  .app-shell.sidebar-collapsed .net-mode-row,
  .app-shell.sidebar-collapsed .new-chat-btn span { display: revert; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-poster-wrap { padding: 24px 16px 0; max-width: 200px; margin: 0 auto; }
  .detail-body { padding: 16px 16px 8px; }
}

@media (max-width: 760px) {
  .quick-search-kbd { display: none; }
  .quick-search input { padding-right: 16px; }
  .net-status-pill { display: none; }
  .chatgpt-stage { padding: 0 14px; }
  .chatgpt-stage.is-empty { padding-top: 3vh; }
  .home-shelves, .catalog-section, .site-footer { padding-left: 14px; padding-right: 14px; }
  .home-shelves { margin-top: 28px; }
  .chat-messages-stream { max-width: 100%; }
  .bubble-user { max-width: 88%; }
  .composer-mode em { display: none; }
  .feature-row { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal-panel {
    border-radius: 0;
    max-height: 100vh;
    max-height: 100dvh;
    width: 100vw;
  }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 11px; }
  .detail-rec-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .shelf-track { grid-auto-columns: 124px; }
  .filter-label { width: 34px; }
  .toast-host { bottom: 14px; }
}

/* ---------------------------- 降级动效 ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .aurora-blob { filter: none; opacity: 0.22; }
}

/* ==================== R5 移动端专项修复 ==================== */

/* P0：手机横屏（矮视口）——舞台占满全高，控制条不得被裁出视口 */
@media (orientation: landscape) and (max-height: 500px) {
  .modal { padding: 0; }
  .player-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .player-stage { aspect-ratio: auto; height: 100vh; height: 100dvh; }
  .player-panel.is-theater .player-layout { grid-template-columns: minmax(0, 1fr); }
  .player-panel.is-theater .player-stage { max-height: 100vh; max-height: 100dvh; }
  .player-right-col { max-height: 100vh; max-height: 100dvh; }
}

/* P1：浅色主题下弹窗关闭按钮浮在视频/深色遮罩上，必须是实底可见 */
html[data-theme='light'] .modal-close { background: #ffffff; color: #101728; border-color: rgba(16, 23, 40, 0.18); }

/* P2：浅色主题补齐缺失覆盖（对照暗色逐一核过的清单） */
html[data-theme='light'] .badge { background: rgba(255, 255, 255, 0.92); }
html[data-theme='light'] .stage-overlay { color: #dfe6f5; } /* 遮罩恒为深色，文字保持浅色 */
html[data-theme='light'] .chip { background: rgba(15, 23, 42, 0.045); color: #3d4a63; }
html[data-theme='light'] .card-act { background: rgba(15, 23, 42, 0.045); color: #3d4a63; }
html[data-theme='light'] .assistant-text code { background: rgba(15, 23, 42, 0.08); }

/* P2：AI 总结卡补齐视觉规格（此前是裸 div） */
.ai-summary-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
}
html[data-theme='light'] .ai-summary-card { background: rgba(15, 23, 42, 0.045); }

/* P2：内层滚动链隔离，防止选集/评论区滚动连带拖动整个弹窗 */
.comment-list, .episode-grid, .companion-thread, .modal-panel { overscroll-behavior: contain; }

/* P1：影院模式在手机上不得吞掉右栏（换线/选集/评论是核心功能） */
@media (max-width: 760px) {
  .player-panel.is-theater .player-right-col { display: flex; }
  .player-panel.is-theater .player-layout { grid-template-columns: minmax(0, 1fr); }

  /* P1：iOS 聚焦 <16px 输入框会整页放大且不回弹 */
  #chat-prompt-input,
  .quick-search input,
  .companion-form input,
  #commentInput,
  #speedSelect { font-size: 16px; }

  /* P1：控制条在窄屏收成单行横向滚动，不再堆 3 行小按钮 */
  .player-controls-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ctrl-group { flex-wrap: nowrap; }
  .ctrl-btn { white-space: nowrap; flex-shrink: 0; }

  /* P1：软键盘弹起时 sticky 输入条抬到键盘上方（--kb 由 JS visualViewport 写入） */
  .chatgpt-composer-box.is-sticky { bottom: var(--kb, 0px); }

  /* P2：safe-area——toast 与悬浮输入条避开 Home Indicator */
  .toast-host { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* P1：触屏设备整体抬高触控目标到 ≥32px（线路 chips/倍速/筛选器是误触重灾区） */
@media (pointer: coarse) {
  .ctrl-btn, .chip, .facet-btn, .card-act, .composer-mode, .net-mode-row button {
    min-height: 32px;
  }
  .chip, .facet-btn, .card-act { padding-block: 7px; }
}
