/* Shared writing tools: generous readers, a quiet settings rail, one visual language. */
.ai-tool-view .ai-tool-main {
    box-sizing: border-box; width: 100%; max-width: 1920px; margin: 0 auto;
    height: calc(100dvh - var(--app-topbar-h, 64px)); min-height: 0;
    padding: 28px clamp(22px, 2.4vw, 42px) 24px;
    display: flex; flex-direction: column; gap: 23px; background: transparent;
}
.ai-tool-view [hidden] { display: none !important; }
.ai-tool-page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex: 0 0 auto; }
.ai-tool-eyebrow { display: block; font-size: 10px; line-height: 1.6; color: var(--muted); margin-bottom: 8px; }
.ai-tool-page-head h2 { margin: 0 0 8px; color: var(--text); font: 600 clamp(26px, 2.3vw, 34px)/1.35 'Songti SC', SimSun, serif; letter-spacing: .025em; }
.ai-tool-page-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.ai-tool-view .ai-settings-jump { display: none; }
.ai-tool-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 260px; align-items: stretch; gap: 20px; flex: 1 1 auto; min-height: 0; min-width: 0; }
.ai-tool-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 1px 3px; scrollbar-width: thin; scroll-margin-top: calc(var(--app-topbar-h, 64px) + 16px); }
.ai-tool-settings { min-width: 0; flex: 0 0 auto; padding: 20px; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.ai-tool-settings h3 { margin: 0 0 23px; font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--text); }
.ai-setting-field { display: flex; flex-direction: column; gap: 9px; min-width: 0; margin-bottom: 23px; font-size: 12px; line-height: 1.7; color: var(--text-sub); }
.ai-setting-field > label { color: var(--text-sub); }
.ai-setting-field small { color: var(--muted); margin-left: 5px; font-size: 11px; }
.ai-tool-settings :is(select, textarea) { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); color: var(--text); font-family: inherit; font-size: 12px; line-height: 1.7; }
.ai-tool-settings select { height: 41px; font-size: 12px; cursor: pointer; }
.ai-tool-settings textarea { font-size: 12px; line-height: 1.8; resize: vertical; min-height: 95px; max-height: 230px; }
.ai-tool-settings textarea::placeholder { color: var(--muted); opacity: 1; }
.ai-tool-settings .polish-req-input { min-height: 132px; }
.ai-tool-settings :is(select, textarea):focus { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: none; }
.ai-role-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-tool-settings .ai-role-actions button { min-height: 34px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 5px; background: var(--card); color: var(--brand); font-size: 11px; }
.ai-tool-settings .ai-text-danger { color: #a04c40; }
.ai-depth-field { min-width: 0; border: 0; padding: 0; margin: 0 0 23px; }
.ai-depth-field legend { margin-bottom: 10px; font-size: 12px; color: var(--text-sub); }
.ai-native-control { display: none; }
.ai-depth-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.ai-depth-options button { min-height: 39px; padding: 7px 5px; background: var(--card-2); color: var(--text-sub); border: 1px solid var(--border); border-radius: 5px; font-size: 12px; cursor: pointer; }
.ai-depth-options button[aria-pressed="true"] { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); font-weight: 600; }
.ai-tool-view .ai-tool-run { margin-top: auto; }
.ai-tool-settings .ai-tool-run { padding-top: 3px; }
.ai-tool-view .polish-start-btn { width: 100%; min-height: 43px; padding: 11px 16px; color: var(--on-brand); background: var(--brand) !important; border: 1px solid var(--brand); border-radius: 6px; box-shadow: none; transform: none; font-size: 13px; }
.ai-tool-view .polish-start-btn:hover { background: var(--brand-dark) !important; }
.ai-tool-view .polish-start-btn:disabled { opacity: .55; cursor: not-allowed; }
.ai-tool-note { margin: 12px 0 0; font-size: 11px; line-height: 1.8; color: var(--muted); }
.ai-tool-run > .ai-tool-note { text-align: center; }
.ai-tool-view :is(button, input, textarea, select, summary):focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.ai-tool-view :is(button, select):disabled { cursor: not-allowed; }

/* Conversation: the transcript owns the space, the composer stays in view. */
.ai-tool-view .chat-shell { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ai-conversation-head { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; min-height: 52px; padding: 10px 20px; gap: 12px; border-bottom: 1px solid var(--border); box-sizing: border-box; }
.ai-conversation-head > div { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ai-conversation-head strong { font-size: 13px; color: var(--text); white-space: nowrap; }
.ai-current-model { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-tool-view .chat-messages { padding: 28px clamp(18px, 2vw, 34px); gap: 28px; background: var(--card); scrollbar-width: thin; }
.ai-tool-view .chat-empty { max-width: 480px; padding: 25px 0; }
.ai-tool-view .chat-empty-icon { width: 48px; height: 48px; border-radius: 12px; }
.ai-tool-view .chat-empty p { font-size: 14px; line-height: 1.8; color: var(--text-sub); }
.ai-tool-view .chat-empty .chat-empty-hint { font-size: 12px; color: var(--muted); }
.ai-tool-view .chat-msg { max-width: 94%; gap: 12px; min-width: 0; }
.ai-tool-view .chat-msg-assistant { width: 100%; max-width: 100%; }
.ai-tool-view .chat-msg-avatar { width: 32px; height: 32px; flex: 0 0 32px; font-size: 12px; }
.ai-tool-view .chat-msg-assistant .chat-msg-avatar { background: var(--brand); color: var(--on-brand); }
.ai-tool-view .chat-msg-user .chat-msg-avatar { background: var(--brand-soft); color: var(--brand); }
.ai-tool-view .chat-msg-content { color: var(--text); font-size: 14px; line-height: 1.95; border: 0; box-shadow: none; }
.ai-tool-view .chat-msg-assistant .chat-msg-content { padding: 0 0 8px; background: transparent; max-width: 54em; }
.ai-tool-view .chat-msg-user .chat-msg-content { padding: 12px 16px; border-radius: 8px; background: var(--brand-soft); color: var(--text); }
.ai-tool-view .chat-msg-meta { font-size: 10px; color: var(--muted); line-height: 1.8; white-space: normal; }
.ai-tool-view .chat-msg-copy-btn { color: var(--text-sub); border-color: var(--border); }
.ai-tool-view .chat-msg-actions { opacity: 1; }
.ai-tool-view .chat-msg-content pre { max-width: 100%; background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.ai-tool-view .chat-msg-content code { background: var(--card-2); color: var(--text); }
.ai-tool-view .chat-composer { flex: 0 0 auto; padding: 12px 18px 14px; background: var(--card); border-top: 0; }
.ai-tool-view .chat-input-row { display: flex; flex-direction: column; align-items: stretch; padding: 13px 14px 10px; border: 1px solid var(--border); background: var(--input-bg); border-radius: 8px; gap: 8px; }
.ai-tool-view .chat-input-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.ai-tool-view .chat-input { width: 100%; min-height: 65px; max-height: 160px; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: var(--text); font-size: 14px; line-height: 1.8; resize: none; outline: none; }
.ai-tool-view .chat-input:focus-visible { outline: none; }
.ai-chat-input-tools { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ai-tool-view .chat-attach-btn { color: var(--text-sub); background: transparent; border-radius: 5px; }
.ai-tool-view .chat-send-btn { width: auto; height: 37px; min-width: 78px; gap: 8px; margin-left: auto; padding: 8px 13px; background: var(--brand); color: var(--on-brand); border-radius: 5px; font-size: 12px; }
.ai-tool-view .chat-send-btn:hover { background: var(--brand-dark); }
.ai-tool-view .chat-stop-btn { background: var(--card-2); color: var(--text); border: 1px solid var(--border); border-radius: 5px; }
.ai-tool-view .chat-composer-bar { flex-wrap: wrap; gap: 5px 12px; padding: 0 2px; margin-top: 9px; }
.ai-tool-view .chat-composer-hint, .ai-tool-view .chat-tokens-info { color: var(--muted); white-space: normal; font-size: 10px; }
.ai-tool-view .chat-att-chip { max-width: 100%; color: var(--text-sub); background: var(--card-2); border-color: var(--border); }
.ai-prompt-section { border-top: 1px solid var(--border); padding-top: 23px; margin-top: 4px; }
.ai-prompt-section h3 { margin-bottom: 14px; font-size: 14px; }
.ai-prompt-list { display: grid; gap: 9px; }
.ai-prompt-list button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 10px 12px; color: var(--text-sub); background: var(--card); border: 1px solid var(--border); border-radius: 5px; font-size: 12px; text-align: left; cursor: pointer; }
.ai-prompt-list button:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.ai-prompt-list span { color: var(--muted); }

/* Editing: matched readers and headers, with a separate progress/control bar. */
.ai-tool-view .polish-shell { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; background: transparent; overflow: hidden; }
.ai-tool-view .polish-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); gap: 16px; padding: 0; min-width: 0; min-height: 0; background: transparent; }
.ai-tool-view .polish-pane { min-width: 0; border-radius: 8px; box-shadow: none; background: var(--card); }
.ai-tool-view .polish-output-pane { scroll-margin-top: calc(var(--app-topbar-h, 64px) + 16px); }
.ai-tool-view .polish-pane-head { flex-wrap: wrap; min-height: 54px; box-sizing: border-box; padding: 12px 16px; gap: 8px 10px; background: var(--card); }
.ai-tool-view .polish-pane-title { font-size: 14px; }
.ai-tool-view .polish-char-count { margin-left: 0; font-size: 10px; color: var(--muted); }
.ai-pane-tools, .ai-tool-view .polish-head-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.ai-tool-view .polish-mini-btn { color: var(--text-sub); font-size: 11px; border-radius: 5px; }
.ai-pane-tools .polish-mini-btn { border-color: transparent; padding: 4px 5px; }
.ai-tool-view .polish-font-size { border-radius: 5px; }
.ai-tool-view .polish-fs-btn { padding: 4px 7px; font-size: 10px; color: var(--text-sub); }
.ai-tool-view .polish-fs-btn.active { color: var(--brand); background: var(--brand-soft); }
.ai-tool-view .polish-input { width: 100%; height: 0; min-width: 0; padding: 21px 22px; font-family: inherit; font-size: 15px; line-height: 1.95; color: var(--text); background: var(--card); scrollbar-width: thin; }
.ai-tool-view .polish-output { padding: 21px 22px; font-size: 15px; line-height: 1.95; color: var(--text); background: var(--card); scrollbar-width: thin; }
.ai-tool-view .polish-output.fs-s { --reading-fs: 13px; }
.ai-tool-view .polish-output.fs-m { --reading-fs: 15px; }
.ai-tool-view .polish-output.fs-l { --reading-fs: 18px; }
.ai-tool-view :is(.polish-output-text, .deai-output-text) { width: 100%; max-width: 44em; color: var(--text); line-height: 1.95; }
.ai-tool-view .polish-empty { padding: 25px 6px; }
.ai-tool-view .polish-empty p { font-size: 13px; }
.ai-tool-view .polish-empty .polish-empty-hint { font-size: 11px; }
.ai-tool-view .polish-empty-icon { width: 42px; height: 42px; font-size: 20px; border-radius: 10px; }
.ai-tool-view .polish-composer { min-height: 42px; padding: 10px 14px; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
.ai-tool-view .polish-status-cluster { flex: 1 1 160px; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; gap: 5px 16px; flex-wrap: wrap; }
.ai-tool-view .polish-status { color: var(--text-sub); font-size: 11px; white-space: normal; line-height: 1.8; overflow-wrap: anywhere; }
.ai-tool-view .polish-cost { color: var(--muted); font-size: 10px; white-space: normal; line-height: 1.8; }
.ai-tool-view .polish-control-btn, .ai-tool-view .polish-stop-btn { min-height: 30px; padding: 5px 10px; font-size: 11px; border: 1px solid var(--border); background: var(--card-2); color: var(--text-sub); border-radius: 5px; }
.ai-tool-view .polish-control-btn:hover, .ai-tool-view .polish-stop-btn:hover { border-color: var(--brand); color: var(--brand); }

/* Detection stays in its own rail card and never consumes the result reader. */
.ai-rewrite-directions h4 { margin: 0 0 12px; font-size: 12px; font-weight: 500; color: var(--text-sub); }
.ai-rewrite-directions > div { display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px; margin-top: 8px; background: var(--card-2); border-radius: 5px; }
.ai-rewrite-directions > div > span { padding-top: 2px; color: var(--brand); font-size: 10px; }
.ai-rewrite-directions p { margin: 0; min-width: 0; }
.ai-rewrite-directions strong { display: block; color: var(--text-sub); font-size: 11px; font-weight: 500; line-height: 1.7; }
.ai-rewrite-directions small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.ai-detection-card h3 { margin-bottom: 18px; }
.ai-detection-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 0 12px; }
.ai-detection-values > div { min-width: 0; display: flex; flex-direction: column; gap: 11px; }
.ai-detection-values > div + div { padding-left: 14px; border-left: 1px solid var(--border); }
.ai-detection-values span { font-size: 11px; color: var(--muted); }
.ai-detection-values strong { font-size: 20px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.ai-tool-view .ai-detect-button { width: 100%; min-height: 36px; margin-top: 9px; padding: 8px 10px; border-color: var(--brand); color: var(--brand); background: transparent; font-size: 12px; }
.ai-tool-view .ai-detect-button:disabled { border-color: var(--border); color: var(--muted); opacity: .8; }

/* ============================================================
   检测对比（放在设置列里、「定向补改」下方）
   · 列宽只有 264px，改成竖排：标题 → 两组数值并排（分界线在列中轴）→ 按钮铺满
   ============================================================ */
#view-deai .ai-detection-col {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 0;
}
/* 与「定向补改」同卡不同区：一条分隔线，不再额外撑开内边距 */
#view-deai .deai-detect-block {
    margin-top: 18px;
    padding-top: 17px;
    border-top: 1px solid var(--border);
}
#view-deai .ai-detection-col h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
#view-deai .ai-detection-col .ai-detection-values {
    display: flex;
    width: 100%;
    gap: 0;
    padding: 0;
}
#view-deai .ai-detection-col .ai-detection-values > div {
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}
#view-deai .ai-detection-col .ai-detection-values > div:first-child {
    justify-content: center;
    padding: 8px 8px 10px 0;
}
#view-deai .ai-detection-col .ai-detection-values > div + div {
    justify-content: center;
    padding: 8px 0 10px 8px;
    border-left: 1px solid var(--border);
}
#view-deai .ai-detection-col .ai-detection-values span { font-size: 10.5px; }
#view-deai .ai-detection-col .ai-detection-values strong { font-size: 14px; }
#view-deai .ai-detection-col .ai-detect-button {
    width: 100%;
    min-height: 30px;
    margin: 0;
    padding: 5px 8px;
    font-size: 11px;
}
#view-deai .ai-detection-col .deai-score-panel {
    max-height: 170px;
    overflow-y: auto;
    padding: 0;
    border: 0;
    background: transparent;
    scrollbar-width: thin;
}
#view-deai .ai-detection-col .deai-score-panel > .ai-detection-values { margin: 0 auto; }

/* 定向补改开关：关掉后只隐藏设置本体，不影响正常改写 */
#view-deai .deai-refine-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
#view-deai .deai-refine-head h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
#view-deai .deai-switch {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
#view-deai .deai-switch input { appearance: none; box-sizing: border-box; flex: 0 0 28px; width: 28px; height: 16px; min-height: 0; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--card-2); cursor: pointer; position: relative; }
#view-deai .deai-switch input::before { content: ""; position: absolute; width: 10px; height: 10px; top: 2px; left: 2px; border-radius: 50%; background: var(--muted); }
#view-deai .deai-switch input:checked { background: var(--brand); border-color: var(--brand); }
#view-deai .deai-switch input:checked::before { left: 14px; background: var(--on-brand); }
#view-deai .deai-refine-body[hidden] { display: none !important; }

/* 页头进了 shell 之后，与下面两栏的间距由 shell 的 gap 接管 */
#view-deai .polish-shell { gap: 22px; }
/* 左右留白与其它工具页一致，保证标题左基线对齐 */
#view-deai .ai-tool-main { padding-top: 24px; }
/* 页头字号/字体与 AI 对话、智能润色保持同一套公共规则，不再单独缩小 */
#view-deai .polish-pane { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
#view-deai .polish-pane-head { min-height: 56px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
#view-deai .polish-pane-title { font-size: 13px; font-weight: 600; }
#view-deai .polish-input, #view-deai .polish-output { padding: 24px; line-height: 2; }
#view-deai .polish-input::placeholder { color: var(--muted); font-size: 13px; }
#view-deai .polish-mini-btn { min-height: 30px; border-radius: 6px; }
#view-deai .polish-mini-btn:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand); }
#view-deai .polish-mini-btn:disabled { cursor: not-allowed; color: var(--muted); }
#view-deai .polish-font-size { background: var(--card-2); border-color: transparent; padding: 2px; }
#view-deai .polish-fs-btn { min-width: 26px; border-radius: 4px; }
#view-deai .polish-empty { gap: 10px; }
#view-deai .polish-empty-icon { background: var(--brand-soft); color: var(--brand); width: 46px; height: 46px; border-radius: 14px; }
#view-deai .polish-empty p { margin: 0; color: var(--text-sub); }
#view-deai .polish-empty .polish-empty-hint { color: var(--muted); line-height: 1.9; }

/* ============================================================
   设置列（夹在原文与改写结果之间）
   · 去AI味页没有右侧栏了：处理策略 / 定向补改 / 开始改写都放在中间这一列；
   · 中间列定宽、两侧文字框等宽，所以检测条中轴线仍然落在中间列的正中。
   · 这一列禁止滚动：内容按 900 高窗口的高度压过一轮，矮窗口另有兜底。
   ============================================================ */
#view-deai .ai-tool-workspace { grid-template-columns: minmax(0, 1fr); }
#view-deai .polish-body { grid-template-columns: minmax(0, 1fr) 264px minmax(0, 1fr); }
#view-deai .deai-settings-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    /* 列本身不滚：设置卡占满剩余高度，「开始改写」恒定贴在列底、永远可见 */
    overflow: hidden;
}
/* 只有矮窗口（约 800 高及以下）设置卡内容放不下时，才让卡片内部滚一点点 */
#view-deai .deai-settings-col > .ai-tool-settings {
    /* 基础规则是 flex:0 0 auto（不收缩），这里允许收缩但不许拉伸：
       卡片按内容高度显示，底部多余空间留白，「开始改写」靠 margin-top:auto 贴底。 */
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}
#view-deai .deai-settings-col > .ai-tool-run { flex: 0 0 auto; }
#view-deai .deai-settings-col .ai-tool-run { margin-top: auto; }
#view-deai .ai-tool-settings { padding: 18px 16px; border-radius: 12px; }
#view-deai .ai-tool-settings h3 { margin-bottom: 16px; font-size: 13px; }
#view-deai .ai-setting-field { gap: 7px; margin-bottom: 14px; }
#view-deai .ai-tool-label { margin-bottom: 10px; font-size: 11px; color: var(--text-sub); }
#view-deai .ai-tool-settings select { height: 37px; padding: 7px 9px; background: var(--card-2); border-radius: 7px; }
#view-deai .deai-style-field { margin-top: 0; }
#view-deai .polish-start-btn { min-height: 44px; border-radius: 9px; font-weight: 600; letter-spacing: .04em; }
#view-deai #deaiRefineBtn { width: 100%; border: 1px solid var(--border); background: var(--card-2); padding: 7px 10px; }
#view-deai .deai-strategy-note { margin: -4px 0 12px; font-size: 11px; line-height: 1.6; }
#view-deai .ai-tool-note { margin-top: 9px; font-size: 10.5px; line-height: 1.65; }
#view-deai .deai-coverage-block { padding: 11px 0 0; border: 0; border-radius: 0; background: transparent; }
#view-deai .deai-coverage-label { font-size: 11px; }
#view-deai .deai-coverage-label span { padding: 2px 7px; background: var(--brand-soft); border-radius: 5px; }
#view-deai .deai-coverage-block input[type="range"] { display: block; margin: 12px 0 3px; }
#view-deai .deai-coverage-hint { margin-top: 5px; font-size: 10px; line-height: 1.5; }

/* 定向补改：并与处理策略同一张卡内，用细分隔线分区，两个下拉并排 */
#view-deai .deai-refine-block {
    display: flex;
    flex-direction: column;
    margin-top: 18px;
    padding-top: 17px;
    border-top: 1px solid var(--border);
}
#view-deai .deai-refine-block h4 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
#view-deai .deai-refine-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px 10px;
}
#view-deai .deai-refine-grid .ai-tool-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    min-width: 0;
}
#view-deai .deai-refine-grid select { width: 100%; min-width: 0; }
#view-deai #deaiRefineBtn { margin-top: 6px; }

/* 设置已经在页面中间，桌面端不再需要「调整设置 ↓」跳转 */
#view-deai .ai-settings-jump { display: none !important; }

/* 矮一些的窗口：两条尾部说明（策略/补改各一句）优先让位，保证「开始改写」不被裁掉 */
@media (max-height: 860px) {
    #view-deai .ai-tool-settings { padding: 13px; }
    #view-deai .ai-tool-settings h3 { margin-bottom: 10px; }
    #view-deai .ai-tool-run > .ai-tool-note { display: none; }
}

/* 内容压缩后仍需 ~584px；窗口再矮只能放开滚动，否则「开始改写」会被裁掉 */
@media (max-height: 720px) {
    #view-deai .deai-settings-col { overflow-y: auto; scrollbar-width: thin; }
}




.ai-tool-view .deai-score-panel { max-height: none; overflow: visible; border: 0; background: transparent; padding: 0; gap: 10px; }
.ai-tool-view .deai-score-body { gap: 10px; }
.ai-tool-view .deai-delta { display: block; width: fit-content; max-width: 100%; white-space: normal; border-radius: 4px; font-size: 10px; line-height: 1.8; }
.ai-tool-view .deai-advice-focus { font-size: 11px; line-height: 1.8; color: var(--text-sub); background: var(--card-2); border-color: var(--border); }
.ai-tool-view .deai-seg-details summary { font-size: 11px; line-height: 1.8; color: var(--text-sub); }
.ai-tool-view .deai-seg { background: var(--card-2); color: var(--text-sub); border-color: var(--border); }
.ai-tool-view .deai-seg-text { font-size: 11px; line-height: 1.8; color: var(--text-sub); }
[data-theme="dark"] .ai-tool-settings .ai-text-danger { color: #efb4a7; }
[data-theme="dark"] .ai-tool-view .deai-delta-down { color: #b6e2c3; background: #294235; }
[data-theme="dark"] .ai-tool-view .deai-delta-up { color: #efb4a7; background: #48312e; }
[data-theme="dark"] .ai-tool-view .deai-delta-flat { color: var(--text-sub); background: var(--card-2); }

@media (min-width: 1740px) {
    .ai-tool-workspace { grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; }
    .ai-tool-view .polish-input, .ai-tool-view .polish-output { font-size: 16px; padding: 24px 26px; }
    .ai-tool-view .polish-output.fs-m { --reading-fs: 16px; }
    .ai-tool-view .chat-msg-content { font-size: 15px; }
}
@media (min-width: 1181px) and (max-width: 1390px) {
    .ai-tool-view .ai-tool-main { padding: 24px 20px 20px; }
    .ai-tool-workspace { grid-template-columns: minmax(0, 1fr) 226px; gap: 14px; }
    .ai-tool-settings { padding: 17px 15px; }
    .ai-tool-view .polish-pane-head { padding: 11px 12px; }
    .ai-tool-view .polish-pane-title { font-size: 13px; }
    .ai-tool-view .polish-input, .ai-tool-view .polish-output { padding: 18px 16px; }
}
@media (max-width: 1180px) {
    .ai-tool-view .ai-tool-main { height: auto; min-height: calc(100dvh - 116px); padding: 25px 22px; }
    .ai-tool-workspace { flex: none; grid-template-columns: minmax(0, 1fr); gap: 18px; }
    .ai-tool-view .ai-settings-jump { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 11px; font-size: 11px; color: var(--brand); background: var(--card); border: 1px solid var(--border); border-radius: 5px; white-space: nowrap; cursor: pointer; }
    .ai-tool-rail { overflow: visible; min-height: auto; }
    .ai-tool-settings { padding: 21px; }
    .ai-tool-view .chat-shell { height: min(690px, 76dvh); min-height: 440px; }
    .ai-tool-view .polish-shell { height: 640px; }
    .ai-tool-view .polish-body { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
    .ai-tool-settings .ai-tool-run { max-width: 280px; }
    .ai-tool-rail > .ai-tool-run { max-width: 300px; width: 100%; }
    .ai-setting-field { margin-bottom: 20px; }
}
@media (max-width: 600px) {
    .ai-tool-view .ai-tool-main { padding: 22px 14px; gap: 20px; }
    .ai-tool-page-head { align-items: flex-start; gap: 12px; }
    .ai-tool-page-head h2 { font-size: 26px; }
    .ai-tool-page-head p { font-size: 11px; max-width: 230px; }
    .ai-tool-view .ai-settings-jump { margin-top: 26px; padding: 6px 8px; font-size: 10px; }
    .ai-tool-view .chat-shell { height: min(640px, 78dvh); min-height: 430px; }
    .ai-conversation-head { padding: 9px 13px; }
    .ai-conversation-head > div { gap: 8px; }
    .ai-current-model { max-width: 115px; }
    .ai-tool-view .chat-messages { padding: 20px 14px; gap: 22px; }
    .ai-tool-view .chat-msg { gap: 8px; max-width: 100%; }
    .ai-tool-view .chat-msg-avatar { width: 26px; height: 26px; flex-basis: 26px; font-size: 10px; }
    .ai-tool-view .chat-msg-content { font-size: 13px; line-height: 1.9; }
    .ai-tool-view .chat-msg-user .chat-msg-content { padding: 9px 11px; }
    .ai-tool-view .chat-composer { padding: 8px 10px 12px; }
    .ai-tool-view .chat-input-row { padding: 10px; }
    .ai-tool-view .chat-input { font-size: 13px; min-height: 60px; }
    .ai-tool-view .chat-composer-hint { display: block; font-size: 9px; }
    .ai-tool-view .chat-composer-bar { gap: 3px; }
    .ai-tool-view .chat-tokens-info { font-size: 9px; }
    .ai-tool-view .chat-send-btn { min-width: 66px; min-height: 34px; height: 34px; padding: 7px 10px; }
    .ai-tool-view .chat-control-btn { padding: 5px 7px; gap: 3px; font-size: 10px; }
    .ai-chat-input-tools { gap: 4px; }
    .ai-tool-view .polish-shell { height: auto; overflow: visible; }
    .ai-tool-view .polish-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, 380px); gap: 14px; flex: none; }
    .ai-tool-view .polish-pane-head { padding: 11px 13px; min-height: 51px; gap: 7px; }
    .ai-tool-view .polish-pane-title { font-size: 13px; }
    .ai-tool-view .polish-input, .ai-tool-view .polish-output { padding: 17px 16px; font-size: 14px; }
    .ai-tool-view .polish-output.fs-m { --reading-fs: 14px; }
    .ai-tool-view .polish-composer { padding: 9px 12px; gap: 8px; }
    .ai-tool-view .polish-status-cluster { order: initial; flex-basis: 160px; text-align: left; align-items: flex-start; }
    .ai-tool-view .polish-status { font-size: 10px; }
    .ai-tool-view .polish-cost { font-size: 9px; }
    .ai-tool-settings { padding: 20px; }
    .ai-tool-settings h3 { margin-bottom: 20px; }
    .ai-tool-settings .ai-tool-run, .ai-tool-rail > .ai-tool-run { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ai-tool-view .chat-messages { scroll-behavior: auto; }
    .ai-tool-view :is(.polish-output-cursor, .deai-output-cursor) { animation: none; }
}

/* ============================================================
   去AI味 · 处理策略（形态岗 / 说法岗 + 编辑范围 + 强度）
   与小说生产同源：两道岗串行，滑块控制说法岗覆盖率
   ============================================================ */
.deai-strategy-note { margin: -10px 0 16px; font-size: 11px; line-height: 1.7; color: var(--muted); }
.deai-strategy-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px; margin-bottom: 8px;
    background: var(--card-2); border: 1px solid var(--border); border-radius: 6px;
    cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.deai-strategy-row:hover { border-color: var(--brand); }
.deai-strategy-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(59, 130, 246, .16); }
.deai-strategy-text { display: flex; flex-direction: column; min-width: 0; }
.deai-strategy-text b { font-size: 12.5px; font-weight: 600; line-height: 1.5; color: var(--text); }
.deai-strategy-text small { font-size: 11px; line-height: 1.6; color: var(--muted); }
.deai-strategy-row input[type="checkbox"] {
    flex: 0 0 auto; width: 16px; height: 16px; margin: 0;
    accent-color: var(--brand); cursor: pointer;
}
.deai-style-field { margin-top: 8px; }
.deai-style-field .polish-model-select { width: 100%; }
/* 深度模式属于「明知有副作用仍主动使用」，用警示色把它和默认选项区分开 */
.deai-style-field select option[value="deep"] { color: #b4553f; }
.deai-coverage-block {
    margin: 6px 0 0; padding: 12px;
    background: var(--card-2); border: 1px solid var(--border); border-left: 3px solid var(--brand);
    border-radius: 6px;
}
.deai-coverage-block[hidden] { display: none; }
.deai-coverage-label {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; color: var(--text-sub);
}
.deai-coverage-label span { color: var(--brand); font-weight: 600; font-variant-numeric: tabular-nums; }
.deai-coverage-block input[type="range"] {
    width: 100%; margin: 10px 0 2px; accent-color: var(--brand); cursor: pointer;
}
.deai-coverage-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.deai-coverage-hint { margin: 8px 0 0; font-size: 11px; line-height: 1.7; color: var(--muted); }
/* 两道岗都没选时的提示：不隐藏、不静默失败，直接把原因写出来 */
.deai-strategy-warn { color: #b4553f; font-weight: 500; }

/* ============================================================
   去AI味 · 设置列在窄屏下的收拢
   · 1180 及以下仍保留三列，只把中间列收窄；
   · 900 及以下三列放不下，改为上下堆叠，并把设置列排到两个文字框之后。
   ============================================================ */
@media (max-width: 1180px) {
    #view-deai .polish-body { grid-template-columns: minmax(0, 1fr) 232px minmax(0, 1fr); }
}
@media (max-width: 900px) {
    #view-deai .polish-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        flex: none;
    }
    #view-deai .polish-input-pane { order: 1; min-height: 320px; }
    #view-deai .polish-output-pane { order: 2; min-height: 320px; }
    #view-deai .ai-tool-main { height: auto; padding: 20px 16px; }
    #view-deai .polish-shell { height: auto; overflow: visible; }
    #view-deai .polish-input-pane, #view-deai .polish-output-pane { height: 380px; }
    #view-deai .deai-settings-col { order: 3; overflow: visible; gap: 12px; }
    #view-deai .deai-settings-col > .ai-tool-settings { overflow: visible; flex: none; }
    #view-deai .deai-settings-col .ai-tool-run { margin-top: 0; }
    #view-deai .polish-input, #view-deai .polish-output { padding: 18px; }
    #view-deai .ai-tool-run { width: 100%; max-width: none; }

}

/* ============================================================
   去AI味 · 状态框（原页面底部「等待开始」条，现在挪到检测对比下方）
   列宽只有 264px，改成竖排小卡：状态一行、费用一行、暂停/停止按钮在需要时出现。
   ============================================================ */
#view-deai .deai-settings-col > .polish-composer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin: 0;
    padding: 11px 13px;
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 9px;
}
#view-deai .deai-settings-col > .polish-composer .polish-composer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
/* 暂停/停止都隐藏时（未开始改写）不留空行 */
#view-deai .deai-settings-col > .polish-composer .polish-composer-actions:not(:has(button:not([hidden]))) {
    display: none;
}
#view-deai .deai-settings-col > .polish-composer .polish-status-cluster {
    flex: 0 0 auto;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
    min-width: 0;
}
#view-deai .deai-settings-col > .polish-composer .polish-status { font-size: 11px; line-height: 1.5; }
#view-deai .deai-settings-col > .polish-composer .polish-cost { font-size: 10px; line-height: 1.5; white-space: normal; }
