/* ============================================================
   短信转发器 · Android 13 Material You（莫奈）风格样式
   ------------------------------------------------------------
   1. 颜色全部走 M3 颜色角色（--md-*），由 assets/theme.js 依据
      「种子色」动态计算并写在 :root 上；未启用 JS 时用下面的基线色。
   2. 圆角、状态层（state layer）、高度、字体阶都按 Material 3 规范。
   ============================================================ */

:root {
    /* ---------- Material 3 基线色调板（浅色） ---------- */
    --md-primary: #6750A4;
    --md-on-primary: #ffffff;
    --md-primary-container: #EADDFF;
    --md-on-primary-container: #21005D;
    --md-secondary-container: #E8DEF8;
    --md-on-secondary-container: #1D192B;
    --md-tertiary: #7D5260;
    --md-tertiary-container: #FFD8E4;
    --md-on-tertiary-container: #31111D;
    --md-error: #B3261E;
    --md-on-error: #ffffff;
    --md-error-container: #F9DEDC;
    --md-on-error-container: #410E0B;

    --md-surface: #FEF7FF;
    --md-surface-dim: #DED8E1;
    --md-surface-container-lowest: #ffffff;
    --md-surface-container-low: #F7F2FA;
    --md-surface-container: #F3EDF7;
    --md-surface-container-high: #ECE6F0;
    --md-surface-container-highest: #E6E0E9;
    --md-on-surface: #1D1B20;
    --md-on-surface-variant: #49454F;
    --md-outline: #79747E;
    --md-outline-variant: #CAC4D0;
    --md-inverse-surface: #322F35;
    --md-inverse-on-surface: #F5EFF7;

    /* ---------- 形状 ---------- */
    --md-shape-xs: 4px;
    --md-shape-s: 8px;
    --md-shape-m: 12px;
    --md-shape-l: 16px;
    --md-shape-xl: 28px;
    --md-shape-full: 999px;

    /* ---------- 高度（elevation） ---------- */
    --md-elev-0: none;
    --md-elev-1: 0 1px 2px rgba(0, 0, 0, .14), 0 1px 3px 1px rgba(0, 0, 0, .08);
    --md-elev-2: 0 1px 2px rgba(0, 0, 0, .14), 0 2px 6px 2px rgba(0, 0, 0, .09);
    --md-elev-3: 0 4px 8px 3px rgba(0, 0, 0, .10), 0 1px 3px rgba(0, 0, 0, .14);

    /* ---------- 状态层透明度 ---------- */
    --md-press: .12;
    --md-hover: .08;

    /* ---------- 动效 ---------- */
    --md-ease: cubic-bezier(.2, 0, 0, 1);
    --md-dur: .2s;

    /* ---------- 字体阶 ---------- */
    --md-font: Roboto, "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
    --md-font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    color-scheme: light;
}

/* 未启用 JS 时跟随系统深色（启用 JS 后由 theme.js 直接写内联变量） */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --md-primary: #D0BCFF;
        --md-on-primary: #381E72;
        --md-primary-container: #4F378B;
        --md-on-primary-container: #EADDFF;
        --md-secondary-container: #4A4458;
        --md-on-secondary-container: #E8DEF8;
        --md-tertiary: #EFB8C8;
        --md-tertiary-container: #633B48;
        --md-on-tertiary-container: #FFD8E4;
        --md-error: #F2B8B5;
        --md-on-error: #601410;
        --md-error-container: #8C1D18;
        --md-on-error-container: #F9DEDC;

        --md-surface: #141218;
        --md-surface-dim: #141218;
        --md-surface-container-lowest: #0F0D13;
        --md-surface-container-low: #1D1B20;
        --md-surface-container: #211F26;
        --md-surface-container-high: #2B2930;
        --md-surface-container-highest: #36343B;
        --md-on-surface: #E6E1E5;
        --md-on-surface-variant: #CAC4D0;
        --md-outline: #938F99;
        --md-outline-variant: #49454F;
        --md-inverse-surface: #E6E1E5;
        --md-inverse-on-surface: #322F35;

        --md-elev-1: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px 1px rgba(0, 0, 0, .25);
        --md-elev-2: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 6px 2px rgba(0, 0, 0, .25);
        --md-elev-3: 0 4px 8px 3px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .4);

        color-scheme: dark;
    }
}

/* ============================================================
   基础
   ============================================================ */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--md-font);
    background: var(--md-surface);
    color: var(--md-on-surface);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body.page-app {
    min-height: 100vh;
    background: var(--md-surface);
    /* 莫奈典型的大色块柔光背景（不支持 color-mix 的浏览器用上一行兜底） */
    background:
        radial-gradient(1100px 620px at 8% -12%, color-mix(in srgb, var(--md-primary) 12%, transparent), transparent 62%),
        radial-gradient(900px 520px at 105% 2%, color-mix(in srgb, var(--md-tertiary) 10%, transparent), transparent 58%),
        var(--md-surface);
}

a {
    color: var(--md-primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

code {
    font-family: var(--md-font-mono);
    font-size: .9em;
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface-variant);
    padding: 2px 7px;
    border-radius: var(--md-shape-s);
    word-break: break-all;
}

mark {
    background: var(--md-tertiary-container);
    color: var(--md-on-tertiary-container);
    padding: 0 3px;
    border-radius: var(--md-shape-xs);
}

.spacer { flex: 1 1 auto; }
.hint { color: var(--md-on-surface-variant); font-size: 12.5px; line-height: 1.7; margin: 8px 0 0; }
.meta { color: var(--md-on-surface-variant); font-size: 12.5px; }
.meta-dim { color: var(--md-outline); }

.section-title {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--md-primary);
    margin: 26px 0 12px;
}

/* ============================================================
   M3 按钮
   高度 40，圆角全高，label-large
   ============================================================ */

.btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: var(--md-shape-full);
    background: transparent;
    color: var(--md-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .01em;
    cursor: pointer;
    transition: box-shadow var(--md-dur) var(--md-ease), background-color var(--md-dur) var(--md-ease);
}
.btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-dur) var(--md-ease);
}
.btn:hover::before { opacity: var(--md-hover); }
.btn:active::before { opacity: var(--md-press); }
.btn[disabled] { opacity: .38; cursor: not-allowed; }
.btn[disabled]::before { opacity: 0; }
.btn:hover { text-decoration: none; }

/* 实心按钮 Filled */
.btn-primary {
    background: var(--md-primary);
    color: var(--md-on-primary);
    box-shadow: var(--md-elev-0);
}
.btn-primary:hover { box-shadow: var(--md-elev-1); }

/* 色调按钮 Tonal */
.btn-ghost {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
}

/* 描边按钮 Outlined */
.btn-outlined {
    border: 1px solid var(--md-outline);
    color: var(--md-primary);
}

/* 危险操作：M3 里用 error 色调按钮 */
.btn-danger {
    background: var(--md-error-container);
    color: var(--md-on-error-container);
}

.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn .ico { width: 18px; height: 18px; flex: 0 0 auto; }
.btn-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ============================================================
   M3 卡片
   ============================================================ */

.card {
    background: var(--md-surface-container-low);
    border-radius: var(--md-shape-l);
    padding: 16px;
}

/* ============================================================
   M3 输入框（filled 文本域：顶圆角 + 底部描边）
   ============================================================ */

input[type="text"],
input[type="password"],
input[type="search"],
input[type="date"],
textarea {
    width: 100%;
    min-height: 56px;
    padding: 18px 16px 8px;
    background: var(--md-surface-container-highest);
    border: none;
    border-bottom: 1px solid var(--md-on-surface-variant);
    border-radius: var(--md-shape-xs) var(--md-shape-xs) 0 0;
    color: var(--md-on-surface);
    font-family: inherit;
    font-size: 15px;
    transition: border-color var(--md-dur) var(--md-ease), background-color var(--md-dur) var(--md-ease);
}
input:focus,
textarea:focus {
    outline: none;
    border-bottom: 2px solid var(--md-primary);
    padding-bottom: 7px;
}
input::placeholder,
textarea::placeholder { color: var(--md-on-surface-variant); }

/* 下拉、日期：M3 药丸形容器 */
select,
.mini-select,
input[type="date"] {
    width: auto;
    min-height: 40px;
    padding: 8px 12px;
    background: var(--md-surface-container-high);
    border: none;
    border-bottom: none;
    border-radius: var(--md-shape-s);
    color: var(--md-on-surface);
    font-family: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: background-color var(--md-dur) var(--md-ease);
}
select:hover { background: var(--md-surface-container-highest); }
select:focus { outline: none; border-bottom: none; padding-bottom: 8px; box-shadow: 0 0 0 2px var(--md-primary); }
input[type="date"]:focus { padding-bottom: 8px; }

/* ============================================================
   M3 开关 / 复选框
   ============================================================ */

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 52px;
    height: 32px;
    flex: 0 0 auto;
    margin: 0;
    border-radius: var(--md-shape-full);
    background: var(--md-surface-container-highest);
    border: 2px solid var(--md-outline);
    position: relative;
    cursor: pointer;
    transition: background-color var(--md-dur) var(--md-ease), border-color var(--md-dur) var(--md-ease);
}
input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--md-outline);
    transform: translateY(-50%);
    transition: left var(--md-dur) var(--md-ease), width var(--md-dur) var(--md-ease),
        height var(--md-dur) var(--md-ease), background-color var(--md-dur) var(--md-ease);
}
input[type="checkbox"]:checked {
    background: var(--md-primary);
    border-color: var(--md-primary);
}
input[type="checkbox"]:checked::after {
    left: 12px;
    width: 22px;
    height: 22px;
    background: var(--md-on-primary);
}

/* 筛选用的小方框复选框（工具条里的“仅含验证码”也走这套） */
.checkbox-sm,
.checkline input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    border-radius: var(--md-shape-xs);
    border-width: 2px;
}
.checkbox-sm::after,
.checkline input[type="checkbox"]::after { display: none; }
.checkbox-sm:checked::after,
.checkline input[type="checkbox"]:checked::after {
    display: block;
    content: "";
    position: absolute;
    inset: 0;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    transform: none;
    border-radius: 0;
    background: var(--md-on-primary);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E");
    -webkit-mask-size: 16px 16px;
    mask-size: 16px 16px;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

/* ============================================================
   M3 标签 chip / badge
   ============================================================ */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--md-shape-s);
    border: 1px solid var(--md-outline-variant);
    background: transparent;
    color: var(--md-on-surface-variant);
    font-size: 13px;
    white-space: nowrap;
}
.chip--filled {
    border-color: transparent;
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--md-shape-s);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: none;
}
.badge-sms  { background: var(--md-primary-container);   color: var(--md-on-primary-container); }
.badge-call { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.badge-app  { background: var(--md-tertiary-container);  color: var(--md-on-tertiary-container); }

/* ============================================================
   M3 提示条（snackbar 用 .toast，这里给流程提示）
   ============================================================ */

.alert {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--md-shape-m);
    font-size: 13.5px;
    margin-bottom: 16px;
    line-height: 1.65;
}
.alert-ok  { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.alert-warn{ background: var(--md-tertiary-container);  color: var(--md-on-tertiary-container); }
.alert-err { background: var(--md-error-container);     color: var(--md-on-error-container); }

/* ============================================================
   M3 顶部应用栏
   ============================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--md-surface-container);
    transition: box-shadow var(--md-dur) var(--md-ease);
}
.topbar.is-stuck { box-shadow: var(--md-elev-2); }

.topbar-inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 10px 20px;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: .01em;
    color: var(--md-on-surface);
}
.device-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--md-on-surface-variant);
    font-size: 12.5px;
    margin-left: 4px;
}
.topbar-actions {
    position: relative;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.topbar-actions .switch { gap: 6px; }

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--md-primary);
    display: inline-block;
    animation: pulse 2.2s var(--md-ease) infinite;
}
.pulse--off { background: var(--md-outline); animation: none; }
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-primary) 55%, transparent); }
    70%  { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* 莫奈取色面板 */
.popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 232px;
    padding: 12px;
    border-radius: var(--md-shape-m);
    background: var(--md-surface-container);
    box-shadow: var(--md-elev-2);
}
.popover[hidden] { display: none; }
.popover-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    margin-bottom: 10px;
}
.swatches { display: flex; gap: 10px; }
.swatch {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--sw);
    cursor: pointer;
    position: relative;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-on-surface) 18%, transparent);
    transition: transform var(--md-dur) var(--md-ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch.is-active::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid var(--md-primary);
}
.popover-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--md-outline-variant);
}
.popover-note { font-size: 11.5px; color: var(--md-outline); }

/* ============================================================
   布局
   ============================================================ */

.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 20px 56px; }

/* 统计卡：莫奈典型的同色系色块 */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    padding: 16px 18px;
    border-radius: var(--md-shape-l);
    background: var(--md-surface-container);
    color: var(--md-on-surface);
}
.stat-card--primary   { background: var(--md-primary-container);   color: var(--md-on-primary-container); }
.stat-card--secondary { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.stat-card--tertiary  { background: var(--md-tertiary-container);  color: var(--md-on-tertiary-container); }
.stat-label { display: block; font-size: 12.5px; opacity: .82; }
.stat-value {
    display: block;
    margin-top: 6px;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: .01em;
    line-height: 1.2;
}
.stat-value--sm { font-size: 16px; font-weight: 500; }

/* 工具条：M3 搜索栏 + 筛选 chip */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 12px;
    border-radius: var(--md-shape-xl);
    background: var(--md-surface-container-low);
    margin-bottom: 14px;
}
.search-box { flex: 1 1 240px; min-width: 180px; }
.search-box input[type="search"] {
    min-height: 48px;
    padding: 12px 20px;
    border-radius: var(--md-shape-full);
    background: var(--md-surface-container-high);
    border-bottom: none;
    font-size: 15px;
}
.search-box input[type="search"]:focus {
    border-bottom: none;
    padding-bottom: 12px;
    box-shadow: 0 0 0 2px var(--md-primary);
}

.checkline {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--md-shape-s);
    border: 1px solid var(--md-outline-variant);
    color: var(--md-on-surface-variant);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--md-dur) var(--md-ease), color var(--md-dur) var(--md-ease);
}
.checkline:has(input:checked) {
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
    border-color: transparent;
}

.list-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 6px 10px;
    color: var(--md-on-surface-variant);
    font-size: 12.5px;
}

/* ============================================================
   短信列表（M3 列表项 / 填充卡片）
   ============================================================ */

.msg-list { display: flex; flex-direction: column; gap: 10px; }

.msg {
    position: relative;
    overflow: hidden;
    background: var(--md-surface-container-low);
    border-radius: var(--md-shape-l);
    padding: 16px 18px;
    transition: background-color var(--md-dur) var(--md-ease);
}
.msg:hover { background: var(--md-surface-container); }
.msg--unread {
    background: var(--md-surface-container-high);
}
.msg.is-new { animation: flash 1.8s var(--md-ease); }
@keyframes flash {
    0%   { background: var(--md-primary-container); }
    100% { background: var(--md-surface-container-high); }
}

.msg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msg-sender { font-size: 16px; font-weight: 500; letter-spacing: .01em; }
.msg--unread .msg-sender { color: var(--md-primary); }
.msg-time { margin-left: auto; color: var(--md-on-surface-variant); font-size: 12.5px; }
.dot-new {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--md-primary);
}

.msg-title { margin-top: 6px; color: var(--md-on-surface-variant); font-size: 13px; }

.msg-body { margin-top: 8px; }
.msg-content {
    margin: 0;
    font-size: 15px;
    line-height: 1.75;
    color: var(--md-on-surface);
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-content.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.expand-btn {
    margin-top: 8px;
    padding: 0;
    border: none;
    background: none;
    color: var(--md-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.expand-btn:hover { text-decoration: underline; }

.msg-code { margin-top: 12px; }
.code-chip {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: stretch;
    padding: 0;
    border: none;
    border-radius: var(--md-shape-m);
    background: var(--md-tertiary-container);
    color: var(--md-on-tertiary-container);
    font-family: inherit;
    cursor: pointer;
}
.code-num {
    padding: 6px 16px;
    font-family: var(--md-font-mono);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 2px;
}
.code-tip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 12.5px;
    background: color-mix(in srgb, currentColor 12%, transparent);
}

.msg-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.icon-btn {
    position: relative;
    overflow: hidden;
    min-height: 34px;
    padding: 0 14px;
    border: none;
    border-radius: var(--md-shape-full);
    background: transparent;
    color: var(--md-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--md-dur) var(--md-ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--md-primary) 10%, transparent); }
.icon-btn--danger { color: var(--md-error); }
.icon-btn--danger:hover { background: color-mix(in srgb, var(--md-error) 10%, transparent); }
.icon-btn--icon { padding: 0; width: 40px; justify-content: center; }

/* 空状态 */
.empty {
    text-align: center;
    padding: 64px 24px;
    border-radius: var(--md-shape-xl);
    background: var(--md-surface-container-low);
    color: var(--md-on-surface-variant);
}
.empty-icon { color: var(--md-primary); margin-bottom: 10px; }
.empty p { margin: 4px 0; }
.empty .hint { max-width: 460px; margin: 10px auto 0; }

/* ============================================================
   分页 / 页脚
   ============================================================ */

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0 0;
    flex-wrap: wrap;
}
.page-btn {
    position: relative;
    overflow: hidden;
    min-height: 40px;
    padding: 0 22px;
    border: 1px solid var(--md-outline);
    border-radius: var(--md-shape-full);
    background: transparent;
    color: var(--md-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--md-dur) var(--md-ease);
}
.page-btn:hover:not(.is-disabled) { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.page-btn.is-disabled { opacity: .38; cursor: not-allowed; }
.page-info { color: var(--md-on-surface-variant); font-size: 12.5px; }

.foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--md-outline-variant);
    color: var(--md-outline);
    font-size: 12px;
}

/* 页脚署名：M3 色调 chip */
.foot-link {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 16px;
    border-radius: var(--md-shape-full);
    background: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: box-shadow var(--md-dur) var(--md-ease);
}
.foot-link:hover {
    text-decoration: none;
    box-shadow: var(--md-elev-1);
}

/* ============================================================
   M3 Snackbar（改用 .toast 元素承载）
   ============================================================ */

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 24px);
    max-width: 92vw;
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 12px 18px;
    border-radius: var(--md-shape-xs);
    background: var(--md-inverse-surface);
    color: var(--md-inverse-on-surface);
    font-size: 14px;
    box-shadow: var(--md-elev-3);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-dur) var(--md-ease), transform var(--md-dur) var(--md-ease);
    z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--md-inverse-surface); }
.toast.err { background: var(--md-error); color: var(--md-on-error); }

.copyable { cursor: pointer; }

/* ============================================================
   水波纹（M3 涟漪反馈）
   ============================================================ */

.ripple {
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: .22;
    transform: scale(0);
    pointer-events: none;
    animation: ripple-out .55s var(--md-ease) forwards;
}
@keyframes ripple-out {
    to { transform: scale(2.4); opacity: 0; }
}

/* ============================================================
   登录 / 安装页
   ============================================================ */

body.page-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    background: var(--md-surface);
    background:
        radial-gradient(820px 560px at 18% -6%, color-mix(in srgb, var(--md-primary) 18%, transparent), transparent 62%),
        radial-gradient(760px 520px at 96% 104%, color-mix(in srgb, var(--md-tertiary) 16%, transparent), transparent 60%),
        var(--md-surface);
}

.auth-wrap { width: 100%; max-width: 420px; }
.auth-wrap--wide { max-width: 640px; }

.auth-card {
    background: var(--md-surface-container-low);
    border-radius: var(--md-shape-xl);
    padding: 30px 26px 26px;
    box-shadow: var(--md-elev-1);
}

.auth-brand { margin-bottom: 22px; }
.auth-brand h1 {
    font-size: 22px;
    font-weight: 400;
    letter-spacing: .01em;
    margin: 14px 0 0;
}
.auth-sub { color: var(--md-on-surface-variant); font-size: 13.5px; margin: 6px 0 0; }

.logo-dot {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--md-primary);
    position: relative;
    vertical-align: middle;
}
.logo-dot::after {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: var(--md-on-primary);
}

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12.5px;
    color: var(--md-on-surface-variant);
    margin-bottom: 6px;
}

.switch-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--md-on-surface-variant);
    font-size: 13.5px;
    cursor: pointer;
}
/* 注意：不要重置这里的宽高，否则 M3 开关会被压成 0 宽 */
.switch-line input { flex: 0 0 auto; min-height: 0; }

/* 环境检测列表 */
.check-list { list-style: none; padding: 0; margin: 0 0 20px; }
.check-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--md-shape-m);
    margin-bottom: 8px;
    background: var(--md-surface-container);
    font-size: 13px;
}
.check-icon { width: 20px; text-align: center; font-weight: 700; }
.check-list li.ok .check-icon { color: var(--md-primary); }
.check-list li.bad .check-icon { color: var(--md-error); }
.check-value { margin-left: auto; text-align: right; color: var(--md-on-surface-variant); font-size: 12px; }

.code-block {
    margin: 0 0 16px;
    padding: 16px;
    overflow: auto;
    border-radius: var(--md-shape-m);
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface);
    font-family: var(--md-font-mono);
    font-size: 12.5px;
}

.kv-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.kv {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--md-shape-m);
    background: var(--md-surface-container);
}
.kv > span { flex: 0 0 108px; color: var(--md-on-surface-variant); font-size: 12.5px; }
.kv code { flex: 1 1 auto; }

/* ============================================================
   响应式
   ============================================================ */

@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .toolbar .select,
    .search-box { flex: 1 1 46%; min-width: 0; }
    .toolbar .checkline,
    .toolbar .btn { flex: 1 1 auto; }
}

@media (max-width: 600px) {
    .wrap { padding: 16px 14px 48px; }
    .topbar-inner { padding: 10px 14px; }
    .brand-name { font-size: 18px; }
    .device-state { display: none; }
    .topbar-actions { width: 100%; margin-left: 0; }
    .topbar-actions .switch { flex: 1 1 auto; }
    .popover { left: 0; right: auto; min-width: 0; width: 100%; }
    .stat-value { font-size: 24px; }
    .msg { padding: 14px; border-radius: var(--md-shape-m); }
    .msg-time { margin-left: 0; width: 100%; }
    .msg-foot .icon-btn { flex: 1 1 auto; }
    .kv { flex-direction: column; align-items: flex-start; gap: 4px; }
    .kv > span { flex: none; }
    .auth-card { padding: 24px 20px; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
