/* ==========================================================================
   懒人之家 LAZYhome · 全站基础样式（Atomic Design）
   依赖：tokens.css（必须先引入）；页面级 section 与 UTILITIES 工具类层
   在 pages.css（之后引入）—— .mb-N/.text-* 等纯工具类在那边末尾。
   分层：Reset → Atoms → Molecules → Organisms → Layout → 语义工具类
   （.page/.form-row/.box/.stack--2 …）→ 全站组件
   （tabbar / toast / 页脚 / 主题切换器 / SVG 图标 / 骨架屏 / A2HS …）
   规则：组件内部只用语义 token 与 --accent，禁止写死色值
   2026-08-30 拆分：原单文件 3784 行 → components.css（全站基础）+ pages.css
   （页面级 + 末尾 utilities 层）。引入顺序即层叠顺序，见 base.html 与
   tests/test_theme_tokens.py。
   ========================================================================== */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--navbar-h) + var(--sp-3)); scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--fg-primary);
  background: var(--bg-canvas);
  transition: background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}
/* 版块氛围底：整页顶部注入一层极淡的品牌色雾，制造沉浸感（MC 草绿 / COC 墨青）。
   用 fixed 伪元素铺在最底层，不参与布局、不拦点击；随 scope 切换自动变色。 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -20%, var(--ambient-tint) 0%, transparent 55%);
}
a { color: var(--fg-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; line-height: var(--leading-tight); font-weight: var(--weight-semibold); }

/* 全局可见焦点环：键盘可达性底线，不要移除 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ==========================================================================
   ATOMS
   ========================================================================== */

/* --- Button --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  height: 34px; padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  background: transparent; color: var(--fg-primary);
  /* 按钮文案永不折行：中文 2 字按钮（登录/注册）在 flex 容器里被压窄时，
     默认会断成上下两行并冲出固定 height，视觉上就是文字和边框重叠。
     flex: none 再保证它不被父级 flex 压到内容宽度以下。 */
  white-space: nowrap; flex: none;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
/* 主按钮用品牌渐变而不是纯色：同一个类在 MC 下是草绿渐变、在 COC 下是墨青渐变，
   比纯色更有"质感"，也顺手把两个板块的气质带进最高频的交互元素里。 */
.btn--primary { background: var(--accent-gradient); color: var(--fg-on-accent, #fff); border-color: transparent; }
/* 深色系主题的主按钮用深色文字压在亮渐变上（白字压亮青/亮蓝会糊）。
   用 --fg-on-accent token 而不是硬编码 —— 各主题已各自声明了正确的前景色。
   2026-08-16 主题重组后深色系 = forest / abyss / ember（旧名 dark 是 forest 别名）。 */
[data-theme="forest"] .btn--primary,
[data-theme="abyss"] .btn--primary,
[data-theme="ember"] .btn--primary { color: var(--fg-on-accent); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--secondary { background: var(--bg-surface); border-color: var(--border-subtle); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--bg-hover); }
.btn--danger { background: var(--state-error); color: #fff; }
.btn--sm { height: 28px; padding: 0 var(--sp-3); font-size: var(--text-xs); }
.btn--icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* 提交中：文字保留（别让按钮宽度跳变），左侧插一个转圈。
   由 app.js 在 form submit 时加上，PRG 跳转后页面刷新自动消失。
   opacity 比 :disabled 的 .45 高一点 —— "正在做事"和"不可用"是两种状态。 */
.btn.is-loading { opacity: .7; cursor: progress; }
.btn.is-loading::before {
  content: ""; flex: none;
  width: 12px; height: 12px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* --- Input / Textarea / Select --- */
.field {
  width: 100%; height: 36px; padding: 0 var(--sp-3);
  background: var(--bg-surface); color: var(--fg-primary);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  font-size: var(--text-md); font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.field::placeholder { color: var(--fg-tertiary); }
.field.field--sm, select.field.field--sm { height: 28px; font-size: var(--text-xs); padding: 0 var(--sp-2); }
.field:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
textarea.field { height: auto; min-height: 120px; padding: var(--sp-3); resize: vertical; line-height: var(--leading-normal); }
.field-label { display: block; margin-bottom: var(--sp-2); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-secondary); }
.field-hint { margin-top: var(--sp-1); font-size: var(--text-xs); color: var(--fg-tertiary); }
.field-error { margin-top: var(--sp-1); font-size: var(--text-xs); color: var(--state-error); }

/* --- 登录 / 注册页 --- */
/* 卡片垂直居中。用 navbar-h token 而不是写死 120px —— 导航栏高度改了这里跟着走，
   否则算多了卡片会被推下去、算少了会顶到导航栏底下 */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - var(--navbar-h) - var(--sp-12));
  padding: var(--sp-6) var(--sp-4);
}
/* 精简布局（body.is-bare，即 scope=='auth'）下导航栏恢复显示，
   但 .auth-page 居中仍然占满整屏减去 navbar 高度（因为页脚不渲染了）。 */
body.is-bare .auth-page { min-height: calc(100vh - var(--navbar-h)); }
.auth-card { width: 100%; max-width: 400px; overflow: hidden; }
/* 品牌头：主题色渐变背景 + logo + 欢迎语，让登录页有社区感 */
.auth-card__brand {
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-weak));
  color: #fff;
}
.auth-card__logo {
  width: 48px; height: 48px; margin: 0 auto var(--sp-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; border-radius: var(--radius-full);
  background: rgba(255,255,255,.18);
  /* 现在 logo 是 <a> 元素（点它回门户首页），需要显式清掉浏览器默认的链接色和下划线 */
  color: inherit; text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.auth-card__logo:hover { background: rgba(255,255,255,.28); transform: scale(1.04); }
.auth-card__logo:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.auth-card__title { font-size: var(--text-xl); font-weight: var(--weight-bold); }
.auth-card__sub { margin-top: var(--sp-1); font-size: var(--text-sm); opacity: .9; }

/* 页内提示条（登录失败 / 重置成功） */
.auth-alert {
  margin-bottom: var(--sp-4); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm); font-size: var(--text-sm);
}
.auth-alert--error {
  background: var(--state-error-weak, rgba(220,50,50,.1));
  color: var(--state-error); border: 1px solid currentColor;
}
.auth-alert--info { background: var(--bg-subtle); color: var(--fg-secondary); }

/* 密码框 + 眼睛按钮：绝对定位按钮压在字段右侧，字段留出右内边距不压字 */
.field-with-toggle { position: relative; }
.field-with-toggle .field { padding-right: 40px; }
/* 隐藏 Edge/IE 自带的密码显示按钮(::-ms-reveal)与清除按钮(::-ms-clear)：
   它们只在聚焦时出现、失焦即消失，和我们自己的 .field-toggle 并存会变成"两个眼睛"，
   且原生那个点别处就没了。统一只用自定义按钮，行为可控。 */
.field-with-toggle .field::-ms-reveal,
.field-with-toggle .field::-ms-clear { display: none; }
.field-toggle {
  position: absolute; top: 0; right: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  font-size: var(--text-md); color: var(--fg-tertiary);
}
.field-toggle:hover { color: var(--fg-secondary); }
/* 两个眼睛 inline SVG 叠在按钮里，用 aria-pressed 切显隐：
     aria-pressed=false（密码隐藏中）  -> 显示 pwd-eye--off（眼睛被划掉）
     aria-pressed=true （密码显示中）  -> 显示 pwd-eye--open（睁眼）
   JS 只翻状态位（app.js），完全不动 DOM —— 图标要换成 MC 皮肤时只改模板。 */
.field-toggle .pwd-eye { width: 20px; height: 20px; display: none; }
.field-toggle .pwd-eye--off { display: block; }
.field-toggle[aria-pressed="true"] .pwd-eye--off { display: none; }
.field-toggle[aria-pressed="true"] .pwd-eye--open { display: block; }

/* 心跳 Token 显隐（服务器详情页）。和上面的密码显隐是同一套思路：
   状态在类名上，JS（app.js 的 [data-token-toggle] 委托）只负责翻 .is-open。
   ⚠️ 默认 display:none 是**安全默认值** —— Token 是密钥，JS 万一没加载，
   最坏结果是服主看不到它（重置一次即可），而不是把密钥直接亮在页面上。 */
.token-reveal__value { display: none; margin-bottom: var(--sp-2); }
.token-reveal.is-open .token-reveal__value { display: block; }

/* 邀请码折叠 —— 给 <details>/<summary> 加视觉提示让用户知道这里能点 */
details.stack > summary {
  list-style: none; /* 去掉默认三角（被 .stack 的 flex 干掉后部分浏览器还保留着） */
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
}
details.stack > summary::before {
  content: "+ ";
  font-weight: bold;
}
details.stack[open] > summary::before {
  content: "- ";
}
details.stack > summary::-webkit-details-marker { display: none; }

.auth-links {
  margin-top: var(--sp-4); text-align: center;
  font-size: var(--text-sm); color: var(--fg-tertiary);
}
.auth-links span { margin: 0 var(--sp-2); opacity: .5; }

/* --- 第三方登录（OAuth）按钮 ---
   分割线用 flex + 两侧伪元素拉线，比 <hr> 加绝对定位文字更好维护。
   按钮走 currentColor 填充 SVG，深浅色主题各自继承文字色，不用两套图标。 */
.oauth-divider {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-4) 0 var(--sp-3);
  font-size: var(--text-xs); color: var(--fg-tertiary);
}
.oauth-divider::before, .oauth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.oauth-row { display: flex; flex-direction: column; gap: var(--sp-2); }
.oauth-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-surface); color: var(--fg-primary);
  font-size: var(--text-sm); font-weight: var(--weight-medium, 500);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.oauth-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--bg-subtle, rgba(0, 0, 0, .03));
  transform: translateY(-1px);
}
.oauth-btn:active { transform: none; }
.oauth-btn__icon { flex: none; }


/* --- Avatar --- */
.avatar {
  display: inline-block; width: 32px; height: 32px; flex: none;
  border-radius: var(--radius-full); object-fit: cover;
  background: var(--bg-subtle);
  /* 品牌色光环：用 box-shadow 而非 border —— border 会撑大尺寸影响布局，
     shadow 纯视觉，不占文档流。透明度 40% 刚好有存在感但不喧宾夺主。 */
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent);
}
.avatar--sm { width: 24px; height: 24px; }
.avatar--lg { width: 48px; height: 48px; }
.avatar--xl { width: 76px; height: 76px; }

/* --- Tag / Badge --- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 var(--sp-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  background: var(--bg-subtle); color: var(--fg-secondary);
  white-space: nowrap;
}
.tag--accent { background: var(--accent-weak); color: var(--accent); }
.tag--warn { background: rgba(217,139,22,.14); color: var(--state-warn); }
.tag--error { background: rgba(214,69,69,.14); color: var(--state-error); }
.tag--outline { background: transparent; border: 1px solid var(--border-subtle); }

/* --- Title 高亮称号 --- */
.title-badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 var(--sp-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: .02em; white-space: nowrap;
}
.title-badge--member  { color: var(--title-member-fg);  background: var(--title-member-bg); }
.title-badge--veteran { color: var(--title-veteran-fg); background: var(--title-veteran-bg); }
.title-badge--mod     { color: var(--title-mod-fg);     background: var(--title-mod-bg); }
.title-badge--admin   { color: var(--title-admin-fg);   background: var(--title-admin-bg); }
.title-badge--sponsor {
  background: var(--title-sponsor-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  border: 1px solid rgba(217,139,22,.4);
  text-shadow: var(--title-sponsor-glow);
  animation: title-shimmer 4s linear infinite;
}
@keyframes title-shimmer { to { background-position: 200% center; } }
@media (prefers-reduced-motion: reduce) {
  .title-badge--sponsor { animation: none; }
  /* 断点跨越时的布局过渡也一并关掉 */
  .layout-forum, .layout-shelf, .server-filter__row,
  .server-grid, .link-grid { transition: none !important; }
}

/* --- Divider --- */
.divider { height: 1px; background: var(--border-subtle); border: 0; margin: var(--sp-4) 0; }

/* ==========================================================================
   MOLECULES
   ========================================================================== */

/* --- Card --- */
/* 视觉分层三件套：surface 底 + 1px 边框 + 柔性阴影。
   hover 时不只是加深阴影，还把边框染上一点品牌色 —— 让"这张卡是可交互的"
   在两个板块里呈现出各自的颜色语言（MC 草绿 / COC 墨青）。 */
.card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border-subtle));
}
/* 整卡可点（列表里的 <a class="card">、门户瓷砖）时再加一点"抬起"手感：
   hover 微微上浮 + 更重的阴影。只对可点卡片生效，避免静态卡片无谓晃动。 */
a.card:hover,
.portal-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
a.card:active,
.portal-tile:active { transform: translateY(0); }
/* 品牌装饰条：卡片顶部 2px 渐变，默认收起（scaleX 0），hover 时从左展开。
   只在显式标了 .card--accent 的卡片上出现，避免全站每张卡都花。 */
.card--accent::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--card-accent-bar);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-slow) var(--ease-out);
}
.card--accent:hover::before { transform: scaleX(1); }
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card__body { padding: var(--sp-5); }
.card__footer {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  border-top: 1px solid var(--border-subtle);
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
}
/* 嵌在 body 里的 footer：body 已有 sp-5 padding，横向归零免得二次缩进 */
.card__body .card__footer { padding: var(--sp-3) 0 0; }

/* --- SearchBar --- */
/* min-width:0 是关键：不给的话搜索框在导航栏里不肯缩，会把右侧账号区顶出去重叠 */
.searchbar { position: relative; flex: 1 1 auto; min-width: 0; max-width: 420px; }
.searchbar .field { padding-left: 34px; }
.searchbar__icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--fg-tertiary); pointer-events: none; font-size: var(--text-md);
}

/* --- ServerSwitcher 多服务器选择 --- */
.server-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 30px; padding: 0 var(--sp-3);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-full);
  background: var(--bg-surface); font-size: var(--text-xs);
  color: var(--fg-secondary);
  transition: all var(--dur-fast) var(--ease-out);
}
.server-chip:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.server-chip[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-weak); color: var(--accent);
  font-weight: var(--weight-medium);
}
.server-chip__dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: var(--fg-tertiary); flex: none; }
.server-chip__dot--online { background: var(--state-success); box-shadow: 0 0 0 3px var(--brand-mc-weak); }
.server-chip__dot--offline { background: var(--state-error); }
.server-chip__ping { color: var(--fg-tertiary); font-family: var(--font-mono); font-size: var(--text-2xs); }

/* --- EmojiPicker ---
   2026-08-16 起原生开合（app.js 的 [data-emoji-toggle] 段）：默认 [hidden]，
   只有 CSS 的 .emoji-picker[hidden]{display:none} 一条管默认藏。
   之前由 Alpine x-show 控制，CDN 半死时面板会永久展开盖住编辑器（实报）。 */
.emoji-picker {
  position: absolute; bottom: calc(100% + var(--sp-2)); left: 0; z-index: var(--z-dropdown);
  width: 280px; padding: var(--sp-3);
  background: var(--bg-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.emoji-picker__grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 180px; overflow-y: auto; }
.emoji-picker__item {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 0; border-radius: var(--radius-xs); background: transparent; font-size: 18px;
}
.emoji-picker__item:hover { background: var(--bg-hover); }
.emoji-picker[hidden] { display: none; }

/* --- 通用弹出菜单（原生开合，不依赖 Alpine）---
   契约见 app.js 的 [data-popmenu] 段。显隐的唯一真值是 .is-open 类。 */
.popmenu {
  position: absolute; z-index: var(--z-dropdown);
  padding: var(--sp-2);
  background: var(--bg-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: none;
}
.popmenu.is-open { display: block; }
/* 顶栏账号菜单：右对齐挂在触发按钮正下方 */
.popmenu--account { width: 180px; right: 0; left: auto; top: calc(100% + 8px); }


/* --- UserMeta 作者行 --- */
.user-meta { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.user-meta__name { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-primary); }
.user-meta__time { font-size: var(--text-xs); color: var(--fg-tertiary); }

/* --- FileCard 剧本上传/下载 --- */
.file-card {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-subtle); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.file-card__icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm); background: var(--accent-weak); color: var(--accent); font-size: var(--text-lg); }
.file-card__main { flex: 1; min-width: 0; }
.file-card__name { font-size: var(--text-sm); font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card__desc { font-size: var(--text-xs); color: var(--fg-tertiary); }

/* --- Upload Dropzone --- */
.dropzone {
  display: grid; place-items: center; gap: var(--sp-2);
  padding: var(--sp-8); text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-subtle); color: var(--fg-secondary);
  transition: all var(--dur-base) var(--ease-out);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); }

/* --- Pagination --- */
.pagination { display: flex; gap: var(--sp-1); justify-content: center; padding: var(--sp-6) 0; }
.pagination__item {
  min-width: 32px; height: 32px; padding: 0 var(--sp-2);
  display: grid; place-items: center;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  background: var(--bg-surface); font-size: var(--text-sm); color: var(--fg-secondary);
}
.pagination__item:hover { background: var(--bg-hover); }
.pagination__item[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--fg-on-accent, #fff); }
/* 省略号占位（_pagination.html 窗口分页）：去边框去底，别让它长得像可点的页码 */
.pagination__gap { border: none; background: none; cursor: default; color: var(--fg-tertiary); }

/* ==========================================================================
   ORGANISMS
   ========================================================================== */

/* --- Navbar --- */
.navbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--navbar-h);
  display: flex; align-items: center; gap: var(--sp-5);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
/* 导航栏底部品牌渐变细线：1px 的"当前在哪个板块"提示。
   比给整条导航栏染色克制得多，但视觉上足够把 MC 和 COC 区分开。 */
.navbar::after {
  content: "";
  position: absolute; inset: auto 0 -1px 0; height: 2px;
  background: var(--accent-gradient);
  opacity: .85;
}
/* flex 子项默认 min-width:auto，宁可溢出也不肯缩 —— 中等宽度下
   6 个导航链接 + 搜索框 + 头衔徽章会互相挤到重叠。下面逐项交代能不能缩。 */
.navbar__logo {
  display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0;
  font-size: var(--text-lg); font-weight: var(--weight-semibold);
  color: var(--fg-primary); white-space: nowrap;
}
.navbar__nav {
  display: flex; gap: var(--sp-1);
  /* 放不下时本行横向滚动，而不是把字压到隔壁元素上 */
  min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.navbar__nav::-webkit-scrollbar { display: none; }
.navbar__link {
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--fg-secondary); text-decoration: none;
  white-space: nowrap;
}
.navbar__link:hover { background: var(--bg-hover); color: var(--fg-primary); text-decoration: none; }
.navbar__link[aria-current="page"] { background: var(--accent-weak); color: var(--accent); font-weight: var(--weight-medium); }
.navbar__spacer { flex: 1; min-width: var(--sp-2); }
/* 账号区（头像 + 头衔）不参与压缩，头衔过长时自己截断 */
.navbar > div:last-of-type { flex-shrink: 0; }
.navbar .title-badge {
  max-width: 10em; overflow: hidden; text-overflow: ellipsis;
}

/* 说明：每日事件导览已从"论坛首页横向滚动 rail"改为"门户主页竖向列表"
   （.portal-events / .portal-event，见 V10 段）。原来的 .event-rail 是横向
   scroll-snap 卡带，在窄屏上只能横滑、不能压缩堆叠，交互不符合直觉，已废弃删除。 */

/* --- ThreadList 论坛帖子列表 --- */
.thread-list { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; }

.thread-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast) var(--ease-out);
}
.thread-item:last-child { border-bottom: 0; }
.thread-item:hover { background: var(--bg-hover); }
.thread-item--pinned { background: var(--accent-weak); }
.thread-item__main { flex: 1; min-width: 0; }
.thread-item__title {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  font-size: var(--text-md); font-weight: var(--weight-medium); color: var(--fg-primary);
}
.thread-item__meta { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); font-size: var(--text-xs); color: var(--fg-tertiary); }
.thread-item__stat { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; min-width: 48px; }
.thread-item__stat b { font-size: var(--text-md); font-weight: var(--weight-semibold); font-family: var(--font-mono); }
.thread-item__stat span { font-size: var(--text-2xs); color: var(--fg-tertiary); }
/* 版主操作栏：帖子列表 / 详情里的管理按钮组 */
.mod-bar { margin-top: var(--sp-2); display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* --- PostEditor --- */
.post-editor { position: relative; }
.post-editor__toolbar { display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-2); border: 1px solid var(--border-subtle); border-bottom: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--bg-subtle); }
.post-editor__toolbar .btn--icon { width: 28px; height: 28px; }
.post-editor textarea.field { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.post-editor__footer { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-3); }

/* --- RecruitList 招人信息（时间排序） --- */
.recruit-item {
  display: grid; grid-template-columns: 76px 1fr auto; gap: var(--sp-4); align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}
.recruit-item:hover { background: var(--bg-hover); }
.recruit-item__when { text-align: center; font-family: var(--font-mono); }
.recruit-item__when b { display: block; font-size: var(--text-lg); color: var(--accent); }
.recruit-item__when span { font-size: var(--text-2xs); color: var(--fg-tertiary); }
.recruit-item__slots { font-size: var(--text-xs); color: var(--fg-secondary); }
.recruit-item__slots.is-full { color: var(--state-error); }

/* --- Table（管理后台） --- */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--border-subtle); }
.table th { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: .04em; background: var(--bg-subtle); }
.table tbody tr:hover { background: var(--bg-hover); }

/* --- Empty State --- */
.empty { display: grid; place-items: center; gap: var(--sp-2); padding: var(--sp-12) var(--sp-6); text-align: center; color: var(--fg-tertiary); }
.empty__icon { font-size: 32px; opacity: .6; }

/* ==========================================================================
   LAYOUT
   ========================================================================== */
/* 布局容器统一用 clamp() 做流体内距/间距：视口在断点之间连续变化时，
   padding/gap 也平滑跟随，而不是卡在固定值上等断点“咔”地跳一下。
   --layout-motion 则给列数/间距切换补一段过渡，让断点跨越不那么生硬。 */
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 clamp(var(--sp-4), 3.2vw, var(--sp-6)); }
.layout-forum {
  display: grid; grid-template-columns: 1fr var(--sidebar-w);
  gap: clamp(var(--sp-4), 2.4vw, var(--sp-6)); align-items: start;
  padding: clamp(var(--sp-4), 2.4vw, var(--sp-6)) 0 var(--sp-12);
  transition: grid-template-columns var(--dur-slow) var(--ease-in-out),
              gap var(--dur-slow) var(--ease-in-out);
}
/* grid/flex 子项默认 min-width:auto —— 内容比轨道宽时会顶开轨道，
   导致里面 overflow-x:auto 的元素（事件卡横滑条、代码块、宽表格）
   根本滚不起来，整页反而横向溢出。这里显式归零。 */
.layout-forum > * { min-width: 0; }
/* 侧栏为空时收成单列。COC 分支不传 servers、游客又拿不到快捷入口，
   于是 <aside class="layout-forum__side"> 里一个元素都没有 —— grid 不会
   自动塌列，右边就留一条空的 240px 带（站长 #167 实报）。
   :has() 判"aside 无元素子节点"（空白/注释不算元素）：命中就隐藏 aside 并把
   轨道收成单列。:has() 不支持的老浏览器退回原两列行为，属渐进增强、不伤功能。 */
.layout-forum:has(> .layout-forum__side:not(:has(*))) { grid-template-columns: 1fr; }
.layout-forum > .layout-forum__side:not(:has(*)) { display: none; }
.layout-shelf > * { min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
/* h1 和 h2 都要选到：页面主标题改用 h1（无障碍要求每页一个 h1），
   但 section-head 也用在页内小节上（那里仍是 h2）。只写 h2 会让 h1 掉回
   浏览器默认的 2em，标题突然巨大 —— 这是"CSS 选择器没跟上 HTML 改动"的典型。 */
.section-head h1, .section-head h2 { font-size: var(--text-xl); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); }

/* ============================================================
   布局工具类（2026-08-30 内联样式收敛批次）
   ------------------------------------------------------------
   背景：模板里散落 1800+ 处 style="" 内联，其中高频模式反复
   手写 —— 响应式调窄屏时必须逐处改、极易漏。这批工具类把
   高频模式收敛到一处：改这里全站生效（对齐"CSS 变量统一调整"
   的工程约定）。命名规则：语义优先（.page/.form-row/.box），
   间距用 .mb-N/.mt-N 直接映射 --sp-N 令牌。
   ⚠️ 只收敛"结构模式"；真正一次性定制的（如某张图的裁切）
   仍允许内联，别为了清零而硬造类名。
   ============================================================ */

/* 页面容器：原 `style="margin-top:var(--sp-6);max-width:Xpx;margin-inline:auto"`。
   宽度档位对应实际在用的几种（680/820/960/1080），加档位先查有没有能归并的。 */
.page { margin-top: var(--sp-6); margin-inline: auto; }
.page--sm { max-width: 680px; }
.page--md { max-width: 820px; }
.page--lg { max-width: 960px; }
.page--xl { max-width: 1080px; }

/* 连续卡片区：原每张卡手写 margin-bottom:var(--sp-4)。
   用兄弟选择器而非给 .card 全局加间距 —— 那会波及所有页面
   与既有手写 margin 叠加出双倍空隙。 */
.section-list > * + * { margin-top: var(--sp-4); }

/* 表单字段行：原 style="gap:var(--sp-2/3);flex-wrap:wrap;align-items:flex-end"。
   和 .row 的差别：默认底部对齐（label 在上、控件在下时按钮和输入框基线齐）、
   gap 收到 sp-2（表单字段密度比工具栏高）。 */
.form-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end; }
.form-row--center { align-items: center; }
.form-row--3 { gap: var(--sp-3); }

/* 身份标行的板块前缀（"MC" / "TRPG" 小标签）：flex 行里不被压缩，原 style="flex:none"。 */
.ident-row__label { flex: none; }

/* 表单动作行：原 style="justify-content:flex-end"（约 60+ 处）。 */
.form-actions { display: flex; justify-content: flex-end; }

/* 边框盒子：原 style="padding:var(--sp-3);border:1px solid var(--border);border-radius:var(--radius-md)"。
   页内嵌套的小节（不配 .card 的完整阴影层级）用它。 */
.box { padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius-md); }
.box--dashed { border-style: dashed; }

/* 行内表单：mod-bar 等处的 style="display:inline"（form 是块级，包在行里会断行）。 */
.inline-form { display: inline; }

/* 堆叠间距档位：.stack 默认 sp-4，这两档覆盖"更紧"的场景（原内联 gap 改写）。 */
.stack--2 { gap: var(--sp-2); }
.stack--3 { gap: var(--sp-3); }

/* 表单控件宽度（后台紧凑表单）：原 style="width:48px" 等散写。
   跟随既有 .field--sm 的"field--"前缀命名习惯。 */
.field--icon { width: 48px; }
.field--num { width: 64px; }

/* 数据表：后台页的裸 <table>（原 style="width:100%;border-collapse:collapse"
   + 每格手写 text-align/padding）。首列对齐由内容决定，全表左对齐。 */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: var(--sp-1) var(--sp-2) var(--sp-1) 0; }
/* 次要说明文字：小一号 + 三级灰。和 .field-hint 同一套视觉，差别是不带 margin-top，
   所以既能当行内补充（时间 / 作者），也能直接挂在 <p> 上（margin 由调用处给） */
.meta { font-size: var(--text-xs); color: var(--fg-tertiary); }
/* 引用块：原样引用用户提交的文本（举报补充说明等）。左竖条 + 浅底，与 .post-content blockquote
   同一视觉语言；margin 归零盖掉 blockquote 的浏览器默认 40px 缩进，pre-wrap 保住原文换行 */
.quote-block { margin: 0; padding: var(--sp-2) var(--sp-3); background: var(--bg-subtle); border-left: 3px solid var(--border-strong); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: var(--text-sm); color: var(--fg-secondary); white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* 拿到焦点时必须重新可见，否则 base.html 的「跳到主内容」等于不存在：
   键盘用户按 Tab 时焦点确实落上去了，但元素是 1px + clip 的，屏幕上看不见任何
   焦点指示 —— 用户以为焦点丢了，skip-link 白做。
   只写 :focus 不写 :focus-visible 也行（<a> 只能靠键盘/点击获得焦点），
   两个都写是为了在把它改成 <button> 时也不退化。
   不会误伤那些纯给读屏器看的 .sr-only 文本：那些是 <span>，不可聚焦，
   这条规则永远命中不到。 */
.sr-only:focus,
.sr-only:focus-visible {
  position: fixed;
  top: var(--sp-2);
  left: var(--sp-2);
  width: auto;
  height: auto;
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  overflow: visible;
  clip: auto;
  clip-path: none;
  background: var(--bg-surface);
  color: var(--fg-primary);
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  z-index: var(--z-toast);
}

@media (max-width: 900px) {
  .layout-forum { grid-template-columns: 1fr; }
  .layout-forum__side { order: -1; }
  .navbar { gap: var(--sp-3); padding: 0 var(--sp-4); }
  .navbar__nav { display: none; }
  .recruit-item { grid-template-columns: 60px 1fr; }
}


/* ==========================================================================
   移动端底部标签栏（tabbar）
   桌面隐藏；手机固定底部，适配 iPhone 安全区
   ========================================================================== */
.tabbar { display: none; }

@media (max-width: 900px) {
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: var(--z-sticky);
    display: flex;
    background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-subtle);
    /* 适配 iPhone 底部小黑条 */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tabbar__item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    /* 最小 48px 触控高度，符合移动端可点击区域规范 */
    min-height: 52px;
    font-size: var(--text-2xs);
    color: var(--fg-tertiary); text-decoration: none;
    transition: color var(--dur-fast) var(--ease-out);
  }
  .tabbar__item:hover, .tabbar__item:active { text-decoration: none; }
  .tabbar__item.is-active { color: var(--accent); font-weight: var(--weight-medium); }
  .tabbar__icon { font-size: 20px; line-height: 1; }

  /* 主内容留出底部空间，避免被 tabbar 遮住 */
  body { padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px)); }

  /* 手机上表单元素放大到 16px，防止 iOS Safari 聚焦时自动缩放页面 */
  .field { font-size: 16px; height: 40px; }
  textarea.field { font-size: 16px; }

  /* 触控目标放大 */
  .btn { height: 38px; }
  .btn--sm { height: 32px; }
  .btn--icon { width: 38px; }

  /* 事件卡宽度已改成 min(78%, 240px) 的自适应公式，不再需要断点覆盖 */

  .container { padding: 0 var(--sp-4); }
  .thread-item { padding: var(--sp-3) var(--sp-4); }
  .thread-item__stat { min-width: 36px; }
  .card__body { padding: var(--sp-4); }
  .searchbar { max-width: none; }
}

/* 超小屏：隐藏搜索框，只留图标入口 */
@media (max-width: 560px) {
  .navbar .searchbar { display: none; }

  /* ── 2026-08-17 顶栏小屏适配（此前 390px 屏实测溢出 100~200px）──
     顶栏一行塞了：品牌长名 + 板块面包屑 + 🧭 + 主题双按钮 + 头像+三枚徽章（176px 不可缩）。
     逐项收：品牌截断省略；板块面包屑交给底部 tabbar（那里本来就有论坛入口）；
     账号按钮只剩头像（徽章在个人中心/主页都看得到）；主题 ▾ 菜单收进 ◐ 的右键。
     gap 同步收紧，游客态（登录+注册两个按钮）也放得下。 */
  .navbar { gap: var(--sp-2); }
  .navbar__logo { max-width: 32vw; overflow: hidden; text-overflow: ellipsis; }
  .navbar > .navbar__link { display: none; }
  .navbar .title-badge,
  .navbar .level-badge,
  .navbar .coc-level-badge { display: none; }
  .theme-switch__more { display: none; }

  .section-head h1, .section-head h2 { font-size: var(--text-lg); }

  /* section-head 按钮区在 375px 手机上会挤爆：改成允许折行 */
  .section-head { flex-wrap: wrap; }

  /* 模组商城封面网格：375px 宽时 180px minmax 让不下两列，改成更小的下限 */
  /* （scripts.html 的封面 grid 是行内 style="minmax(180px…)" → 无法用 CSS 覆盖，
     但后台 console-grid 和侧栏受这里约束） */
  .console-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  /* 招人列表三列 grid 在小手机上第三列（报名按钮）压到文字上 → 改两行堆叠 */
  .recruit-item { grid-template-columns: 1fr; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); }
  .recruit-item__when {
    display: flex; gap: var(--sp-2); text-align: left;
  }
  .recruit-item__when b { display: inline; font-size: var(--text-md); }

  /* 后台指标卡数字在极窄屏下 28px 太大 */
  .stat-card__value { font-size: 22px; }

  /* 登录/注册品牌头在 375px 手机上padding 收紧 */
  .auth-card__brand { padding: var(--sp-4) var(--sp-4) var(--sp-3); }
  .auth-card__title { font-size: var(--text-lg); }
}

/* Alpine.js x-cloak：元素初始化前保持隐藏，避免闪现 */
[x-cloak] { display: none !important; }


/* ==========================================================================
   V6 · SVG 图标（sprite: /static/icons/sprite.svg，Lucide/ISC）
   用法：{{ icon('user') }}（Jinja 全局，见 rendering.py）
        或裸写 <svg class="icon"><use href="/static/icons/sprite.svg#user"/></svg>

   为什么 stroke 用 currentColor 而不是写死：
     图标要跟着按钮/链接的文字色走。放在 .btn--primary 里就是白的，
     放在 .field-hint 里就是灰的，一个类走通所有场景，不用为每种容器写变体。
   ========================================================================== */
.icon {
  /* 1em 让图标跟着上下文字号缩放：小按钮里自动变小，标题里自动变大 */
  width: 1em; height: 1em;
  /* 视觉基线对齐：SVG 默认按 baseline 排，跟中文字形会偏高一点 */
  vertical-align: -0.125em;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}
/* 尺寸修饰：需要脱离字号独立控制时用 */
.icon--sm { width: 14px; height: 14px; }
.icon--md { width: 18px; height: 18px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; }
/* 语义色修饰 */
.icon--accent { color: var(--accent); }
.icon--muted { color: var(--fg-tertiary); }
.icon--danger { color: var(--state-error); }
.icon--success { color: var(--state-success); }


/* ==========================================================================
   V12 站点页脚
   此前全站没有页脚，页面到底就直接断掉。页脚承担三件事：
     1. 视觉收尾 —— 顶部 2px 品牌渐变线和导航栏底部那条呼应，首尾把整页框住
     2. 导航兜底 —— 按板块拆两列，滚到底的用户和爬虫都能找到路
     3. 身份声明 —— "玩家自建自营，非官方"，避免被误认为官方站
   ========================================================================== */
.site-footer {
  position: relative;
  margin-top: var(--sp-16);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--fg-secondary);
}
.site-footer::before {
  content: "";
  position: absolute; inset: -1px 0 auto 0; height: 2px;
  background: var(--accent-gradient);
  opacity: .85;
}
/* 品牌列占 2fr，三个导航列各 1fr —— 品牌区有标语要放，需要更多横向空间 */
.site-footer__inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: clamp(var(--sp-4), 3vw, var(--sp-8));
  padding-top: var(--sp-8);
  padding-bottom: var(--sp-6);
}
.site-footer__inner > * { min-width: 0; }
.site-footer__logo { font-size: var(--text-2xl); font-weight: var(--weight-bold); font-style: italic; }
.site-footer__tagline {
  margin: var(--sp-2) 0 0;
  font-size: var(--text-xs); color: var(--fg-tertiary);
  line-height: var(--leading-normal);
}
.site-footer__col { display: flex; flex-direction: column; gap: var(--sp-2); }
.site-footer__head {
  margin: 0 0 var(--sp-1);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  color: var(--fg-primary); letter-spacing: .04em;
}
.site-footer__col a {
  color: var(--fg-secondary); text-decoration: none;
  font-size: var(--text-xs);
  transition: color var(--dur-fast) var(--ease-out);
}
.site-footer__col a:hover { color: var(--accent); text-decoration: none; }
.site-footer__bottom {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding-top: var(--sp-3); padding-bottom: var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-2xs); color: var(--fg-tertiary);
}
.site-footer__dot { opacity: .5; }

@media (max-width: 900px) {
  /* 移动档（2026-08-30 断点统一：720 并入）：四列一列只剩 ~80px，链接会折行。
     品牌独占一行，三个导航列并排。 */
  .site-footer__inner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-footer__brand { grid-column: 1 / -1; }
  .site-footer { margin-top: var(--sp-10); }
  /* 手机有固定底部 tabbar，页脚要多留出它的高度，否则版权行被挡住 */
  .site-footer__bottom { padding-bottom: calc(var(--sp-6) + 56px + env(safe-area-inset-bottom, 0px)); }
}

/* ==========================================================================
   标签选择器（.tag-pick）
   展示态的标签直接用 .tag，但选择态需要更大的点击区（.tag 只有 20px 高，
   手机上按不准）和明确的"已选"反馈，所以单独一套。
   真正的 checkbox 用 .sr-only 藏起来而不是 display:none —— 保留键盘可聚焦。
   ========================================================================== */
.tag-pick-group { margin-bottom: var(--sp-3); }
.tag-pick-group__name {
  font-size: var(--text-2xs); color: var(--fg-tertiary);
  margin-bottom: var(--sp-2);
}
.tag-pick-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tag-pick {
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 var(--sp-3);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  font-size: var(--text-xs); color: var(--fg-secondary);
  background: transparent; cursor: pointer; user-select: none;
  transition: all var(--dur-fast) var(--ease-out);
}
.tag-pick:hover { border-color: var(--accent); color: var(--accent); }
.tag-pick.is-on {
  background: var(--accent-weak); border-color: var(--accent);
  color: var(--accent); font-weight: var(--weight-medium);
}
/* 到上限后未选中的项禁用，用透明度表达"现在选不了" */
.tag-pick:has(input:disabled) { opacity: .4; cursor: not-allowed; }
.tag-pick:has(input:disabled):hover { border-color: var(--border-subtle); color: var(--fg-secondary); }
.tag-pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }


/* ==================== 收藏按钮（详情页） ====================
   未收藏是描边态、已收藏用 accent 填充 —— 状态一眼可辨，
   不靠文案（"收藏"/"已收藏"）单独承载，色弱用户也能区分。 */
.fav-btn.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.fav-btn .js-fav-count:not(:empty)::before { content: ' '; }
/* 收藏成功的即时反馈：星标弹一下。收藏是 fetch 异步的，没有页面跳转，
   如果只换个颜色用户会怀疑"点到了没"，一个 260ms 的弹跳把"生效了"说清楚。
   由 app.js 在 toggleFavorite 成功回调里加 .just-faved，动画结束自动移除。 */
.fav-btn.just-faved .js-fav-icon {
  display: inline-block;
  animation: fav-pop 260ms var(--ease-out);
}
@keyframes fav-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.45) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* ==================== 表单校验失败的抖动 ====================
   服务端 400 回填表单时，错误提示在页面顶部，长表单里用户可能压根没滚到那儿。
   给整个卡片一个 320ms 的横向抖动，把注意力拉回来。只抖一次，不循环。 */
.shake { animation: lh-shake 320ms var(--ease-in-out); }
@keyframes lh-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(2px); }
}

/* ==================== 骨架屏占位 ====================
   给"数据还在路上"的位置用（HTMX 局部刷新、异步列表）。
   靠一条斜向高光在灰底上来回扫，比转圈更能暗示"这里将出现内容"。 */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    100deg,
    var(--bg-subtle) 30%,
    var(--bg-hover) 50%,
    var(--bg-subtle) 70%
  );
  background-size: 220% 100%;
  animation: skeleton-sweep 1.4s var(--ease-in-out) infinite;
}
.skeleton--text { height: 12px; margin: var(--sp-2) 0; }
.skeleton--title { height: 20px; width: 45%; margin: var(--sp-2) 0 var(--sp-3); }
.skeleton--block { height: 96px; }
@keyframes skeleton-sweep {
  0%   { background-position: 180% 0; }
  100% { background-position: -80% 0; }
}

/* 尊重系统的"减少动效"设置：这几个都是纯装饰，关掉不影响任何功能。
   骨架屏关掉动画后保留静态灰底，仍然传达"此处待加载"。 */
@media (prefers-reduced-motion: reduce) {
  .fav-btn.just-faved .js-fav-icon,
  .shake,
  .skeleton { animation: none; }
}


/* ==================== 主题切换器 ====================
   顶栏右侧的"◐ + ▾"组合：单击循环、下拉选具体主题 */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.theme-switch__more {
  font-size: 10px;
  padding: 2px 4px;
  margin-left: -4px;
  color: var(--fg-tertiary);
}
.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 150px;
  padding: var(--sp-2);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  /* ⚠️ 默认隐藏必须写在 CSS 里，不能只靠 Alpine 的 x-show / x-cloak。
     之前就是只有 [x-cloak]{display:none} 撑着：Alpine 一初始化就把 x-cloak
     摘掉，此后显隐全交给 x-show。只要 x-show 没绑上（CDN 半死、页面上别的
     Alpine 表达式抛错导致这个组件没 init 完），菜单就**永久展开且点不掉** ——
     这正是 2026-08-14 报的"主题选项收不回去"。
     现在显隐由 .is-open 类负责（app.js 原生 JS 切），CSS 是唯一真值。 */
  display: none;
  flex-direction: column;
  gap: 2px;
}
.theme-menu.is-open { display: flex; }
.theme-menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--dur-fast) var(--ease-out);
}
.theme-menu__item:hover {
  background: var(--bg-hover);
  color: var(--fg-primary);
}
.theme-menu__item[aria-checked="true"] {
  background: var(--accent-weak, var(--bg-active));
  color: var(--accent, var(--fg-primary));
  font-weight: var(--weight-medium);
}
.theme-menu__dot {
  font-size: var(--text-lg);
  line-height: 1;
  width: 22px;
  text-align: center;
}
.theme-menu__label { flex: 1; }

/* 窄屏：导航栏本来就挤，把展开箭头收掉 —— 单击循环足够用，
   长按/右键仍能开菜单（@contextmenu 在移动端由长按触发）。 */
@media (max-width: 560px) {
  .theme-switch__more { display: none; }
  /* 菜单贴右边缘会被 navbar 的 padding 裁掉一角，这里往回收 4px */
  .theme-menu { right: -4px; min-width: 132px; }
}


/* ==========================================================================
   添加到主屏（A2HS）横幅：固定在页面底部中间，小、可关、不打断浏览。
   默认 hidden（base.html 模板属性），由 app.js 的 [data-a2hs] 段决定显示。2026-08-17
   ========================================================================== */
.a2hs {
  position: fixed; left: 50%; bottom: var(--sp-4); transform: translateX(-50%);
  z-index: 60; max-width: min(92vw, 560px);
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elev); color: var(--fg-primary);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  font-size: var(--text-sm);
}
.a2hs__icon { font-size: 18px; }
.a2hs__text { flex: 1; min-width: 200px; }
.a2hs__close {
  border: 0; background: none; color: var(--fg-tertiary);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px;
}
.a2hs__close:hover { color: var(--fg-primary); }

/* hidden 属性必须生效：类样式的 display（.a2hs 的 flex、.btn 的 inline-flex 等）
   会覆盖 UA 的 display:none，导致带 [hidden] 的元素（A2HS 横幅、iOS 隐藏按钮）
   照常显示。用 !important 压过一切作者声明，显隐完全交给 JS 的 hidden 切换。 */
[hidden] { display: none !important; }
