:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0f1724;
  --panel-2: #131d2c;
  --line: #1e2b40;
  --text: #e5eefb;
  --muted: #8ba0bb;
  --dim: #5f748f;
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --accent: #38bdf8;
  --input: var(--input);
  --chip: var(--chip);
  --elev: var(--elev);
  --dot: var(--dot);
  --slide-1: #12324a;
  --slide-2: #0b1a29;
  --slide-3: #101b2b;
  --radius: 14px;
}

/* 亮色主题 */
:root[data-theme=light] {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef4fb;
  --line: #d7e2f0;
  --text: #14202e;
  --muted: #4c6076;
  --dim: #64748b;
  --ok: #0b7a4b;
  --bad: #dc2626;
  --warn: #b45309;
  --accent: #0369a1;
  --input: #ffffff;
  --chip: #e6eefa;
  --elev: #f7fafd;
  --dot: #c3d3e6;
  --slide-1: #dbeafe;
  --slide-2: #f4f9ff;
  --slide-3: #eaf3fe;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  /* 底部只留一个悬浮按钮，不再需要大块留白 */
  padding: max(14px, env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 340px at 10% -10%, rgba(56, 189, 248, .13), transparent 65%),
    radial-gradient(600px 300px at 100% 0%, rgba(52, 211, 153, .08), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  max-width: 760px;
  margin: 0 auto;
}

/* 顶部 */
.top { display: flex; align-items: center; gap: 12px; margin: 6px 2px 16px;
  position: relative;
  z-index: 80;
}

/* 标题栏站点切换 */
.sources { margin-left: auto; display: flex; gap: 6px; flex: none; }
.src-btn {
  height: 30px; padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.src-btn.active {
  background: rgba(56, 189, 248, .16);
  border-color: rgba(56, 189, 248, .45);
  color: var(--accent);
  font-weight: 600;
}
.logo {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #0ea5e9, #22d3ee);
  color: #031018; font-size: 17px;
  box-shadow: 0 6px 18px rgba(14, 165, 233, .35);
}
.titles h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: .2px; }
.titles p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }

/* 输入区 */
.input-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#url, #keyword {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  /* 16px 以下 iOS 会自动放大页面 */
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#url:focus, #keyword:focus { border-color: rgba(56, 189, 248, .7); box-shadow: 0 0 0 3px rgba(56, 189, 248, .12); }
#url::placeholder, #keyword::placeholder { color: var(--dim); }

/* 两栏之间留出间隔 */
.input-card + .input-card { margin-top: 10px; }

/* 返回上一级 */
.back-btn {
  width: 100%;
  min-height: 40px;
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--muted);
}

/* 线路分页 */
.load-more {
  width: 100%;
  min-height: 44px;
  border-radius: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--accent);
  font-size: 13px;
}

button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid #2b3d57;
  background: var(--chip);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .08s, background .15s;
}
button:active { transform: scale(.985); }
button.primary {
  background: linear-gradient(180deg, #0ea5e9, #0284c7);
  border-color: #0ea5e9;
  color: #001018;
  font-weight: 650;
}
button.primary:disabled { opacity: .55; }
button.ghost { background: transparent; }

.opt { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.opt input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: #0ea5e9; flex: none; }

.mode-label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.hint { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }

/* 搜索结果卡片 */
.show-card {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.show-card:active { background: var(--panel-2); }
.show-card:hover { border-color: rgba(56, 189, 248, .45); }
.show-card .cover {
  width: 78px; height: 108px; flex: none;
  object-fit: cover; border-radius: 8px; background: var(--input);
}
.show-card .cover.ph { display: grid; place-items: center; font-size: 26px; color: var(--dim); }
.show-info { min-width: 0; flex: 1; }
.show-title { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.show-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
/* 演员列表往往很长，限两行，避免一张卡片占大半屏 */
.show-sub {
  font-size: 12px; color: var(--dim); margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.show-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show-desc {
  font-size: 11.5px; color: var(--dim); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 更多线路 */
.more-btn { width: 100%; margin-top: 2px; }
.line-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); overflow: hidden;
}
.line-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
}
.line-row:last-child { border-bottom: 0; }
.line-name { flex: none; width: 62px; font-size: 12.5px; color: var(--dim); }
.line-label { flex: 1; font-size: 13.5px; color: var(--text); }
.line-row button { flex: none; }

/* 状态 */
.status {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 11px;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  line-height: 1.55;
}
.status.running { border-color: rgba(56, 189, 248, .45); color: var(--accent); }
.status.ok { border-color: rgba(52, 211, 153, .45); color: var(--ok); background: rgba(52, 211, 153, .06); }
.status.err { border-color: rgba(248, 113, 113, .45); color: var(--bad); background: rgba(248, 113, 113, .06); }
.spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 7px;
  border: 2px solid rgba(56, 189, 248, .3); border-top-color: #38bdf8;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 结果 */
.results { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.card.ad { opacity: .55; }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(56, 189, 248, .14); color: var(--accent); border: 1px solid rgba(56, 189, 248, .3);
}
.badge.m3u8 { background: rgba(168, 85, 247, .16); color: #d8b4fe; border-color: rgba(168, 85, 247, .35); }
.badge.mp4 { background: rgba(52, 211, 153, .14); color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.badge.flv, .badge.mp4 { }
.meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.meta .chip {
  padding: 1px 7px; border-radius: 6px; background: var(--input); border: 1px solid var(--line);
}
.chip.enc { color: var(--warn); border-color: rgba(251, 191, 36, .35); }
.src { margin-left: auto; font-size: 11px; color: var(--dim); }

/* 可用性状态 */
.vstate {
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.vstate.ok { background: rgba(52, 211, 153, .14); color: var(--ok); border: 1px solid rgba(52, 211, 153, .3); }
.vstate.ref { background: rgba(251, 191, 36, .14); color: var(--warn); border: 1px solid rgba(251, 191, 36, .35); }
.vstate.unk { background: rgba(148, 163, 184, .14); color: var(--muted); border: 1px solid rgba(148, 163, 184, .35); }
.vstate.bad { background: rgba(248, 113, 113, .14); color: var(--bad); border: 1px solid rgba(248, 113, 113, .35); }

/* 自动选线提示（结果区内部） */
.line-note {
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.5;
  border: 1px solid rgba(52, 211, 153, .35);
  background: rgba(52, 211, 153, .07);
  color: var(--ok);
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 6px;
  margin: 0 2px 12px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tab {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.tab.active {
  background: rgba(56, 189, 248, .16);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, .35);
}

/* 热门 */
.hot-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 8px; }
.hot-meta { font-size: 12px; color: var(--muted); }
.hot-body { display: flex; flex-direction: column; gap: 12px; }
.hot-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.hot-group h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.hot-list { display: flex; flex-wrap: wrap; gap: 8px; }
.hot-item {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  font-size: 13px;
}
.hot-item:active { background: var(--chip); }

/* 小按钮（重测） */
button.mini {
  min-height: 24px;
  padding: 0 9px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1;
}
button.mini:active { background: var(--chip); }

/* 参考页 */
.refcard {
  background: var(--panel);
  border: 1px dashed rgba(56, 189, 248, .35);
  border-radius: var(--radius);
  padding: 12px;
}
.refcard-title { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.5; }

.warnline {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--warn);
  word-break: break-all;
}
.warnline code {
  background: rgba(251, 191, 36, .1);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11.5px;
}
.warnline.badline { color: var(--bad); }

.url {
  display: block;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12px; line-height: 1.5;
  color: var(--muted);
  word-break: break-all;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  max-height: 84px;
  overflow: auto;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
a.url:active { background: #111d2c; }
a.url:hover { border-color: rgba(56, 189, 248, .45); }

.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions > * { flex: 1; min-width: 0; }
.actions button { min-height: 42px; font-size: 14px; }
.actions .dl { flex: 1.4; }
.actions .btnlike {
  min-height: 42px;
  display: grid; place-items: center;
  border-radius: 11px; border: 1px solid #2b3d57;
  background: var(--chip); color: var(--text);
  text-decoration: none; font-size: 14px;
  padding: 0 12px;
}
.actions .btnlike:active { background: #1b2c47; }

/* 投屏弹层 */
.cast-box { max-width: 420px; }
.cast-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
}
.cast-device {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 52px;
  text-align: left;
}
.cast-device small { color: var(--dim); font-size: 11px; }

.progress {
  margin-top: 10px; height: 26px; border-radius: 8px; background: var(--input);
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.progress .bar {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, rgba(14, 165, 233, .55), rgba(34, 211, 238, .75));
  transition: width .3s;
}
.progress .txt {
  position: relative; z-index: 1; display: grid; place-items: center;
  height: 100%; font-size: 12px; color: var(--text);
}
.done-row { margin-top: 10px; display: flex; gap: 8px; }
.done-row a {
  flex: 1; min-height: 42px; display: grid; place-items: center;
  border-radius: 11px; text-decoration: none; font-size: 14px;
  background: rgba(52, 211, 153, .16); color: var(--ok);
  border: 1px solid rgba(52, 211, 153, .35);
}

/* 技术细节 */
.trace {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}
.trace summary { cursor: pointer; color: var(--muted); }
.trace pre {
  margin: 8px 0 0; white-space: pre-wrap; word-break: break-all;
  font-size: 11px; color: var(--muted); max-height: 240px; overflow: auto;
}

.foot { margin-top: 18px; padding: 0 2px; font-size: 11.5px; color: var(--dim); line-height: 1.6; }
.foot strong { color: var(--muted); font-weight: 600; }

/* 底部「随手贴」：默认缩成右下角悬浮按钮，点开才铺开成输入条 */
.quickbar {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: auto;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  transition: left .18s ease;
}
.quickbar.open {
  left: 14px;
}
.quick-form {
  display: none;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 8px;
}
.quickbar.open .quick-form { display: flex; }
.quick-toggle {
  flex: none;
  width: 42px;
  height: 42px;
  /* 全局 button 有 min-height:46px，会把圆形拉成椭圆，这里必须压回去 */
  min-height: 42px;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(56, 189, 248, .45);
  background: linear-gradient(145deg, #0ea5e9, #22d3ee);
  color: #031018;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(14, 165, 233, .32);
}
.quick-toggle:active { transform: scale(.96); }
.quickbar input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  font-size: 16px; /* 低于 16px iOS 会放大页面 */
  outline: none;
}
.quickbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .12); }
.quickbar .quick-form .primary {
  flex: none;
  width: 76px;
  height: 42px;
  border-radius: 11px;
  font-size: 15px;
}

/* 预览 */
.player {
  position: fixed; inset: 0;
  /* 要盖过右下角悬浮按钮(60)、菜单下拉(400)、门禁(200) */
  z-index: 600;
  display: grid; place-items: center;
  padding: 12px;
}
.player.hidden { display: none; }
.player-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .78); }
.player-box {
  position: relative; width: 100%; max-width: 720px;
  background: var(--elev); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
}
.player-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 12px; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--line);
}
.player-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 弹层里的「新窗口打开（可投屏）」——hls.js 预览用的是 blob 地址，投屏得走真实链接 */
.player-head a.mini {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  text-decoration: none;
  color: var(--accent);
  border-color: rgba(56, 189, 248, .35);
  white-space: nowrap;
}
.player-head .icon {
  min-height: 34px; width: 38px; padding: 0; border-radius: 8px;
  background: var(--chip); font-size: 15px;
}
#video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; }
.player-tip { padding: 8px 12px 2px; font-size: 12px; color: var(--muted); word-break: break-all; }
/* 播放器实时诊断：模式 / 缓冲 / 带宽，用来判断起播卡在哪 */
.player-diag {
  padding: 0 12px 8px;
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  min-height: 14px;
  word-break: break-all;
}

.hidden { display: none !important; }

@media (min-width: 640px) {
  .input-card { display: grid; grid-template-columns: 1fr auto; gap: 10px 10px; }
  #url { grid-column: 1; }
  #go { grid-column: 2; }
  .opt { grid-column: 1 / -1; }
}


/* 顶部轮播：本站最新影视剧（横向 scroll-snap + 自动滚动）
   封面图有防盗链（站内图片接口返回 850），所以用渐变卡片 + 文字 */
.slides {
  margin: 0 0 12px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
}
.slide-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.slide-track::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  min-height: 132px;
  padding: 14px;
  display: flex;
  align-items: flex-end;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(135deg, var(--slide-1) 0%, var(--slide-2) 55%, var(--slide-3) 100%);
}
.slide-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
.slide-tags {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--accent);
}
.slide-desc {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--dim);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.slide-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 7px 0;
  background: var(--panel);
}
.slide-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--dot);
}
.slide-dot.on { background: var(--accent); }


/* 搜索结果分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 8px;
}
.pager-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13px;
}
.pager-btn:disabled { opacity: .35; }
.pager-info { font-size: 12px; color: var(--muted); }

/* 标题栏明暗切换 */
.theme-btn {
  flex: none;
  width: 40px;
  height: 36px;
  margin-left: 8px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
}
.theme-btn:active { transform: scale(.95); }


/* 未通过验证的地址折叠区 */
.fold { margin-top: 4px; }
.fold-btn {
  /* 右侧留给右下角的悬浮按钮，别被它盖住 */
  width: calc(100% - 58px);
  min-height: 38px;
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.fold-body { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }


/* 访问门禁 */
.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.gate-box {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  text-align: center;
}
.gate-logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px;
  color: #031018;
  background: linear-gradient(145deg, #0ea5e9, #22d3ee);
  box-shadow: 0 8px 20px rgba(14, 165, 233, .35);
}
.gate-box h2 { margin: 0 0 14px; font-size: 16px; }
.gate-box input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.gate-box input:focus { border-color: var(--accent); }
.gate-tip { min-height: 18px; margin: 8px 0 4px; font-size: 12.5px; color: var(--bad); }
.gate-btn { width: 100%; height: 46px; border-radius: 11px; font-size: 15px; }
.gate-admin { display: inline-block; margin-top: 14px; font-size: 12px; color: var(--dim); text-decoration: none; }
.gate-admin:hover { color: var(--accent); }

/* 未登录时彻底隐藏主页内容（门禁是 fixed，但内容不该先闪一下） */
body.gated > :not(#loginGate) {
  visibility: hidden !important;
}
body.gated {
  overflow: hidden;
}

#logoutBtn {
  width: auto;
  padding: 0 10px;
  font-size: 12.5px;
  letter-spacing: .5px;
}

/* 右上角菜单 */
.menu-wrap { position: relative; flex: 0 0 auto; z-index: 401; }
.menu-btn { display: grid; place-items: center; }
.menu-bars { display: flex; flex-direction: column; gap: 4px; }
.menu-bars i {
  display: block;
  width: 18px; height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform .18s ease, opacity .18s ease;
}
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.menu-drop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 152px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  /* 用不透明的面板色，否则会透出下面的标签栏 */
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .5);
  z-index: 400;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--input); outline: none; }
.menu-item.danger { color: var(--bad); }

.menu-icon {
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  flex: 0 0 18px;
}
.menu-icon svg { display: block; }

/* 回到顶部：贴在「粘贴链接」按钮正上方（42 + 间距 10） */
.float-top {
  position: fixed;
  right: 16px;
  bottom: calc(16px + 42px + 10px + env(safe-area-inset-bottom));
  z-index: 60;
  width: 42px;
  height: 42px;
  min-height: 42px;   /* 同上：压过全局 button 的 min-height */
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .32);
  opacity: 1;
  transition: opacity .18s ease, transform .18s ease, border-color .18s ease, color .18s ease;
}
.float-top:hover { border-color: var(--accent); color: var(--accent); }
.float-top:active { transform: scale(.94); }
.float-top.off { opacity: 0; pointer-events: none; }
