/* 尽量贴近 ChatGPT 网页的观感：浅色白底 / 深色 #212121，正文栏 768px 居中，
   用户消息是右侧灰色气泡，助手消息不带气泡直接铺在页面上。 */

:root {
    --bg: #ffffff;
    --sidebar: #f9f9f9;
    --text: #0d0d0d;
    --text-soft: #5d5d5d;
    --text-faint: #8f8f8f;
    --line: #e3e3e3;
    --hover: #f0f0f0;
    --bubble: #e8e8e880;
    --composer: #ffffff;
    --composer-line: #d8d8d8;
    --accent: #0d0d0d;
    --accent-text: #ffffff;
    --code-bg: #f5f5f5;
    --danger: #e02e2a;
}

html[data-theme="dark"] {
    --bg: #212121;
    --sidebar: #171717;
    --text: #ececec;
    --text-soft: #b4b4b4;
    --text-faint: #8f8f8f;
    --line: #2f2f2f;
    --hover: #2f2f2f;
    --bubble: #303030;
    --composer: #303030;
    --composer-line: #3f3f3f;
    --accent: #ffffff;
    --accent-text: #0d0d0d;
    --code-bg: #1a1a1a;
    --danger: #f87171;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 下面好几个元素都设了 display，会盖掉 hidden 属性，这里统一兜住 */
[hidden] { display: none !important; }

body {
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
                 "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 只作用于界面图标。写成全局 svg 会把回答里的 SVG 一起改成 20×20 描边图标 */
button svg, .side-item svg {
    width: 20px; height: 20px;
    fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

#app { display: flex; height: 100dvh; }

/* ---------------------------------------------------------- 侧边栏 */

#sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 8px;
    transition: margin-left .2s ease;
}
#sidebar.collapsed { margin-left: -260px; }

.sidebar-top { display: flex; justify-content: space-between; margin-bottom: 12px; }
.sidebar-body { flex: 1; overflow-y: auto; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 8px; }

.side-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: none; border: none;
    cursor: pointer;
    text-align: left;
}
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--hover); }
.side-hint {
    font-size: 12px; line-height: 1.6;
    color: var(--text-faint);
    padding: 12px 10px;
}

.side-section-title {
    font-size: 12px; font-weight: 600;
    color: var(--text-faint);
    padding: 10px 10px 4px;
}
.side-history-list { display: flex; flex-direction: column; }
.side-history-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: none; background: none;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-history-item:hover { background: var(--hover); }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border: none; border-radius: 8px;
    background: none; color: var(--text);
    cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.round { border-radius: 50%; }

/* ---------------------------------------------------------- 顶栏 */

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#topbar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    font-size: 14px;
    /* 控件多了会撑破窄屏。让顶栏自己横向滚动，而不是把整个页面撑出横向滚动条 */
    overflow-x: auto;
    scrollbar-width: none;
    /* 真机验证过的 bug：.picker 自己 position:relative 但没有 z-index，
       所以它的 .menu（z-index:50）并没有真的被抬高到全局层叠顺序里——
       DOM 里排在后面的 #scroller/.welcome 反而盖在了上面，弹出的模型/
       工具菜单框是空的，看不到里面的选项文字，点击也点在了 welcome 上。
       顶栏本身建立一个够高的层叠上下文，菜单才能真正浮在正文之上。 */
    position: relative;
    z-index: 10;
}
#topbar::-webkit-scrollbar { display: none; }
#topbar > * { flex-shrink: 0; }
.spacer { flex: 1; }

/* 侧边栏收起时，顶栏这个按钮是唯一能把它打开的入口 —— 桌面端也必须显示，
   否则收起来就再也回不去了（收起按钮本身在侧边栏里面）。 */
.only-mobile { display: none; }
#app:has(#sidebar.collapsed) .only-mobile { display: inline-flex; }

.badge {
    font-size: 12px;
    color: var(--text-faint);
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--hover);
    white-space: nowrap;
}

.picker { position: relative; }
.picker-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 7px 10px;
    border: none; border-radius: 8px;
    background: none; color: var(--text);
    font-size: 15px; font-weight: 500;
    cursor: pointer;
    max-width: 220px;
}
.picker-btn:hover { background: var(--hover); }
.picker-btn:disabled { opacity: 0.5; cursor: default; pointer-events: none; }
.picker-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { width: 16px; height: 16px; color: var(--text-faint); }

.menu {
    /* fixed，不是 absolute：#topbar 为了在窄屏不被撑破，自己是横向可滚动的
       （overflow-x:auto）——CSS 规范里只要某一个轴不是 visible，另一个轴会
       被强制一起变成 auto，等于顶栏在垂直方向也会裁切。真机验证过：菜单
       跟着 .picker 走 position:absolute 的话，弹出来的部分会被顶栏自己的
       边界裁掉，得把顶栏本身往下滚才能看到裁掉的选项。改成 fixed 定位，
       由 JS（app.js 的 bindPicker）按钮开的那一刻算好屏幕坐标摆过去，
       彻底避开这层裁切，不用再去动 #topbar 的 overflow 设置。 */
    position: fixed;
    min-width: 240px; max-height: 60vh; overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0,0,0,.14);
    padding: 6px;
    z-index: 50;
    display: none;
}
.menu.open { display: block; }
.menu button {
    display: block; width: 100%;
    padding: 9px 12px;
    border: none; border-radius: 8px;
    background: none; color: var(--text);
    font-size: 14px; text-align: left;
    cursor: pointer;
}
.menu button:hover { background: var(--hover); }
.menu .empty { padding: 12px; font-size: 13px; color: var(--text-faint); }

.seg {
    display: flex; gap: 2px;
    background: var(--hover);
    border-radius: 999px;
    padding: 3px;
}
.seg-btn {
    border: none; background: none;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 13px; font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
}
.seg-btn.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ---------------------------------------------------------- 消息区 */

#scroller { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
#thread { max-width: 768px; margin: 0 auto; padding: 8px 20px 40px; }

.welcome { text-align: center; padding: 22vh 0 0; }
.welcome h1 { font-size: 28px; font-weight: 600; margin-bottom: 10px; }
.welcome p { color: var(--text-faint); font-size: 14px; }

.turn { margin: 26px 0; }
.turn.user { display: flex; justify-content: flex-end; }
.user .bubble {
    background: var(--bubble);
    padding: 10px 18px;
    border-radius: 20px;
    max-width: 75%;
    font-size: 16px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
}
.user .bubble .att {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-soft);
    margin-bottom: 6px;
}

.assistant .body {
    font-size: 16px; line-height: 1.75;
    word-break: break-word;
}
.assistant .body > *:first-child { margin-top: 0; }
.assistant .body p { margin: 0 0 16px; }
.assistant .body ul, .assistant .body ol { margin: 0 0 16px; padding-left: 24px; }
.assistant .body li { margin: 4px 0; }
.assistant .body h1, .assistant .body h2, .assistant .body h3 { margin: 24px 0 12px; line-height: 1.3; }
.assistant .body h1 { font-size: 24px; }
.assistant .body h2 { font-size: 20px; }
.assistant .body h3 { font-size: 17px; }
.assistant .body a { color: #2563eb; text-decoration: underline; }
.assistant .body code {
    background: var(--code-bg);
    padding: 2px 6px; border-radius: 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9em;
}
.assistant .body pre {
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 0 0 16px;
}
.assistant .body pre code { background: none; padding: 0; }
/* 表格：横向滚动交给外面这层，表格本身保持 table 布局，
   不然 display:block 会让列宽算不准、表头也粘不住 */
.table-wrap {
    overflow-x: auto;
    margin: 0 0 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    max-height: 60vh;
}
.assistant .body table {
    border-collapse: collapse; width: 100%;
    margin: 0; font-size: 14px;
}
.assistant .body th, .assistant .body td {
    border: 1px solid var(--line); padding: 8px 12px; text-align: left;
    white-space: nowrap;
}
/* 滚动时表头留在原地，长表格才看得下去 */
.assistant .body thead th {
    position: sticky; top: 0;
    background: var(--sidebar);
    z-index: 1;
}
.assistant .body th.sortable { cursor: pointer; user-select: none; padding-right: 24px; position: sticky; }
.assistant .body th.sortable::after {
    content: '↕'; opacity: .3;
    position: absolute; right: 8px;
}
.assistant .body th[data-dir='asc']::after { content: '↑'; opacity: .9; }
.assistant .body th[data-dir='desc']::after { content: '↓'; opacity: .9; }

/* 从 ChatGPT 搬过来的组件常常自带写死的宽度，会撑破版心 */
.assistant .body .fluid { max-width: 100% !important; }

/* 截回来的图表 / 组件 */
.visuals { display: flex; flex-direction: column; gap: 12px; }
.visuals:not(:empty) { margin: 12px 0; }
img.snapshot {
    max-width: 100%; width: auto;
    height: auto; max-height: 70vh;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    display: block;
}
/* 回答里残留的按钮（比如附件名）已经不能点了，收成一个小标签，
   别让它顶着一个空按钮框杵在正文中间 */
.assistant .body button {
    font: inherit; font-size: 13px;
    padding: 3px 10px; margin: 2px 0;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--sidebar); color: var(--text-soft);
    cursor: default;
}
/* 实时查看窗口：和日志面板一样贴在底部，开着就一直刷 */
/* 现在这个面板不只是「看」，还要在上面点准位置，所以给到接近满屏的高度：
   对面视口是 1440×900（比例 1.6），配合下面 #liveShot 的 max-height，
   整屏能一次完整显示出来，不用再滚动面板去找要点的地方。 */
#live {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: 94vh;
    background: var(--sidebar);
    border-top: 1px solid var(--line);
    display: flex; flex-direction: column;
    z-index: 80;
}
#liveBody {
    flex: 1; overflow: auto;
    display: flex; align-items: center; justify-content: center;
    padding: 10px;
    min-height: 0;   /* flex 子项默认 min-height:auto，不清掉的话下面的 max-height 压不住它 */
}
/* 宽高都限住，图片自己按比例缩到完整装得下为止——保证「一次看全整个屏幕」 */
#liveShot {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    border: 1px solid var(--line); border-radius: 10px;
    background: #fff;
    cursor: crosshair;   /* 提示这个画面是能点的 */
}
#live .switch { font-size: 12px; }

.live-ctl {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
}
.live-ctl #liveInput {
    flex: 1; min-width: 0;
    padding: 7px 10px;
    border: 1px solid var(--composer-line); border-radius: 8px;
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 14px;
    outline: none;
}
.live-ctl #liveInput:focus { border-color: var(--text-soft); }

.turn-foot { margin-top: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.turn-foot .snap-btn { font-size: 12px; padding: 4px 10px; }
/* 生成期间每两秒重截一次，等于把对面那一块页面直播过来 */
.live-snap { font-size: 12px; color: var(--text-faint); }
.assistant .body img {
    max-width: 100%; height: auto;
    border-radius: 10px;
    display: block; margin: 12px 0;
}
/* 回答里的 SVG 按它自己的尺寸渲染，但要压在视口内 ——
   有些 SVG 写的是 width:100% 加一个很大的 viewBox，不限高会撑出一屏多 */
.assistant .body svg {
    width: auto; height: auto;
    max-width: 100%;
    max-height: 70vh;
    border-radius: 10px;
    background: #fff;
    display: block; margin: 12px 0;
}
.assistant .body blockquote {
    border-left: 3px solid var(--line);
    padding-left: 14px; color: var(--text-soft);
    margin: 0 0 16px;
}

/* 思考过程 */
.thinking {
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    background: var(--sidebar);
}
.think-head {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: none; background: none;
    cursor: pointer;
    font: inherit; font-size: 13px; font-weight: 500;
    color: var(--text-soft);
    text-align: left;
}
.think-head:hover { color: var(--text); }
.think-head .chev {
    margin-left: auto;
    width: 16px; height: 16px;
    transition: transform .15s ease;
}
.thinking.open .think-head .chev { transform: rotate(180deg); }
.thinking:not(.open) .content { display: none; }
.thinking .pulse {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-faint);
    animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
.thinking .content {
    padding: 0 14px 14px;
    font-size: 13px; line-height: 1.7;
    color: var(--text-soft);
    white-space: pre-wrap;
    max-height: 320px; overflow-y: auto;
}

.file-card {
    display: inline-flex; align-items: center; gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 14px;
    margin: 8px 8px 0 0;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.file-card:hover { background: var(--hover); }
.file-card .meta { font-size: 12px; color: var(--text-faint); }

.notice { font-size: 13px; color: var(--text-faint); margin-top: 8px; }
.notice.error { color: var(--danger); }

/* ---------------------------------------------------------- 网络诊断
   后端连不上时自动跑的分层探测结果（2026-09-22 加）。#offlineDiag 和
   #pickerOfflineDiag 两处共用同一套（整屏离线页 / 选服务页离线兜底
   页），renderNetworkDiagnostics() 往里面塞的都是这几个 class。 */
.diag-row {
    display: flex; align-items: baseline; gap: 4px;
    font-size: 13px; margin: 4px 0;
}
.diag-icon { width: 14px; text-align: center; font-weight: 700; }
.diag-row.ok .diag-icon { color: #16a34a; }
.diag-row.error .diag-icon { color: var(--danger); }
.diag-label { color: var(--text-soft); }
.diag-detail { color: var(--text-faint); }
.diag-verdict {
    margin-top: 8px; padding-top: 8px;
    border-top: 1px solid var(--line);
    font-size: 13px; font-weight: 500;
}

.cursor::after {
    content: ''; display: inline-block;
    width: 8px; height: 16px;
    background: var(--text);
    margin-left: 2px; vertical-align: text-bottom;
    animation: pulse 1s steps(2) infinite;
}

/* ---------------------------------------------------------- 输入区 */

#composer-wrap { padding: 0 20px 12px; }
#composer {
    max-width: 768px; margin: 0 auto;
    background: var(--composer);
    border: 1px solid var(--composer-line);
    border-radius: 26px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.composer-row { display: flex; align-items: flex-end; gap: 6px; }

#input {
    flex: 1;
    border: none; outline: none; resize: none;
    background: none; color: var(--text);
    font: inherit; font-size: 16px; line-height: 1.5;
    padding: 8px 4px;
    max-height: 200px;
}
#input::placeholder { color: var(--text-faint); }

.send-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    border: none; border-radius: 50%;
    background: var(--accent); color: var(--accent-text);
    cursor: pointer;
}
.send-btn:disabled { opacity: .25; cursor: default; }
.send-btn.stop svg { fill: currentColor; }

#attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 4px 0; }
#attachments:empty { display: none; }
.chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--hover);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    max-width: 220px;
}
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.chip .x { border: none; background: none; color: var(--text-soft); cursor: pointer; font-size: 16px; line-height: 1; }
.chip.uploading { opacity: .55; }
.orig-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-soft); cursor: pointer; user-select: none; }
.orig-toggle input { margin: 0; }

#continue-bar { max-width: 768px; margin: 0 auto 10px; text-align: center; }
#continueBtn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--line);
    background: var(--bg); color: var(--text);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
}
#continueBtn:hover { background: var(--hover); }

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-faint);
    padding-top: 10px;
}

/* ---------------------------------------------------------- 图片点开看大图 */

.body img, .visuals img { cursor: zoom-in; }
#lightbox {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0, 0, 0, .85);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; cursor: zoom-out;
}
#lightbox[hidden] { display: none; }
#lightbox img {
    max-width: 100%; max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

/* ---------------------------------------------------------- 连接设置 */

#setup {
    position: fixed; inset: 0; z-index: 200;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    overflow-y: auto;
}
#setupForm {
    width: 100%; max-width: 420px;
}
#setupForm h2 { font-size: 22px; font-weight: 600; margin-bottom: 10px; }
#setupForm .hint { font-size: 13px; line-height: 1.7; color: var(--text-soft); margin-bottom: 20px; }
#setupForm .hint.small { margin: 6px 0 18px; font-size: 12px; color: var(--text-faint); }
#setupForm code {
    background: var(--code-bg); padding: 1px 5px; border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
}
#setupForm label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
#setupForm input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--composer-line);
    border-radius: 10px;
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 15px;
    outline: none;
}
#setupForm input:focus { border-color: var(--text-soft); }
#setupForm button {
    width: 100%;
    margin-top: 18px;
    padding: 12px;
    border: none; border-radius: 10px;
    background: var(--accent); color: var(--accent-text);
    font-size: 15px; font-weight: 500;
    cursor: pointer;
}
.build-info {
    text-align: center; font-size: 12px;
    color: var(--text-faint); margin-top: 18px;
}

.setup-msg { font-size: 13px; color: var(--text-soft); margin-top: 14px; min-height: 18px; }
.setup-msg.error { color: var(--danger); }

/* ---------------------------------------------------------- 登录 / 设置 / 选服务 */

/* ---------------------------------------------------------- 直连模式 */

#direct {
    position: fixed; inset: 0; z-index: 150;
    background: var(--bg);
    display: flex; flex-direction: column;
}
.direct-bar, .direct-foot {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    flex-wrap: wrap;
}
.direct-bar { border-bottom: 1px solid var(--line); }
.direct-foot { border-top: 1px solid var(--line); }
.direct-bar .sep {
    width: 1px; height: 20px; background: var(--line); margin: 0 2px;
}
.direct-bar .grow, .direct-foot .grow { flex: 1; }
.direct-bar .switch { font-size: 12px; white-space: nowrap; }
/* 三档预设按钮：省流/标准/视频，一次性设好画质/节奏/分辨率/无变化帧
   几个滑杆，靠得紧一点看着像一组 */
.direct-presets { display: inline-flex; gap: 4px; }
/* 画质/节奏那两个滑杆：连续可拖，旁边数字框能直接填精确值，两边同步 */
.direct-slider, .direct-num {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-soft); white-space: nowrap;
}
.direct-slider input[type="range"] { width: 76px; accent-color: var(--accent); }
.direct-slider input.val-num, .direct-num input[type="number"] {
    width: 52px; padding: 4px 6px; border-radius: 8px;
    border: 1px solid var(--composer-line);
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 12px;
}
#directStats { font-variant-numeric: tabular-nums; }

/* 地址栏：浏览器模式的主入口，给它抢一点宽度（flex 生长），窄屏下也别
   被挤成一条缝 */
.direct-addr {
    display: flex; align-items: center; gap: 4px;
    flex: 1 1 220px; min-width: 140px;
}
.direct-addr input {
    flex: 1; min-width: 0;
    padding: 5px 10px; border-radius: 999px;
    border: 1px solid var(--composer-line);
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 13px; outline: none;
}
.direct-addr input:focus { border-color: var(--text-soft); }

/* 键盘接管中：按钮自己亮起来。这是去掉画面那圈白框之后，「现在打字是打给
   对面的」两个提示之一（另一个是 #directKbState 徽章的文字）。 */
#directKbBtn.on, #directAudioBtn.on, #macKbBtn.on {
    background: var(--accent); color: var(--accent-text);
    border-color: var(--accent);
}
/* 固定宽度，别让「点画面即可打字」→「键盘已接管…」这次文字变长顺带把
   工具栏撑到换行——那样会在按下和松开之间把 #directShot 的位置/尺寸
   往下挤一截，用户点哪就点偏到哪去了（点击那一下的坐标是按松开时的
   画面量的，中途布局一变就对不上了）。 */
#directKbState { min-width: 168px; text-align: center; }
#macKbState { min-width: 168px; text-align: center; }

.direct-tabs {
    display: flex; gap: 6px; padding: 6px 12px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
}
.direct-tabs::-webkit-scrollbar { display: none; }
.direct-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    border: 1px solid var(--line); background: none; color: var(--text);
    font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer;
    max-width: 240px;
}
.direct-tab.active { background: var(--hover); border-color: var(--text-soft); }
.direct-tab .label { overflow: hidden; text-overflow: ellipsis; }
.direct-tab .x { opacity: .6; }
.direct-tab .x:hover { opacity: 1; }

#directBody {
    flex: 1; min-height: 0;
    position: relative;
    display: flex; align-items: center; justify-content: center;
    padding: 8px;
    overflow: hidden;
    outline: none;
}
/* 这里原来有一圈 `inset 0 0 0 3px var(--accent)` 的高亮框，用来提示
   「键盘已接管」。深色主题下 --accent 是白色，点一下画面就框出一个很扎眼
   的白框，用户明确要求去掉。提示没有丢：顶栏那个 #directKbState 徽章
   会写「键盘已接管」，「⌨️ 键盘」按钮也会亮起来（.on），两处都比这圈框
   更明确，别再把它加回来。 */
/* 隐形的键盘捕获框：看不见但能拿焦点、能挂输入法。留一点尺寸而不是
   width:0，是因为尺寸为 0 的输入框在部分浏览器上会被跳过、拿不到焦点；
   透明放在画面上而不是挪到屏幕外，是为了让输入法候选词窗口出现在你正在
   看的位置附近。 */
#directCapture, #macCapture {
    position: absolute; top: 8px; left: 8px;
    width: 200px; height: 28px;
    opacity: 0; border: none; background: transparent;
    color: transparent; caret-color: transparent;
    font: inherit;
    outline: none;
    pointer-events: none;   /* 别挡住画面上的点击 */
}
#directShot {
    /* 固定画面框；旧的 auto 尺寸会在首次帧/分辨率切换时沿用上一张自然
       尺寸，导致画面有时不铺满，得反复调整才恢复。 */
    box-sizing: border-box;
    width: 100%; height: 100%;
    object-fit: contain;
    border: 1px solid var(--line); border-radius: 10px;
    background: #fff;
    cursor: crosshair;
    /* 画面是拿来点的，别让浏览器把它当图片拖走/选中 */
    user-select: none; -webkit-user-drag: none;
    /* 手指划屏幕要能滚对面的页面，就不能让浏览器先把手势拿去滚本地页面/
       缩放 —— 没有这行，touchmove 压根轮不到我们，「移动端下滑」就是废的 */
    touch-action: none;
    /* 手机上点一下会闪一层半透明高亮方块，跟被点的是「对面的画面」这件事
       完全对不上，关掉 */
    -webkit-tap-highlight-color: transparent;
}
.direct-foot #directInput {
    flex: 1 1 320px; min-width: 0;
    padding: 7px 10px;
    border: 1px solid var(--composer-line); border-radius: 8px;
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 14px; outline: none;
}
.direct-foot #directInput:focus { border-color: var(--text-soft); }

#macWindow {
    min-width: 220px; max-width: 430px; padding: 6px 10px;
    border: 1px solid var(--composer-line); border-radius: 8px;
    background: var(--composer); color: var(--text); font: inherit;
}

.direct-result {
    max-height: 30vh; overflow: auto;
    padding: 10px 12px; border-top: 1px solid var(--line);
    background: var(--sidebar); font-size: 13px; line-height: 1.6;
    white-space: pre-wrap; user-select: text;
}
.direct-result .row { margin-bottom: 6px; }

@media (max-width: 820px) {
    .direct-bar { gap: 6px; }
}

/* 全屏时把画质/节奏/分辨率这些控件全部藏起来，纯纯就是那块画面——用户
   明确要求的观感。#directBody 是 flex:1，藏掉别的行之后它自动补满整个
   全屏窗口，不用额外调它的尺寸。退出全屏（点按钮或者被浏览器用 Esc 强制
   退出）都会经过同一个 fullscreenchange 监听器把这个 class 摘掉，工具栏
   照常露出来。 */
#direct.fullscreen-mode .direct-bar,
#direct.fullscreen-mode .direct-tabs,
#direct.fullscreen-mode .direct-foot,
#direct.fullscreen-mode .direct-result {
    display: none;
}

/* 折叠工具栏（window-fill-mode）：跟全屏一样藏掉工具栏，但不触发浏览器原生全屏，
   画面只填满当前窗口。工具栏藏了之后折叠按钮也跟着没了，所以右上角留一个
   半透明的展开按钮（.direct-unfold），双击 Esc 也能展开。手机横屏默认折叠。 */
#direct.window-fill-mode .direct-bar,
#direct.window-fill-mode .direct-tabs,
#direct.window-fill-mode .direct-foot,
#direct.window-fill-mode .direct-result {
    display: none;
}
.icon-btn.active {
    color: var(--accent, #0070f3);
}
.direct-unfold {
    display: none;
    position: absolute; top: 6px; right: 6px; z-index: 5;
    padding: 2px 12px; font-size: 18px; line-height: 1.4;
    opacity: .6; border-radius: 8px;
}
.direct-unfold:hover { opacity: 1; }
#direct.window-fill-mode .direct-unfold { display: block; }
#direct.window-fill-mode #directBody { padding: 0; }
/* 手机横屏：工具栏一行排不下，按钮缩小、能横向滑 */
@media (orientation: landscape) and (max-height: 500px) {
    .direct-bar, .direct-foot { flex-wrap: nowrap; overflow-x: auto; padding-top: 4px; padding-bottom: 4px; }
    #directBody { padding: 2px; }
}

/* Admin 用户行里的 credits 余额。欠着的时候标红，一眼看得出来。 */
.user-row .credits {
    font-size: 13px; color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.user-row .credits.negative { color: var(--danger); font-weight: 600; }

/* ---------------------------------------------------------- 章节视图（校本答案）

   一个文件夹＝一章：左边扫描原题、右边答案，配对着看。两种版式：
   · stack（默认）—— 上下混排，手机上一列到底最顺
   · split        —— 左右分栏，iPad / Mac 大屏一眼对得上
   窄屏时强制退回上下混排：分栏在手机上两边都挤成条，反而更难看。 */

#githubChapter { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }

/* 图片加载进度条：数字是真实的懒加载完成数/总数，不是编的百分比。
   全部加载完就 hidden 掉，不会一直占地方。 */
.gh-progress {
    position: relative;
    height: 22px; border-radius: 999px; overflow: hidden;
    background: var(--composer); border: 1px solid var(--line);
}
.gh-progress-fill {
    position: absolute; inset: 0 auto 0 0; width: 0%;
    background: var(--accent); transition: width .25s ease;
}
.gh-progress-label {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center;
    font-size: 12px; color: var(--text-soft);
}

.gh-pair {
    display: grid;
    grid-template-columns: 1fr;      /* stack：图在上、答案在下 */
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--sidebar);
}
#githubChapter.split .gh-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
/* 手机上分栏没有意义，强制回到上下 */
@media (max-width: 820px) {
    #githubChapter.split .gh-pair { grid-template-columns: 1fr; }
}

.gh-scan img {
    width: 100%; height: auto; display: block;
    border: 1px solid var(--line); border-radius: 10px;
    background: #fff;
    min-height: 120px;               /* 还没加载出来时别塌成一条线 */
    cursor: zoom-in;                 /* 点开能放大看——化学那类题经常要看清图 */
}
.gh-scan .who { margin-top: 4px; font-size: 12px; }

/* 「今日作业答案」相册：跟 .gh-pair（一左一右配对）不一样，这里是很多人
   各传一张，没有配对关系，用响应式网格铺开——手机上一列，宽屏自动多列。 */
.coop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 10px 0;
}
.coop-grid .gh-scan {
    padding: 8px; border-radius: 12px;
    border: 1px solid var(--line); background: var(--sidebar);
}
.coop-grid .gh-scan img { margin-bottom: 0; }

/* 答案/前言现在是 renderAnswerMarkdown() 输出的真 HTML（段落/列表/公式），
   不再是纯文本，所以不能再靠 white-space: pre-wrap 保留换行——那样会跟
   <p>/<li> 自带的间距叠在一起，变成双倍空行。块级元素自己控制间距。 */
.gh-answer {
    font-size: 15px; line-height: 1.75;
    word-break: break-word;
    user-select: text;
}
.gh-answer p { margin: 0 0 10px; }
.gh-answer p:last-child { margin-bottom: 0; }
.gh-answer ul, .gh-answer ol { margin: 0 0 10px; padding-left: 1.4em; }
.gh-answer li { margin-bottom: 4px; }
.gh-answer code {
    padding: 1px 5px; border-radius: 5px;
    background: var(--composer); font-size: 0.9em;
}
/* KaTeX 块级公式自己居中、留点上下间距，别贴着相邻段落 */
.gh-answer .katex-display, .gh-intro .katex-display { margin: 8px 0; }
.gh-answer.empty { color: var(--text-faint); font-style: italic; }
/* 分栏时答案跟着滚到视线里，别让长答案把行撑得老高 */
#githubChapter.split .gh-answer {
    position: sticky; top: 8px;
    max-height: 80vh; overflow-y: auto;
}
.gh-intro {
    font-size: 14px; line-height: 1.7; color: var(--text-soft);
    margin-bottom: 8px;
}
.gh-intro p { margin: 0 0 8px; }
.gh-intro p:last-child { margin-bottom: 0; }

/* 这几个整屏面板必须自己能滚：body 是 overflow:hidden 的，漏掉哪个
   哪个就会「内容超出一屏但滚不动」。#admin 就漏过一次（跟当初语录那个
   一模一样的原因），加面板的时候记得一起加进来。 */
#auth, #settings, #github, #forum, #offline, #admin, #chess, #duel, #ideas, #exams, #mistakes {
    position: fixed; inset: 0; z-index: 150;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; overflow-y: auto;
}
/* 内容比一屏高的，从顶上开始排，别垂直居中（居中会把上半截顶出可视区） */
#settings, #github, #forum, #admin, #duel, #ideas, #exams, #mistakes { align-items: flex-start; padding-top: 40px; }

.panel { width: 100%; max-width: 400px; }
.chess-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0 8px; }
.chess-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.chess-card-name { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.chess-card:disabled { opacity: .4; cursor: default; }
#chess .link-btn { display: block; margin: 10px auto 0; text-align: center; }
.panel.wide { max-width: 560px; }
/* 校本答案左右分栏模式下，560px 分成两栏之后每栏只剩两百多像素，扫描件
   糊得看不清——用户点名反馈过。GitHub 板块（语录/校本答案/coop）本来
   就该比登录/设置这些表单页宽，单独给宽一点，图片才有地方伸展开；
   窄屏本来就有 max-width:100% 兜底，这条只在桌面宽屏才实际生效。 */
#github .panel.wide { max-width: 1100px; }

.brand { font-size: 24px; font-weight: 600; text-align: center; margin-bottom: 22px; }
#offline .panel { text-align: center; }
#offline .hint { font-size: 13px; line-height: 1.7; color: var(--text-soft); margin-bottom: 20px; }
#offline button {
    padding: 11px 24px;
    border: none; border-radius: 10px;
    background: var(--accent); color: var(--accent-text);
    font-size: 15px; font-weight: 500;
    cursor: pointer;
}

.tabs {
    display: flex; gap: 4px;
    background: var(--hover);
    border-radius: 999px; padding: 4px;
    margin-bottom: 22px;
}
.tab {
    flex: 1; border: none; background: none;
    padding: 8px; border-radius: 999px;
    font-size: 14px; font-weight: 500; color: var(--text-soft);
    cursor: pointer;
}
.tab.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.avatar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.avatar-row .im-avatar { width: 64px; height: 64px; font-size: 26px; border-radius: 10px; }
.im-avatar.has-img { background-size: cover; background-position: center; color: transparent; }
.auth-choice { display: flex; flex-direction: column; gap: 10px; }
.auth-choice button { padding: 14px; font-size: 16px; border-radius: 10px; cursor: pointer; }
.auth-done { text-align: center; padding: 20px 0; }
.auth-done .ok-mark { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; background: #07c160; color: #fff; font-size: 30px; line-height: 52px; }
.auth-done p { font-size: 16px; font-weight: 500; }
#wizard .link-btn { display: block; margin: 10px auto 0; }
.pane label, #settings label {
    display: block; font-size: 13px; font-weight: 500;
    margin: 14px 0 6px;
}
.pane label:first-child { margin-top: 0; }
.opt { font-weight: 400; color: var(--text-faint); }

.pane input, #settings input[type="text"], #settings input[type="password"], #settings input[type="email"], #settings input:not([type]) {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--composer-line);
    border-radius: 10px;
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 15px; outline: none;
}
.pane input:focus, #settings input:focus { border-color: var(--text-soft); }

.pane button[type="submit"], #settings button.primary {
    width: 100%; margin-top: 20px; padding: 12px;
    border: none; border-radius: 10px;
    background: var(--accent); color: var(--accent-text);
    font-size: 15px; font-weight: 500; cursor: pointer;
}

.msg { font-size: 13px; color: var(--text-soft); margin-top: 14px; min-height: 18px; }
.msg.error { color: var(--danger); }
.msg.ok { color: #16a34a; }

.foot-note {
    margin-top: 20px; font-size: 12px; line-height: 1.7;
    color: var(--text-faint); text-align: center;
}
.foot-note code, .kv code, .hint code {
    background: var(--code-bg); padding: 1px 5px; border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
}
.link-btn {
    display: block; margin: 12px auto 0;
    background: none; border: none; color: var(--text-faint);
    font-size: 12px; text-decoration: underline; cursor: pointer;
}

.ghost {
    border: 1px solid var(--line); background: none; color: var(--text);
    border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.ghost:hover { background: var(--hover); }

/* 选服务 */
#picker {
    position: fixed; inset: 0; z-index: 140;
    background: var(--bg);
    padding: 28px 24px; overflow-y: auto;
}
.picker-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; max-width: 820px; margin: 0 auto 26px;
}
.picker-head h1 { font-size: 22px; font-weight: 600; }
.picker-head .sub { font-size: 13px; color: var(--text-faint); margin-top: 5px; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.cards {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    max-width: 820px; margin: 0 auto;
}

/* 管理后台编辑公告用的输入框——跟登录页那几个 input 一个观感，
   textarea 默认没有全局样式规则罩着，得单独写一份 */
#announcementInput {
    width: 100%; margin-top: 8px;
    padding: 9px 11px;
    border: 1px solid var(--composer-line); border-radius: 8px;
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 13px; line-height: 1.6;
    resize: vertical;
}

/* 选服务页卡片下面的公告栏，管理后台编辑。空的时候整条 hidden，不占地方。
   支持文字中间插图片（![说明](链接)），setAnnouncement() 里换行换成
   <br> 了，这里不用再靠 white-space: pre-wrap 保留换行。 */
.announcement-bar {
    max-width: 820px; margin: 16px auto 0;
    padding: 12px 16px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--sidebar);
    font-size: 13px; line-height: 1.7; color: var(--text-soft);
    word-break: break-word;
}
/* 缩略图大小，不占满整条公告栏——点一下能放大看（灯箱），用户明确
   要求过图片别太大喧宾夺主。 */
.announcement-img {
    display: block; max-width: 240px; max-height: 200px;
    width: auto; height: auto;
    margin: 8px 0; border-radius: 8px; border: 1px solid var(--line);
    cursor: zoom-in;
}
/* 选服务页底下「网站状态」小字旁边那一小截紧凑指示——近 1 小时，
   2026-09-22 改版从原来公告栏底下那整条三档状态条收缩成这几个小方块。
   数据来自 server.py 的自我心跳/外部探测采样（每 5 分钟一次），不是
   编的。方块颜色代表那个时间窗口的在线率，跟 #statusPanel 环形时钟里
   图例用的是同一套颜色（.status-cell 这几个类两处共用）。 */
.status-strip { display: inline-flex; gap: 2px; vertical-align: middle; }
.status-cell {
    width: 7px; height: 16px; border-radius: 2px;
    background: var(--line);           /* 兜底，正常都会被下面几个类覆盖 */
}
.status-cell.up { background: #16a34a; }
.status-cell.partial { background: #f97316; }
.status-cell.down { background: #dc2626; }
.status-cell.warn { background: #eab308; }
.status-cell.off { background: #000; box-shadow: inset 0 0 0 1px rgba(128,128,128,.45); }
/* ai_remote 那排：同样 15 格，小一号，跟上面网站状态左对齐排在下面 */
.status-strip-sm .status-cell { width: 5px; height: 10px; }
.status-strip[hidden] { display: none; }
/* 临时的小狗格子（app.js 的 AI_STATUS_DOG） */
.status-cell-dog { font-size: 10px; line-height: 1; }
.status-ai-label { color: var(--text-faint); font-size: 11px; }

.card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    background: var(--sidebar);
    text-align: left;
    cursor: pointer;
    font: inherit; color: var(--text);
}
.card:hover:not(:disabled) { background: var(--hover); }
.card:disabled { opacity: .5; cursor: not-allowed; }
.card .icon { font-size: 26px; }
.card .name { font-size: 16px; font-weight: 600; margin: 8px 0 4px; }
.card .sub { font-size: 12px; color: var(--text-faint); line-height: 1.6; }
.card .state {
    display: inline-block; margin-top: 12px;
    font-size: 12px; padding: 3px 9px; border-radius: 999px;
    background: var(--hover); color: var(--text-soft);
}
.card .state.free { background: #16a34a22; color: #16a34a; }
.card .state.busy { background: #f9731622; color: #f97316; }
.card .state.mine { background: #2563eb22; color: #2563eb; }

.who { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 26px; }
.who-latency { font-variant-numeric: tabular-nums; opacity: 0.8; }

/* 设置页 */
.settings-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.settings-head h1 { font-size: 22px; font-weight: 600; }
#settings section, #github section, #forum section {
    border-top: 1px solid var(--line);
    padding: 20px 0;
}
#settings h2, #github h2, #forum h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

/* GitHub 面板——语录/校本答案/coop 这几个板块共用。原来这里太素了
   （纯文字列表、没有卡片感），2026-09-04 加了边框/圆角/悬停阴影，
   跟直连模式工具栏、公告栏那些已经有的卡片观感统一起来。 */
.files-dropzone {
    margin: 10px 0; padding: 28px 12px; border-radius: 10px;
    border: 2px dashed var(--line); background: var(--sidebar);
    color: var(--text-soft); text-align: center; font-size: 13px;
    transition: border-color .12s, background .12s;
}
.files-dropzone.drag-over {
    border-color: var(--accent); background: var(--hover); color: var(--text);
}
.gh-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.gh-list button {
    display: flex; align-items: center; gap: 8px;
    text-align: left; padding: 9px 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--sidebar); color: var(--text);
    font: inherit; font-size: 13px; cursor: pointer;
    transition: border-color .12s, transform .12s;
}
.gh-list button:hover {
    background: var(--hover); border-color: var(--text-soft);
    transform: translateX(2px);
}
.gh-file {
    margin-top: 10px; padding: 12px; border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--code-bg); font-size: 12.5px; line-height: 1.6;
    max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.gh-comments { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.gh-comments .gh-comment {
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--sidebar);
    font-size: 13px; line-height: 1.6;
}
.gh-comments .gh-comment .who {
    display: block; font-size: 12px; color: var(--text-faint); margin-bottom: 4px;
    text-align: left;
}
/* 面包屑：原来是纯文字链接堆一排，加个胶囊底让层级看得更清楚 */
#githubBreadcrumb a {
    padding: 3px 9px; border-radius: 999px;
    background: var(--sidebar); border: 1px solid var(--line);
    font-size: 12px; text-decoration: none; color: var(--text-soft);
}
#githubBreadcrumb a:hover { color: var(--text); border-color: var(--text-soft); }
.kv { font-size: 13px; color: var(--text-soft); margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: 16px; height: 16px; }
.badge-admin {
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: #2563eb22; color: #2563eb; font-weight: 500;
    vertical-align: middle; margin-left: 6px;
}
.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
/* 服务管理表格：每行一个服务，跟 .user-row 一样必须能换行，窄屏下不许
   横向长出屏幕（管理后台那条「窄屏每颗按钮都点得到」的看门狗盯着）。 */
.svc-table { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.svc-row {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 8px;
    padding: 8px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--sidebar);
}
.svc-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 100%; }
.svc-cell input, .svc-cell select { max-width: 100%; }
.svc-label { font-size: 11px; color: var(--text-faint); }
.svc-hidden { flex-direction: row; align-items: center; gap: 4px; font-size: 13px; }
.svc-example {
    white-space: pre-wrap; word-break: break-all;
    font-size: 12px; padding: 8px; border-radius: 6px; background: var(--sidebar);
}
.svc-fields {
    width: 100%; table-layout: fixed; border-collapse: collapse;
    font-size: 12px; margin: 6px 0;
}
.svc-fields td {
    padding: 3px 6px; border-bottom: 1px solid var(--line);
    vertical-align: top; overflow-wrap: anywhere;
}
.svc-fields td:first-child { width: 34%; font-family: monospace; color: var(--text-faint); }
#svcImportText { width: 100%; box-sizing: border-box; font-family: monospace; }

.user-row {
    display: flex; align-items: center; gap: 10px;
    /* 挤不下必须换行。不写这条的话这一行只会一直往右长，多出来的按钮被顶到
       屏幕外面——而 body 是 overflow:hidden、面板只开了纵向滚动，那几颗按钮
       就**永远点不到**了。管理后台每加一颗按钮都在逼近这条线：加了 credits
       的「加/减」「流水」之后，390px 宽的手机上「删除」就已经跑到屏幕外。
       tests/test_ui.py 里「窄屏下管理后台每颗按钮都点得到」那条是看门狗。 */
    flex-wrap: wrap;
    border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; font-size: 13px;
}
.user-row .uid { font-family: ui-monospace, Menlo, monospace; color: var(--text-soft); }
/* 名字/ID 长了要能自己压缩换行，不然它们照样能把按钮挤出去 */
.user-row .uname { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.user-row .tag {
    font-size: 11px; padding: 2px 7px; border-radius: 999px;
    background: var(--hover); color: var(--text-soft);
}
.user-row .grow { flex: 1; min-width: 0; }
.user-row button { font-size: 12px; padding: 5px 9px; }
/* flex-basis:100% 逼着它换到自己单独一行，不跟按钮挤在一起；
   长的 User-Agent 字符串会被 nowrap+ellipsis 砍断，完整版在 title 里 */
.user-row .user-meta {
    flex-basis: 100%;
    font-size: 12px; color: var(--text-faint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 访客账号（2026-09-17 起选服务页不登录也能进）默认折叠在这里面，不跟
   真实账号混在一起铺满整份用户列表——访客会一直攒、管理员日常更关心
   的是真实账号。<details> 自带展开/收起，不用另写 JS。里面的 .user-row
   不再是 .user-list 的直接子元素，拿不到那份 flex gap，自己补一条
   margin-top（第一条紧贴 summary，用 :not(:first-child) 跳过）。 */
.guest-users {
    border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px;
}
.guest-users summary {
    cursor: pointer; font-size: 13px; color: var(--text-soft);
    user-select: none;
}
.guest-users[open] summary { margin-bottom: 10px; }
.guest-users .user-row + .user-row { margin-top: 8px; }

/* ---------------------------------------------------------- 移动端 */

@media (max-width: 820px) {
    .only-mobile { display: inline-flex; }
    #sidebar {
        position: fixed; top: 0; bottom: 0; left: 0;
        z-index: 100;
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }
    #sidebar.collapsed { margin-left: -280px; box-shadow: none; }
    .seg-btn { padding: 5px 10px; }
    .picker-btn { max-width: 130px; font-size: 14px; padding: 7px 8px; }
    .menu { min-width: 200px; }
    #thread { padding: 8px 14px 30px; }
    #composer-wrap { padding: 0 12px 8px; }
    .user .bubble { max-width: 88%; }
    #topbar { gap: 4px; }
    .badge { display: none; }
}

/* ---------------------------------------------------------- 日志面板 */

#logs {
    position: fixed; inset: auto 0 0 0; z-index: 180;
    height: 55vh;
    background: var(--bg);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 32px rgba(0,0,0,.2);
    display: flex; flex-direction: column;
}
.logs-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}
.logs-head .grow { flex: 1; }
#logBody {
    flex: 1; overflow: auto;
    margin: 0; padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px; line-height: 1.6;
    color: var(--text-soft);
    white-space: pre-wrap; word-break: break-all;
}

@media (max-width: 820px) {
    #logs { height: 70vh; }
    /* 按钮多了会被挤出屏幕。窄屏下让它们换行，并去掉那个把它们推走的弹性空隙 */
    .logs-head { flex-wrap: wrap; gap: 8px; }
    .logs-head .grow { display: none; }
    .logs-head strong { width: 100%; }
    .logs-head .ghost { flex: 1; min-width: 64px; text-align: center; }
}

/* ---------------------------------------------------------- 历史记录面板 */

#history {
    position: fixed; inset: auto 0 0 0; z-index: 180;
    height: 60vh;
    background: var(--bg);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 32px rgba(0,0,0,.2);
    display: flex; flex-direction: column;
}
#historyBody { flex: 1; overflow: auto; padding: 12px 14px; }
.history-turn { padding: 12px 0; border-top: 1px solid var(--line); }
.history-turn:first-child { border-top: none; }
.history-turn .who { font-size: 12px; color: var(--text-faint); margin-bottom: 4px; }
.history-turn .prompt { font-size: 14px; font-weight: 500; margin-bottom: 8px; white-space: pre-wrap; }
.history-turn .body { font-size: 14px; line-height: 1.6; }
@media (max-width: 820px) { #history { height: 75vh; } }

/* ---------------------------------------------------------- 网站状态 */

/* 选服务页底下的小字入口——跟 #whoAmI 那行一个视觉级别，不抢眼。
   .status-strip/.status-cell 的定义在上面「网站状态」小字入口那节。 */
/* 两行两列：左列标签（右对齐）、右列方块（左对齐），整体居中——
   以前是 flex 一行，方块被挤到页面最右边，第二行又靠左，上下对不齐。 */
.status-entry {
    display: grid; grid-template-columns: auto auto;
    justify-content: center; align-items: center;
    gap: 6px 8px;
}
.status-entry[hidden] { display: none; }
.status-entry .status-label { justify-self: end; }
.status-entry .status-strip { justify-self: start; }
/* 小方块跟上面那排右端对齐；标签悬在它左边（绝对定位，不算进这一列
   的宽度，不然会把整列撑宽、两排就对不齐了）。 */
.status-ai-row {
    grid-column: 2; justify-self: end;
    position: relative; display: inline-flex; align-items: center;
}
.status-ai-row .status-ai-label {
    position: absolute; right: 100%; margin-right: 6px; white-space: nowrap;
}

#statusPanel {
    position: fixed; inset: auto 0 0 0; z-index: 180;
    height: 70vh;
    background: var(--bg);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 32px rgba(0,0,0,.2);
    display: flex; flex-direction: column;
}
.status-clock-wrap {
    flex: 1; overflow: auto;
    padding: 24px 14px 14px;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}
/* 环形本体：conic-gradient 画 12 个扇形（renderStatusClock() 现算颜色/
   角度），中间挖空一圈露出面板背景做成"圆环"而不是实心饼图——
   ::after 叠一个更小的同色圆在上面，比用 mask/clip-path 简单，
   两个主题（浅色/深色）下都对，因为背景色直接吃 --bg 这个变量。 */
/* flex-shrink:0 + aspect-ratio：它是纵向 flex 容器里的一项，面板高度
   不够时默认会被纵向压缩，有的机器上看到的就是一个扁椭圆。 */
.status-clock {
    position: relative;
    width: 220px; height: 220px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    margin: 14px auto;
}
.status-clock::after {
    content: '';
    position: absolute; inset: 9%;
    border-radius: 50%;
    background: var(--bg);
    z-index: 1;
}
/* 内圈＝ai_remote，同心、同一套角度（renderStatusClock() 一起画），
   自己再挖一个洞做成细一点的环。 */
.status-clock-inner {
    position: absolute; inset: 13%;
    border-radius: 50%;
    z-index: 2;       /* 得盖过外圈挖洞那层（::after，z-index 1，DOM 里排在最后） */
}
.status-clock-inner::after {
    content: '';
    position: absolute; inset: 13%;
    border-radius: 50%;
    background: var(--bg);
}
/* 指针：2026-09-22 改版，用户明确要求"现在9点,那就是指针指向左边"——
   跟真实模拟时钟一样，这根针的角度是当前时钟位置（renderStatusClock()
   按浏览器本地时间现算 nowAngle，内联 style 转出来的 rotate(...)），
   不再假设"现在"永远在 12 点。默认（未设置角度前）指向 12 点，跟
   rotate(0deg) 的语义天然对上，不用额外初始化。z-index 得盖过上面那个
   挖洞用的 ::after（donut hole），不然指针在圆环中心那截会被背景色
   盖住看不见。 */
/* 底端必须落在圆心（top = 50% - height），旋转轴 transform-origin 设在
   底端——以前写成 top:50%，指针从圆心往下长，轴心跑到了圆环底边，整根
   针绕着 6 点那个位置转（2026-09-22 真机截图抓到的）。 */
.status-clock-hand {
    position: absolute;
    top: 8%; left: 50%;
    width: 3px; height: 42%;
    background: var(--text);
    transform-origin: 50% 100%;
    transform: translateX(-50%) rotate(0deg);
    border-radius: 2px;
    z-index: 3;
}
.status-clock-hand::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 50%;
    width: 9px; height: 9px;
    background: var(--text);
    border-radius: 50%;
    transform: translateX(-50%);
}
.status-clock-label {
    position: absolute;
    font-size: 11px; color: var(--text-faint);
    white-space: nowrap;
    z-index: 3;
}
.status-clock-label-12 { top: -18px; left: 50%; transform: translateX(-50%); }
.status-clock-label-3 { top: 50%; right: -46px; transform: translateY(-50%); }
.status-clock-label-6 { bottom: -18px; left: 50%; transform: translateX(-50%); }
.status-clock-label-9 { top: 50%; left: -46px; transform: translateY(-50%); }
@media (max-width: 480px) {
    /* 窄屏放不下环外的四个标签，圆环本身缩小一点、标签贴更近，
       免得被切到屏幕外——CLAUDE.md 记过好几次这类窄屏溢出的坑。 */
    .status-clock { width: 180px; height: 180px; }
    .status-clock-label-3 { right: -38px; }
    .status-clock-label-9 { left: -38px; }
}

/* 公式：只保留 KaTeX 的 MathML 部分（那份靠样式表的 HTML 已在后端去掉），
   浏览器原生渲染，字号跟正文对齐 */
.assistant .body math { font-size: 1.05em; }
.assistant .body .katex { display: inline-block; }
.assistant .body .katex-display, .assistant .body .katex-display math {
    display: block; margin: 12px 0; text-align: center;
}

/* ---------------------------------------------------------- 版本不一致警告

   index.html 和 app.js 不是同一版时弹这条。这种故障本身是**没有症状**的：
   按钮画得出来、悬停有反应、点了没事、控制台一声不吭，所以这条必须显眼、
   必须压在所有东西上面（整屏面板的 z-index 是 200）。 */
#staleWarn {
    position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
    padding: 10px 14px;
    background: var(--danger); color: #fff;
    font-size: 13px; line-height: 1.6; text-align: center;
}
#staleWarn code { background: rgba(255, 255, 255, .2); padding: 1px 5px; border-radius: 4px; }

/* ---------------------------------------------------------- 页面内对话框

   取代原生 alert/confirm/prompt。原生那套会同步阻塞整个标签页的 JS：弹窗
   一旦藏到别的窗口后面，页面就彻底冻住、所有按钮都点不动，而且不报错。
   真机上就这么坏过一次。 */
#modal {
    position: fixed; inset: 0; z-index: 500;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, .45);
}
.modal-box {
    width: 100%; max-width: 420px;
    max-height: 80vh; overflow-y: auto;
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 14px;
    padding: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
.modal-box h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
#modalText {
    font-size: 13px; line-height: 1.7; color: var(--text-soft);
    white-space: pre-wrap; word-break: break-word;
}
#modalInput {
    width: 100%; margin-top: 12px;
    padding: 9px 11px;
    border: 1px solid var(--composer-line); border-radius: 8px;
    background: var(--composer); color: var(--text);
    font-size: 14px;
}
.modal-actions {
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
    margin-top: 16px;
}
.modal-actions button { padding: 8px 16px; font-size: 13px; }
#annPopup { position: fixed; inset: 0; z-index: 480; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .45); }
#annPopup[hidden] { display: none; }
#annPopup .announcement-bar { margin: 0; border: none; padding: 0; background: none; font-size: 14px; color: var(--text); }
#annPopup .announcement-img { max-width: 100%; max-height: 260px; }

/* ---- 讨论 ---- */
#forum .panel.wide { max-width: 720px; }
#forum section:first-of-type { border-top: none; padding-top: 0; }
#forum input, #forum textarea, #githubDiscussionSection textarea {
    display: block; width: 100%; margin-bottom: 10px;
    padding: 11px 14px;
    border: 1px solid var(--composer-line); border-radius: 10px;
    background: var(--composer); color: var(--text);
    font: inherit; font-size: 15px; outline: none; resize: vertical;
}
#forum input:focus, #forum textarea:focus, #githubDiscussionSection textarea:focus { border-color: var(--text-soft); }
#forum .row, #githubDiscussionSection .row { display: flex; gap: 10px; margin-bottom: 12px; }
#forum button.primary, #githubDiscussionSection button.primary {
    padding: 10px 18px; border: none; border-radius: 10px;
    background: var(--accent); color: var(--accent-text);
    font-size: 15px; font-weight: 500; cursor: pointer;
}
#forumTopics { display: flex; flex-direction: column; gap: 8px; }
.forum-topic {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--line); background: var(--sidebar);
}
.forum-topic:hover { border-color: var(--text-soft); }
.forum-topic .t { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forum-topic .m { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
#forumPosts .gh-comment { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--sidebar); font-size: 14px; line-height: 1.6; }
#forumPosts .who { display: block; margin: 0 0 4px; font-size: 12px; color: var(--text-faint); margin-bottom: 4px; }

.forum-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.forum-files .f, .forum-att {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--bg);
    font-size: 12px; color: var(--text-soft); cursor: pointer;
}
.forum-img { display: block; max-width: 100%; max-height: 360px; border-radius: 8px; margin-top: 8px; }
.forum-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.gh-disc-link { font-size: 13px; color: var(--text-soft); text-decoration: none;
    max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-disc-link:hover { color: var(--text); }
#githubDiscussionSection .settings-head { margin-bottom: 10px; }
#githubDiscussionSection .settings-head h2 { margin-bottom: 0; }
#githubComments .gh-comment { font-size: 14px; }
#githubComments .gh-comment p { margin: 0 0 6px; }
.mute-note { margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; font-size: 13px;
    line-height: 1.6; border: 1px solid var(--danger); color: var(--danger); }
.mute-note .quote { color: var(--text-soft); }
.mute-note button { margin-top: 8px; }
#githubComments .gh-comment .who, #forumPosts .gh-comment .who { margin: 0 0 4px; padding: 0; }

/* ---- 管理后台：左侧标题栏 + 右侧内容 ---- */
#admin .panel { max-width: 1040px; }
#adminLayout { display: flex; gap: 24px; align-items: flex-start; }
#adminNav { display: flex; flex-direction: column; gap: 4px; width: 150px; flex-shrink: 0;
    position: sticky; top: 0; }
#adminNav button { text-align: left; padding: 8px 12px; border: none; border-radius: 8px;
    background: transparent; color: var(--text-soft); font-size: 14px; cursor: pointer; }
#adminNav button:hover { background: var(--sidebar); color: var(--text); }
#adminNav button.active { background: var(--sidebar); color: var(--text); font-weight: 600; }
#adminSections { flex: 1; min-width: 0; }
#adminSections > section { border-top: none; padding-top: 0; }
@media (max-width: 720px) {
    /* 竖排时必须 stretch：沿用桌面的 flex-start 会让右边内容按最大内容宽度排，用户行的一排按钮把面板撑到 600+px */
    #adminLayout { flex-direction: column; gap: 12px; align-items: stretch; }
    #adminNav { flex-direction: row; width: 100%; overflow-x: auto; position: static; }
    #adminNav button { white-space: nowrap; }
}
details.adv { margin-top: 14px; }
details.adv > summary { cursor: pointer; font-size: 14px; color: var(--text-soft); margin-bottom: 10px; }
#forumPosts .gh-comment button { margin: 8px 6px 0 0; padding: 3px 10px; font-size: 12px; }
#forumPosts .gh-comment button.on { border-color: var(--text-soft); }
#forum .row input[type="search"] { flex: 1; margin-bottom: 0; }

/* ---- 举报 ---- */
.rep-corner { margin-left: auto; margin-right: 12px; padding: 3px 10px; font-size: 12px; }
#githubDiscussionSection .settings-head { gap: 8px; }
.gh-comment.rep-pick { cursor: pointer; }
.gh-comment.rep-on { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
#reportBar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 400;
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
    background: var(--bg); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
#reportBar button { padding: 6px 14px; font-size: 14px; }

/* ---------------- 下棋对战 */
.duel-new { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0 10px; }
.duel-new button { padding: 18px 0; font-size: 16px; }
.duel-join { display: flex; gap: 8px; margin: 10px 0; }
.duel-join input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
.duel-join button, .duel-actions button, .duel-preview button { min-width: 44px; min-height: 44px; }
.duel-mine { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.duel-mine button { text-align: left; }
.duel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.duel-clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.duel-clock.on { color: var(--accent, #2563eb); }
.duel-board { width: 100%; max-width: 520px; margin: 0 auto; touch-action: manipulation; user-select: none; }
.duel-guide { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; line-height: 1.6; }
.duel-guide summary { cursor: pointer; font-weight: 600; }
.duel-guide p { margin: 4px 0; }
.duel-guide ol { margin: 8px 0; padding-left: 22px; }
.duel-preview { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 0; color: var(--accent, #2563eb); font-size: 14px; }
.duel-preview[hidden] { display: none; }
.duel-board svg { width: 100%; height: auto; display: block; }
.duel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.duel-public { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; }
#duel h3 { margin: 16px 0 4px; font-size: 15px; }
.gh-comment-actions { display: flex; gap: 12px; margin-top: 4px; }
.gh-comment-actions .link-btn { font-size: 13px; padding: 0; }
.duel-bet { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; }
#duelLocalJoin input { min-width: 0; }
.duel-balance { margin: 8px 0 12px; padding: 12px 16px; border-radius: 12px; background: var(--sidebar);
    font-size: 15px; display: flex; align-items: baseline; gap: 10px; }
.duel-balance strong { font-size: 30px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 聊天（static/im.js） */
#im { position: fixed; inset: 0; z-index: 150; background: var(--bg); }
.im-wrap { display: flex; height: 100%; max-width: 1100px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.im-side { width: 300px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--sidebar); min-width: 0; }
.im-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.im-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line);
    padding-top: max(10px, env(safe-area-inset-top)); }
.im-bar strong { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-convs { flex: 1; overflow-y: auto; }
.im-conv { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border: none; background: none;
    color: var(--text); text-align: left; cursor: pointer; font: inherit; border-bottom: 1px solid var(--line); }
.im-conv:hover { background: var(--hover); }
.im-conv.on { background: var(--hover); }
.im-avatar { width: 40px; height: 40px; flex: none; border-radius: 6px; display: flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 600; color: #fff; position: relative; }
.im-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 500; }
.im-conv .c { flex: 1; min-width: 0; }
.im-conv .t { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.im-conv .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-conv .t span:last-child, .im-conv .p { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.im-conv .p { overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.im-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.im-more { align-self: center; font-size: 12px; }
.im-time, .im-sys { align-self: center; font-size: 12px; color: var(--text-faint); text-align: center; max-width: 90%; }
.im-row { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.im-row.me { flex-direction: row-reverse; }
.im-row .im-avatar { width: 34px; height: 34px; font-size: 14px; }
.im-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; max-width: min(72%, 560px); }
.im-row.me .im-col { align-items: flex-end; }
.im-name { font-size: 12px; color: var(--text-faint); }
.im-bubble { padding: 8px 11px; border-radius: 8px; background: var(--bubble); font-size: 15px; line-height: 1.5;
    white-space: pre-wrap; word-break: break-word; }
.im-row.me .im-bubble { background: #95ec69; color: #111; }
html[data-theme="dark"] .im-row.me .im-bubble { background: #3eb575; color: #111; }
.im-bubble a { color: inherit; }
.im-img { display: block; max-width: 240px; max-height: 300px; border-radius: 8px; cursor: zoom-in; background: var(--hover); min-width: 60px; min-height: 60px; }
.im-video-file { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 320px; max-width: 100%; min-width: 0; }
.im-video { display: block; width: 100%; max-height: 360px; border-radius: 6px; background: #000; }
.im-video-file .forum-att { max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere; }
.im-recall { font-size: 11px; color: var(--text-faint); background: none; border: none; cursor: pointer; padding: 0; }
.im-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line);
    padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.im-compose textarea { flex: 1; resize: none; max-height: 140px; padding: 9px 12px; border: 1px solid var(--composer-line);
    border-radius: 10px; background: var(--composer); color: var(--text); font: inherit; font-size: 16px; outline: none; }
.im-compose button.primary { padding: 9px 16px; border: none; border-radius: 10px; background: #07c160; color: #fff; font-size: 15px; cursor: pointer; }
.im-pending { padding: 0 12px; margin: 0; }
.im-pending:empty { display: none; }
.im-pending { padding-top: 8px; }
#imMsg { padding: 0 12px; }
#imMsg:empty { display: none; }
.im-empty { margin: auto; color: var(--text-faint); font-size: 14px; }
.im-sheet { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: rgba(0, 0, 0, .45); }
.im-sheet .modal-box { padding: 0 0 12px; max-width: 440px; }
.im-sheet .im-bar { position: sticky; top: 0; background: var(--bg); z-index: 1; padding-top: 10px; }
:is(.im-sheet, .im-page) input[type=text], :is(.im-sheet, .im-page) input[type=search] { display: block; width: calc(100% - 24px); margin: 10px 12px 6px; padding: 9px 12px;
    border: 1px solid var(--composer-line); border-radius: 10px; background: var(--composer); color: var(--text); font: inherit; font-size: 15px; outline: none; }
.im-user { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
.im-user:hover { background: var(--hover); }
.im-user .im-avatar { width: 32px; height: 32px; font-size: 13px; }
.im-user > span:not(.im-avatar) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-user input { width: 18px; height: 18px; }
:is(.im-sheet, .im-page) .row { display: flex; gap: 8px; padding: 10px 12px 0; flex-wrap: wrap; }
:is(.im-sheet, .im-page) .row button { flex: 1; }
.im-narrow-only { display: none; }
@media (max-width: 720px) {
    .im-wrap { border: none; }
    .im-side { width: 100%; border-right: none; }
    .im-main { display: none; }
    .im-wrap.chatting .im-side { display: none; }
    .im-wrap.chatting .im-main { display: flex; }
    .im-narrow-only { display: inline-block; }
}
.card { position: relative; }
.card > .im-badge { top: 10px; right: 10px; }
.im-icon-btn { position: relative; }
.im-icon-btn .im-badge { top: -6px; right: -6px; }
.im-sys.im-pat { color: var(--text-soft); }
.im-sticker { display: block; max-width: 130px; max-height: 130px; cursor: pointer; }
.im-view { display: block; max-width: calc(100% - 24px); max-height: 60vh; margin: 12px auto 0; border-radius: 8px; }
.im-sec { padding: 14px 12px 4px; font-size: 12px; color: var(--text-faint); }
.im-qr { width: 220px; height: 220px; margin: 16px auto 6px; background: #fff; border-radius: 10px; padding: 4px; }
.im-qr svg { display: block; width: 100%; height: 100%; }
.im-qr-name { text-align: center; font-size: 15px; font-weight: 600; }
.im-tag { flex: none !important; font-size: 12px; color: var(--text-faint); }
.im-emoji-panel { border-top: 1px solid var(--line); max-height: 260px; overflow-y: auto; padding: 8px 10px; }
.im-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; }
.im-emoji { font-size: 24px; line-height: 1; padding: 6px 0; border: none; background: none; cursor: pointer; border-radius: 6px; }
.im-emoji:hover, .im-sticker-cell:hover { background: var(--hover); }
.im-sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.im-sticker-cell { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; }
.im-sticker-cell img { max-width: 100%; max-height: 100%; }
.im-sticker-add { font-size: 26px; color: var(--text-faint); }
.im-user button { flex: none; }

/* 选服务页卡片整理 */
.card-edit-bar { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 6px; justify-content: flex-end; }
.card-edit-btn { padding: 3px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-size: 12px; color: var(--text-soft); cursor: pointer; }
.card-edit-btn:hover { color: var(--text); border-color: var(--text-soft); }
.card.card-editing { padding-bottom: 44px; cursor: default; }
.card.card-hidden { opacity: .45; }
a.link-btn { text-decoration: none; }

/* 新功能提议 */
#ideas textarea { display: block; width: 100%; margin: 10px 0; padding: 11px 14px; border: 1px solid var(--composer-line); border-radius: 10px;
    background: var(--composer); color: var(--text); font: inherit; font-size: 15px; outline: none; resize: vertical; }
#ideas .row { display: flex; gap: 10px; margin-bottom: 8px; }
#ideas button.primary { padding: 10px 18px; border: none; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 15px; cursor: pointer; }
.ideas-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.idea { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--sidebar); font-size: 14px; line-height: 1.6; }
.idea .t { white-space: pre-wrap; word-break: break-word; }
.idea .m { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.idea .st { padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--text-soft); }
.idea .st.done { background: #16a34a22; color: #16a34a; }
.idea .st.doing { background: #2563eb22; color: #2563eb; }
.idea .reply { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--text-soft); white-space: pre-wrap; word-break: break-word; }
.idea .reply.claude { border-left-color: #2563eb; }
.idea .reply.admin { border-left-color: #16a34a; }
.idea .reply b { font-weight: 600; color: var(--text); }
.idea .st.queued, .idea .st.checking { background: #f9731622; color: #f97316; }
.idea .nb { font-size: 12px; color: var(--text-faint); align-self: center; }
.idea .follow { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }
.idea .follow textarea { margin: 0 !important; font-size: 14px !important; }
.idea .follow button.primary { flex: none; padding: 8px 14px !important; }
.idea .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.idea .acts button, .idea .acts select { font-size: 12px; padding: 4px 10px; }
.idea .vote.on { color: var(--danger); border-color: var(--danger); }
.im-badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: -3px; right: -3px; background: var(--text-faint); }
.im-mute { justify-content: space-between; border-top: 1px solid var(--line); margin-top: 6px; }
.forum-topic .t .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-right: 6px; vertical-align: middle; }
.forum-topic .t .dot.muted { background: var(--text-faint); }

/* 离线（2026-10-19）：标题旁的小标签、待发送的消息/帖子 */
.off-tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 999px; background: var(--hover); color: var(--text-faint); vertical-align: middle; }
.pending-meta { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-faint); }
.pending-meta.failed { color: var(--danger); }
.pending-meta .link-btn { font-size: 11px; padding: 0; }
.forum-topic.pending, .gh-comment.pending { opacity: 0.75; }
.im-row.pending .im-bubble { opacity: 0.7; }


/* ---- 聊天：微信样式（2026-10-19）---- */
#im { --im-bg: #ededed; --im-panel: #fff; --im-bar: #ededed; --im-bub: #fff; --im-me: #95ec69; --im-line: #dcdcdc;
    --im-pin: #f7f7f7; --im-sel: #dedede; --im-link: #576b95; background: var(--im-bg); }
html[data-theme="dark"] #im { --im-bg: #111; --im-panel: #191919; --im-bar: #191919; --im-bub: #2c2c2c; --im-me: #3eb575;
    --im-line: #2a2a2a; --im-pin: #202020; --im-sel: #2a2a2a; --im-link: #7d90a9; }
.im-wrap { border-color: var(--im-line); }
.im-side { background: var(--im-panel); border-right-color: var(--im-line); }
.im-main { background: var(--im-bg); }
.im-bar { background: var(--im-bar); border-bottom-color: var(--im-line); min-height: 48px; }
.im-bar strong { text-align: center; font-size: 16px; font-weight: 600; }
.im-bar .ghost { border: none; background: none; font-size: 18px; min-width: 36px; }
.im-searchbox { padding: 8px 10px; background: var(--im-bar); }
.im-searchbox input { width: 100%; padding: 7px 10px; border: none; border-radius: 6px; background: var(--im-panel); color: var(--text); font: inherit; font-size: 14px; outline: none; text-align: center; }
.im-searchbox input:focus { text-align: left; }
.im-convs { background: var(--im-panel); }
.im-conv { position: relative; padding: 12px 14px; border-bottom: none; background: var(--im-panel); }
.im-conv::after { content: ''; position: absolute; left: 74px; right: 0; bottom: 0; height: 1px; background: var(--im-line); }
.im-conv:hover { background: var(--im-pin); }
.im-conv.pinned { background: var(--im-pin); }
.im-conv.on { background: var(--im-sel); }
.im-conv .im-avatar { width: 46px; height: 46px; font-size: 18px; border-radius: 6px; }
.im-conv .t { font-size: 16px; }
.im-conv .p { font-size: 13px; margin-top: 3px; }
.im-conv .t span:last-child { font-size: 11px; }
.im-conv .p .at, .im-conv .p .draft { color: var(--danger); }
.im-sec-title { padding: 8px 14px; font-size: 12px; color: var(--text-faint); background: var(--im-bar); }
.im-hit .p mark, .im-bubble mark { background: #ffe58f; color: #111; border-radius: 2px; }
.im-msgs { background: var(--im-bg); padding: 12px 12px 16px; gap: 18px; }
.im-time { font-size: 12px; color: var(--text-faint); }
.im-sys { font-size: 12px; color: var(--text-faint); }
.im-sys .link-btn { color: var(--im-link); font-size: 12px; padding: 0 2px; }
.im-row { gap: 10px; }
.im-row .im-avatar { width: 40px; height: 40px; font-size: 16px; border-radius: 5px; }
.im-col { gap: 4px; max-width: min(74%, 560px); }
.im-bubble { position: relative; padding: 9px 12px; border-radius: 6px; background: var(--im-bub); color: var(--text); font-size: 16px; line-height: 1.45; }
.im-row.me .im-bubble, html[data-theme="dark"] .im-row.me .im-bubble { background: var(--im-me); color: #111; }
.im-bubble::before { content: ''; position: absolute; top: 14px; width: 0; height: 0; border-style: solid; }
.im-row:not(.me) .im-bubble::before { left: -6px; border-width: 6px 6px 6px 0; border-color: transparent var(--im-bub) transparent transparent; }
.im-row.me .im-bubble::before { right: -6px; border-width: 6px 0 6px 6px; border-color: transparent transparent transparent var(--im-me); }
.im-name { font-size: 12px; color: var(--text-faint); }
.im-at { color: var(--im-link); }
.im-quote { max-width: 100%; padding: 5px 8px; border-radius: 4px; background: rgba(0, 0, 0, .07); color: var(--text-soft); font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
html[data-theme="dark"] .im-quote { background: rgba(255, 255, 255, .08); }
.im-quote.gone { cursor: default; font-style: italic; }
.im-quote.unlinked { cursor: default; }
.im-row.flash .im-bubble, .im-row.flash .im-img, .im-row.flash .im-sticker { animation: imflash 1.6s; }
@keyframes imflash { 0%, 60% { box-shadow: 0 0 0 3px #ffd666; } 100% { box-shadow: 0 0 0 3px transparent; } }
.im-img { border-radius: 6px; }
@media (pointer: coarse) { .im-bubble, .im-img, .im-sticker, .im-conv { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } }
.im-notice { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--im-panel); border-bottom: 1px solid var(--im-line);
    font-size: 13px; color: var(--text-soft); cursor: pointer; }
.im-notice span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-notice span::before { content: '📢 '; }
.im-notice button { border: none; background: none; padding: 0 4px; font-size: 14px; color: var(--text-faint); }
.im-compose { background: var(--im-bar); border-top-color: var(--im-line); padding: 8px 10px; gap: 6px; align-items: flex-end; }
.im-compose textarea { min-height: 38px; border: none; border-radius: 6px; background: var(--im-panel); padding: 9px 10px; line-height: 1.35; }
.im-compose .im-tool { border: none; background: none; font-size: 24px; padding: 0 4px; line-height: 38px; height: 38px; cursor: pointer; }
.im-compose button.primary { border-radius: 6px; padding: 0 14px; height: 38px; background: #07c160; font-size: 15px; }
.im-replybar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--im-bar); border-top: 1px solid var(--im-line); font-size: 12px; color: var(--text-soft); }
.im-replybar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-replybar button { border: none; background: none; padding: 0 4px; font-size: 14px; color: var(--text-faint); }
.im-atpop { max-height: 180px; overflow-y: auto; background: var(--im-panel); border-top: 1px solid var(--im-line); }
.im-atpop .im-user { padding: 7px 14px; }
.im-emoji-panel { background: var(--im-bar); border-top-color: var(--im-line); }
.im-menu { position: fixed; z-index: 420; display: flex; flex-wrap: wrap; max-width: 280px; padding: 4px; border-radius: 8px; background: #4c4c4c;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .3); }
.im-menu.col { flex-direction: column; flex-wrap: nowrap; width: 150px; padding: 4px 0; }
.im-menu button { border: none; background: none; color: #fff; font: inherit; font-size: 14px; padding: 8px 12px; cursor: pointer; text-align: left; white-space: nowrap; }
.im-menu button:hover { background: rgba(255, 255, 255, .12); }
.im-act { justify-content: space-between; border-top: 1px solid var(--line); }
.im-act .hint { flex: none; max-width: 55%; font-size: 13px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-act::after { content: '›'; color: var(--text-faint); font-size: 18px; }
.im-note { padding: 10px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.im-sheet textarea { display: block; width: calc(100% - 24px); margin: 10px 12px 0; padding: 9px 12px; min-height: 90px; border: 1px solid var(--composer-line); border-radius: 10px; background: var(--composer); color: var(--text); font: inherit; font-size: 15px; outline: none; resize: vertical; }


/* ======================================================================
   现代化外观（2026-10-19，用户要求「整体 UI 仿照现代网站再优化」）
   做法：不动结构，换一套更讲究的颜色/圆角/阴影/动效变量，再把选服务页、登录、设置、弹窗、按钮、输入框
   统一润色。聊天页另有自己的微信配色（#im 里），不受这里影响。尊重「界面要简洁」：只改样子，不加说明文字。
   ====================================================================== */
:root {
    --brand: #5b6cff; --brand-soft: rgba(91, 108, 255, .14); --brand-ink: #ffffff;
    --bg: #ffffff; --sidebar: #fafafb; --hover: #f2f2f5; --line: #e6e6ea;
    --text: #111114; --text-soft: #535866; --text-faint: #8a8f9c;
    --composer-line: #d9d9e0; --code-bg: #f2f2f5;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 8px 28px rgba(16, 24, 40, .10);
    --ease: cubic-bezier(.2, .7, .2, 1);
}
html[data-theme="dark"] {
    --brand: #8c98ff; --brand-soft: rgba(140, 152, 255, .16); --brand-ink: #0e0e11;
    --bg: #0f0f12; --sidebar: #17171b; --hover: #202027; --line: #26262e;
    --text: #ececf1; --text-soft: #b4b7c3; --text-faint: #80848f;
    --composer: #1b1b21; --composer-line: #2e2e37; --code-bg: #1b1b21;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 10px 32px rgba(0, 0, 0, .5);
}
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
body { letter-spacing: -.003em; font-feature-settings: "cv11", "ss01"; }
h1, h2, h3, .brand { letter-spacing: -.02em; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* 按钮：统一过渡、按下回弹 */
button { transition: background-color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .12s var(--ease), color .15s var(--ease); }
button:not(:disabled):active { transform: scale(.975); }
.ghost { border-radius: 10px; padding: 7px 14px; border-color: var(--line); background: var(--bg); box-shadow: var(--shadow-sm); }
.ghost:hover { background: var(--hover); border-color: var(--composer-line); }
.link-btn:hover { color: var(--text); }
button.primary, .modal-actions button:last-child, #annPopupOk { background: var(--brand); color: var(--brand-ink); border: none; border-radius: 10px; font-weight: 500; box-shadow: 0 1px 2px rgba(91, 108, 255, .35); }
button.primary:hover, .modal-actions button:last-child:hover, #annPopupOk:hover { filter: brightness(1.08); }
.modal-actions button { padding: 8px 18px; border-radius: 10px; }

/* 输入框：聚焦时品牌色光圈 */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), textarea, select {
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
    border-radius: 10px;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):focus, textarea:focus, select:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

/* 登录 / 设置 / 各板块的面板 */
#auth, #setup, #offline { background: radial-gradient(900px 420px at 50% -80px, var(--brand-soft), transparent 70%), var(--bg); }
#auth .panel, #setup .panel {
    background: var(--bg); border: 1px solid var(--line); border-radius: 22px; padding: 34px 30px; box-shadow: var(--shadow-md);
    animation: cs-rise .4s var(--ease) both;
}
.brand { font-size: 28px; font-weight: 700; background: linear-gradient(90deg, var(--text) 30%, var(--brand)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tabs { background: var(--hover); }
.tab.active { box-shadow: var(--shadow-sm); }
.auth-choice button { transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.auth-choice button:first-child { background: var(--brand); color: var(--brand-ink); border: none; box-shadow: 0 4px 14px rgba(91, 108, 255, .35); }
.auth-choice button:not(:disabled):hover { transform: translateY(-1px); }
#settings .panel, #forum .panel, #ideas .panel, #exams .panel, #duel .panel, #github .panel { animation: cs-rise .35s var(--ease) both; }
#gTabs { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:8px; }
.g-tab { flex:0 0 auto; padding:6px 10px; border:none; border-radius:6px; cursor:pointer; font-size:13px; background:var(--card-bg); color:var(--fg2); transition:.15s; }
.g-tab.active { background:var(--brand); color:#fff; font-weight:600; }
#gArena { display:flex; flex-direction:column; align-items:center; }
.ggame { display:none; flex-direction:column; align-items:center; gap:6px; width:100%; }
.ggame.active { display:flex; }
.g-score { font-size:16px; font-weight:700; color:var(--brand); min-height:22px; }
.settings-head h1, .picker-head h1 { font-weight: 700; }

/* 选服务页 */
#picker { background: radial-gradient(1100px 460px at 50% -140px, var(--brand-soft), transparent 70%), var(--bg); }
.picker-head { max-width: 960px; margin-bottom: 28px; }
.picker-head h1 { font-size: 26px; }
.cards { max-width: 960px; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
    position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 20px;
    box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease);
    animation: cs-rise .45s var(--ease) both;
}
.card:hover:not(:disabled) { background: var(--bg); transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand-soft); }
.card:active:not(:disabled) { transform: translateY(-1px) scale(.99); }
.card { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
.card .icon { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 14px; background: var(--hover); font-size: 24px; }
.card .name { font-size: 16px; font-weight: 650; margin: 14px 0 4px; letter-spacing: -.01em; }
.card .sub { font-size: 12.5px; }
.card .state { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 0; background: none; font-size: 12px; font-weight: 500; }
.card .state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.card .state.free { background: none; color: #16a34a; }
.card .state.busy { background: none; color: #ea8a1a; }
.card .state.mine { background: none; color: var(--brand); }
.card:nth-child(1) { animation-delay: .00s; } .card:nth-child(2) { animation-delay: .04s; } .card:nth-child(3) { animation-delay: .08s; }
.card:nth-child(4) { animation-delay: .12s; } .card:nth-child(5) { animation-delay: .16s; } .card:nth-child(6) { animation-delay: .20s; }
.card:nth-child(7) { animation-delay: .24s; } .card:nth-child(8) { animation-delay: .28s; } .card:nth-child(n+9) { animation-delay: .32s; }
.announcement-bar { max-width: 960px; border-radius: 16px; background: var(--sidebar); border-color: var(--line); border-left: 3px solid var(--brand); }
.who { margin-top: 30px; line-height: 2.1; }
.who .link-btn {
    display: inline-block; margin: 0 4px; padding: 2px 12px; border: 1px solid var(--line); border-radius: 999px;
    text-decoration: none; color: var(--text-soft); background: var(--bg); font-size: 12px;
}
.who .link-btn:hover { background: var(--hover); color: var(--text); }
.head-actions .ghost { border-radius: 999px; }

/* 弹窗：毛玻璃遮罩 + 弹出动画 */
#modal, #annPopup, .im-sheet { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal-box { border-radius: 20px; box-shadow: var(--shadow-md); animation: cs-pop .22s var(--ease) both; }
#annPopup .modal-box { padding: 26px 24px 20px; }
.toast, #toasts > * { border-radius: 12px; box-shadow: var(--shadow-md); }

/* 讨论 / 提议 / 下棋等列表里的条目 */
.forum-topic, .idea, .duel-room-row, .chess-card { border-radius: 14px; transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease); }
.forum-topic:hover, .idea:hover { box-shadow: var(--shadow-sm); border-color: var(--composer-line); }

@keyframes cs-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cs-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}

/* 手机：卡片排两列，更像应用 */
@media (max-width: 560px) {
    #picker { padding: 20px 14px 28px; }
    .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
    .card { padding: 16px 14px; border-radius: 16px; }
    .card .icon { width: 40px; height: 40px; font-size: 21px; border-radius: 12px; }
    .card .name { font-size: 15px; margin-top: 12px; }
    .card .sub { font-size: 11.5px; }
    #auth .panel, #setup .panel { padding: 26px 20px; border-radius: 20px; }
}

/* 开关：圆角滑块 */
label.switch input[type=checkbox] {
    appearance: none; -webkit-appearance: none; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--composer-line);
    position: relative; cursor: pointer; transition: background-color .2s var(--ease); border: none;
}
label.switch input[type=checkbox]::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease);
}
label.switch input[type=checkbox]:checked { background: var(--brand); }
label.switch input[type=checkbox]:checked::after { transform: translateX(16px); }
.hint.small { font-size: 12px; color: var(--text-faint); margin-top: 6px; }
#settings label.switch { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }

/* 手机上别误触放大（2026-10-19）：双击不缩放；输入框字号 ≥16px（iOS 聚焦时小于 16px 会自动放大页面） */
html, body { touch-action: manipulation; }
@media (pointer: coarse) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select,
    .idea .follow textarea, .direct-slider input.val-num { font-size: 16px !important; }
}

/* 聊天顶栏：按钮别撑大，标题不被挤掉（2026-10-20） */
#im .im-bar .ghost { flex: none; height: 36px; min-height: 36px; min-width: 36px; padding: 0 8px; background: none; border: none; box-shadow: none; font-size: 17px; }
#im .im-bar strong { min-width: 0; flex: 1 1 auto; }

/* 公告里的音频：一颗按钮，点一下循环播放 */
.ann-audio { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.ann-audio.playing { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* 点歌台 */
.music-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.music-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.music-row.playing { border-color: var(--brand); background: var(--brand-soft); }
.music-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-now-playing { padding: 8px 0; font-size: 14px; color: var(--brand); }

/* ---- 考试分析 ---- */
#exams .panel.wide { max-width: 1080px; }
.exam-actions { gap: 8px; flex-wrap: wrap; }
.exam-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.exam-chips[hidden] { display: none; }
.exam-chip { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.exam-chip.on { border-color: var(--c, var(--brand)); color: var(--c, var(--brand)); font-weight: 600; }
.exam-chart { margin: 10px 0; border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: var(--bg); }
.exam-chart[hidden] { display: none; }
.exam-chart svg { width: 100%; height: auto; display: block; }
.exam-grid { stroke: var(--line); stroke-width: 1; }
.exam-axis { fill: var(--text-faint); font-size: 11px; }
.exam-dot { cursor: pointer; stroke: var(--bg); stroke-width: 2; }
.exam-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.exam-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); padding: 10px 14px; cursor: pointer; }
.exam-item b { display: block; }
.exam-item small { color: var(--text-faint); }
.exam-score { font-weight: 700; font-size: 18px; white-space: nowrap; }
.exam-points { margin-top: 18px; }
.exam-points[hidden] { display: none; }
.exam-points h2 { font-size: 16px; }
.exam-points h3 { font-size: 14px; margin: 10px 0 4px; }
.exam-points li { margin: 3px 0 3px 18px; font-size: 14px; }
.exam-points small { color: var(--text-faint); }
#examEdit { position: fixed; inset: 0; z-index: 470; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .45); }
#examEdit[hidden] { display: none; }
.exam-edit { width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.exam-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.exam-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-soft); }
.exam-q-head, .exam-q { display: grid; grid-template-columns: 70px 1fr 1fr 56px 32px; gap: 6px; align-items: center; }
.exam-q-head { font-size: 12px; color: var(--text-faint); padding: 0 2px; }
.exam-qs { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.exam-q input { min-width: 0; padding: 6px 8px; }
.exam-q.wrong { background: rgba(214, 51, 108, .07); border-radius: 8px; }
.exam-wrong { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.exam-q-info { grid-column: 1 / -1; font-size: 12px; color: var(--text-soft); padding: 0 4px 4px; }

.exam-wide { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-soft); margin: 4px 0 10px; }
#examProfile { position: fixed; inset: 0; z-index: 470; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .45); }
#examProfile[hidden] { display: none; }
#examReview { position: fixed; inset: 0; z-index: 460; display: flex; flex-direction: column; background: var(--bg); }
#examReview[hidden] { display: none; }
.exam-review-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.exam-review-bar strong { flex: 1; text-align: center; font-size: 14px; }
.exam-review-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.exam-review-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-soft); }
.exam-review-form input { padding: 5px 7px; min-width: 0; }
#examReviewMsg { padding: 0 12px; }
.exam-pages { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.exam-page { position: relative; width: min(900px, 100%); user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.exam-page img { width: 100%; display: block; border-radius: 6px; box-shadow: var(--shadow-md); pointer-events: none; }
.exam-box { position: absolute; border: 2.5px solid #16a34a; border-radius: 4px; background: rgba(22, 163, 74, .08); cursor: move; touch-action: none; }
.exam-box.wrong { border-color: #dc2626; background: rgba(220, 38, 38, .12); }
.exam-box.busy { border-style: dashed; opacity: .7; }
.exam-box-tag { position: absolute; left: -2px; top: -22px; padding: 1px 6px; border-radius: 6px 6px 6px 0; font-size: 12px; font-weight: 600; color: #fff; background: #16a34a; white-space: nowrap; pointer-events: none; }
.exam-box.wrong .exam-box-tag { background: #dc2626; }
.exam-box-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2.5px solid currentColor; color: #16a34a; cursor: nwse-resize; touch-action: none; }
.exam-box.wrong .exam-box-handle { color: #dc2626; }
.exam-box-x { position: absolute; right: -10px; top: -10px; width: 20px; height: 20px; border-radius: 50%; border: none; background: #64748b; color: #fff; font-size: 13px; line-height: 20px; padding: 0; cursor: pointer; }

.ann-audio.loading { opacity: .7; cursor: progress; }

/* 考试分析：现代化（2026-10-22）——概览卡、卡片式列表、渐变按钮 */
#exams .settings-head h1 { font-size: 24px; letter-spacing: .02em; }
.exam-actions button { border-radius: 999px; padding: 8px 16px; }
.exam-actions .primary { background: linear-gradient(135deg, var(--brand), #7c5cff); border: none; color: #fff; box-shadow: 0 6px 18px rgba(79, 107, 237, .28); }
.exam-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.exam-stats[hidden] { display: none; }
.exam-stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line);
             background: linear-gradient(180deg, var(--bg), var(--sidebar)); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05)); }
.exam-stat span { font-size: 12px; color: var(--text-faint); }
.exam-stat b { font-size: 26px; line-height: 1.15; font-weight: 750; letter-spacing: -.01em; }
.exam-stat small { font-size: 12px; color: var(--text-soft); }
.exam-stat small.up { color: #16a34a; font-weight: 600; }
.exam-stat small.down { color: #dc2626; font-weight: 600; }
.exam-chart { border-radius: 18px; padding: 12px 10px 6px; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05)); }
.exam-item { position: relative; overflow: hidden; border-radius: 14px; padding: 12px 16px 14px 18px; transition: transform .15s var(--ease, ease), box-shadow .15s; }
.exam-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--brand)); }
.exam-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-md, 0 6px 18px rgba(0,0,0,.08)); }
.exam-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--c, var(--brand)); opacity: .55; border-radius: 0 3px 3px 0; }
.exam-chip { transition: background .15s, border-color .15s; }
.exam-chip.on { background: color-mix(in srgb, var(--c, var(--brand)) 12%, transparent); }
.exam-points { padding: 14px 16px; border: 1px solid var(--line); border-radius: 18px; }
#examImport { position: fixed; inset: 0; z-index: 470; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .45); }
#examImport[hidden] { display: none; }
.exam-import-list { display: flex; flex-direction: column; gap: 6px; max-height: 55dvh; overflow: auto; margin: 8px 0; }
.exam-import-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.exam-import-row b { display: block; font-size: 14px; }
.exam-import-row small { color: var(--text-faint); font-size: 12px; }
@media (max-width: 520px) { .exam-stat b { font-size: 22px; } .exam-actions button { flex: 1 1 auto; } }

.exam-actions button:not(.primary) { border: 1px solid var(--line); background: var(--bg); color: var(--text); box-shadow: none; }
.exam-actions button:not(.primary):hover { border-color: var(--brand); color: var(--brand); }
.exam-actions { display: flex; }

/* 考试分析：往下滑的初步分析 */
#mistakes .panel.wide { max-width: 760px; }
.exam-report { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.exam-report[hidden] { display: none; }
.exam-sec { padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05)); }
.exam-sec h2 { font-size: 17px; margin: 0 0 10px; }
.exam-sec h3 { font-size: 14px; margin: 12px 0 6px; color: var(--text-soft); }
.exam-sec ol, .exam-sec ul { margin: 0; padding-left: 20px; line-height: 1.7; }
.exam-table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 12px; }
.exam-table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
.exam-table th { position: sticky; top: 0; background: var(--sidebar); text-align: left; padding: 7px 10px; font-weight: 600; }
.exam-table td { padding: 6px 10px; border-top: 1px solid var(--line); }
.exam-table tbody tr { cursor: pointer; }
.exam-table tbody tr:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.exam-list-title { font-size: 17px; margin: 18px 0 4px; }
.mistake-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.mistake-card { border: 1px solid var(--line); border-left: 4px solid var(--c, var(--brand)); border-radius: 14px; padding: 10px 14px; background: var(--bg); }
.mistake-card summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; list-style: none; }
.mistake-card summary::-webkit-details-marker { display: none; }
.mistake-card summary small { color: var(--text-faint); }
.mistake-reason { flex-basis: 100%; font-size: 13px; color: #dc2626; }
.mistake-row { display: grid; grid-template-columns: 56px 1fr; gap: 8px; margin-top: 8px; font-size: 14px; line-height: 1.6; }
.mistake-row em { font-style: normal; color: var(--text-faint); font-size: 12px; padding-top: 2px; }

.exam-sec .hint { font-size: 12px; color: var(--text-faint); margin: 8px 0 0; line-height: 1.6; }

/* 考试分析：中考冲刺版（2026-10-22）——大曲线 + 录取线、差距表、可对话的 AI */
.exam-chart-card { margin: 12px 0; padding: 10px 12px 8px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05)); }
.exam-chart-card .exam-chips { margin: 4px 0; }
.exam-chart-card .exam-chart { border: none; box-shadow: none; padding: 4px 0 0; margin: 4px 0 0; }
.exam-chip.small { padding: 2px 10px; font-size: 12px; }
.exam-ctl-gap { width: 10px; }
.exam-ref { font-size: 11px; fill: var(--text-faint); }
.exam-ref.target { fill: #dc2626; font-weight: 700; }
.exam-val { font-size: 13px; font-weight: 700; fill: #4f6bed; }
.exam-chart-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12px; color: var(--text-faint); padding: 4px 2px 0; }
.exam-key::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 4px; vertical-align: -1px; }
.exam-big-btn { margin-left: auto; padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.exam-chart-card.big { position: fixed; inset: 0; z-index: 480; margin: 0; border-radius: 0; overflow: auto; padding: 14px max(14px, env(safe-area-inset-left)); }
.exam-chart-card.big .exam-chart svg { max-height: none; }
.exam-gap { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
.exam-gap th { position: sticky; top: 0; background: var(--sidebar); text-align: left; padding: 7px 10px; font-weight: 600; }
.exam-gap td { padding: 6px 10px; border-top: 1px solid var(--line); }
.exam-gap td.num { font-weight: 700; text-align: right; }
.exam-gap td.dim { color: var(--text-faint); }
.exam-gap tr.short td.num { color: #dc2626; }
.exam-gap tr.over td.num { color: #16a34a; }
.exam-gap tr.target td { background: color-mix(in srgb, var(--brand) 8%, transparent); font-weight: 600; }
.exam-gap tr.guessed td { color: var(--text-faint); }
.exam-ai[hidden] { display: none; }
.exam-ai-msgs { display: flex; flex-direction: column; gap: 10px; }
.exam-bubble { max-width: 92%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.exam-bubble.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.exam-bubble.ai { align-self: flex-start; background: var(--sidebar); border-bottom-left-radius: 4px; }
.exam-bubble.pending { opacity: .7; }
.exam-bubble h3 { font-size: 15px; margin: 10px 0 4px; color: var(--text); }
.exam-bubble li { margin-left: 18px; }
.exam-bubble p { margin: 4px 0; }
.exam-ai-changes { margin-top: 10px; padding: 10px 12px; border: 1px solid #e0820f; border-radius: 14px; background: color-mix(in srgb, #e0820f 7%, transparent); }
.exam-ai-changes[hidden] { display: none; }
.exam-ai-changes h3 { margin: 0 0 6px; color: var(--text); }
.exam-change { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 4px 0; cursor: pointer; }
.exam-ai-input { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.exam-ai-input textarea { flex: 1; min-width: 0; resize: vertical; border-radius: 12px; padding: 8px 10px; font: inherit; font-size: 14px; }
.exam-ai-input button { border-radius: 999px; padding: 9px 18px; white-space: nowrap; }
.exam-ai-reset { margin-top: 6px; font-size: 12px; padding: 2px 8px; }
.exam-ai-reset[hidden] { display: none; }

/* 提分诊断和错题复习沿用考试面板的明暗主题。 */
.exam-priority { display:grid; gap:6px; padding:12px 0; border-bottom:1px solid var(--line); font-variant-numeric:tabular-nums; }
.exam-priority small { color:var(--text-soft); }
.exam-priority button { justify-self:start; }
.exam-q-fields { grid-column:1 / -1; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding:8px 0; }
.exam-q-fields label { display:grid; gap:4px; font-size:12px; }
.exam-q-fields textarea { width:100%; min-width:0; resize:vertical; }
.mistake-original { display:block; width:100%; height:auto; margin-top:12px; }
#mistakesSearch { flex:1; min-width:150px; }
#mistakes .exam-actions { flex-wrap:wrap; }
#examImprove { font-variant-numeric:tabular-nums; }
@media(max-width:480px) { .exam-q-fields { grid-template-columns:1fr; } }

.exam-source .exam-sort { border:0; background:transparent; color:inherit; font:inherit; font-weight:600; padding:4px 0; white-space:nowrap; cursor:pointer; }
.exam-source .exam-sort:hover { text-decoration:underline; }
.exam-source .exam-sort:focus-visible { outline:2px solid var(--brand, #4f6bed); outline-offset:3px; }

.exam-legend-toggle { border:0; background:transparent; color:inherit; font:inherit; padding:4px 6px; cursor:pointer; }
.exam-legend-toggle.off { opacity:.4; filter:grayscale(1); }
.exam-legend-toggle:focus-visible { outline:2px solid var(--brand, #4f6bed); outline-offset:2px; }

/* 桌面悬停/移动端轻点的考试详情，不依赖浏览器原生 SVG title。 */
.exam-point { cursor:pointer; touch-action:manipulation; }
.exam-point-hit { fill:transparent; stroke:none; pointer-events:all; }
.exam-point:focus-visible { outline:none; }
.exam-point:focus-visible .exam-dot { stroke:var(--brand, #4f6bed); stroke-width:3; }
.exam-point-details { position:fixed; z-index:550; width:min(360px, calc(100vw - 24px)); max-height:min(60vh, 460px); overflow:auto; background:var(--bg); color:var(--text); border:1px solid var(--line); border-radius:6px; box-shadow:0 6px 24px #0002; padding:0 12px 10px; font-size:13px; line-height:1.5; font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.exam-point-head { position:sticky; top:0; display:flex; align-items:center; justify-content:space-between; gap:10px; background:var(--bg); padding:10px 0 6px; z-index:1; }
.exam-point-head button { flex:none; min-width:32px; min-height:32px; padding:3px 8px; }
.exam-point-date { color:var(--text-faint); margin-bottom:6px; }
.exam-point-record { border-top:1px solid var(--line); padding-top:6px; margin-top:6px; }
.exam-point-row { display:flex; justify-content:space-between; gap:12px; padding:2px 0; }
.exam-point-row > span { color:var(--text-soft); }
.exam-point-row > b { text-align:right; }
.exam-point-details .hint { font-size:11px; margin:4px 0 0; }
.im-account-id { display: block; color: var(--text-faint); font-size: 11px; }
:is(#imSheetBody, #imPageBody) > form.row { flex-wrap: nowrap; }
:is(#imSheetBody, #imPageBody) > form.row input { flex: 1; min-width: 0; margin: 0; }
:is(#imSheetBody, #imPageBody) > form.row button { flex: none; min-height: 40px; }
:is(#imSheetBody, #imPageBody) .im-danger { color: var(--danger); border-color: var(--danger); }
.im-add-menu { display: grid; gap: 8px; }
:is(#imSheetBody, #imPageBody) .im-qr-shortcut { margin: 8px 12px; }
.im-add-menu { padding: 12px; }
:is(#imSheetBody, #imPageBody) .im-qr-shortcut { margin: 8px 12px; }

/* 单次考试总览：与历史曲线分开选场次，原始记录仍可编辑。 */
.exam-event-toolbar,.exam-event-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.exam-event-toolbar{margin:16px 0}.exam-event-toolbar select{flex:1;min-width:0;max-width:720px}
.exam-event-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:16px 0}
.exam-event-stat,.exam-event-panel{border:1px solid var(--line);background:var(--sidebar);border-radius:6px;padding:18px;min-width:0}
.exam-event-stat{display:flex;flex-direction:column;gap:10px}.exam-event-number{font-size:26px;line-height:1.3;overflow-wrap:anywhere}
.exam-event-stat:first-child .exam-event-number{color:#d6336c}.exam-event-layout{display:grid;grid-template-columns:minmax(0,1fr) 250px;gap:16px}
.exam-event-heading h3,.exam-event-panel h3{margin:0;font-size:17px}.exam-event-heading select{max-width:190px;font-size:13px}
.exam-event-row{display:grid;grid-template-columns:70px minmax(30px,1fr) 75px 66px;gap:10px;align-items:center;width:100%;text-align:left;border:0;border-bottom:1px solid var(--line);background:transparent;border-radius:0;padding:17px 0;color:inherit;min-height:54px}
.exam-event-row:hover,.exam-event-row:focus-visible{background:var(--bg)}.exam-event-row strong{color:var(--c);text-align:right}.exam-event-marks{text-align:right;font-size:13px;opacity:.75}
.exam-event-track{height:8px;background:var(--line);border-radius:4px;overflow:hidden}.exam-event-track i{display:block;height:100%;background:var(--c);border-radius:4px}
.exam-event-note{display:flex;flex-direction:column;gap:7px;padding:18px 0;border-bottom:1px solid var(--line)}.exam-event-review button{width:100%;margin-top:10px}
@media(max-width:700px){.exam-event-layout{grid-template-columns:1fr}.exam-event-stats{gap:7px}.exam-event-stat{padding:11px}.exam-event-number{font-size:20px}.exam-event-panel{padding:13px}.exam-event-row{grid-template-columns:55px minmax(25px,1fr) 61px 54px;gap:6px;font-size:13px}.exam-event-marks{font-size:12px}.exam-event-heading select{max-width:160px}.exam-event-toolbar{align-items:stretch;flex-direction:column}.exam-event-toolbar select{width:100%}}

.exam-event-toolbar select,.exam-event-heading select{padding:9px 10px;min-height:44px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--text);font:inherit}
.exam-event-review button{padding:10px 14px;min-height:44px;cursor:pointer;border-radius:6px;font-size:14px}
.exam-event-panel p.hint{margin-top:12px}.exam-event-view>p.hint{margin-top:14px}

@media(max-width:700px){.exam-event-stat:first-child .exam-event-number{font-size:16px;white-space:nowrap}}
#modalBanFields label { display: block; margin: 12px 0 6px; font-size: 13px; }
#modalBanFields select, #modalBanFields input {
    width: 100%; min-width: 0; padding: 9px 11px; margin-bottom: 8px;
    border: 1px solid var(--composer-line); border-radius: 8px;
    background: var(--composer); color: var(--text); font: inherit;
}
#banError { color: var(--danger, #c33); font-size: 13px; }

.user-row .ban-feedback { flex-basis: 100%; margin: 0; white-space: normal; overflow-wrap: anywhere; }

#imReportForm { display: grid; gap: 12px; padding: 16px; }
#imReportForm textarea { width: 100%; min-height: 96px; resize: vertical; font: inherit; }
#imReportFiles { min-width: 0; max-width: 100%; }
.im-report-previews, .report-images { display: flex; flex-wrap: wrap; gap: 8px; }
.im-report-previews > div { display: grid; gap: 4px; width: 96px; }
.im-report-previews img, .report-images img { width: 96px; height: 96px; object-fit: contain; cursor: zoom-in; }
.im-my-reports { display: grid; gap: 8px; margin-top: 16px; }
.im-my-reports h4 { margin: 0; }
.im-my-report { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line); }
.im-my-report p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.im-my-report button { justify-self: start; }
#modalFiles { display: grid; gap: 8px; margin-top: 8px; }
#modalFiles[hidden] { display: none; }
#modalFileError:empty { display: none; }
.report-note { flex-basis: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
.report-images { flex-basis: 100%; }
.im-contact-shortcuts { display: flex; gap: 8px; padding: 8px 12px 12px; border-bottom: 1px solid var(--line); }
:is(#imSheetBody, #imPageBody) .im-contact-shortcuts .im-qr-shortcut { margin: 0; }
.im-contact-shortcuts button { flex: 1; }
.im-start-contact { min-height: 64px; border-bottom: 1px solid var(--line); }
.im-start-contact:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
:is(#imSheetBody, #imPageBody) .im-contact-action { color: #07883e; border-color: #07a34b33; background: #07c16012; }
:is(#imSheetBody, #imPageBody) .im-contact-action:disabled { color: var(--text-faint); background: transparent; border-color: transparent; }
.im-contact-list:empty { min-height: 60px; }
:is(#imSheetBody, #imPageBody) .row .primary { min-height: 40px; padding: 9px 16px; border: 0; border-radius: 8px; background: #07a94f; color: #fff; font: inherit; cursor: pointer; }
:is(#imSheetBody, #imPageBody) .row .primary:disabled { opacity: .45; cursor: default; }
.im-contact-entry { width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; font: inherit; }
.im-contact-entry:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* iPad/手机只滚动图表本身；图例和放大按钮留在当前视口。 */
.exam-chart-card,.exam-chart{min-width:0;max-width:100%}
.exam-chart-scroll{width:100%;max-width:100%;min-width:0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain;touch-action:pan-x pan-y;border-radius:4px}
.exam-chart-scroll svg{display:block;width:100%;height:auto;max-width:none}
.exam-chart-scroll:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.exam-scroll-hint{font-size:12px;margin:6px 0}

.im-bridge-paused[data-state="stuck"] { color: #b3261e; background: color-mix(in srgb, #b3261e 10%, var(--card)); }
.im-bridge-paused { padding: 8px 14px; border-bottom: 1px solid var(--line); color: var(--text-soft); background: var(--card); font-size: 13px; text-align: center; }
.diag-row.unknown .diag-icon { color: var(--text-faint); }
.diag-row { flex-wrap: wrap; overflow-wrap: anywhere; }
.diag-action { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.diag-time { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* 通知状态紧跟开关，手机端操作可换行。 */
.im-push { padding: 8px 12px; border-block: 1px solid var(--line); }
.im-push .im-user { padding-inline: 0; }
.im-push-status { color: var(--text-soft); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.im-push-actions { flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* 聊天导航与独立页面；导航始终保留在左侧。 */
.im-nav { width: 84px; flex: none; display: flex; flex-direction: column; gap: 6px; padding: max(12px, env(safe-area-inset-top)) 8px max(12px, env(safe-area-inset-bottom)); border-right: 1px solid var(--line); background: var(--sidebar); }
.im-nav-brand { text-align: center; font-size: 12px; font-weight: 600; padding: 8px 0 16px; }
.im-nav button { position: relative; min-height: 44px; padding: 8px 4px; border: 0; border-radius: 6px; background: transparent; color: var(--text-soft); font: inherit; font-size: 14px; cursor: pointer; }
.im-nav button:hover, .im-nav button.active { background: var(--hover); color: var(--text); }
.im-nav button.active { font-weight: 600; box-shadow: inset 3px 0 var(--accent); }
.im-nav button:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.im-nav .im-nav-back { margin-top: auto; font-size: 12px; }
.im-nav .im-badge { top: 0; right: 0; }
.im-wrap[data-section="contacts"] > .im-side, .im-wrap[data-section="contacts"] > .im-main,
.im-wrap[data-section="settings"] > .im-side, .im-wrap[data-section="settings"] > .im-main { display: none; }
.im-page { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.im-page-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px 24px; }
.im-page-body > * { max-width: 680px; }
.im-page-body > .msg { margin: 12px; }
.im-page-body .im-user { width: 100%; }
.im-page-body .im-push { margin: 12px 0; }
@media (max-width: 720px) {
    .im-nav { width: 72px; padding-inline: 4px; }
    .im-side { flex: 1; width: auto; }
    .im-page-body { padding-inline: 4px; }
}

/* 首屏占位只表示正在读取，不借用缓存里的旧权限或占用状态。 */
.picker-loading { grid-column: 1 / -1; }
.picker-skeleton { min-height: 148px; border: 1px solid var(--line); border-radius: 12px; background: var(--sidebar); }

.ai-current { font-size: 12px; font-weight: 600; }
.ai-current.off { color: var(--text); }
.ai-current.up { color: #16a34a; }
.ai-current.warn { color: #a16207; }
.ai-current.down { color: var(--danger); }
.ai-current.unknown { color: var(--text-faint); }
.status-cell.unknown { background: #9ca3af; }

/* 注册资格题：题目里的八个空格，支持手机逐格输入和整段粘贴。 */
#signupQualification h2 { font-size: 20px; margin: 0 0 22px; text-align: center; }
.signup-riddle { font-size: 18px; line-height: 3.4; text-align: center; }
.signup-slots { display: inline-flex; gap: 14px; width: min(236px, 100%); vertical-align: middle; }
.signup-slot-group { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; flex: 1; min-width: 0; }
.pane .signup-slots input { min-width: 0; width: 100%; height: 42px; padding: 0; border-radius: 5px; text-align: center; font-size: 20px; font-family: ui-monospace, monospace; }
.pane .signup-slots input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--line); }
.signup-letter-hint { text-align: center; color: var(--text-soft); font-size: 13px; margin-top: 8px; }

.exam-event-edit-total{align-self:flex-start;padding:7px 10px;min-height:36px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--text);cursor:pointer}

/* 比较沿用同一组科目行，前场成绩标记与变化不另复制一份列表。 */
.exam-event-track{position:relative}.exam-event-track>i.exam-compare-marker{position:absolute;top:0;bottom:0;width:2px;height:100%;background:var(--text);transform:translateX(-1px);border-radius:0}
.exam-event-previous,.exam-rate-change{display:block;font-size:11px;line-height:1.4;font-weight:400;color:var(--text-soft);margin-top:4px;overflow-wrap:anywhere}
.exam-event-row:has(.exam-event-previous){grid-template-columns:64px minmax(30px,1fr) 125px 95px}
.exam-compare-summary{margin:8px 0 12px}.exam-compare-toolbar{margin-top:8px}
.mistake-rich{min-width:0;overflow-x:auto;overflow-wrap:anywhere}.mistake-rich p{margin:0 0 6px}.mistake-rich ul,.mistake-rich ol{padding-left:22px}.mistake-rich .katex-display{overflow-x:auto;overflow-y:hidden;padding:5px 0}
.mistake-rich svg.answer-svg{max-width:100%;max-height:none}.mistake-edit-preview{border:1px solid var(--line);border-radius:4px;padding:8px;margin-top:4px;max-height:260px;overflow:auto}
.mistake-row{min-width:0}.mistake-photo-button{display:block;width:100%;background:var(--bg);border:1px solid var(--line);border-radius:6px;padding:4px;margin-top:10px;cursor:zoom-in}.mistake-photo-button .mistake-original{margin:0;max-height:none}
.mistake-image-viewer{position:fixed;inset:0;z-index:540;background:var(--bg);color:var(--text);display:flex;flex-direction:column;padding:14px max(14px,env(safe-area-inset-left))}
.mistake-image-tools{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding-bottom:12px}.mistake-image-tools label{display:flex;align-items:center;gap:10px}.mistake-image-tools button,.mistake-diagram-zoom{min-height:40px;padding:8px 12px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--text);cursor:pointer}
.mistake-image-stage{flex:1;min-height:0;overflow:auto;touch-action:pan-x pan-y;-webkit-overflow-scrolling:touch}.mistake-image-canvas{width:100%;min-width:100%}.mistake-zoom-media{display:block;width:100%;max-width:none!important;height:auto;max-height:none!important}
@media(max-width:700px){.exam-event-row:has(.exam-event-previous){grid-template-columns:52px minmax(24px,1fr) 82px 70px;gap:5px}.exam-event-previous,.exam-rate-change{font-size:10px}.mistake-row{grid-template-columns:45px minmax(0,1fr)}.mistake-image-tools input{max-width:160px}}

.mistake-rich svg.answer-svg,.mistake-image-canvas>svg{background:#fff;color:#111;border:1px solid var(--line);border-radius:4px}
/* 下棋帮助：原地弹出，练习和实际房间完全分离。 */
.duel-help-dialog { width: min(680px, calc(100% - 24px)); max-height: 92dvh; margin: auto; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--text); overflow-y: auto; overscroll-behavior: contain; }
.duel-help-dialog::backdrop { background: rgba(0,0,0,.5); }
.duel-help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.duel-help-head h2 { font-size: 20px; }
.duel-help-dialog button { min-height: 44px; }
.duel-help-games { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.duel-help-games button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.duel-help-games button[aria-pressed="true"] { border-color: #2563eb; background: rgba(37,99,235,.12); }
.duel-help-dialog p { line-height: 1.6; margin: 8px 0; }
.duel-help-example { margin: 8px 0; }
.duel-help-example img { display: block; width: 100%; max-width: 440px; height: auto; margin: auto; border: 1px solid var(--line); border-radius: 10px; }
.duel-help-example figcaption { margin: 8px 0; line-height: 1.6; font-size: 14px; }
.duel-help-coach { min-height: 120px; padding: 10px 12px; margin: 10px 0; border: 2px solid #2563eb; border-radius: 10px; }
#duelPracticeMessage { min-height: 3.2em; }
.duel-coach-input { outline: 3px solid #2563eb; outline-offset: 3px; border-radius: 10px; }
.duel-coach-ring { animation: duelCoachPulse 1.5s ease-in-out infinite; }
@keyframes duelCoachPulse { 50% { stroke-opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .duel-coach-ring { animation: none; } }
@media (max-width: 480px) { .duel-help-dialog { padding: 12px; } .duel-help-games button { padding: 6px 9px; font-size: 14px; } }

.im-group-member { flex-wrap: wrap; }
.im-group-member .im-member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.im-group-member button { flex: none; }

.wechat-sched-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.wechat-sched-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.wechat-sched-row .wechat-day { min-width: 30px; padding: 4px 6px; }
.wechat-sched-row .wechat-day.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.wechat-sched-row input[type=time] { width: auto; padding: 4px 6px; }

/* Netlify 给免费站点自动插的「Powered by Netlify」角标（/.netlify/scripts/hud），挡住聊天输入框右下角 */
#nl-badge-frame { display: none !important; }

.bug-btn { padding: 2px 8px; font-size: 15px; line-height: 1.4; flex: 0 0 auto; }

/* 聊天顶栏：对方在线状态；设置页登录设备 */
.im-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.im-titles strong { flex: none; }
.im-titles small { font-size: 11px; color: var(--text-faint); line-height: 1.2; }
.im-titles small.on { color: #2ba245; }
.sess-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.sess-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.sess-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sess-info span { font-size: 12px; color: var(--text-soft); overflow-wrap: anywhere; }
.sess-row .tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--hover); color: var(--text-soft); }
.sess-row button { font-size: 12px; padding: 5px 9px; flex: none; }

/* 后台：服务权限表格（表格自己横向/纵向滚，首行首列钉住） */
.perm-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.perm-table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.perm-table th, .perm-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--bg); text-align: center; white-space: nowrap; }
.perm-table thead th { position: sticky; top: 0; z-index: 2; }
.perm-table tbody th { position: sticky; left: 0; z-index: 1; text-align: left; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.perm-table thead th:first-child { left: 0; z-index: 3; }
.perm-table tbody tr:first-child th, .perm-table tbody tr:first-child td { background: var(--hover); }
.perm-table .tag { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--hover); color: var(--text-soft); }
.perm-col { border: none; background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.perm-col:hover { background: var(--hover); }
.perm-table input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* GitHub 类板块：文件搜索和排序 */
.gh-tools { display: flex; gap: 8px; margin: 6px 0 8px; }
.gh-tools input[type=search] { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--composer-line); border-radius: 8px; background: var(--composer); color: var(--text); font: inherit; font-size: 14px; }
.gh-tools select { flex: none; padding: 6px 8px; border: 1px solid var(--composer-line); border-radius: 8px; background: var(--composer); color: var(--text); font: inherit; font-size: 14px; }

/* 外链风险提示（聊天板块）：弹窗里的「不再询问」勾选 */
#modalCheckRow { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 13px; }
#modalCheckRow[hidden] { display: none; }
#modalText { white-space: pre-line; word-break: break-all; }

/* 使用条款（总控）：注册框里的同意说明 */
.terms-note { font-size: 12px; color: var(--text-faint); margin: 8px 0 0; }
.terms-note a { color: inherit; text-decoration: underline; }

/* 隐藏入口 /mubapei 的播放器 */
.mbp { max-width: 420px; text-align: center; padding: 24px 16px; }
.mbp-cover { width: 160px; height: 160px; margin: 8px auto 16px; border-radius: 24px; display: grid; place-items: center;
    font-size: 72px; background: linear-gradient(135deg, #5b6cff22, #ff7a5922); }
.mbp-title { font-size: 22px; margin: 0; }
.mbp-sub { color: var(--muted, #888); margin: 4px 0 20px; font-size: 14px; }
.mbp-bar { position: relative; height: 24px; }
.mbp-bar::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 2px; background: #8883; }
.mbp-buf { position: absolute; left: 0; top: 10px; height: 4px; width: 0; border-radius: 2px; background: #8887; transition: width .3s; }
.mbp-bar input { position: absolute; inset: 0; width: 100%; margin: 0; background: transparent; }
.mbp-time { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted, #888); font-variant-numeric: tabular-nums; }
.mbp-ctrl { display: flex; justify-content: center; align-items: center; gap: 20px; margin: 16px 0 8px; }
.mbp-play { width: 64px; height: 64px; border-radius: 50%; font-size: 24px; padding: 0; }

.privacy-dialog ul { padding-left: 1.2em; margin: 8px 0; line-height: 1.6; }
.privacy-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
