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

:root {
    --primary: #4a5fc1;
    --primary-hover: #6c7fd8;
    --primary-dark: #3a4fa1;
    --danger: #ff6b6b;
    --danger-hover: #ff5252;
    --success: #4caf50;
    --warning: #ffa726;

    --text: #1a1f36;
    --text-2: #4a5568;
    --text-3: #718096;
    --text-4: #a0aec0;

    --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;
}

/* 账号3专属小号池：每个账号固定一行，避免 160 个状态挤在同一段文字里。 */
.small-pool-panel {
    margin: 16px 0 20px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

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

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

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

.small-pool-list {
    max-height: 620px;
    overflow-y: auto;
    padding-top: 4px;
}

.small-pool-row {
    display: grid;
    grid-template-columns: 74px minmax(100px, 180px) minmax(90px, 130px) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 34px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border-light);
    font-size: 13px;
}

.small-pool-row:last-child { border-bottom: 0; }
.small-pool-id { color: var(--text-3); font-variant-numeric: tabular-nums; }
.small-pool-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-pool-status { color: #3fb950; white-space: nowrap; }
.small-pool-status.failed { color: #d13c36; }
.small-pool-status.waiting { color: var(--text-3); }
.small-pool-task { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-pool-empty { color: var(--text-3); font-size: 13px; padding: 14px 0; }

@media (max-width: 700px) {
    .small-pool-row { grid-template-columns: 62px minmax(90px, 1fr) minmax(72px, 92px); }
    .small-pool-task { grid-column: 2 / -1; padding-bottom: 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;
}

/* ------------------------------------------------------------------ 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex: none;
    margin-top: 7px;
}

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

.switch .track {
    position: absolute;
    inset: 0;
    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;
}

.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%; }
    .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;
}

/* 标签只占自身宽度、不折行；过长时省略号（完整名称看 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;
}

/* 开关与标签垂直居中（.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; }
}
