/* ============================================================
   ArityFlow App 设计系统
   主色：科技蓝 #2563EB ｜ 零渐变、零紫色
   双模式：浅色 / 深色（CSS 变量驱动）
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  color-scheme: light; /* 原生控件/滚动条/键盘跟随浅色 */

  /* 主色 */
  --primary: #2563EB;
  --primary-strong: #1D4ED8;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --primary-softer: rgba(37, 99, 235, 0.04);
  --on-primary: #FFFFFF;

  /* 语义色 */
  --success: #16A34A;
  --success-soft: rgba(22, 163, 74, 0.10);
  --warning: #D97706;
  --warning-soft: rgba(217, 119, 6, 0.10);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --info: #0891B2;

  /* 中性色 */
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F0F1F3;
  --surface-3: #E7E8EB;
  --border: #E4E6EA;
  --border-strong: #D3D6DC;
  --text-1: #16181D;
  --text-2: #555A64;
  --text-3: #9AA0AA;
  --text: var(--text-1); /* 兼容别名：修复历史组件引用未定义 --text */
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 2px 8px rgba(22, 24, 29, 0.05);
  --shadow-lg: 0 8px 32px rgba(22, 24, 29, 0.14);

  /* 布局 */
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-h: 56px;
  --header-h: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark; /* 原生控件/滚动条/键盘跟随深色 */

  --primary: #3B82F6;
  --primary-strong: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --primary-softer: rgba(59, 130, 246, 0.07);
  --on-primary: #FFFFFF;

  --success: #22C55E;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #22D3EE;

  --bg: #101216;
  --surface: #191C22;
  --surface-2: #22262E;
  --surface-3: #2B303A;
  --border: #2A2F38;
  --border-strong: #3A404C;
  --text-1: #ECEEF2;
  --text-2: #A6ACB8;
  --text-3: #6C7380;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ---------- 重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* App 手感：默认禁文本选择，避免长按列表出现选区/放大镜 */
  user-select: none;
  -webkit-user-select: none;
}
/* 可复制内容恢复选择 */
.md, .md *, .tc-key-text, input, textarea { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--text-1); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
i[data-lucide] { display: inline-flex; }

/* ---------- App 壳 ---------- */
.app {
  position: relative;
  max-width: 480px;
  /* 旧版 WebView（Chromium <108）不识别 dvh，会导致整条声明被丢弃、高度塌为 auto，
     页面只剩内容高度且无法滚动。WebView 内无浏览器地址栏，vh 与 dvh 等价，故不再使用 dvh。 */
  height: 100%;
  height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px var(--border);
  overflow: hidden;
}

/* ---------- 顶部导航栏 ---------- */
.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  transition: box-shadow 0.2s;
}
.app-header.scrolled { box-shadow: 0 1px 10px rgba(0, 0, 0, 0.06); }
.header-title {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 17px; font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  padding: 0 4px;
  min-width: 0;
}
.header-title svg { width: 18px; height: 18px; color: var(--primary); flex: none; }
.header-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 2px; min-width: 84px; justify-content: flex-end; }
.app-header:not(.has-back) .header-actions { min-width: 0; flex: 1; justify-content: flex-end; }
/* 子页：右侧空区与返回按钮等宽，保证标题居中 */
.app-header.has-back .header-actions { min-width: 44px; }
.app-header:not(.has-back) .header-title { justify-content: flex-start; padding-left: 10px; }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:active { background: var(--surface-2); color: var(--text-1); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- 视图容器 ---------- */
.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain; /* 防止滚动链触发浏览器整页回弹 */
  position: relative;
}
.page { padding: 12px 14px calc(16px + var(--safe-bottom)); min-height: 100%; animation: pageIn 0.22s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* ---------- 路由转场（原生 push/pop 感） ---------- */
.page-enter-tab  { animation: pageFadeUp 0.22s ease; }
.page-enter-push { animation: pageInRight 0.26s cubic-bezier(0.32, 0.72, 0, 1); }
.page-enter-back { animation: pageInLeft 0.26s cubic-bezier(0.32, 0.72, 0, 1); }
.page-leave-push { animation: pageOutLeft 0.16s ease forwards; }
.page-leave-back { animation: pageOutRight 0.16s ease forwards; }
@keyframes pageFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pageInRight { from { opacity: 0.4; transform: translateX(28%); } to { opacity: 1; transform: none; } }
@keyframes pageInLeft { from { opacity: 0.4; transform: translateX(-28%); } to { opacity: 1; transform: none; } }
@keyframes pageOutLeft { to { opacity: 0.4; transform: translateX(-28%); } }
@keyframes pageOutRight { to { opacity: 0.4; transform: translateX(28%); } }

/* 顶栏标题切换过渡（内容同步写入，仅入场动画） */
.header-title.title-enter { animation: titleIn 0.18s ease; }
@keyframes titleIn { from { opacity: 0; transform: translateX(8px); } }

/* ---------- 底部 Tab 栏 ---------- */
.tabbar {
  flex: none;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  z-index: 20;
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font-size: 11px;
  transition: color 0.15s, background 0.15s;
  position: relative;
}
/* 激活指示条 */
.tab-item::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  width: 20px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--primary);
  transform: translateX(-50%) scaleX(0);
  transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
.tab-item.active::before { transform: translateX(-50%) scaleX(1); }
.tab-item svg { width: 22px; height: 22px; transition: transform 0.15s; }
.tab-item:active { background: var(--primary-soft); }
.tab-item:active svg { transform: scale(0.88); }
.tab-item.active { color: var(--primary); }
.tab-item.active svg { animation: tabPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes tabPop { 0% { transform: scale(0.82); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500;
  transition: transform 0.08s, opacity 0.15s, background 0.15s, color 0.15s;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-strong); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:active { background: var(--primary-softer); }
.btn-ghost { background: var(--surface-2); color: var(--text-1); }
.btn-ghost:active { background: var(--surface-3); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #FFF; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; font-size: 16px; border-radius: var(--radius); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.input {
  width: 100%; height: 44px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus { border-color: var(--primary); background: var(--surface); }
.textarea {
  width: 100%; padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none; resize: vertical; min-height: 72px;
  transition: border-color 0.15s, background 0.15s;
}
.textarea:focus { border-color: var(--primary); background: var(--surface); }
.select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%; height: 44px; padding: 0 34px 0 14px;
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA0AA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  outline: none; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.select:focus { border-color: var(--primary); }
.select option { background: var(--surface); color: var(--text-1); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }

/* 开关 */
.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border-radius: 999px;
  transition: background 0.2s;
}
.switch .track::after {
  content: "";
  position: absolute; top: 2.5px; left: 2.5px;
  width: 22px; height: 22px;
  background: #FFF;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(19px); }

/* ---------- 卡片 / 列表 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 14px 16px; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  width: 100%; text-align: left;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--surface-2); }
.list-item .li-icon {
  width: 36px; height: 36px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
}
.list-item .li-icon svg { width: 18px; height: 18px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { display: block; font-size: 15px; color: var(--text-1); }
.list-item .li-sub { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-right { flex: none; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.list-item .li-right svg { width: 16px; height: 16px; }
.section-title { font-size: 13px; color: var(--text-3); font-weight: 600; margin: 18px 4px 8px; letter-spacing: 0.02em; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-orange { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  max-width: 90vw;
}
.toast {
  background: rgba(22, 24, 29, 0.92);
  color: #FFF;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  max-width: 82vw;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
html[data-theme="dark"] .toast { background: rgba(236, 238, 242, 0.95); color: #16181D; }
.toast.toast-error { background: var(--danger); color: #FFF; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.95); } to { opacity: 1; transform: none; } }
.toast.toast-out { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(0.96); } }

/* ---------- 底部面板 Sheet ---------- */
.sheet-mask {
  position: fixed; inset: 0;
  background: rgba(10, 12, 16, 0.45);
  z-index: 200;
  animation: fadeIn 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88vh; /* 不用 dvh：旧版 WebView 不识别会丢失 max-height 限制 */
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: sheetUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: 0.5; } to { transform: none; opacity: 1; } }
.sheet-mask.overlay-closing { animation: fadeOut 0.15s ease forwards; }
.sheet.closing { animation: sheetDown 0.22s ease forwards; }
@keyframes sheetDown { from { transform: none; opacity: 1; } to { transform: translateY(60%); opacity: 0.5; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
.sheet-head {
  flex: none;
  display: flex; align-items: center;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sheet-head .sheet-title {
  flex: 1; font-size: 16px; font-weight: 600; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.sheet-head .sheet-title > i { display: inline-flex; }
.sheet-head .sheet-title svg { width: 17px; height: 17px; color: var(--primary); }
.sheet-head .icon-btn { color: var(--text-3); }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.sheet-footer {
  flex: none;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.sheet-grip {
  flex: none;
  width: 36px; height: 4px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: var(--surface-3);
}

/* 居中弹窗 */
.dialog-mask {
  position: fixed; inset: 0;
  background: rgba(10, 12, 16, 0.45);
  z-index: 210;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
  animation: fadeIn 0.18s ease;
}
.dialog {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 18px 14px;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes dialogIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.dialog-mask.overlay-closing { animation: fadeOut 0.15s ease forwards; }
.dialog.closing { animation: dialogOut 0.18s ease forwards; }
@keyframes dialogOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.92); } }
.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; text-align: center; }
.dialog-msg { font-size: 14px; color: var(--text-2); text-align: center; line-height: 1.6; word-break: break-all; }
.dialog-btns { display: flex; gap: 10px; margin-top: 18px; }
.dialog-btns .btn { flex: 1; }

/* ---------- App 风格选择器（替代原生 select） ---------- */
.select-custom {
  width: 100%; height: 44px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 15px; color: var(--text-1);
  transition: border-color 0.15s, background 0.15s;
}
.select-custom:active { background: var(--surface-3); }
.select-custom-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-custom svg { width: 16px; height: 16px; color: var(--text-3); flex: none; transition: transform 0.2s; }
.select-custom.open svg { transform: rotate(180deg); }
/* 顶栏紧凑模式（聊天页模型选择） */
.chat-topbar #chat-model-slot { flex: 1; min-width: 0; }
.chat-topbar #chat-model-slot.model-slot-narrow { flex: 1; min-width: 0; }
.chat-topbar .select-custom {
  width: 100%; height: 38px;
  border-radius: 9px; font-size: 13.5px;
  background: var(--surface-2);
}
/* 流式/非流式切换（对话参数面板） */
.chat-stream-seg { width: 100%; }
.chat-stream-seg button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 12px; white-space: nowrap;
}
.chat-stream-seg button svg { width: 16px; height: 16px; flex: none; }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.45; }
/* 模型分组选择器（sheet 内两级：分组 → 模型） */
.gmp-group-label { font-size: 13px; color: var(--text-3); font-weight: 600; margin: 4px 4px 8px; letter-spacing: 0.02em; }
.gmp-group-list {
  display: flex; flex-direction: column;
  max-height: 200px; overflow-y: auto;
  background: var(--surface-2);
  border-radius: 14px;
  margin-bottom: 12px;
}
.gmp-group-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background 0.12s;
  position: relative;
}
.gmp-group-item:last-child { border-bottom: none; }
.gmp-group-item:active { background: var(--surface-3); }
.gmp-group-item.active { background: var(--primary-soft); }
.gmp-group-item.active .gmp-gname { color: var(--primary); font-weight: 600; }
.gmp-gname { font-size: 15px; font-weight: 600; color: var(--text-1); }
.gmp-gdesc { font-size: 12px; color: var(--text-3); }
.gmp-gcheck { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--primary); }
.gmp-search {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 10px;
}
.gmp-search svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.gmp-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--text-1);
}
.gmp-model-list {
  display: flex; flex-direction: column;
  max-height: 320px; overflow-y: auto;
}
.gmp-model-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  font-size: 15px;
  color: var(--text-1);
  text-align: left;
  transition: background 0.12s;
}
.gmp-model-item:active { background: var(--surface-2); }
.gmp-model-item.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.gmp-model-item .gmp-mname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmp-model-item svg { width: 16px; height: 16px; flex: none; }
/* 选项列表（底部面板内） */
.pick-list { display: flex; flex-direction: column; }
.pick-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  font-size: 15px;
  color: var(--text-1);
  text-align: left;
  transition: background 0.12s;
}
.pick-item:active { background: var(--surface-2); }
.pick-item.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.pick-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item svg { width: 16px; height: 16px; flex: none; }

/* 导入重名冲突提示文案 */
.conflict-tip { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 12px; }

/* ---------- 骨架屏（扫光 shimmer） ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  border-radius: 8px;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* 首页数据到达过渡 / 下拉刷新指示器 */
.home-data-enter { animation: pageFadeUp 0.28s ease; }
.ptr-indicator {
  position: fixed; top: calc(var(--safe-top) + 10px); left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.ptr-indicator svg { width: 18px; height: 18px; }

/* ---------- 空状态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; gap: 12px;
  color: var(--text-3);
}
.empty svg { width: 44px; height: 44px; opacity: 0.5; }
.empty .empty-text { font-size: 13.5px; }

/* ============================================================
   认证页
   ============================================================ */
.auth-view {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: calc(64px + var(--safe-top)) 28px calc(24px + var(--safe-bottom));
  animation: pageIn 0.22s ease;
}
.auth-brand { text-align: center; margin-bottom: 34px; }
.auth-logo-img {
  width: 78px; height: 78px;
  margin: 0 auto 16px;
  border-radius: 22px;
  object-fit: cover;
  display: block;
  box-shadow: 0 4px 16px rgba(22, 24, 29, 0.10);
}
.auth-brand h1 { font-size: 24px; letter-spacing: 0.01em; }
.auth-welcome { font-size: 13.5px; color: var(--text-3); margin-top: 6px; }
.auth-brand-sm { margin-bottom: 26px; }
.auth-register { padding-top: calc(14px + var(--safe-top)); }
.auth-back {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface-2); color: var(--text-2);
  margin-bottom: 18px;
}
.auth-back:active { background: var(--surface-3); }
.auth-back svg { width: 20px; height: 20px; }

/* 图标输入框（App 原生风格，无卡片包裹） */
.auth-input {
  display: flex; align-items: center; gap: 10px;
  height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.auth-input > svg { width: 19px; height: 19px; color: var(--text-3); flex: none; transition: color 0.15s; }
.auth-input:focus-within > svg { color: var(--primary); }
.auth-input .input {
  flex: 1; height: 100%;
  border: none; background: transparent;
  padding: 0;
}
.auth-input .input:focus { border-color: transparent; background: transparent; }
.auth-eye {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); border-radius: 8px;
}
.auth-eye:active { background: var(--surface-2); color: var(--text-1); }
.auth-eye svg { width: 18px; height: 18px; }

/* 登录页「自动登录」勾选：整行可点，不用开关 */
.auth-check {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 2px 0 18px;
  min-height: 36px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.auth-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.auth-check-box {
  width: 18px;
  height: 18px;
  flex: none;
  box-sizing: border-box;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.auth-check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid var(--on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transform-origin: center;
  transition: transform 0.12s ease;
}
.auth-check input:checked + .auth-check-box {
  background: var(--primary);
  border-color: var(--primary);
}
.auth-check input:checked + .auth-check-box::after {
  transform: rotate(45deg) scale(1);
}
.auth-check input:focus-visible + .auth-check-box {
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.auth-check:active .auth-check-box { border-color: var(--primary); }

/* 验证码行 */
.auth-code-row { display: flex; gap: 10px; align-items: stretch; }
.auth-code-row .auth-input { flex: 1; }
.auth-code-row #btn-send-code { flex: none; width: 118px; height: 48px; border-radius: 14px; }

/* 登录页关于/检查更新页脚 */
.auth-about { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-3); display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-about button { color: var(--primary); font-weight: 600; background: none; border: none; padding: 4px 6px; cursor: pointer; font-size: 12px; }
.auth-about button:active { opacity: 0.7; }
.auth-about button:disabled { color: var(--text-3); }
/* 页面底部切换链接 */
.auth-switch {
  text-align: center;
  font-size: 14px;
  color: var(--text-2);
  margin-top: 24px;
}
.auth-switch button { color: var(--primary); font-weight: 600; }
.auth-switch button:active { opacity: 0.7; }

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: none;
}
.form-error.show { display: block; animation: pageIn 0.18s ease; }

/* ============================================================
   首页
   ============================================================ */
.home-hello { display: flex; align-items: center; gap: 12px; margin: 4px 2px 14px; }
.home-avatar {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 17px;
}
.home-hello .hh-name { font-size: 17px; font-weight: 600; }
.home-hello .hh-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

.quota-card {
  background: var(--primary);
  color: #FFF;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.quota-card::after {
  content: "";
  position: absolute; right: -26px; top: -26px;
  width: 110px; height: 110px;
  border: 18px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}
.quota-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; opacity: 0.9; }
.quota-refresh-btn {
  position: absolute; bottom: 14px; right: 14px;
  background: rgba(255, 255, 255, 0.16); color: #FFF;
  border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.quota-refresh-btn:active { background: rgba(255, 255, 255, 0.28); }
.quota-refresh-btn svg { width: 14px; height: 14px; }
.quota-refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.quota-num { font-size: 30px; font-weight: 700; margin: 8px 0 2px; letter-spacing: 0.01em; padding-right: 122px; }
.quota-sub { font-size: 12.5px; opacity: 0.85; padding-right: 122px; }
.quota-actions { display: flex; gap: 8px; margin-top: 14px; position: relative; z-index: 1; }
.quota-actions .btn { background: rgba(255, 255, 255, 0.16); color: #FFF; height: 34px; font-size: 13px; border-radius: 9px; }
.quota-actions .btn:active { background: rgba(255, 255, 255, 0.28); }

/* 看广告赚余额入口（余额卡右侧空白处，垂直居中胶囊；三态：正常/冷却倒计时/今日达上限） */
.quota-ad-btn {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  z-index: 1;
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.16); color: #FFF;
  border-radius: 999px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; /* disabled 态文案「明日 8 点重置」不换行 */
}
.quota-ad-btn:active { background: rgba(255, 255, 255, 0.28); }
.quota-ad-btn:disabled { opacity: 0.65; }
.quota-ad-btn svg { width: 19px; height: 19px; flex: none; }
.quota-ad-text { display: flex; flex-direction: column; align-items: flex-start; }
.quota-ad-text small { font-size: 10.5px; font-weight: 400; opacity: 0.85; margin-top: 1px; }

/* 看广告收益入口行（余额卡内：今日已赚 + 明细） */
.quota-ad-earn { display: flex; align-items: stretch; gap: 8px; margin-top: 10px; position: relative; z-index: 1; }
.quota-ad-detail {
  flex: 0 0 auto;           /* 不撑满整行：按内容自适应宽度，只占一小段 */
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.14); color: #FFF;
  border-radius: 10px; padding: 7px 12px;
  font-size: 12.5px; text-align: left; line-height: 1.3;
  min-width: 0;
  max-width: 100%;
}
.quota-ad-detail:active { background: rgba(255, 255, 255, 0.28); }
.quota-ad-detail svg { width: 15px; height: 15px; flex: none; }
.quota-ad-detail .qad-txt { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.quota-ad-detail .qad-main { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quota-ad-detail small { font-size: 10.5px; opacity: 0.85; white-space: nowrap; }
.quota-ad-detail .chev { margin-left: auto; flex: none; opacity: 0.7; }

/* 看广告收益子页（本地账本汇总卡） */
.ads-earn-card { padding: 14px; }
.ads-earn-stat-row { display: flex; gap: 10px; margin-bottom: 10px; }
.ads-earn-stat-row:last-child { margin-bottom: 0; }
.ads-earn-stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}
.aes-label { font-size: 12px; color: var(--text-3); }
.aes-val { font-size: 17px; font-weight: 700; color: var(--text-1); margin-top: 2px; }
.ads-earn-stat.up .aes-val { color: var(--success); }
.ads-earn-note { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 12px; }

.stat-row { display: flex; gap: 10px; margin-top: 12px; }
.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-card .sc-label { font-size: 12px; color: var(--text-3); }
.stat-card .sc-value { font-size: 18px; font-weight: 650; margin-top: 3px; }
.stat-card .sc-value small { font-size: 11.5px; font-weight: 500; color: var(--text-3); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }
.quick-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 6px 11px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-2);
  transition: transform 0.1s, background 0.12s;
}
.quick-item:active { transform: scale(0.95); background: var(--surface-2); }
.quick-item .qi-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.quick-item .qi-icon svg { width: 19px; height: 19px; }

.model-list { display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip {
  padding: 8px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; color: var(--text-2);
  transition: all 0.15s;
}
.model-chip:active { transform: scale(0.94); }
.model-chip.chip-active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); font-weight: 500; }

/* 折叠区块（details/summary 通用） */
.collapse summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.collapse summary::-webkit-details-marker { display: none; }
.collapse summary .chev {
  flex: none;
  width: 15px; height: 15px;
  color: var(--text-3);
  transition: transform 0.2s;
  margin-left: auto;
}
.collapse[open] summary .chev { transform: rotate(180deg); }

/* ---------- 首页折叠组件 ---------- */
.banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
}
.banner summary {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 14px;
  font-size: 13.5px; font-weight: 600;
}
.banner summary:active { background: var(--surface-2); }
.banner-title { display: flex; align-items: center; gap: 6px; }
.banner-title svg { width: 15px; height: 15px; color: var(--primary); }
.banner-text { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; max-height: 96px; overflow-y: auto; line-height: 1.7; padding: 0 14px 12px; }
.banner-text:empty { display: none; }

.model-panel summary {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.model-panel[open] summary { margin-bottom: 10px; }

/* ============================================================
   聊天页
   ============================================================ */
.chat-page { display: flex; flex-direction: column; padding: 0; height: 100%; }
.chat-topbar {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-topbar .select {
  flex: 1; height: 38px;
  background-color: var(--surface-2);
  font-size: 13.5px;
  border-radius: 9px;
}
.chat-topbar .icon-btn { width: 38px; height: 38px; flex: none; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* 长内容/代码块横向溢出防护 */
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  color: var(--text-3);
}
.chat-empty svg { width: 46px; height: 46px; opacity: 0.45; }
.chat-empty .ce-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.chat-empty .ce-sub { font-size: 12.5px; }

.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 94%; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-assistant { align-self: flex-start; }
.msg-main { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: calc(100% - 40px); }
.msg-user .msg-main { align-items: flex-end; }
/* 头像：仅每组首条显示，连续消息自动隐藏并收紧间距 */
.msg-avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.msg-assistant .msg-avatar { background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.msg-assistant .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-user .msg-avatar { background: var(--primary-soft); color: var(--primary); }
.msg:not(.msg-group-start) .msg-avatar { visibility: hidden; }
.msg:not(.msg-group-start) { margin-top: -9px; }
/* 日期分隔条 */
.chat-date-sep {
  align-self: center; margin: 2px 0;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-3); font-size: 11px;
}

.msg-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.62;
  word-break: break-word;
}
.msg-user .msg-bubble {
  background: var(--primary);
  color: #FFF;
  border-bottom-right-radius: 5px;
}
.msg-assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow);
}
.msg-time { font-size: 10.5px; color: var(--text-3); margin-top: 4px; padding: 0 4px; }
.msg-error .msg-bubble { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* 思考过程折叠 */
.msg-reasoning {
  margin-bottom: 8px;
  width: 100%;
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
}
.msg-reasoning summary {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  cursor: pointer; user-select: none;
  list-style: none;
}
.msg-reasoning summary::-webkit-details-marker { display: none; }
.msg-reasoning summary svg { width: 14px; height: 14px; transition: transform 0.18s; }
.msg-reasoning[open] summary svg { transform: rotate(90deg); }
.msg-reasoning .reason-body {
  padding: 2px 12px 10px;
  font-size: 12.5px;
  color: var(--text-2);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.msg-streaming .msg-bubble::after {
  content: "";
  display: inline-block;
  width: 7px; height: 14px;
  margin-left: 2px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--primary);
  animation: blink 0.9s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* 流式加载态：thinking 三点动画 */
.thinking {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-3);
  padding: 2px 0;
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: thinkBounce 1.2s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 消息内图片（多模态） */
.chat-msg-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-msg-img {
  max-width: 200px; max-height: 200px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}
.chat-msg-text { white-space: pre-wrap; word-break: break-word; }

/* 待发送图片预览 */
.chat-img-preview {
  display: flex; gap: 8px;
  padding: 0 12px 6px;
  overflow-x: auto;
}
.chat-img-preview.hidden { display: none; }
.chat-preview {
  position: relative; flex: none;
  width: 64px; height: 64px;
}
.chat-preview img {
  width: 100%; height: 100%;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.chat-preview-del {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--danger); color: #FFF;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.chat-preview-del svg { width: 11px; height: 11px; }

/* 输入栏图片按钮 */
.chat-img-btn { color: var(--text-3); flex: none; }
.chat-img-btn:active { color: var(--primary); background: var(--primary-soft); }

/* 编辑指示条 */
.chat-editbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 2px;
}
.chat-edit-tip {
  flex: 1;
  font-size: 11.5px; color: var(--primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-editbar .icon-btn { width: 26px; height: 26px; }
.chat-editbar .icon-btn svg { width: 14px; height: 14px; }
.chat-input-inner.editing { border-color: var(--primary); }

/* 会话抽屉：搜索 + 分类 */
.sess-search {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 10px;
}
.sess-search svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.sess-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--text-1);
}
.sess-cats { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sess-cats-scroll {
  flex: 1; min-width: 0;
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px;
}
.sess-chip {
  flex: none;
  height: 30px; padding: 0 13px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px; color: var(--text-2);
  transition: all 0.15s;
}
.sess-chip:active { transform: scale(0.95); }
.sess-chip.active { background: var(--primary); color: #FFF; font-weight: 600; }
.sess-cat-manage {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); background: var(--surface-2);
}
.sess-cat-manage:active { background: var(--surface-3); }
.sess-cat-manage svg { width: 16px; height: 16px; }

/* 消息操作条 */
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity 0.15s; }
.msg:hover .msg-actions, .msg-actions.pinned { opacity: 1; }
/* 触屏：操作条隐藏，改为长按消息弹出菜单（App 手势习惯） */
.msg-actions .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.msg-actions .icon-btn svg { width: 14px; height: 14px; }
.msg-meta { font-size: 11px; color: var(--text-3); padding: 0 4px; }

/* markdown 渲染 */
.md { word-break: break-word; overflow-x: auto; } /* 宽公式/表格横向滚动 */
.md-raw { white-space: pre-wrap; } /* 流式期间的纯文本过渡态 */
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* AI 回复原地编辑 */
.msg-edit-box { width: 100%; }
.msg-edit-input { background: var(--surface-2); }
.msg-edit-btns { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.md p { margin: 4px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; font-size: 1.06em; }
.md h1 { font-size: 1.18em; } .md h2 { font-size: 1.12em; } .md h3 { font-size: 1.07em; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 10px;
  color: var(--text-2);
  margin: 6px 0;
}
.md code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 1.5px 5px;
  border-radius: 5px;
}
.md pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  position: relative;
}
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; white-space: pre; }
.md pre .code-lang {
  position: absolute; top: 6px; right: 10px;
  font-size: 10.5px; color: var(--text-3);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.md pre .code-copy {
  position: absolute; top: 5px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  background: transparent;
  transition: background 0.12s, color 0.12s;
  opacity: 0;
}
.md pre:hover .code-copy { opacity: 1; }
.md pre .code-copy:active { background: var(--surface-3); color: var(--text-1); }
.md pre .code-copy svg { width: 13px; height: 13px; }
.md a { word-break: break-all; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 10px; }
.md th { background: var(--surface-2); font-weight: 600; }
.md img { max-width: 100%; border-radius: 8px; }

/* 输入栏 */
.chat-inputbar {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 10px calc(8px + var(--safe-bottom));
}
.chat-input-inner {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface-2);
  border-radius: 20px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.chat-input-inner:focus-within { border-color: var(--primary); background: var(--surface); }
.chat-input-inner textarea {
  flex: 1;
  min-width: 0;
  border: none; outline: none; background: transparent;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  overflow-x: hidden;
  overflow-y: auto;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 7px 0;
  color: var(--text-1);
}
.chat-input-inner textarea::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-input-hint {
  display: none;
  margin: 6px 0 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (hover: hover) and (pointer: fine) {
  .chat-input-hint { display: block; }
}
.send-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}
.send-btn svg { width: 17px; height: 17px; }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.4; pointer-events: none; }
.send-btn.stop { background: var(--danger); }

/* 会话抽屉 */
.session-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.session-item.active { background: var(--primary-soft); }
.si-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.session-item.active .si-icon { background: var(--primary); color: #FFF; }
.si-icon svg { width: 16px; height: 16px; }
.session-item .si-main { flex: 1; min-width: 0; }
.session-item .si-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .si-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.session-item .si-del { color: var(--text-3); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.session-item .si-del:active { background: var(--danger-soft); color: var(--danger); }
.session-item .si-del svg { width: 15px; height: 15px; }

/* 参数面板 */
.param-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.param-row:last-child { border-bottom: none; }
.param-row .pr-label { font-size: 14px; }
.param-row .pr-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.param-row .pr-val { font-size: 14px; color: var(--primary); font-weight: 600; width: 52px; text-align: right; }
/* 自定义 range：原生滑杆在 iOS/Android 下差异大，改成 App 风格轨道+滑块 */
.param-row input[type="range"] {
  flex: 1; margin: 0 12px;
  -webkit-appearance: none; appearance: none;
  height: 24px; background: transparent; cursor: pointer;
}
.param-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) 50%, var(--surface-3) 50%, var(--surface-3) 100%);
}
.param-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #FFF; border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border);
  margin-top: -7px;
  transition: transform 0.12s;
}
.param-row input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
.param-row input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 999px; background: var(--surface-3);
}
.param-row input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--primary); }
.param-row input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #FFF;
  border: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   密钥管理页（App 卡片风格）
   ============================================================ */
.token-list { display: flex; flex-direction: column; gap: 10px; }
.token-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow);
  animation: pageIn 0.2s ease;
}
.tc-head { display: flex; align-items: center; gap: 10px; }
.tc-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.tc-icon svg { width: 18px; height: 18px; }
.tc-info { flex: 1; min-width: 0; }
.tc-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tc-name .ellipsis { flex: 1; }
.tc-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.tc-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.12s, transform 0.08s, background 0.12s;
}
.tc-btn:active { opacity: 0.7; transform: scale(0.94); background: var(--surface-2); }
.tc-btn svg { width: 18px; height: 18px; }
.tc-btn-copy { background: var(--primary-soft); color: var(--primary); }
.tc-btn-view { background: var(--surface-2); color: var(--text-2); }
.tc-btn-view.revealed { background: var(--primary-soft); color: var(--primary); }
.tc-btn-del { background: var(--danger-soft); color: var(--danger); }
.tc-key {
  width: 100%;
  margin-top: 12px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  transition: background 0.15s;
}
.tc-key:active { background: var(--surface-3); }
.tc-key-text {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  word-break: break-all;
}
.tc-key-icon { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.tc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tc-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-3);
  margin-top: 8px;
}

/* ============================================================
   我的页
   ============================================================ */
.profile-head {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 4px;
}
.profile-avatar {
  width: 54px; height: 54px; flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 600;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.profile-email { font-size: 12.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-stats { display: flex; gap: 0; margin-top: 8px; }
.profile-stats .ps {
  flex: 1;
  display: flex; flex-direction: column;
  font-size: 11px; color: var(--text-3);
}
.profile-stats .ps b { font-size: 14px; color: var(--text-1); font-weight: 600; }

/* 签到日历 */
.checkin-card { margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; }
.cal-head { text-align: center; font-size: 11px; color: var(--text-3); padding: 3px 0; }
.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  border-radius: 10px;
  color: var(--text-2);
  position: relative;
  transition: background 0.15s, transform 0.12s, color 0.15s;
}
.cal-day:active { transform: scale(0.9); background: var(--surface-2); }
.cal-day.other { color: var(--text-3); opacity: 0.45; }
.cal-day.done { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.cal-day.done::after {
  content: "";
  position: absolute; bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--primary);
}
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); font-weight: 600; }
.cal-day.checkin-pop { animation: checkinPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes checkinPop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* 签到表单区：签到码 / 图片验证码 / Turnstile */
.ck-form-field { margin-bottom: 0; }
.ck-captcha-row { display: flex; align-items: center; gap: 8px; }
.ck-captcha-img {
  width: 108px; height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  object-fit: cover;
  flex: none;
  user-select: none;
}
.ck-captcha-refresh { height: 42px; padding: 0 12px; flex: none; }
.ck-cf { min-height: 64px; display: flex; align-items: center; justify-content: center; }

/* 日志 */
.log-item { flex-direction: column; align-items: stretch; gap: 6px; }
.log-top { display: flex; align-items: center; gap: 10px; }
.log-content { font-size: 14px; flex: 1; min-width: 0; word-break: break-all; }
.log-model { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); background: var(--surface-2); padding: 2px 7px; border-radius: 6px; }
.log-meta { font-size: 11.5px; color: var(--text-3); display: flex; gap: 12px; flex-wrap: wrap; }
.log-quota { color: var(--warning); font-weight: 600; }

/* 分段切换 */
.seg { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3.5px; gap: 3.5px; }
.seg button {
  flex: 1; height: 32px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  padding: 0 6px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg button svg { width: 14px; height: 14px; flex: none; }
.seg button.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
#theme-seg {
  flex: 0 0 auto;
  min-width: 196px;
  max-width: 228px;
}
#theme-seg button { font-size: 12.5px; }

/* 设置项 */
.set-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); width: 100%; }
.set-item:last-child { border-bottom: none; }
.set-item .si-label { flex: 1; font-size: 14.5px; text-align: left; }
.set-item .si-sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }
.flex { display: flex; align-items: center; }
.flex-1 { flex: 1; min-width: 0; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb12 { margin-bottom: 12px; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.text-right { text-align: right; }
.mono { font-family: var(--mono); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 分页加载 */
.load-more { display: flex; justify-content: center; padding: 12px 0 4px; }
.load-more .btn { width: 100%; }

/* 滚动条：移动端隐藏（App 感），桌面媒体查询内保留细滚动条 */
.view, .chat-body, .sheet-body, .md pre, .banner-text { scrollbar-width: none; }
.view::-webkit-scrollbar, .chat-body::-webkit-scrollbar, .sheet-body::-webkit-scrollbar,
.md pre::-webkit-scrollbar, .banner-text::-webkit-scrollbar { display: none; }

@media (min-width: 480px) {
  .toast-wrap { max-width: 480px; }
  .view, .chat-body, .sheet-body, .md pre, .banner-text { scrollbar-width: thin; }
  .view::-webkit-scrollbar, .chat-body::-webkit-scrollbar, .sheet-body::-webkit-scrollbar,
  .md pre::-webkit-scrollbar, .banner-text::-webkit-scrollbar { display: block; width: 5px; height: 5px; }
  .view::-webkit-scrollbar-thumb, .chat-body::-webkit-scrollbar-thumb,
  .sheet-body::-webkit-scrollbar-thumb, .md pre::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
}

/* ============================================================
   模型详情 Sheet
   ============================================================ */
.mdl-sheet { display: flex; flex-direction: column; height: 100%; }
.mdl-sheet .mdl-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  background: var(--surface-2); border-radius: 11px; padding: 4px;
}
.mdl-sheet .mdl-tab {
  flex: 1; height: 36px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text-2);
  background: transparent; transition: all 0.15s;
}
.mdl-sheet .mdl-tab.active {
  background: var(--surface); color: var(--primary); font-weight: 600;
  box-shadow: var(--shadow);
}
.mdl-sheet .mdl-panel { flex: 1; overflow-y: auto; }
.mdl-sheet .mdl-panel.hidden { display: none; }
.mdl-sheet .mdl-panel.mdl-panel-enter { animation: pageFadeUp 0.22s ease; }
.mdl-sheet .mdl-content { display: flex; flex-direction: column; gap: 12px; }
.mdl-sheet .mdl-footer {
  flex: none; padding-top: 12px; margin-top: 4px;
  border-top: 1px solid var(--border);
}
.mdl-sheet .mdl-footer .btn { height: 48px; font-size: 16px; border-radius: 12px; }

/* 模型详情卡片 */
.mdl-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.mdl-card .mdl-card-title {
  font-size: 13px; color: var(--text-2); font-weight: 600;
  margin-bottom: 10px; letter-spacing: 0.02em;
}
.mdl-card .mdl-empty {
  font-size: 13px; color: var(--text-3); text-align: center;
  padding: 24px 0;
}

/* 模型详情头部 */
.mdl-header {
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 0 12px;
}
.mdl-header-name {
  font-size: 20px; font-weight: 700; color: var(--text-1);
  letter-spacing: -0.01em;
}

/* 指标网格 */
.mdl-metrics {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.mdl-metric {
  flex: 1; min-width: 80px;
  display: flex; flex-direction: column; gap: 4px;
}
.mdl-metric-label {
  font-size: 11px; color: var(--text-3);
}
.mdl-metric-val {
  font-size: 18px; font-weight: 600; color: var(--text-1);
}
.mdl-metric-val.success { color: var(--success); }

/* 定价信息 */
.mdl-pricing-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.mdl-pricing-row:last-child { border-bottom: none; padding-bottom: 0; }
.mdl-pricing-label { font-size: 13px; color: var(--text-2); }
.mdl-pricing-val { font-size: 13px; color: var(--text-1); font-weight: 500; }

/* 模型信息 */
.mdl-model-info { display: flex; flex-direction: column; gap: 6px; }
.mdl-model-name {
  font-size: 16px; font-weight: 600; color: var(--text-1);
}
.mdl-model-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
}

/* 表格 */
.mdl-table-wrap { overflow-x: auto; }
.mdl-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.mdl-table th, .mdl-table td {
  padding: 8px 6px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.mdl-table th {
  font-weight: 600; color: var(--text-2); background: var(--surface-3);
  white-space: nowrap;
}
.mdl-table td { color: var(--text-1); }
.mdl-table tr:last-child td { border-bottom: none; }

/* ============================================================
   订阅管理页
   ============================================================ */
.sub-list { display: flex; flex-direction: column; gap: 10px; }
.sub-card { animation: pageIn 0.2s ease; }
.sub-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sub-card-title { font-size: 15.5px; font-weight: 600; }
.sub-card-meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 12.5px; color: var(--text-2);
  margin-top: 8px;
}
.sub-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.sub-card-meta svg { width: 13px; height: 13px; }

.plan-list { display: flex; flex-direction: column; gap: 10px; }
.plan-card { animation: pageIn 0.2s ease; }
.plan-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 4px;
}
.plan-card-title { font-size: 15.5px; font-weight: 600; }
.plan-card-price {
  font-size: 14px; font-weight: 600; color: var(--primary);
  white-space: nowrap;
  margin-bottom: 8px;
}
.plan-card-desc {
  font-size: 13px; color: var(--text-2);
  margin-bottom: 8px; line-height: 1.5;
}
.plan-card-meta-list {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 10px;
}
.plan-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2);
}
.plan-meta svg { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.plan-card-models {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 12px;
}
.plan-model-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  font-family: var(--mono);
}

/* API 密钥卡片（复用 .tc-icon / .tc-key 等） */
.sub-apikey-card { animation: pageIn 0.2s ease; }
.sub-apikey-head {
  display: flex; align-items: center; gap: 10px;
}
.sub-apikey-info { flex: 1; min-width: 0; }
.sub-apikey-title { font-size: 15px; font-weight: 600; }
.sub-apikey-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.sub-apikey-actions {
  display: flex; gap: 8px; margin-top: 12px;
}

/* ============================================================
   角色卡工作台（card workshop）— cw-* 命名空间
   ============================================================ */

.cw-page {
  display: flex; flex-direction: column;
  height: 100%; padding-top: 8px;
}

/* ---------- 顶栏 ---------- */
.cw-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 10px;
}
.cw-header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cw-title-btn {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 50%;
  padding: 6px 10px; border: none; background: transparent;
  color: var(--text-2); font-size: 15px; font-weight: 600;
  cursor: pointer; border-radius: var(--radius-sm);
}
.cw-title-btn:active { background: var(--surface-2); }
.cw-title-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.cw-title-btn svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }

/* 模型选择 pill：外观与聊天页模型选择器（.chat-topbar .select-custom）保持一致 */
.cw-model-pill {
  display: inline-flex; align-items: center;
  max-width: 200px;
  cursor: pointer;
}
.cw-model-pill .select-custom {
  width: 100%; height: 38px;
  padding: 0 12px;
  border-radius: 9px; font-size: 13.5px;
  background: var(--surface-2);
}
.cw-model-pill .select-custom-label { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cw-icon-btn {
  width: 40px; height: 40px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer;
}
.cw-icon-btn svg { width: 18px; height: 18px; }
.cw-icon-btn:active { background: var(--surface-2); }
.cw-icon-btn:disabled { opacity: 0.4; pointer-events: none; }
.cw-danger { color: #EF4444; }

/* ---------- Tab 栏（分段器：容器 + 选中滑块） ---------- */
.cw-tabs {
  display: flex; gap: 4px; padding: 4px;
  margin: 0 16px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.cw-segment-item {
  flex: 1; padding: 8px 6px;
  font-size: 13px; color: var(--text-3);
  background: transparent; border: none; border-radius: 9px;
  cursor: pointer; transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.cw-segment-item:active { background: var(--surface-3); }
.cw-segment-item-active {
  color: var(--primary); font-weight: 600;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ---------- 内容区 ---------- */
.cw-content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
}

/* 字段区块 */
.cw-field { margin-bottom: 14px; }
.cw-row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cw-field-head { margin-bottom: 6px; }
.cw-field-side { display: flex; align-items: center; gap: 8px; }
.cw-setting-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.cw-setting-sub { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.cw-mt12 { margin-top: 12px; }
.cw-mt16 { margin-top: 16px; }
.cw-my16 { margin-top: 16px; margin-bottom: 16px; }
.cw-flex1 { flex: 1; min-width: 0; }
.cw-char-count { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.cw-prompt-input, .cw-dialog-input, .cw-dialog-textarea {
  width: 100%; box-sizing: border-box;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); padding: 10px 12px;
  font-size: 15px; color: var(--text); outline: none;
  transition: border-color 0.15s; font-family: inherit;
}
.cw-prompt-input:focus, .cw-dialog-input:focus, .cw-dialog-textarea:focus { border-color: var(--primary); }
.cw-prompt-input { resize: none; line-height: 1.6; min-height: 56px; }
.cw-dialog-textarea { resize: none; line-height: 1.6; }
.cw-prompt-input:disabled, .cw-dialog-input:disabled, .cw-dialog-textarea:disabled {
  opacity: 0.6; background: var(--surface-2);
}

/* ---------- 按钮 ---------- */
.cw-btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 34px; padding: 0 12px; font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border: none;
  border-radius: 10px; cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.cw-btn-outline svg { width: 15px; height: 15px; }
.cw-btn-outline:active { transform: scale(0.96); background: var(--surface-3); }
.cw-btn-outline.cw-danger { color: #EF4444; background: rgba(239,68,68,0.08); }
.cw-btn-outline:disabled { opacity: 0.4; pointer-events: none; }
/* 主操作（新建等）：primary 填充 */
.cw-btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 34px; padding: 0 12px; font-size: 13px; font-weight: 600; color: #fff;
  background: var(--primary); border: none;
  border-radius: 10px; cursor: pointer;
  transition: opacity 0.12s, transform 0.1s;
}
.cw-btn-primary svg { width: 15px; height: 15px; }
.cw-btn-primary:active { transform: scale(0.96); opacity: 0.85; }
.cw-btn-primary:disabled { opacity: 0.4; pointer-events: none; }
.cw-btn-active { background: var(--primary); color: #fff; font-weight: 600; }
.cw-btn-active svg { color: #fff; }
.cw-btn-text {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 8px;
  font-size: 13px; color: var(--text-3); background: transparent; border: none;
  cursor: pointer; border-radius: 6px;
}
.cw-btn-text svg { width: 14px; height: 14px; flex: none; }
.cw-btn-text.cw-primary { color: var(--primary); font-weight: 600; }

.cw-tpl-list { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; }
.cw-tpl-group-name {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-bottom: 8px;
}
.cw-tpl-items { display: flex; flex-direction: column; gap: 6px; }
.cw-tpl-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 12px; text-align: left;
  background: var(--surface-2); border: none; border-radius: 10px;
  cursor: pointer; transition: background 0.12s;
}
.cw-tpl-item:active { background: var(--surface-3); }
.cw-tpl-name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.cw-tpl-desc {
  font-size: 11.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cw-cm-search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 38px;
  background: var(--surface-2); border-radius: 10px;
  margin-bottom: 10px;
}
.cw-cm-search svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.cw-cm-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--text);
}
.cw-cm-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cw-tag-chip {
  padding: 3px 10px; font-size: 12px; color: var(--text-2);
  background: var(--surface-2); border: none; border-radius: 999px;
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.cw-tag-chip.active { background: var(--primary); color: #fff; font-weight: 600; }
.cw-cm-sort { display: flex; gap: 4px; margin-bottom: 10px; }
.cw-sort-btn {
  padding: 4px 10px; font-size: 12px; color: var(--text-3);
  background: transparent; border: none; border-radius: 6px; cursor: pointer;
}
.cw-sort-btn.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.cw-cm-check {
  width: 22px; height: 22px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); border-radius: 50%;
  color: transparent; cursor: pointer;
}
.cw-cm-check.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.cw-cm-check svg { width: 13px; height: 13px; }
.cw-cm-batch {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 8px 10px;
  background: var(--surface-2); border-radius: 12px;
}
.cw-cm-batch.hidden { display: none; }
.cw-cm-batch-count { flex: 1; font-size: 13px; color: var(--text-2); font-weight: 500; }

/* ---------- 试聊 ---------- */
.cw-trial { display: flex; flex-direction: column; height: 56vh; min-height: 320px; }
.cw-trial-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cw-trial-msgs {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 2px;
}
.cw-trial-msg { display: flex; gap: 8px; align-items: flex-start; }
.cw-trial-msg.user { justify-content: flex-end; }
.cw-trial-msg.user .cw-trial-body { align-items: flex-end; }
.cw-trial-avatar {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  background: var(--surface-3); border-radius: 50%;
  object-fit: cover; overflow: hidden;
}
.cw-trial-body { display: flex; flex-direction: column; gap: 3px; max-width: 78%; }
.cw-trial-name { font-size: 11.5px; color: var(--text-3); padding: 0 4px; }
.cw-trial-bubble {
  max-width: 100%;
  padding: 9px 12px;
  font-size: 14px; line-height: 1.6;
  background: var(--surface-2); border-radius: 14px;
  word-break: break-word;
}
.cw-trial-msg.user .cw-trial-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.cw-trial-msg.assistant .cw-trial-bubble { border-bottom-left-radius: 4px; }
.cw-trial-bubble p { margin: 0 0 6px; }
.cw-trial-bubble p:last-child { margin-bottom: 0; }
.cw-trial-thinking { color: var(--text-3); }
.cw-trial-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 30px; text-align: center;
  color: var(--text-3); font-size: 14px;
}
.cw-trial-empty svg { width: 28px; height: 28px; opacity: 0.5; margin-bottom: 4px; }
.cw-trial-bar {
  display: flex; align-items: flex-end; gap: 8px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}
.cw-trial-bar textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px;
  padding: 10px 12px; font-size: 14.5px; color: var(--text);
  background: var(--surface-2); border: none; border-radius: 20px; outline: none;
  line-height: 1.5; font-family: inherit;
}

/* ---------- 引导 ---------- */
.cw-guide {
  position: relative; margin-bottom: 14px;
  padding: 14px 14px 12px; background: var(--primary-soft);
  border: 1px solid rgba(37,99,235,0.15); border-radius: var(--radius);
}
.cw-guide-close {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.cw-guide-close svg { width: 14px; height: 14px; }
.cw-guide-title { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.cw-guide-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cw-chip {
  padding: 5px 10px; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer;
}
.cw-chip:active { transform: scale(0.96); }

/* ---------- 头像 ---------- */
.cw-avatar-row { display: flex; gap: 14px; margin-bottom: 14px; }
.cw-avatar {
  position: relative; width: 72px; height: 72px; flex: none;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.cw-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.cw-avatar-placeholder { color: var(--text-3); display: flex; }
.cw-avatar-placeholder svg { width: 32px; height: 32px; }
.cw-avatar-badge {
  position: absolute; bottom: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.cw-avatar-badge svg { width: 12px; height: 12px; }
.cw-avatar-side { display: flex; flex-direction: column; gap: 4px; }
.cw-avatar-btns { display: flex; gap: 8px; margin-top: 6px; }

/* ---------- 条目列表（世界书/正则） ---------- */
.cw-tab-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.cw-tab-actions .cw-btn-outline, .cw-tab-actions .cw-btn-primary { flex: 1; height: 36px; }
.cw-entry-list { display: flex; flex-direction: column; gap: 8px; }
.cw-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  transition: border-color 0.12s, transform 0.1s;
}
.cw-entry:active { border-color: var(--primary-soft); }
.cw-entry-main { flex: 1; min-width: 0; cursor: pointer; }
.cw-entry-off { opacity: 0.55; }
.cw-entry-title { font-size: 14px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.cw-entry-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-entry-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.cw-chip-mini {
  padding: 1px 7px; font-size: 10.5px; color: var(--text-3);
  background: var(--surface-2); border-radius: 5px;
}
.cw-entry-tag {
  display: inline-block; padding: 1px 7px;
  font-size: 11px; color: var(--primary);
  background: var(--primary-soft); border-radius: 4px; flex: none;
}
.cw-entry-batch {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 8px 10px;
  background: var(--surface-2); border-radius: 12px;
  position: sticky; top: 0; z-index: 2;
}
/* 多选态高亮：优先 :has 自动跟随；旧 WebView 用 JS 渲染的 .selected 类兜底 */
.cw-entry:has(.cw-cm-check.on),
.cw-card-item:has(.cw-cm-check.on),
.cw-entry.selected,
.cw-card-item.selected {
  background: var(--primary-softer);
  box-shadow: 0 0 0 1.5px var(--primary);
}
.cw-entry-batch .cw-btn-outline { flex: none; height: 30px; padding: 0 10px; }
.cw-batch-count { flex: 1; font-size: 13px; color: var(--text-2); font-weight: 500; }
.cw-empty { padding: 24px 0; text-align: center; font-size: 13px; color: var(--text-3); }

/* ---------- 开关（热区 ≥44px，视觉保持紧凑） ---------- */
.cw-toggle {
  width: 44px; height: 24px; flex: none;
  border-radius: 999px; border: none;
  background: var(--surface-3); cursor: pointer;
  position: relative; transition: background 0.15s;
  padding: 0;
}
.cw-toggle-on { background: var(--primary); }
.cw-toggle-dot {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cw-toggle-dot-on { transform: translateX(20px); }

/* ---------- 弹层内表单 ---------- */
.cw-form { display: flex; flex-direction: column; gap: 4px; }
.cw-toggle-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.cw-num-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.cw-num-grid-2 { grid-template-columns: 1fr 1fr; }
.cw-flags { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.cw-flag { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-2); }
.cw-flag input { accent-color: var(--primary); width: 16px; height: 16px; }
.cw-regex-result {
  margin-top: 8px; padding: 10px 12px; min-height: 48px; max-height: 120px; overflow: auto;
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
}
.cw-regex-result-err { color: #EF4444; }
.cw-divider { height: 1px; background: var(--border); flex-shrink: 0; }
.cw-sheet-section-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.cw-sheet-list { display: flex; flex-direction: column; }
.cw-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 12px; font-size: 14px; color: var(--text-2);
  background: transparent; border: none; cursor: pointer;
  border-radius: var(--radius-sm); text-align: left;
}
.cw-menu-item svg { width: 18px; height: 18px; flex: none; }
.cw-menu-item:active { background: var(--surface-2); }
.cw-menu-item.cw-danger { color: #EF4444; }

/* 导出条目选择 */
.cw-export-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.cw-export-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.cw-export-item:active { background: var(--surface-2); }
.cw-export-item input { accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.cw-export-item-title { font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 卡片管理列表 ---------- */
.cw-card-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: default;
}
.cw-card-item-active { background: var(--primary-soft); }
.cw-card-thumb {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.cw-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cw-card-thumb svg { width: 20px; height: 20px; color: var(--text-3); }
.cw-card-item-main { flex: 1; min-width: 0; cursor: pointer; }
.cw-card-item-name { font-size: 14px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 底部 composer（流式贴底，与聊天页 .chat-inputbar 一致；fixed 会在窄视口超出） ---------- */
.cw-composer {
  flex: none;
  padding: 10px 12px calc(12px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.cw-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.cw-composer-input {
  flex: 1; resize: none; min-height: 40px; max-height: 120px;
  padding: 10px 12px; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; outline: none; line-height: 1.5;
  font-family: inherit;
}
.cw-composer-input:focus { border-color: var(--primary); }
.cw-send-btn {
  width: 40px; height: 40px; flex: none;
  border: none; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.1s;
}
.cw-send-btn svg { width: 18px; height: 18px; }
.cw-send-btn:active { transform: scale(0.92); }
.cw-diff-btn { margin-top: 8px; width: 100%; justify-content: center; }

/* 进度条 */
.cw-progress { margin-bottom: 8px; }
.cw-progress-bar {
  height: 4px; background: var(--surface-3); border-radius: 999px; overflow: hidden;
}
.cw-progress-fill {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width 0.2s; width: 0%;
}
.cw-progress-text { display: block; margin-top: 5px; font-size: 12px; color: var(--text-3); }

/* ---------- Diff 确认 ---------- */
.cw-diff-list { display: flex; flex-direction: column; gap: 10px; max-height: 56vh; overflow: auto; }
.cw-diff-item {
  padding: 10px; background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.cw-diff-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cw-diff-head input { accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.cw-diff-cols { display: flex; gap: 8px; }
.cw-diff-before, .cw-diff-after {
  flex: 1; min-width: 0; padding: 8px;
  background: var(--surface); border-radius: 8px;
  font-size: 12px; color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 120px; overflow: auto;
}
.cw-diff-before { border-left: 2px solid #EF4444; }
.cw-diff-after { border-left: 2px solid var(--success); }

/* ---------- 预览 iframe ---------- */
.cw-preview-wrap { padding: 0; }
.cw-preview-frame {
  width: 100%; height: 60vh; border: none; border-radius: var(--radius-sm);
  background: var(--surface);
}
html[data-theme="dark"] .cw-preview-frame { background: #101216; }

/* 弹层内避免 .sheet-body 默认 padding 过大影响表单密度 */
.sheet-body .cw-form,
.sheet-body .cw-sheet-list { padding: 0; }

/* ---------- 广告 OAID 权限引导弹窗 ---------- */
.ad-perm-tip { line-height: 1.65; }
.ad-perm-tip-main { margin: 0 0 12px; font-size: 14px; color: var(--text-1); }
.ad-perm-tip-step {
  margin: 0 0 16px; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2);
  word-break: break-word;
}

/* ---------- 原生 App 细节补全 ---------- */
/* 可点击行统一按压反馈 */
.set-item:active, .session-item:active, .param-row:active, .cw-card-item:active,
.pick-item:active, .list-item:active { background: var(--surface-2); }
.cw-card-item { cursor: pointer; transition: background 0.12s, box-shadow 0.12s; }

/* 主题切换平滑过渡（仅表面色，避免滚动拖慢） */
body, .app, .app-header, .tabbar, .card, .list, .input, .textarea, .sheet, .dialog {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* 窄屏 Diff 前后对比上下堆叠 */
@media (max-width: 479px) {
  .cw-diff-cols { flex-direction: column; }
}

/* 减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   在线听歌 / 在线影视（media 页，music-* video-* 命名空间）
   ============================================================ */
/* 首页快捷宫格第二行：媒体入口各占 2 列（宽度为上方单个入口 2 倍） */
.quick-item.q-wide { grid-column: span 2; }

/* ---------- 媒体页通用 ---------- */
.media-search { display: flex; gap: 8px; margin-bottom: 12px; }
.media-search .media-q { flex: 1; min-width: 0; }
.media-search .media-go { flex: none; padding: 0 14px; }
.media-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.media-tab {
  flex: 1; padding: 9px 0; background: none; border: none;
  font-size: 13px; color: var(--text-2); border-bottom: 2px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.media-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.media-fav-n {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 11px; display: inline-flex; align-items: center; justify-content: center;
}
.media-tab.active .media-fav-n { background: var(--primary-soft); color: var(--primary); }
.media-empty {
  padding: 34px 16px; text-align: center; font-size: 13px; color: var(--text-3);
}
.media-loading { display: flex; align-items: center; justify-content: center; gap: 8px; }
.media-list { display: flex; flex-direction: column; gap: 8px; }
.media-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: background 0.12s;
}
.media-item:active { background: var(--surface-2); }
.media-item-main { flex: 1; min-width: 0; }
.media-item-name { display: block; font-size: 13px; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item-sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item-go { flex: none; color: var(--text-3); }
.media-item-go svg { width: 17px; height: 17px; }
.media-chip {
  padding: 7px 13px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 12.5px; color: var(--text-2); transition: all 0.15s;
}
.media-chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.media-chip.mini { padding: 3px 9px; font-size: 11.5px; }
.media-chip:active { transform: scale(0.95); }
/* 缩略图容器（48 方块；影视宽版用 .video-thumb 覆盖） */
.media-thumb {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 10px;
  background: var(--surface-2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.media-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-thumb-fb { font-size: 18px; font-weight: 600; color: var(--text-3); }
.media-back { margin-bottom: 10px; }
.media-back-btn { padding: 7px 13px; font-size: 13px; }
.media-more { width: 100%; margin-top: 10px; font-size: 13px; }

/* ---------- 在线听歌 ---------- */
.music-player {
  margin-top: 14px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.music-hero { display: flex; gap: 12px; align-items: flex-start; }
.music-hero .media-thumb { width: 72px; height: 72px; border-radius: 12px; }
.music-hero .media-thumb-fb { font-size: 26px; }
.music-hero-info { flex: 1; min-width: 0; padding-top: 2px; }
.music-name { font-size: 15px; font-weight: 650; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-singer { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.music-meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.music-hero-actions { display: flex; flex-direction: column; gap: 8px; }
.music-hero-actions .icon-btn { width: 36px; height: 36px; }
.music-fav.on svg { fill: #ef4444; stroke: #ef4444; }
.music-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.music-play-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
}
.music-play-btn svg { width: 20px; height: 20px; }
.music-play-btn:active { transform: scale(0.94); }
.music-time { font-size: 11.5px; color: var(--text-3); min-width: 34px; text-align: center; }
.music-range {
  flex: 1; min-width: 0; height: 26px; -webkit-appearance: none; appearance: none;
  background: none; margin: 0; padding: 0;
}
.music-range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: var(--surface-2);
}
.music-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary); margin-top: -5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.music-range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface-2); }
.music-range::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--primary); }
.music-quality { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.music-lyric {
  margin-top: 12px; max-height: 230px; overflow-y: auto;
  scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
  border-top: 1px dashed var(--border); padding-top: 10px;
}
.lyric-line {
  padding: 7px 10px; font-size: 13px; color: var(--text-2);
  border-radius: 8px; text-align: center; line-height: 1.5;
  transition: color 0.15s, background 0.15s;
}
.lyric-line.active {
  color: var(--primary); font-weight: 650; font-size: 14.5px;
  background: var(--primary-soft);
}
.music-lyric-empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 14px 0; }

/* ---------- 在线影视 ---------- */
.video-sources { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.video-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.video-card {
  display: flex; flex-direction: column; padding: 0; text-align: left; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.1s, background 0.12s;
}
.video-card:active { transform: scale(0.97); background: var(--surface-2); }
.video-card.loading { opacity: 0.6; }
.video-card .media-thumb {
  position: relative; width: 100%; height: 0; aspect-ratio: 16 / 10;
  border-radius: 0; background: linear-gradient(160deg, var(--surface-2), var(--surface));
}
.video-card .media-thumb-fb { font-size: 26px; }
.video-card-main { padding: 8px 10px 10px; }
.video-card-name { display: block; font-size: 13px; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-card-sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-detail { display: flex; flex-direction: column; gap: 10px; }
.video-d-head { display: flex; gap: 12px; }
.video-d-head .media-thumb { width: 92px; height: 128px; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.video-d-head .media-thumb-fb { font-size: 30px; }
.video-d-main { flex: 1; min-width: 0; }
.video-d-name { font-size: 15px; font-weight: 650; color: var(--text-1); line-height: 1.35; }
.video-d-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.video-d-ops { display: flex; gap: 8px; }
.video-d-ops .btn { flex: 1; font-size: 13px; min-height: 42px; border-radius: 12px; }
.video-d-intro {
  padding: 10px 12px; background: linear-gradient(180deg, var(--surface-2), transparent);
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-2); line-height: 1.65; word-break: break-word;
}
.video-ep-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.video-ep {
  min-height: 36px;
  padding: 8px 4px; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: all 0.12s;
}
.video-ep:active { transform: scale(0.95); background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.video-player-page { display: flex; flex-direction: column; }
.video-play-title {
  font-size: 13.5px; font-weight: 600; color: var(--text-1);
  margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 播放器固定适配容器：不随视频固有分辨率变化（不同集分辨率不同会忽大忽小） */
.video-el {
  display: block; width: 100%; max-width: 100%;
  aspect-ratio: 16 / 9; background: #000; border-radius: 12px;
}
.video-el::-webkit-media-controls-enclosure { border-radius: 12px; overflow: hidden; }
.video-ops { display: flex; gap: 8px; margin-top: 10px; }
.video-ops .btn { flex: 1; font-size: 13px; }
.btn.disabled { opacity: 0.45; pointer-events: none; }

/* ---------- 影视播放视图（vplay：沉浸背景 + 信息 + 操作组 + 选集） ---------- */
.vplay { display: flex; flex-direction: column; padding-bottom: calc(8px + var(--safe-bottom)); }
.vplay-media {
  position: relative; overflow: hidden; border-radius: 16px;
  background: linear-gradient(160deg, var(--surface-2), var(--bg));
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
}
.vplay-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(26px) saturate(1.15); transform: scale(1.25);
  opacity: 0.5; pointer-events: none;
}
.vplay-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.6));
}
.vplay-media .video-el { position: relative; z-index: 1; border-radius: 0; }
.vplay-info { padding: 12px 2px 0; }
.vplay-title {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 17px; font-weight: 700; color: var(--text-1); line-height: 1.35;
}
.vplay-title .vt-ep {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vplay-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vplay-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.vplay-actions .btn {
  flex: 1 1 calc(25% - 8px); min-width: 72px; min-height: 44px;
  padding: 10px 6px; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  transition: background 0.12s, transform 0.1s;
}
.vplay-actions .btn:active { background: var(--surface-2); transform: scale(0.97); }
.vplay-actions .btn svg { flex: none; width: 17px; height: 17px; }
.vplay-actions .btn.on svg { fill: #ef4444; stroke: #ef4444; }
.vplay-ep { margin-top: 16px; }
/* 当前集高亮（播放视图内选集） */
.video-ep.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 600;
}
/* 横屏（手机横过来看视频）：媒体区最大化、信息压缩 */
@media (orientation: landscape) and (max-height: 520px) {
  .vplay-media { border-radius: 0; box-shadow: none; }
  .vplay-info { padding-top: 8px; }
  .vplay-title { font-size: 14px; }
  .vplay-actions { margin-top: 8px; }
  .vplay-actions .btn { min-height: 40px; padding: 8px 4px; font-size: 12px; }
}
/* 小屏：剧集网格 4 列 → 3 列 */
@media (max-width: 359px) {
  .video-ep-grid { grid-template-columns: repeat(3, 1fr); }
  .music-lyric { max-height: 180px; }
}

/* ---------- 音乐独立播放页（home/music/play） ---------- */
/* 高度撑满 #view（.page 已 min-height:100%），歌词区内部滚动、控制条吸底 */
.mplay { display: flex; flex-direction: column; height: 100%; }
/* 唱片：圆形封面 + 沟槽环 + 中心孔，播放时旋转（暂停停转） */
.mplay-disc { display: flex; justify-content: center; padding-top: 10px; }
.mplay-disc .media-thumb {
  position: relative; flex: none; width: 74%; max-width: 300px; height: auto;
  aspect-ratio: 1 / 1; border-radius: 50%; overflow: hidden;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.20), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.mplay-disc .media-thumb::before {
  content: ''; position: absolute; inset: 7%; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  pointer-events: none; z-index: 1;
}
.mplay-disc .media-thumb::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 13%; height: 13%; transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6b7280, #374151 60%, #1f2937);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  pointer-events: none; z-index: 1;
}
.mplay-disc .media-thumb img { z-index: 0; }
.mplay-disc .media-thumb-fb { font-size: 64px; }
.mplay-disc.playing .media-thumb { animation: disc-spin 18s linear infinite; }
@keyframes disc-spin { to { transform: rotate(360deg); } }
.mplay-info { margin-top: 16px; text-align: center; }
.mplay-name {
  font-size: 19px; font-weight: 700; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mplay-singer { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.mplay-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.mplay-actions { display: flex; justify-content: center; gap: 14px; margin-top: 14px; }
.mplay-actions .icon-btn {
  width: 42px; height: 42px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.mplay-actions .music-fav.on svg { fill: #ef4444; stroke: #ef4444; }
.mplay-controls {
  position: sticky; bottom: 0; margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0 6px; border-top: 1px solid var(--border);
  background: var(--bg);
}
.mplay-controls .music-play-btn { width: 56px; height: 56px; }
.mplay-controls .music-play-btn svg { width: 24px; height: 24px; }
.mplay-controls .music-time { font-size: 12px; }
.mplay-quality { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
/* 歌词占播放页主体（控制条上方滚动区），当前行高亮居中 */
.mplay-lyric {
  flex: 1 1 0; min-height: 170px; max-height: none;
  margin-top: 14px; border-top: none; padding-top: 4px;
}

/* 列表页「正在播放」迷你条（点击回播放页） */
.mplay-mini {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 12px;
  background: var(--primary-soft); border: 1px solid var(--primary);
  border-radius: var(--radius); cursor: pointer; transition: background 0.12s;
}
.mplay-mini:active { background: var(--surface-2); }
.mplay-mini .media-thumb { width: 40px; height: 40px; border-radius: 8px; }
.mplay-mini .media-thumb-fb { font-size: 15px; }
.mplay-mini-main { flex: 1; min-width: 0; }
.mplay-mini-name {
  font-size: 13px; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mplay-mini-sub { font-size: 11.5px; color: var(--text-2); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mplay-mini-go { flex: none; color: var(--primary); }
.mplay-mini-progress {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: var(--primary); border-radius: 1px; pointer-events: none;
}
