/* =============================================================================
 *  styles.css —— 美化版配置页样式
 *
 *  设计理念：
 *    · 深蓝色调体系 - 传递专业与可信赖感
 *    · 呼吸感布局 - 充足的留白与层次分明的卡片
 *    · 精简的排版 - 通过字重与尺寸建立层次，避免过度装饰
 *    · 有意义的色彩 - 蓝色代表操作，珊瑚色代表警示
 * ========================================================================== */

:root {
    --primary: #4a5fc1;
    --primary-hover: #6c7fd8;
    --primary-dark: #3a4fa1;
    /* 对比度：原 #ff6b6b 对白底仅 2.64:1（对浅灰底 2.47:1）。
     * 取 #c0392b 后对白底 ≈5.0:1、对 #f8f9fc ≈4.8:1，红仍读作"危险"
     * 且达到正文 4.5:1 的可读标准。 */
    --danger: #c0392b;
    --danger-hover: #a93226;
    --success: #4caf50;
    --warning: #ffa726;

    --text: #1a1f36;
    --text-2: #4a5568;
    --text-3: #718096;
    /* 对比度：原 #a0aec0 对白底仅 2.26:1（开关关闭态轨道也用它）。
     * 压深到 #7b8794 后约 3.9:1，满足非文字 UI 部件 ≥3:1。 */
    --text-4: #7b8794;

    --bg: #f0f2f8;
    --card-bg: #f8f9fc;
    --white: #ffffff;

    --border: #e8eaf6;
    --border-light: #f0f2f8;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(26, 31, 54, 0.06);
    --shadow: 0 4px 12px rgba(26, 31, 54, 0.08);
    --shadow-lg: 0 8px 24px rgba(26, 31, 54, 0.12);

    /* 顶栏 / 底栏高度（正文上下留白用）。这里只是兜底默认值 ——
     * 实际由 scripts/fit_bars.js 按元素实测高度实时校正：
     * 顶栏只有一个按钮（实测 76px，原页遗留 220px 会把正文顶下一大截），
     * 底栏含「保存 + 重置为默认值」两行（实测 137px，原页遗留 76px 会盖住内容）。 */
    --topbar-h: 76px;
    --bottombar-h: 137px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "WenQuanYi Micro Hei", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    padding-top: var(--topbar-h);
    padding-bottom: var(--bottombar-h);
}

/* ---------------------------------------------------------------- 顶部固定 */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 999;
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    backdrop-filter: blur(8px);
}

.btn-login-now {
    display: block;
    width: 100%;
    height: 48px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.btn-login-now:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-login-now:active {
    transform: translateY(0);
}

.btn-login-now[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- 底部固定 */
.bottombar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 999;
    background: var(--white);
    box-shadow: 0 -4px 12px rgba(26, 31, 54, 0.08);
    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(8px);
}

.btn-save {
    display: block;
    width: 100%;
    height: 52px;
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-save:active {
    transform: translateY(0);
}

.btn-save[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ------------------------------------------------------------------ 内容区 */
/* 铺满视口宽度（不再设上限）：宽屏下卡片直接拉伸到两边，不留下右侧空白。 */
.wrap {
    width: 100%;
    margin: 0;
    padding: 20px 16px;
}

/* 信息卡片 */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

#pageTitle {
    text-align: left;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
    letter-spacing: 0.5px;
}

.card .remain {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-light);
}

.card .kv {
    font-size: 15px;
    color: var(--text-2);
    line-height: 2;
    display: flex;
    align-items: center;
}

.card .kv b {
    color: var(--text);
    font-weight: 600;
    min-width: 80px;
    margin-right: 8px;
}

/* 信息卡下半区：左边机器人摘要，右边持续任务流程 */
.overview-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    gap: 22px;
    align-items: stretch;
}

.overview-main {
    min-width: 0;
}

.task-flow-panel {
    min-width: 0;
    min-height: 168px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    padding: 14px 16px;
}

.task-flow-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.task-flow-head b {
    color: var(--text);
    font-size: 15px;
}

.task-flow-head span {
    color: var(--text-3);
    font-size: 12px;
}

.task-flow-list {
    max-height: 180px;
    overflow-y: auto;
    padding-top: 4px;
}

.task-flow-item {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-light);
    font-size: 13px;
    line-height: 1.45;
}

.task-flow-item:last-child {
    border-bottom: 0;
}

.task-flow-dot {
    width: 7px;
    height: 7px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--primary);
}

.task-flow-item.success .task-flow-dot {
    background: #3fb950;
}

.task-flow-item.failure .task-flow-dot {
    background: #f85149;
}

.task-flow-item.success .task-flow-text {
    color: #2f8f45;
}

.task-flow-item.failure .task-flow-text {
    color: #d13c36;
}

.task-flow-text {
    color: var(--text-2);
    min-width: 0;
    word-break: break-word;
}

.task-flow-time {
    color: var(--text-3);
    font-size: 12px;
    white-space: nowrap;
}

.task-flow-empty {
    color: var(--text-3);
    font-size: 13px;
    padding: 14px 0;
}

/* ★ 固定置顶的「最近成功」（2026-10-14）
 *   它不在 80 条流程窗口里，是**当前状态**；用左边框 + 浅底与流程条目区分，
 *   否则用户会以为它也是流程中的一条（进而困惑"为什么它时间比下面还早"）。 */
.task-flow-item.task-flow-pinned {
    border-left: 3px solid #3fb950;
    background: rgba(63, 185, 80, 0.07);
    padding-left: 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.task-flow-item.task-flow-pinned .task-flow-time {
    color: #3fb950;
    font-weight: 600;
}
.notice {
    margin-top: 20px;
    padding: 16px;
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.8;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.notice a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.notice a:hover {
    color: var(--primary-hover);
}

.notice .tag-顶 {
    color: var(--danger);
    font-weight: 600;
    background: rgba(255, 107, 107, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ------------------------------------------------------- fieldset（分区容器）*/
fieldset {
    border: 1px solid var(--border);
    padding: 24px;
    margin: 0 0 20px 0;
    border-radius: var(--radius-lg);
    background: var(--white);
    min-width: 0;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

fieldset:hover {
    box-shadow: var(--shadow);
}

legend {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    padding: 0 12px;
    background-color: var(--white);
}

/* ------------------------------------------------------------------ 表单项 */
.form { display: block; }

.row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    min-height: 40px;
    gap: 8px;
}

.row > .label {
    flex: 0 0 auto;
    min-width: 110px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    line-height: 40px;
}

.row.lh40 > .label { line-height: 40px; }

.tlabel {
    font-size: 13px;
    color: var(--text-3);
    margin-left: 8px;
}

.tlabel2 {
    vertical-align: middle;
    line-height: 40px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    margin-right: 8px;
}

/* ------------------------------------------------------------------ 开关 */
/* 盒子 48×44（含上下各 9px 透明内边距）用于触摸命中；视觉轨道仍是 48×26，
 * 用绝对定位把它钉在盒子正中 —— 这样：
 *   · 触摸命中区达标（44px 高）
 *   · 行内 align-items:center 居中的是 44px 盒子，而轨道在其正中，
 *     所以轨道中心 == 盒子中心 == 标签中心，三者在同一水平线上。
 * 若改成给 label 直接加 padding 而不重定位轨道，轨道会跟着被撑高或
 * 停在盒子顶部，导致开关看起来比文字偏高（实测比标签中心高 9px）。 */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 44px;
    padding: 0;
    box-sizing: border-box;
    flex: none;
    margin-top: 0;
}

.switch .track {
    position: absolute;
    left: 0;
    right: 0;
    top: 9px;
    bottom: auto;
    height: 26px;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .track {
    background: var(--text-4);
    border-radius: 13px;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .track {
    background: var(--primary);
}

.switch input:checked + .track::after {
    transform: translateX(22px);
}

.switch input:focus-visible + .track {
    box-shadow: 0 0 0 3px rgba(74, 95, 193, 0.25);
}

.switch input:disabled + .track {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ------------------------------------------------- 下拉 / 输入 / 时间选择器 */
.ctl {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    outline: none;
    transition: all 0.2s ease;
    min-width: 0;
    max-width: 100%;
}

.ctl:hover {
    border-color: var(--primary);
}

.ctl:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 95, 193, 0.1);
}

.ctl:disabled, .ctl[readonly] {
    background: var(--card-bg);
    color: var(--text-4);
    cursor: not-allowed;
}

.ctl.invalid {
    border-color: var(--danger);
}

select.ctl {
    min-width: 100px;
    padding-right: 8px;
    cursor: pointer;
}

input.ctl[type="number"] { width: 100px; }
input.ctl[type="time"] { width: 130px; }
input.ctl[type="text"] { width: 150px; }
input.ctl.w-80 { width: 80px; }
input.ctl.w-100 { width: 110px; }
input.ctl.w-140 { width: 150px; }

.w-80 { max-width: 80px; }
.w-100 { max-width: 110px; }
.w-140 { max-width: 150px; }
.w-180 { max-width: 190px; }

/* ------------------------------------------------------------------ 滑块 */
.slider-box {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 240px;
    max-width: 450px;
}

input[type="range"].ctl-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border-light);
    outline: none;
    transition: background 0.2s;
}

input[type="range"].ctl-range:hover {
    background: var(--border);
}

input[type="range"].ctl-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--white);
    border: 3px solid var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

input[type="range"].ctl-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

input[type="range"].ctl-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--white);
    border: 3px solid var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

input[type="range"].ctl-range::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

/* --------------------------------------------------- 多选（标签云 / 可新增）*/
.tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: var(--white);
    min-height: 42px;
    transition: all 0.2s ease;
}

.tags:hover {
    border-color: var(--primary);
}

.tags:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 95, 193, 0.1);
}

.tags .tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    font-size: 13px;
    padding: 4px 10px;
    max-width: 100%;
    word-break: break-all;
    transition: all 0.2s;
}

.tags .tag:hover {
    background: var(--border-light);
}

.tags .tag .x {
    cursor: pointer;
    color: var(--text-3);
    font-size: 16px;
    line-height: 1;
    border: 0;
    background: none;
    padding: 0;
    transition: color 0.2s;
    /* 触摸目标：视觉仍是一个小叉，但命中区扩到 ≥24px，
     * 手机上不再轻易误触成删除（原 16×16 远小于 44 的建议值）。 */
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: -4px -6px -4px 0;
}

.tags .tag .x:hover {
    color: var(--danger);
}

.tags input {
    flex: 1;
    min-width: 100px;
    border: 0;
    outline: none;
    font-size: 14px;
    height: 28px;
    background: transparent;
    color: var(--text);
}

/* 名单收起后保留一行，可横向查看；展开后恢复完整标签编辑。 */
.tags.tags-collapsed {
    flex-wrap: nowrap;
    overflow-x: auto;
}
.tags.tags-collapsed .tag {
    flex: 0 0 auto;
    white-space: nowrap;
}
.tags.tags-collapsed input { flex: 0 0 140px; }
.list-toggle {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
    color: var(--primary);
    background: var(--card-bg);
    cursor: pointer;
    white-space: nowrap;}
.list-toggle:hover { border-color: var(--primary); }
.list-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 只读小标签 */
.chip {
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--primary);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    line-height: 20px;
}

/* ------------------------------------------------------------- 提示 / 弹窗 */
.toast-host {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    width: min(90vw, 440px);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0 0 16px;
    margin-bottom: 12px;
    animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.toast header {
    padding: 20px 20px 8px;
    font-size: 17px;
    color: var(--text);
    font-weight: 600;
}

.toast .body {
    padding: 0 20px 20px;
    color: var(--text-2);
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow: auto;
    line-height: 1.6;
}

.toast footer {
    padding: 0 20px;
    text-align: right;
}

.toast .ok {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.toast .ok:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.toast.err header { color: var(--danger); }
.toast.ok header { color: var(--success); }

/* 顶部行内提示条 */
.hintbar {
    position: fixed;
    left: 50%;
    top: calc(var(--topbar-h) + 12px);
    transform: translateX(-50%);
    z-index: 1500;
    background: rgba(26, 31, 54, 0.95);
    color: var(--white);
    font-size: 14px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow);
}

.hintbar.show { opacity: 1; }

/* --------------------------------------------------------------- 加载遮罩 */
.mask {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    font-size: 15px;
}

.mask.show { display: flex; }

.spinner {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.link-underline {
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    transition: border-color 0.2s;
}

.link-underline:hover {
    border-bottom-color: transparent;
}

/* =====================================================================
 *  移动端适配
 * ===================================================================== */
@media (max-width: 640px) {
    .row { align-items: flex-start; }
    .row > .label {
        flex: 1 0 100%;
        line-height: 1.6;
        min-width: 0;
        margin-bottom: 4px;
    }
    .row.lh40 > .label { line-height: 1.6; }

    fieldset {
        margin: 0 0 16px 0;
        padding: 20px 16px;
    }

    .card {
        padding: 20px 16px;
        margin-bottom: 16px;
    }

    .overview-split {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .task-flow-panel {
        min-height: 140px;
    }

    select.ctl,
    input.ctl[type="text"],
    input.ctl[type="number"],
    input.ctl[type="time"] {
        width: auto;
        flex: 1 1 120px;
        max-width: 100%;
    }

    input.ctl.w-80,
    input.ctl.w-100,
    input.ctl.w-140 {
        width: auto;
        max-width: none;
    }

    .w-80, .w-100, .w-140, .w-180 { max-width: none; }
    .slider-box { max-width: 100%; min-width: 0; flex: 1 1 100%; }
    .tags { flex: 1 1 100%; }

    /* 手机端：含「展开名单」按钮的行允许换行。
     * 该行是 .row.row-sw，被 `.row-line > .row.row-sw { flex-wrap: nowrap }`
     * 按住不许换行；而手机端 .label 是 flex:1 0 100%（独占整行），
     * 于是 switch 与按钮只能挤在同一行、被顶出容器（实测右边界 484 > 视口 390），
     * 顺着 overflow-x:visible 把 .wrap / body / html 一起撑宽 → 整页横向滚动。
     * 选择器必须与上面那条同为两级，才能覆盖它的 nowrap。 */
    .row-line > .row.row-sw:has(> .list-toggle) {
        flex-wrap: wrap;
        /* row-gap 不在这里设 —— 纵向间距统一由后文手机断点的
         * `label.margin-bottom: 3px` + 轨道偏移 9px 承担（= 12px），
         * 这里再给 8px 会因为本选择器权重更高而把该行撑到 20px。 */
        row-gap: 0;
    }
    .row > .list-toggle {
        flex: 0 0 auto;
        white-space: normal;
        max-width: 100%;
    }
    /* 收起态必须与桌面同一套语义（nowrap + 横向滚动）。
     * ★ 原先这里写成 flex-wrap:wrap / overflow-x:visible，等于把「收起」
     *   的实现手段两条都取消 —— 实测手机端收起态与展开态高度完全相同
     *   （均 2219px / 56 行），「展开名单」按钮变成空转的死控件。
     *   收起态改回单行横滑后恢复到 ~49px（1 行）。
     * 注意：下面不要再给 .tags-collapsed .tag 加 flex:1 1 auto，
     *   那会让标签继续换行撑高。 */
    .tags.tags-collapsed {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .tags.tags-collapsed .tag { flex: 0 0 auto; }
    .tags.tags-collapsed input { flex: 0 0 120px; min-width: 0; }

    /* 龟兔赛跑等显式网格：列宽是 max-content，窄屏放不下会顶破外层。
     * 让网格自己成为横向滚动容器（父级给 min-width:0 才量得准），
     * 从而只在网格内部滚动，不再把整页撑宽。 */
    .row-grid {
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .form, .row-line { min-width: 0; }

    .btn-login-now { font-size: 17px; height: 46px; }
    .btn-save { font-size: 17px; height: 50px; }
    .toast-host { width: 92vw; }

    .wrap { padding: 16px 12px; }
}

@media (min-width: 641px) {
    .row > .ctl,
    .row > .switch,
    .row > .chip {
        margin-right: 8px;
    }
}

/* =====================================================================
 *  分区的行分组 —— 复刻线上 el-form :inline + 手写 <br>
 *
 *  线上「任务配置」等分区用的是 <el-form :inline="true">：表单项 inline-block
 *  横向排列、满行自动换行，再用 <br> 做人为分组。复现版原先把每项渲染成
 *  独立一行，竖着拉成一条、右侧大片留白，和原页对不上。
 *
 *  现在：ui.js 按 assets/rows.js（从 lemon/index.html 自动提取的「每组几项」）
 *  把组内各项包进 .row-line —— 组内横向排列、满行自动换行，组与组之间换行，
 *  与线上一致。手机端同样适用（宽度不够时自动少放几项，无需媒体查询）。
 * ===================================================================== */
.row-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 24px;
}

.row-line > .row {
    flex: 0 0 auto;
    max-width: 100%;
    min-height: 38px;
    margin-bottom: 4px;
}

/* 含标签云 / 长控件的那一项必须可收缩 ——
 * .row 默认 flex:0 0 auto 永不收缩，标签云按 max-content 撑开，
 * 会顶破 .row-line 甚至把整页撑出横向滚动（手机端尤其明显）。
 * 放开收缩 + min-width:0，标签云内部的 wrap / overflow-x 才真正生效。 */
.row-line > .row:has(> .tags),
.row-line > .row:has(> .slider-box) {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
}

.row-line > .row > .tags,
.row-line > .row > .slider-box {
    min-width: 0;
    max-width: 100%;
}

/* 标签只占自身宽度、不折行；过长时省略号（完整名称看 title 悬浮） */
.row-line > .row > .label {
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 开关行内部绝不换行 —— 否则把开关顶到第二行，行高翻倍 */
.row-line > .row.row-sw {
    flex-wrap: nowrap;
}

/* ★ 手机端必须放开上面那条 nowrap。
 * 原因：手机端（见 @media max-width:640px）`.row > .label` 被改成
 *      flex: 1 0 100%（标签独占整行）。此时还要 nowrap，开关就被硬挤在
 *      同一行并顶出容器 —— 实测右边界 417 > 视口 390，再顺着
 *      overflow-x: visible 把 .wrap / body / html 逐级撑宽，整页横向滚动。
 * 为什么写在这里而不是媒体查询里：CSS 选择器权重相同时**按源码顺序**决胜，
 *      媒体查询本身不增加权重。写在 @media 块里会输给上面这条同权重的
 *      nowrap（实测 computed 仍是 nowrap）；因此必须排在它之后。
 * 观感无变化：手机上标签本来就在开关上方，放开换行只是不再溢出。 */
@media (max-width: 640px) {
    .row-line > .row.row-sw { flex-wrap: wrap; }
}

/* 开关与标签垂直居中（.switch 原带的 margin-top:7px 是给单列布局做基线对齐的） */
.row-line > .row > .switch {
    margin-top: 0;
}

/* 指定的活动行保持列数，窄窗口通过横向滚动查看。 */
.row-line.fixed-columns {
    display: grid;
    grid-template-columns: repeat(var(--form-columns), max-content);
    overflow-x: auto;
    gap: 0 24px;
}
.row-line.fixed-columns > .row { flex-wrap: nowrap; }
.row-line.fixed-columns[style="--form-columns:2"] {
    grid-template-columns: repeat(2, minmax(300px, max-content));
}

/* =====================================================================
 *  显式网格 —— 供 scripts/guitui_grid.js 用（龟兔赛跑 2 行 × 3 列）
 *
 *  ★ 为什么必须是「一个 grid + 显式 grid-area」，而不是两个 .row-line：
 *      .row-line 是 flex + wrap，列宽按 max-content 各算各的，
 *      上下两排**不会互相对齐**。要「龟龟1 / 龟龟2」真正落在同一列，
 *      必须同一个 grid 容器、由 --grid-cols 统一列轨道。
 *  ★ grid-template-columns 用 max-content：列宽跟着最宽的那项走，
 *    与 .row-line 的观感一致，不会被拉成等宽大格。
 * ===================================================================== */
.row-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 3), max-content);
    column-gap: 24px;
    row-gap: 4px;
    align-items: center;
    max-width: 100%;
    overflow-x: auto;
}

.row-grid-cell {
    min-width: 0;
    max-width: 100%;
}

/* 格子里的 .row 不再吃额外下边距（间距交给 row-gap 统一控制） */
.row-grid-cell > .row {
    margin-bottom: 0;
}

/* 没有分组数据的分区（脚本后追加的）退回逐项一行 */
.form > .row {
    margin-bottom: 12px;
}

/* =====================================================================
 *  手机端「纯开关行」——正好 4 列（2026-10-14 用户要求）
 *
 *  需求：适配手机 ui —— 开关行正好展示 4 列，且**不影响勾选**。
 *
 *  为什么必须显式 4 列：.row-line 是 flex + wrap，列宽按内容各算各的 ——
 *  手机上一条 4 项的开关行会挤成 2+2 甚至 3+1，既零散又难点。
 *  这里改成一个 4 轨道网格（每轨 1fr），行内开关刚好 4 列。
 *
 *  ★ 不影响勾选（三条硬约束，自检 tools/_probe_mobile4.html 逐条断言）：
 *    ① 开关本体尺寸不变（48×26）—— 缩放会缩小触摸目标；
 *    ② 格内**标签独占一行、开关落到第二行**—— 手机 4 列每格约 85px，
 *       标签与开关并排必然溢出到邻格，点击会落进别人格子里；
 *    ③ 只对「整行都是开关」的组生效（sw-grid-4 由 scripts/mobile_switch_grid.js
 *       按 DOM 事实逐个判定后打标），含下拉 / 数字 / 标签云的组一律保持原样 ——
 *       那些控件需要横向空间，压成 4 列会点不了、填不进。
 *
 *  ★ 只作用于手机断点：桌面端仍走 .row-line 的 flex 排布（与线上原版一致）。
 * ===================================================================== */
@media (max-width: 640px) {
    .row-line.sw-grid-4 {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        column-gap: 6px;
        row-gap: 2px;
        align-items: start;
    }

    /* 每一格：标签一行 + 开关一行（上下堆叠，谁也不挤谁） */
    .row-line.sw-grid-4 > .row {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        flex-wrap: wrap;
        min-width: 0;
        max-width: 100%;
        min-height: 0;
        margin-bottom: 2px;
        gap: 2px;
    }

    .row-line.sw-grid-4 > .row > .label {
        width: 100%;
        flex: 0 0 auto;
        min-width: 0;
        margin-bottom: 0;
        line-height: 1.25;
        font-size: 13px;
        /* 超长标签压到两行、第三行省略；完整文案仍在 title 里（鼠标/长按可看） */
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        word-break: break-word;
    }

    /* 开关本体：尺寸、垂直位置都不动（触摸目标 48×26 与桌面一致） */
    .row-line.sw-grid-4 > .row > .switch {
        flex: none;
        margin-top: 0;
    }
}
@media print {
    .topbar, .bottombar, .toast-host, .mask { display: none !important; }
    body { padding: 0; }
}

/* ===== 开关行视觉对齐与间距 整改补丁 ===== */
/* ============================================================================
 *  开关行视觉对齐与间距 —— 整改补丁（只改 CSS，不改字段名 / data.js / rows.js）
 *
 *  适用文件：config-page/assets/styles.css
 *  建议位置：追加到文件末尾（必须在 @media (max-width:640px) 主块之后，
 *            且必须排在 .row-line > .row.row-sw { flex-wrap: nowrap } 之后）
 *
 *  复现基线：http://127.0.0.1:8978  视口 390×900 / 1280×900
 *  度量脚本：见 交付说明 中的 measure snippet
 * ========================================================================== */


/* ---------------------------------------------------------------------------
 * 修复 1（P0，影响全部 73 个开关行 —— 桌面 + 手机）
 *
 * 缺陷：`.switch .track` 的垂直定位被后文覆盖。
 *   styles.css:440  .switch .track { top: 9px; bottom: auto; }   ← 权重 0-2-0
 *   styles.css:453  .switch .track { inset: 0; }                 ← 权重 0-2-0，源码在后 → 胜
 *
 * `inset: 0` 是 top/right/bottom/left 的简写，把 top 覆盖为 0，
 * 于是 26px 高的轨道贴在 44px 触摸盒的顶部，而不是落在 9px 的居中位置。
 *
 * 实测量化（修复前）：
 *   桌面 1280：track 相对 switch 盒顶偏移 = 0px（应为 9px）→ 中心偏差恒定 -9px
 *   手机 390 ：偏移同为 0px，视觉间距被少算 9px
 *
 * 修法：显式重写，并把 inset 先复位为 auto（否则 left/right 也会被重置）。
 * ------------------------------------------------------------------------- */
/* 注意（2026-10-15）：上面 L441 处的 `.switch .track` 已直接写成 top:9px，
 * 不再需要在这里重复覆盖 —— 两处都写会因为「后写的 top 生效、但先写的
 * transform 仍残留」而把轨道额外上移 13px（实测中心偏差 9px 劣化到 13px）。
 * 轨道定位只保留 L441 那一处。 */


/* ---------------------------------------------------------------------------
 * 修复 2（P0，手机端 ≤640px）——「标签底 → 轨道视觉顶」统一为 12px
 *
 * 「视觉间距」T 的完整算式（手机端，标签独占一行、开关换到下一行）：
 *
 *     T = label.margin-bottom + .row 的 row-gap + .switch 的 padding-top(9px)
 *
 * 修复前实测：
 *   纯开关行 .row.row-sw            : 4 + 8 + 9 = 21px   （48 行）
 *   4 列网格 .sw-grid-4 > .row      : 0 + 2 + 9 = 11px   （17 行）
 *   显式网格 .row-grid-cell > .row  : 0 + 2 + 9 = 11px   （ 1 行）
 *   多开关行 .row.lh40              : 4 + 8 + 9 = 21px   （ 6 行）
 *   → 三种值 {2, 12, 19}（按 track-top 计）／{11, 21}（按视觉间距计），σ = 4.38px
 *
 * 目标 T = 12px，故令 row-gap = 0、label.margin-bottom = 3px：
 *     3 + 0 + 9 = 12px
 *
 * 注意：只清 row-gap，不要动 column-gap。
 *   column-gap 是行内横向间隔（桌面靠它分隔 label 与控件），
 *   实测把它一起置 0 会让桌面中心偏差从 0px 劣化到 1.34px。
 * ------------------------------------------------------------------------- */
@media (max-width: 640px) {

    /* ① 纯开关行 / ② 4 列网格格 / ③ 显式网格格：纵向间距改由 margin-bottom 承担 */
    .form .row.row-sw,
    .row-line.sw-grid-4 > .row,
    .row-grid-cell > .row {
        row-gap: 0;
    }

    /* ④ 多开关行（位面战场 / 界域之争的「1」~「4」）也走同一条 label 规则 */
    .form .row > .label,
    .row-line.sw-grid-4 > .row > .label,
    .row-grid-cell > .row > .label {
        margin-bottom: 3px;
    }

    /* ⑤ 补齐漏网行型（2026-10-15 实测 8 行仍偏离 12px）：
     *   上一条只覆盖了 .row-sw / .sw-grid-4 / .row-grid-cell 三种父容器，
     *   而「位面战场 / 界域之争」的 1~4 行是 .row.lh40（多控件行、
     *   父级是普通 .row-line），「只采集自己加以下玩家洞府」也是 .row-sw
     *   但父级为 .row-line —— 它们的 row-gap 仍是 8px，实测 vgap = 20px。
     *   统一把手机端开关行的 row-gap 归零，让纵向间距只由 label.margin-bottom
     *   承担（3 + 9 = 12px），四种行型落到同一个值。 */
    .form .row,
    .row-line > .row {
        row-gap: 0;
    }
}


/* ---------------------------------------------------------------------------
 * 已知残留（2 处，非阻断，可按需追加处理）
 *
 *  A. ".row-grid-cell > .row"（龟兔赛跑）视觉间距 = 19px 而非 12px
 *     原因：该格所在网格行轨道高度 85.39px，本格内容高 76.39px，
 *           .row-grid { align-items: center } 使本行整体下移 ~7px，
 *           .row 的 row-gap:8px 又把这份余量计入 label↔switch 之间。
 *     验证：把该格 row-gap 显式置 0 后 vgap 19 → 11（可精确落到 12）。
 *     若要修，追加：
 *         @media (max-width: 640px) {
 *             .row-grid-cell > .row { row-gap: 0; column-gap: 8px; }
 *             .row-grid-cell > .row > .label { margin-bottom: 3px; }
 *         }
 *     风险：需与 .row-grid 的 align-items 一起回归，单独改会让该格高度塌到 76.39。
 *
 *  B. 含「展开名单」按钮的行（采集配置「只采集自己加以下玩家洞府」）vgap = 20px
 *     原因：.list-toggle(29px) 与 .switch(44px) 同处一个 flex line，
 *           该行 row-gap:0 已加，但按钮使 flex line 高度取 max(44,29)=44，
 *           叠加 .row 的 gap 简写后仍余 8px。
 * ------------------------------------------------------------------------- */



/* ===========================================================================
 *  「不采集以下玩家洞府」整行默认隐藏（点「展开名单」后显示）
 *  （2026-10-15 用户要求）
 *
 *  ★ 必须用 display:none 且带 !important：
 *    · .row-line 上有 display:grid（.row-line.fixed-columns）与
 *      display:flex（.row-line）等更高优先级声明，
 *      实测加 hidden 属性后仍是 display:flex（190x44），**静默失效**。
 *  ★ 只隐藏呈现，节点仍在 DOM 里 —— checkBox_屏蔽洞府 的值照常参与保存。
 * =========================================================================== */
.row-line.shield-row-hidden {
    display: none !important;
}

/* 「展开名单」按钮的触摸目标补到 44px（原 79x29 偏小）。 */
.list-toggle {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
}
