/* 主界面：侧栏、对话、依据抽屉、查法条。登录页与管理后台见 legacy.css。 */
:root {
    --accent: #c4623f;
    --accent-soft: #fbeee8;
    --ok: #17633a;
    --ok-bg: #e9f7ef;
    --warn: #9a5b00;
    --warn-bg: #fff4df;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --side-w: 264px;
    --drawer-w: 420px;
    --read-w: 760px;
}

body { overflow-x: hidden; }
[hidden] { display: none !important; }

.app-shell {
    display: none;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
}
body.is-authenticated .app-shell { display: flex; }

/* ---------- 侧栏 ---------- */
.sidebar {
    width: var(--side-w);
    flex: 0 0 var(--side-w);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 12px 12px;
    background: var(--surface-soft);
    border-right: 1px solid var(--line);
    min-height: 0;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px 6px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 15px; }
.brand-logo { width: 30px; height: 30px; border-radius: 7px; object-fit: contain; }
.new-chat {
    display: flex; align-items: center; gap: 8px; width: 100%;
    height: 40px; padding: 0 12px; border-radius: 10px;
    background: var(--primary); color: #fff; cursor: pointer; font-weight: 600;
}
.new-chat:hover { background: var(--primary-hover); }
.side-nav { display: flex; gap: 4px; padding: 3px; background: rgba(0,0,0,.05); border-radius: 10px; }
.side-nav button { flex: 1; height: 32px; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 14px; }
.side-nav button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.side-history { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.side-group { padding: 12px 8px 4px; font-size: 12px; color: var(--faint); }
.side-empty { padding: 16px 8px; font-size: 13px; color: var(--faint); }
.history-item {
    display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px;
    color: var(--text); font-size: 14px; line-height: 1.4; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item:hover { background: rgba(0,0,0,.05); }
.history-item.active { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.side-footer { position: relative; border-top: 1px solid var(--line); padding-top: 10px; }
.user-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 8px; border-radius: 10px; cursor: pointer; color: var(--text); text-align: left; }
.user-btn:hover { background: rgba(0,0,0,.05); }
.avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.badge { font-size: 11px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 5px; }
.user-menu { position: absolute; left: 0; right: 0; bottom: calc(100% - 2px); padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 20; }
.user-menu button { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); }
.user-menu button:hover { background: var(--surface-soft); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar { display: none; align-items: center; gap: 8px; height: 48px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--bg); }
.topbar-title { font-weight: 700; font-size: 15px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 18px; }
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--text); }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }

.welcome { max-width: var(--read-w); margin: 0 auto; padding: 18vh 20px 24px; text-align: center; }
.welcome h1 { font-size: 28px; font-weight: 700; letter-spacing: 0; margin-bottom: 26px; font-family: var(--font-serif); }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.example { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.5; cursor: pointer; }
.example:hover { border-color: var(--accent); background: var(--accent-soft); }

.thread { max-width: var(--read-w); margin: 0 auto; padding: 24px 20px 8px; }
.turn { margin-bottom: 26px; }
.turn-user { display: flex; justify-content: flex-end; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--surface-soft); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }

.status-line { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; padding: 4px 0; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.thinking { margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.thinking summary { cursor: pointer; user-select: none; }
.thinking-body { margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--line-strong); white-space: pre-wrap; max-height: 260px; overflow-y: auto; }

/* ---------- 回答正文 ---------- */
.md { word-break: break-word; font-size: 15.5px; line-height: 1.8; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 .85em; white-space: pre-line; }
.md h3, .md h4, .md h5, .md h6 { margin: 1.2em 0 .5em; font-size: 16px; line-height: 1.45; }
.md h3 { font-size: 17px; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.6em; }
.md li { margin: .2em 0; }
.md blockquote { margin: 0 0 .85em; padding: 2px 14px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.md pre { margin: 0 0 .85em; padding: 12px 14px; overflow-x: auto; background: var(--surface-soft); border-radius: 8px; font: 13px/1.6 var(--font-mono); }
.md code { padding: 1px 5px; background: var(--surface-soft); border-radius: 4px; font: .9em var(--font-mono); }
.md pre code { padding: 0; background: none; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md a { color: var(--accent); }
.md-table { overflow-x: auto; margin: 0 0 .85em; }
.md table { border-collapse: collapse; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-soft); }
.md-unverified { color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 0 4px; font-size: .88em; }

.cite {
    display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px;
    border-radius: 9px; background: var(--accent-soft); color: var(--accent); font: 600 11px/1 var(--font-sans);
    vertical-align: super; cursor: pointer; border: 1px solid transparent;
}
button.cite:hover, .cite.on { background: var(--accent); color: #fff; }
.cite-bad { background: var(--bad-bg); color: var(--bad); cursor: help; }

.answer-tail { margin-top: 10px; }
.actions { display: flex; gap: 4px; margin-top: 8px; }
.act { height: 28px; padding: 0 10px; border-radius: 7px; color: var(--muted); font-size: 13px; cursor: pointer; }
.act:hover { background: var(--surface-soft); color: var(--text); }
.note { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.error-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 14px; }
.error-line .act { color: var(--bad); border: 1px solid currentColor; }

/* ---------- 引用核对 ---------- */
.check { margin-top: 12px; border-radius: 10px; border: 1px solid; font-size: 13.5px; overflow: hidden; }
.check-ok { border-color: #bfe3cd; background: var(--ok-bg); color: var(--ok); }
.check-warn { border-color: #f1d49a; background: var(--warn-bg); color: var(--warn); }
.check-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; cursor: pointer; color: inherit; text-align: left; font-weight: 600; }
.check-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.check-sub { font-weight: 400; opacity: .8; }
.check-caret { margin-left: auto; transition: transform .15s; }
.check-head[aria-expanded="true"] .check-caret { transform: rotate(90deg); }
.check-list { list-style: none; margin: 0; padding: 2px 12px 10px; color: var(--text); }
.check-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 5px 0; border-top: 1px dashed rgba(0,0,0,.1); }
.check-list li.is-link { cursor: pointer; }
.check-list li.is-link:hover .check-law { text-decoration: underline; }
.check-tag { font-size: 12px; font-weight: 700; padding: 0 6px; border-radius: 5px; }
.is-ok .check-tag { background: var(--ok-bg); color: var(--ok); }
.is-bad .check-tag { background: var(--bad-bg); color: var(--bad); }
.check-law { font-weight: 600; }
.check-note { color: var(--muted); }

/* ---------- 输入框 ---------- */
.composer-wrap { padding: 8px 20px 12px; }
.composer { max-width: var(--read-w); margin: 0 auto; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface); box-shadow: 0 2px 12px rgba(31,31,29,.05); padding: 10px 12px 8px; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,98,63,.15); }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); line-height: 1.6; max-height: 200px; padding: 2px 4px; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.composer-hint { margin-left: auto; font-size: 12px; color: var(--faint); }
.composer-hint.over { color: var(--bad); font-weight: 600; }
.send-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; }
.composer-hint:empty + .send-btn { margin-left: auto; }
.send-btn:disabled { background: var(--line-strong); cursor: not-allowed; }
.send-btn .i-stop { display: none; }
.send-btn.is-stop .i-stop { display: block; }
.send-btn.is-stop .i-send { display: none; }
.disclaimer { max-width: var(--read-w); margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- 依据抽屉 ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 100vw; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0,0,0,.08); transform: translateX(105%); transition: transform .2s ease; z-index: 40; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer > header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.drawer h2 { font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }
@media (min-width: 1280px) {
    body.drawer-open .main { margin-right: var(--drawer-w); }
    .drawer { box-shadow: none; }
}
.source-card { padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.source-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,98,63,.15); }
.source-card header { display: flex; gap: 10px; align-items: flex-start; }
.source-no { flex: none; width: 22px; height: 22px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.source-name { font-weight: 700; line-height: 1.4; }
.source-loc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.source-loc .kind { margin-right: 8px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 11px; }
.source-heading { margin-top: 8px; font-size: 13px; color: var(--muted); }
.source-flag { margin-top: 8px; padding: 4px 8px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.source-text { margin-top: 8px; white-space: pre-wrap; font-family: var(--font-serif); font-size: 15px; line-height: 1.8; }
.source-card footer { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--faint); }
.source-card footer a { color: var(--accent); }
.empty { padding: 24px 8px; color: var(--muted); text-align: center; }

.scrim { display: none; }

/* ---------- 查法条 ---------- */
.lookup { max-width: var(--read-w); margin: 0 auto; padding: 8vh 20px 40px; }
.lookup h1 { font-size: 24px; font-family: var(--font-serif); }
.lead { margin: 8px 0 18px; color: var(--muted); }
.lookup-form { display: flex; gap: 8px; }
.lookup-form input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); outline: 0; }
.lookup-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196,98,63,.15); }
.primary { height: 46px; padding: 0 22px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; }
.primary:hover { background: var(--primary-hover); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.lookup-section { margin-top: 22px; }
.lookup-section h2 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 400; color: var(--muted); background: var(--surface-soft); border-radius: 9px; padding: 0 7px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
    .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .scrim, body.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45; }
    body.drawer-open .scrim { z-index: 35; }
    .topbar { display: flex; }
    .welcome { padding-top: 8vh; }
    .welcome h1 { font-size: 23px; }
    .examples { grid-template-columns: 1fr; }
    .thread { padding: 16px 14px 4px; }
    .composer-wrap { padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); }
    .drawer { width: 100vw; }
    .bubble { max-width: 92%; }
}

@media (prefers-color-scheme: dark) {
    /* 暂不提供暗色：登录页与管理后台尚未适配，避免半套主题。 */
}
@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
    .drawer, .sidebar { transition: none; }
}

/* ---------- 登录页补充 / 修改密码弹窗 ---------- */
.auth-link { display: block; margin: 12px auto 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.auth-link:hover { color: var(--text); }
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(0,0,0,.4); padding: 16px; }
.modal-card { width: min(380px, 100%); background: var(--surface); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.modal-card h2 { font-size: 18px; margin-bottom: 14px; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.modal-card input { display: block; width: 100%; height: 40px; margin-top: 4px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; background: var(--surface); }
.modal-card input:focus { border-color: var(--accent); }
.modal-msg { min-height: 20px; font-size: 13px; color: var(--bad); margin-bottom: 8px; }
.modal-msg.ok { color: var(--ok); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .primary { height: 38px; padding: 0 18px; border-radius: 10px; }
.modal-actions .ghost { height: 38px; padding: 0 14px; border-radius: 10px; color: var(--muted); cursor: pointer; }

/* ---------- 等待阶段 / 深度思考开关 ---------- */
.wait { margin: 2px 0 10px; }
.wait .elapsed { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.step { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--faint); }
.step.done { color: var(--ok); background: var(--ok-bg); }
.step.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.wait-hint { margin-top: 8px; font-size: 13px; color: var(--muted); }
.status-line.checking { margin-top: 8px; font-size: 13px; }
.pill { height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 13px; cursor: pointer; }
.pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.issue { flex-basis: 100%; margin: 2px 0 4px; padding: 6px 10px; border-left: 3px solid var(--bad); background: var(--bad-bg); border-radius: 0 6px 6px 0; font-size: 13px; line-height: 1.6; }
.composer-hint { margin-left: auto; }
.check-foot { padding: 6px 12px 8px; font-size: 12px; color: var(--muted); border-top: 1px dashed rgba(0,0,0,.1); }
.source-tier { display: inline-block; margin-top: 8px; padding: 1px 8px; border-radius: 5px; font-size: 12px; }
.tier-official { background: var(--ok-bg); color: var(--ok); }
.tier-book { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--line); }
.plan-body { margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--line-strong); }
.plan-body ul { margin: 4px 0 0 1.2em; }
.book-notes { margin: 12px -4px 0; padding: 10px; background: var(--accent-soft); border: 1px solid #f0cdbf; border-radius: 10px; }
.book-notes h3 { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--accent); margin-bottom: 8px; }
.book-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.book-note { margin-bottom: 8px; padding: 8px 10px; background: var(--surface); border-radius: 8px; }
.book-note:last-child { margin-bottom: 0; }
.book-note-head { font-size: 12.5px; color: var(--muted); }
.book-note-head .kind { margin-right: 6px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 11px; }
.book-note-text { margin-top: 4px; font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.md-table { -webkit-overflow-scrolling: touch; }
.md table { min-width: 100%; }
.md th, .md td { min-width: 5.5em; }
.other-version { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.other-version h3 { font-size: 13px; color: var(--warn); margin-bottom: 6px; }
.is-soft .check-tag { background: var(--warn-bg); color: var(--warn); }
.same-as { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.same-as h3 { font-size: 13px; color: var(--accent); margin-bottom: 4px; }
.same-as .act { margin-top: 6px; border: 1px solid var(--line-strong); }
.same-as-panel { margin-top: 8px; padding: 8px 10px; background: var(--surface-soft); border-radius: 8px; }
.cite.cite-book { padding: 0 7px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap; }
button.cite.cite-book:hover, .cite.cite-book.on { background: #a8492a; }
.source-card.is-book { border-left: 4px solid var(--accent); }
.tier-book-editorial { background: var(--accent-soft); color: var(--accent); }
.tier-unknown { display: none; }
.case-summary { margin-top: 8px; padding: 8px 10px; background: var(--surface-soft); border-radius: 8px; font-size: 14px; }
.case-sec { margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; }
.case-sec summary { padding: 7px 12px; cursor: pointer; font-size: 14px; color: var(--muted); }
.case-sec .source-text { padding: 0 12px 10px; font-size: 14.5px; }
.case-sec.is-key { border-color: var(--accent); background: var(--accent-soft); }
.case-sec.is-key summary { color: var(--accent); font-weight: 700; }
.case-sec[open] summary { border-bottom: 1px dashed var(--line-strong); margin-bottom: 8px; }
.group-title { margin: 16px 2px 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.issue-soft { border-left-color: var(--warn); background: var(--warn-bg); }
.source-extras { margin-top: 8px; display: grid; gap: 4px; }
.extra { padding: 5px 9px; border-radius: 6px; background: var(--surface-soft); font-size: 13px; line-height: 1.6; }
.extra-why { background: var(--accent-soft); }
.extra-refs { background: var(--warn-bg); color: var(--warn); }
.extra-old { background: var(--warn-bg); color: var(--warn); }
.degraded-note { margin: 4px 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; }
.old-alert { padding: 8px 10px; border: 1px solid #e3b25a; border-left: 5px solid #d98a00; background: #fff1d6; color: #7a4a00; border-radius: 8px; font-size: 13.5px; line-height: 1.6; }
.old-alert b { display: block; margin-bottom: 2px; font-size: 13px; }
.old-alert-sub { display: block; margin-top: 2px; font-size: 12px; opacity: .85; }
.cite.cite-book { }
.case-ident { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.case-keywords { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.error-limit { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.note-replay { padding: 6px 10px; border-radius: 8px; background: var(--surface-soft); }
.quota:not(:empty)::after { content: " · "; }
.quota.low { color: var(--warn); font-weight: 600; }
.kind-unknown { border-color: var(--warn); color: var(--warn); }
.kind-excerpt { color: var(--muted); }
.source-chapter { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.composer textarea { min-height: 28px; }

.history-loading { padding: 40px 0; text-align: center; color: var(--muted, #8a8a85); font-size: 14px; }

/* 生成中的状态行：固定在输入框正上方，小号灰字一行 */
.gen-status { max-width: var(--read-w); margin: 0 auto 6px; padding: 0 6px; }
.gen-status .wait { margin: 0; }
.gen-status .status-line { font-size: 13px; padding: 0; }

/* ---------- 左侧历史栏可收起（桌面） ---------- */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.side-toggle { width: 30px; height: 30px; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.side-toggle:hover { background: rgba(0,0,0,.06); color: var(--text); }
@media (min-width: 861px) {
    .sidebar { transition: width .15s ease, flex-basis .15s ease; }
    body.side-collapsed .sidebar { width: 56px; flex-basis: 56px; padding: 14px 8px; align-items: center; }
    body.side-collapsed .side-top { flex-direction: column; gap: 10px; }
    body.side-collapsed .brand, body.side-collapsed .side-nav, body.side-collapsed .side-history,
    body.side-collapsed .side-footer, body.side-collapsed .nc-label { display: none; }
    body.side-collapsed .new-chat { width: 40px; padding: 0; justify-content: center; }
}
@media (max-width: 860px) { .side-toggle { display: none; } }

/* ---------- 会员额度提示 / 账户菜单 ---------- */
.quota-notice { max-width: var(--read-w); margin: 8px auto 0; padding: 8px 12px; border-radius: 10px; background: #FFF1D6; color: #7a4a00; font-size: 13px; line-height: 1.6; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.quota-redeem { padding: 2px 12px; border-radius: 999px; border: 1px solid #c98a1b; color: #7a4a00; background: #fff; cursor: pointer; font-size: 13px; }
.user-menu-tier:empty { display: none; }
.user-menu-tier { padding: 8px 10px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); }
.user-menu .user-menu-link { display: block; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.user-menu .user-menu-link:hover { background: rgba(0,0,0,.05); }
.quota-seg { white-space: nowrap; }
.quota-seg:first-child { white-space: normal; }

/* 额度行：剩余 ≤1 变黄色 */
.quota.low { color: #b7791f; font-weight: 600; }
.quota-redeem.is-main { background: #c98a1b; color: #fff; border-color: #c98a1b; }

/* ---------- 升级 / 续费页 ---------- */
.upg { align-items: start; overflow-y: auto; padding: 4vh 16px; }
.upg-card { width: min(860px, 100%); margin: 0 auto; background: var(--surface); border-radius: 18px; padding: 24px 26px 28px; box-shadow: var(--shadow); }
.upg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.upg-head h2 { font-size: 20px; }
.upg-x { width: 32px; height: 32px; border-radius: 8px; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.upg-x:hover { background: rgba(0,0,0,.06); }
.upg-status { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.upg-status:empty { display: none; }
.upg-tier { color: var(--text); font-weight: 700; }
.upg-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.upg-loading { color: var(--muted); font-size: 14px; padding: 12px 0; }
.upg-plan { border: 1px solid var(--line-strong); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.upg-plan.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(196,98,63,.18); }
.upg-plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.upg-plan-head h3 { font-size: 17px; }
.upg-cur { font-size: 12px; padding: 1px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; }
.upg-price { font-size: 24px; font-weight: 700; }
.upg-feat { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.upg-feat li::before { content: '✓ '; color: var(--ok); font-weight: 700; }
.upg-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.upg-buy, .upg-redeem { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.upg-buy h3, .upg-redeem h3 { font-size: 15px; margin-bottom: 8px; }
.upg-note { margin: 0 0 8px; font-size: 14px; line-height: 1.8; white-space: pre-wrap; }
.upg-contact { display: grid; gap: 4px; font-size: 14px; }
.upg-qr { margin-top: 6px; border-radius: 8px; border: 1px solid var(--line); object-fit: contain; background: #fff; }
.upg-redeem-row { display: flex; gap: 8px; }
.upg-redeem-row input { flex: 1; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; background: var(--surface); min-width: 0; }
.upg-redeem-row input:focus { border-color: var(--accent); }
.upg-redeem .primary { height: 40px; padding: 0 18px; border-radius: 10px; }
@media (max-width: 640px) { .upg { padding: 0; } .upg-card { border-radius: 0; min-height: 100%; padding: 18px 16px 28px; } .upg-plans { grid-template-columns: 1fr; } }
.upg-flow { margin: 0 0 8px; font-size: 13px; color: var(--muted); }

/* ---------- 合规文案：保密提醒 / 首次使用弹窗 / 协议链接 ---------- */
.confid { max-width: var(--read-w); margin: 6px auto 0; font-size: 12px; color: var(--muted); text-align: center; }
.confid .confid-short { display: none; }
@media (max-width: 640px) { .confid .confid-long { display: none; } .confid .confid-short { display: inline; } }
.auth-legal { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.auth-legal:empty { display: none; }
.auth-legal a, #legalLinks a { color: inherit; text-decoration: underline; }
.notice-card { width: min(460px, 100%); }
.notice-card ol { padding-left: 1.3em; margin: 8px 0 12px; line-height: 1.8; font-size: 14px; }
.notice-card p { font-size: 14px; line-height: 1.8; margin: 0; }
.notice-links { display: flex; gap: 14px; font-size: 13px; margin-bottom: 14px; }
.notice-links a { color: var(--muted); }
.upg-steps { margin: 0 0 10px; padding-left: 1.4em; font-size: 14px; line-height: 1.9; }
.upg-small { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- 删除对话 ---------- */
.history-row { position: relative; }
.history-row .history-item { padding-right: 32px; }
.history-del { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 6px; color: var(--faint); font-size: 16px; line-height: 1; cursor: pointer; opacity: 0; }
.history-row:hover .history-del, .history-row:focus-within .history-del, .history-del:focus { opacity: 1; }
.history-del:hover { background: rgba(0,0,0,.08); color: var(--bad); }
@media (hover: none) { .history-del { opacity: .7; } }
.del-title { margin: 0 0 6px; font-size: 14px; font-weight: 600; word-break: break-all; }
.del-note { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.primary.danger { background: var(--bad); }
