        @font-face {
            font-family: "Maple Mono";
            src: url("../fonts/MapleMonoNL-NF-CN-Regular.ttf") format("truetype");
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        :root {
            color-scheme: light;
            --p-glass: rgba(255, 255, 255, 0.88);
            --p-line: rgba(255, 255, 255, 0.98);
            --v-sky: #007AFF;
            --v-field: linear-gradient(135deg, #1d976c 0%, #007AFF 100%);
            --v-mono: "Maple Mono", "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
            --page-radial-1: rgba(210, 255, 210, 0.25);
            --page-radial-2: rgba(230, 235, 255, 0.35);
            --page-bg: #fcfdfc;
            --panel-shadow: 0 50px 100px rgba(0,0,0,0.04), inset 0 0 2px rgba(255,255,255,0.7);
            --border-soft: rgba(0,0,0,0.06);
            --border-faint: rgba(0,0,0,0.04);
            --text-main: #2c3e50;
            --text-strong: #1a1a1a;
            --text-secondary: #7c858e;
            --text-muted: #8ea099;
            --text-dim: #a0b0a8;
            --surface-soft: rgba(255,255,255,0.85);
            --surface-panel: rgba(255,255,255,0.92);
            --surface-modal: rgba(255,255,255,0.96);
            --surface-table: rgba(255,255,255,0.4);
            --surface-bot: rgba(255,255,255,0.45);
            --surface-input: rgba(255,255,255,0.7);
            --surface-input-focus: #fff;
            --surface-status: rgba(255,255,255,0.9);
            --surface-card: rgba(248,252,250,0.8);
            --surface-card-hover: rgba(240,250,245,0.95);
            --surface-code: rgba(0,0,0,0.05);
            --overlay: rgba(20,35,25,0.35);
            --sensor-hover: rgba(29,151,108,0.08);
            --logo-mark: #2c7a7b;
            --chart-axis: #80908a;
            --chart-grid: rgba(0,0,0,0.06);
            --chart-tooltip-bg: rgba(29,34,38,0.9);
            --chart-tooltip-fg: #fff;
            --chart-today: #1d976c;
            --status-dot: #8e8e93;
            --modal-header-bg: linear-gradient(135deg,#1d976c08 0%,#007AFF08 100%);
            --cancel-bg: rgba(0,0,0,0.08);
        }

        @media (prefers-color-scheme: dark) {
            :root {
                color-scheme: dark;
                --p-glass: rgba(12,18,23,0.82);
                --p-line: rgba(255,255,255,0.08);
                --page-radial-1: rgba(29,151,108,0.16);
                --page-radial-2: rgba(0,122,255,0.18);
                --page-bg: #081017;
                --panel-shadow: 0 50px 110px rgba(0,0,0,0.42), inset 0 0 2px rgba(255,255,255,0.06);
                --border-soft: rgba(255,255,255,0.08);
                --border-faint: rgba(255,255,255,0.06);
                --text-main: #e2edf1;
                --text-strong: #f4f8fa;
                --text-secondary: #9dafb8;
                --text-muted: #8ea2ac;
                --text-dim: #7f9099;
                --surface-soft: rgba(16,24,30,0.82);
                --surface-panel: rgba(14,21,26,0.92);
                --surface-modal: rgba(12,18,23,0.96);
                --surface-table: rgba(255,255,255,0.05);
                --surface-bot: rgba(16,24,30,0.78);
                --surface-input: rgba(14,22,27,0.84);
                --surface-input-focus: rgba(18,28,34,0.96);
                --surface-status: rgba(16,24,30,0.9);
                --surface-card: rgba(17,25,31,0.84);
                --surface-card-hover: rgba(22,32,38,0.96);
                --surface-code: rgba(255,255,255,0.08);
                --overlay: rgba(2,8,11,0.58);
                --sensor-hover: rgba(102,212,167,0.12);
                --logo-mark: #78d6ce;
                --chart-axis: #8ea2ac;
                --chart-grid: rgba(255,255,255,0.08);
                --chart-tooltip-bg: rgba(234,241,245,0.94);
                --chart-tooltip-fg: #0c1720;
                --chart-today: #66d4a7;
                --status-dot: #71808a;
                --modal-header-bg: linear-gradient(135deg, rgba(29,151,108,0.14) 0%, rgba(0,122,255,0.12) 100%);
                --cancel-bg: rgba(255,255,255,0.12);
            }
        }

        html { height: 100%; }
        * { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, "SF Pro Display", "PingFang SC", sans-serif; }

        body {
            background:
                radial-gradient(at 15% 15%, var(--page-radial-1) 0%, transparent 45%),
                radial-gradient(at 85% 85%, var(--page-radial-2) 0%, transparent 45%),
                var(--page-bg);
            min-height: 100vh;
            min-height: 100dvh;
            padding: 18px;
            display: flex; align-items: center; justify-content: center;
            color: var(--text-main);
        }

        .main-pnl {
            --history-width: 320px;
            width: min(96vw, 1380px); height: min(92vh, 980px);
            background: var(--p-glass);
            backdrop-filter: blur(60px) saturate(200%);
            -webkit-backdrop-filter: blur(60px) saturate(200%);
            border: 1.5px solid var(--p-line);
            border-radius: 30px;
            display: flex;
            min-height: 0;
            position: relative;
            overflow: hidden;
            box-shadow: var(--panel-shadow);
            animation: p-in 1.2s cubic-bezier(0.1, 0.9, 0.2, 1);
        }

        .history-rail {
            width: var(--history-width);
            flex-shrink: 0;
            min-height: 0;
            display: flex;
            flex-direction: column;
            background:
                linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.04) 100%);
            border-right: 1px solid var(--border-faint);
            overflow: hidden;
            transition: width 0.28s ease, border-color 0.28s ease;
            z-index: 30;
        }

        .history-scrim {
            position: absolute;
            inset: 0;
            background: var(--overlay);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.24s ease;
        }

        .app-shell {
            flex: 1;
            min-width: 0;
            min-height: 0;
            display: flex;
            flex-direction: column;
        }

        .main-pnl.sidebar-hidden .history-rail {
            width: 0;
            border-right-color: transparent;
        }

        /* ── 顶栏 ─────────────────────────────────────────────── */
        .top-nav {
            padding: 22px 45px 16px;
            display: flex; justify-content: space-between; align-items: center;
            border-bottom: 1px solid var(--border-faint);
            flex-wrap: wrap; gap: 12px;
        }
        .nav-left {
            display: flex;
            align-items: center;
            gap: 14px;
            min-width: 0;
        }

        .logo-box h1 {
            font-size: 1.45rem; font-weight: 800; letter-spacing: -0.6px;
            background: var(--v-field);
            -webkit-background-clip: text; -webkit-text-fill-color: transparent;
        }
        .logo-box { min-width: 0; }
        .logo-box h1 span { -webkit-text-fill-color: initial; color: var(--logo-mark); font-size: 0.9rem; margin-left: 1px; font-weight: 600; }
        .logo-box p {
            font-size: 0.72rem; color: var(--text-secondary); letter-spacing: 0.8px;
            margin-top: 4px; font-weight: 500; font-variant: small-caps; opacity: 0.9;
        }
        .context-links {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }
        .context-link {
            border: none;
            background: transparent;
            color: var(--text-secondary);
            font: inherit;
            padding: 0;
            cursor: pointer;
            transition: color 0.2s ease, opacity 0.2s ease;
        }
        .context-link[data-pop-card="suining"] {
            display: inline-block;
            max-width: 9em;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            vertical-align: bottom;
        }
        .context-link:hover,
        .context-link:focus-visible,
        .context-link.is-active {
            color: var(--chart-today);
            opacity: 1;
        }
        .context-link:focus-visible {
            outline: none;
        }
        .context-sep {
            color: var(--text-dim);
            user-select: none;
        }

        /* ── 右侧工具组 ───────────────────────────────────────── */
        .nav-right {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 10px;
            flex-wrap: nowrap;
            min-width: 0;
        }

        /* 传感器状态条 */
        .sensor-strip {
            display: flex; align-items: center;
            background: var(--surface-soft);
            border: 1px solid var(--border-soft);
            border-radius: 14px; overflow: hidden;
            box-shadow: 0 2px 8px rgba(0,0,0,0.03);
            font-size: 11.5px; font-family: var(--v-mono);
            cursor: default;
            max-width: 100%;
            min-width: 0;
            flex-wrap: nowrap;
        }
        .sensor-cell {
            display: flex; align-items: center; gap: 5px;
            padding: 8px 13px;
            border-right: 1px solid var(--border-soft);
            min-width: 0;
            flex: 1 1 0;
            position: relative;
            cursor: pointer;
            transition: background 0.22s ease, transform 0.22s ease;
        }
        .sensor-cell:last-child { border-right: none; }
        .sensor-cell-static { cursor: default; }
        .sensor-cell-static:active { transform: none; }
        .sensor-weather-cell {
            justify-content: center;
            min-width: 86px;
        }
        .sensor-cell:hover,
        .sensor-cell.is-active {
            background: var(--sensor-hover);
        }
        .sensor-cell:active { transform: scale(0.985); }
        .sensor-icon { font-size: 13px; line-height: 1; }
        .sensor-val {
            font-weight: 700;
            letter-spacing: -0.3px;
            transition: color 0.4s;
            white-space: nowrap;
            word-break: keep-all;
        }
        .sensor-weather-val {
            font-size: 11px;
            line-height: 1;
            white-space: nowrap;
        }
        .sensor-unit {
            color: var(--text-dim);
            font-size: 10px;
            margin-left: 1px;
            white-space: nowrap;
            word-break: keep-all;
        }
        .sensor-lbl  {
            color: var(--text-muted);
            font-size: 10px;
            margin-left: 2px;
            white-space: nowrap;
            word-break: keep-all;
            writing-mode: horizontal-tb;
        }

        .sensor-pop {
            position: fixed;
            z-index: 960;
            width: min(300px, calc(100vw - 24px));
            padding: 12px 12px 10px;
            border-radius: 18px;
            background: var(--surface-panel);
            border: 1px solid var(--p-line);
            box-shadow: 0 24px 60px rgba(10,24,30,0.16), 0 4px 14px rgba(15,40,28,0.07);
            backdrop-filter: blur(24px) saturate(170%);
            -webkit-backdrop-filter: blur(24px) saturate(170%);
            opacity: 0;
            pointer-events: none;
            transform: translateY(8px) scale(0.98);
            transition: opacity 0.18s ease, transform 0.18s ease;
        }
        .sensor-pop.visible {
            opacity: 1;
            pointer-events: auto;
            transform: translateY(0) scale(1);
        }
        .sensor-pop-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 6px;
            min-width: 0;
        }
        .sensor-pop-title {
            font-size: 12px;
            font-weight: 800;
            letter-spacing: 0.2px;
            color: var(--text-strong);
            min-width: 0;
            flex: 1 1 auto;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .sensor-pop-sub {
            font-size: 10px;
            color: var(--text-muted);
            font-family: var(--v-mono);
            min-width: 0;
            flex: 0 1 52%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            text-align: right;
        }
        .sensor-pop-chart {
            width: 100%;
            height: 156px;
        }
        .sensor-pop-card {
            width: 100%;
            height: 156px;
            border-radius: 14px;
            position: relative;
            z-index: 1;
            overflow-y: auto;
            overflow-x: hidden;
            background: var(--surface-soft);
            border: 1px solid var(--border-soft);
            overscroll-behavior: contain;
            -webkit-overflow-scrolling: touch;
        }
        .sensor-pop-embed {
            width: 100%;
            height: 100%;
            border: 0;
            display: block;
            background: #f3f7f4;
        }
        .sensor-pop-map-shell {
            position: relative;
            width: 100%;
            height: 100%;
            min-height: 156px;
            overflow: hidden;
            border-radius: 14px;
            background: #e9f5ef;
            z-index: 1;
        }
        .sensor-pop-map-stage {
            width: 100%;
            height: 100%;
            min-height: 156px;
            background: linear-gradient(180deg, rgba(233,245,239,0.98), rgba(223,240,232,0.98));
            position: relative;
            z-index: 1;
        }
        .sensor-pop-map {
            width: 100%;
            height: 100%;
            min-height: 156px;
            position: relative;
            z-index: 1;
        }
        .sensor-pop-map-shell .leaflet-pane {
            z-index: 10 !important;
        }
        .sensor-pop-map-shell .leaflet-top,
        .sensor-pop-map-shell .leaflet-bottom,
        .sensor-pop-map-shell .leaflet-control {
            z-index: 20 !important;
        }
        .sensor-pop-map-status {
            min-height: 156px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 18px;
            color: var(--text-secondary);
            font-size: 11px;
            text-align: center;
            line-height: 1.6;
        }
        .sensor-pop-map-status-error {
            flex-direction: column;
            gap: 10px;
        }
        #sensor-pop-map-provider .sensor-pop-provider-menu {
            top: auto;
            right: 0;
            bottom: calc(100% + 6px);
            min-width: 124px;
        }
        .sensor-pop-map-fallback {
            justify-content: center;
        }
        .sensor-pop-card-body {
            min-height: 100%;
            padding: 12px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .sensor-pop-card-badge {
            align-self: flex-start;
            padding: 4px 8px;
            border-radius: 999px;
            background: rgba(29,151,108,0.08);
            color: var(--chart-today);
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.2px;
        }
        .sensor-pop-crop-switch {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }
        .sensor-pop-crop-option {
            border: 1px solid var(--border-soft);
            background: var(--surface-soft);
            color: var(--text-secondary);
            border-radius: 999px;
            padding: 4px 9px;
            font-size: 10px;
            line-height: 1.2;
            cursor: pointer;
            transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .sensor-pop-crop-option:hover,
        .sensor-pop-crop-option.is-active,
        .sensor-pop-crop-option[aria-pressed="true"] {
            color: var(--chart-today);
            border-color: rgba(29,151,108,0.28);
            background: rgba(29,151,108,0.08);
        }
        .sensor-pop-card-copy {
            color: var(--text-main);
            font-size: 12px;
            line-height: 1.6;
        }
        .sensor-pop-card-note {
            color: var(--text-secondary);
            font-size: 11px;
            line-height: 1.5;
        }
        .sensor-pop-card-copy strong {
            color: var(--text-strong);
        }
        .sensor-pop-card-media {
            align-self: flex-start;
            width: 100%;
            max-width: 132px;
            aspect-ratio: 4 / 3;
            flex-shrink: 0;
            overflow: hidden;
            border-radius: 12px;
            border: 1px solid var(--border-soft);
            background: rgba(255,255,255,0.06);
        }
        .sensor-pop-card-media img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        .sensor-pop-card-actions {
            margin-top: auto;
        }
        .sensor-pop-card-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 34px;
            padding: 0 12px;
            border-radius: 11px;
            text-decoration: none;
            background: var(--v-field);
            color: #fff;
            font-size: 11px;
            font-weight: 700;
        }
        .sensor-pop-token-form {
            margin-top: auto;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .sensor-pop-token-row {
            display: flex;
            gap: 8px;
        }
        .sensor-pop-token-input {
            flex: 1;
            min-width: 0;
            border: 1px solid var(--border-soft);
            background: var(--surface-input);
            color: var(--text-main);
            border-radius: 11px;
            padding: 9px 11px;
            font-size: 12px;
            outline: none;
            text-transform: uppercase;
        }
        .sensor-pop-token-submit {
            border: none;
            border-radius: 11px;
            padding: 0 12px;
            background: var(--v-field);
            color: #fff;
            font-size: 11px;
            font-weight: 700;
            cursor: pointer;
            flex-shrink: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            min-width: 64px;
        }
        .sensor-pop-token-submit:disabled {
            cursor: wait;
            opacity: 0.86;
        }
        .sensor-pop-token-spinner {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            border: 1.8px solid rgba(255,255,255,0.35);
            border-top-color: #fff;
            animation: token-spin 0.7s linear infinite;
            display: none;
            flex-shrink: 0;
        }
        .sensor-pop-token-submit.is-loading .sensor-pop-token-spinner {
            display: inline-block;
        }
        .sensor-pop-token-submit.is-loading .sensor-pop-token-label {
            opacity: 0.96;
        }
        .sensor-pop-token-feedback {
            min-height: 16px;
            font-size: 11px;
            color: #c75a5a;
        }
        .sensor-pop-loading,
        .sensor-pop-empty {
            height: 156px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-secondary);
            font-size: 12px;
        }
        .sensor-pop-chart[hidden],
        .sensor-pop-card[hidden],
        .sensor-pop-loading[hidden],
        .sensor-pop-empty[hidden] {
            display: none !important;
        }
        .sensor-pop-foot {
            margin-top: 6px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            gap: 8px;
            position: relative;
            z-index: 5000;
            isolation: isolate;
        }
        .sensor-pop-source-wrap {
            position: relative;
            display: flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
            flex: 1 1 auto;
        }
        .sensor-pop-source {
            font-size: 10px;
            color: var(--text-secondary);
            text-decoration: none;
            transition: color 0.2s ease;
            min-width: 0;
            flex: 1 1 auto;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .sensor-pop-source:hover {
            color: var(--chart-today);
        }
        .sensor-pop-provider {
            position: relative;
            flex: 0 0 auto;
            z-index: 5100;
        }
        .sensor-pop-provider-btn {
            border: 1px solid var(--border-soft);
            background: var(--surface-soft);
            color: var(--text-secondary);
            border-radius: 999px;
            font: inherit;
            font-size: 9px;
            line-height: 1;
            padding: 4px 7px;
            cursor: pointer;
            transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
            white-space: nowrap;
            flex: 0 0 auto;
        }
        .sensor-pop-provider-btn:hover,
        .sensor-pop-provider-btn[aria-expanded="true"] {
            color: var(--chart-today);
            border-color: rgba(29,151,108,0.25);
            background: rgba(29,151,108,0.06);
        }
        .sensor-pop-provider-btn:disabled {
            opacity: 0.62;
            cursor: wait;
        }
        .sensor-pop-provider-menu {
            position: absolute;
            right: 0;
            top: calc(100% + 6px);
            min-width: 112px;
            padding: 5px;
            border-radius: 12px;
            border: 1px solid var(--border-soft);
            background: var(--surface-panel);
            box-shadow: 0 18px 40px rgba(10,24,30,0.12), 0 4px 10px rgba(15,40,28,0.06);
            display: flex;
            flex-direction: column;
            gap: 4px;
            z-index: 5200;
        }
        .sensor-pop-provider-menu[hidden] {
            display: none !important;
        }
        .sensor-pop-provider-option {
            border: none;
            background: transparent;
            color: var(--text-main);
            font: inherit;
            font-size: 10px;
            text-align: left;
            padding: 6px 8px;
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.18s ease, color 0.18s ease;
        }
        .sensor-pop-provider-option:hover,
        .sensor-pop-provider-option[aria-checked="true"] {
            background: rgba(29,151,108,0.08);
            color: var(--chart-today);
        }

        .sensor-strip.refreshing .sensor-val { animation: val-blink 0.42s ease; }
        @keyframes val-blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

        .val-ok    { color: #1d976c; }
        .val-dry   { color: #e17055; }
        .val-flood { color: #0984e3; }
        .val-cold  { color: #6c5ce7; }
        .val-hot   { color: #d63031; }
        .val-rain  { color: #0984e3; }
        .val-cloud { color: #5f6f8b; }
        .val-storm { color: #8e44ad; }

        /* 连接状态标签 */
        .st-tag {
            font-size: 11px; padding: 7px 15px;
            background: var(--surface-status);
            border-radius: 14px; border: 1px solid var(--p-line);
            display: flex; align-items: center; gap: 9px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.01);
            min-width: 160px;
        }
        .dot { width: 6px; height: 6px; background: var(--status-dot); border-radius: 50%; transition: 0.3s; }
        .dot.loading { background: #007AFF; animation: blink 1s infinite; }
        .dot.ok { background: #34c759; box-shadow: 0 0 10px #34c759; }
        .st-link {
            color: inherit;
            text-decoration: none;
        }
        .st-link:hover {
            text-decoration: none;
        }

        .history-toggle-btn,
        .history-new {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            border: 1px solid var(--border-soft);
            background: var(--surface-soft);
            color: var(--text-main);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
        }
        .history-toggle-btn:hover,
        .history-new:hover {
            transform: translateY(-1px);
            background: var(--surface-panel);
            border-color: rgba(29,151,108,0.18);
            box-shadow: 0 10px 24px rgba(29,151,108,0.10);
        }
        .history-toggle-btn:disabled,
        .history-new:disabled {
            opacity: 0.45;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        .history-toggle-btn svg,
        .history-new svg {
            width: 18px;
            height: 18px;
        }

        .history-panel {
            display: flex;
            flex-direction: column;
            min-height: 0;
            height: 100%;
            width: var(--history-width);
            min-width: var(--history-width);
            transition: opacity 0.18s ease;
        }
        .main-pnl.sidebar-hidden .history-panel {
            opacity: 0;
            pointer-events: none;
        }
        .history-panel-head {
            position: relative;
            overflow: hidden;
            padding: 26px 20px 18px;
            border-bottom: 1px solid var(--border-faint);
            background: transparent;
        }
        .history-panel-head::before {
            display: none;
        }
        .history-panel-head::after {
            display: none;
        }
        .history-panel-head > * {
            position: relative;
            z-index: 1;
        }
        .history-panel-top {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
        }
        .history-panel-kicker {
            font-size: 10px;
            font-family: var(--v-mono);
            letter-spacing: 1px;
            color: var(--text-muted);
            text-transform: uppercase;
        }
        .history-panel-title {
            margin-top: 6px;
            font-size: 1.08rem;
            font-weight: 800;
            color: var(--text-strong);
            letter-spacing: -0.35px;
        }
        .history-panel-copy {
            margin-top: 8px;
            font-size: 12.5px;
            line-height: 1.6;
            color: var(--text-secondary);
        }
        .history-toolbar { flex-shrink: 0; }
        .history-status {
            margin-top: 12px;
            padding: 0;
            color: var(--text-secondary);
            font-size: 11px;
            line-height: 1.55;
        }
        .history-status.is-error {
            color: #1aa6a6;
        }
        .history-status.is-ok {
            color: #1d976c;
        }
        .history-list {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            padding: 14px 14px 20px;
        }
        .history-empty {
            padding: 18px 14px;
            color: var(--text-secondary);
            font-size: 13px;
            line-height: 1.7;
            text-align: center;
            border: 1px dashed var(--border-soft);
            border-radius: 18px;
            background: var(--surface-card);
        }
        .history-item {
            position: relative;
            border-radius: 18px;
            margin-bottom: 8px;
            border: 1px solid transparent;
            transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
        }
        .history-item:hover {
            background: var(--surface-card-hover);
            border-color: var(--border-soft);
            transform: translateY(-1px);
        }
        .history-list.is-busy .history-item:hover {
            background: transparent;
            border-color: transparent;
            transform: none;
        }
        .history-item.is-active {
            background: var(--sensor-hover);
            border-color: rgba(29,151,108,0.22);
            box-shadow: inset 0 0 0 1px rgba(29,151,108,0.08);
        }
        .history-open {
            width: 100%;
            padding: 14px 58px 14px 14px;
            text-align: left;
            color: inherit;
            cursor: pointer;
            display: block;
            border-radius: 18px;
        }
        .history-item.is-active .history-open {
            cursor: default;
        }
        .history-open:focus-visible {
            outline: none;
            box-shadow: inset 0 0 0 1px rgba(29,151,108,0.22);
            border-radius: 18px;
        }
        .history-list.is-busy .history-open,
        .history-list.is-busy .history-delete {
            cursor: not-allowed;
        }
        .history-list.is-busy .history-open {
            opacity: 0.62;
        }
        .history-list.is-busy .history-delete {
            opacity: 0.3;
            pointer-events: none;
        }
        .history-item-title {
            font-size: 14px;
            font-weight: 800;
            color: var(--text-strong);
            line-height: 1.45;
        }
        .history-item-preview {
            margin-top: 6px;
            font-size: 12px;
            line-height: 1.55;
            color: var(--text-secondary);
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .history-item-meta {
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            font-size: 10px;
            color: var(--text-muted);
            font-family: var(--v-mono);
        }
        .history-delete {
            position: absolute;
            top: 12px;
            right: 12px;
            z-index: 2;
            width: 30px;
            height: 30px;
            border-radius: 10px;
            border: 1px solid transparent;
            background: transparent;
            color: var(--text-muted);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
        }
        .history-delete svg {
            width: 14px;
            height: 14px;
        }
        .history-item:hover .history-delete,
        .history-item:focus-within .history-delete,
        .history-item.is-active .history-delete {
            opacity: 1;
            pointer-events: auto;
        }
        .history-delete:hover {
            color: #cc4c4c;
            background: rgba(204,76,76,0.08);
            border-color: rgba(204,76,76,0.18);
        }

        /* ── 聊天区 ───────────────────────────────────────────── */
        #chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 35px 50px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }

        .row { width: 100%; margin-bottom: 30px; display: flex; animation: row-in 0.6s ease-out forwards; opacity: 0; }
        .cnt { max-width: 88%; padding: 18px 25px; font-size: 15.5px; line-height: 1.8; color: var(--text-main); overflow-wrap: anywhere; }
        .message-attachments {
            margin-top: 12px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(96px, 132px));
            gap: 10px;
            justify-content: flex-start;
        }
        .message-attachment {
            position: relative;
            display: block;
            border-radius: 16px;
            overflow: hidden;
            width: min(132px, 100%);
            aspect-ratio: 1 / 1;
            border: 1px solid var(--border-soft);
            background: rgba(255,255,255,0.08);
        }
        .message-attachment img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            background: rgba(0,0,0,0.04);
        }
        .message-attachment.is-expired {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 16px;
            color: var(--text-secondary);
            font-size: 12px;
            text-align: center;
            line-height: 1.6;
        }
        .ai-loading {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            color: var(--text-secondary);
        }
        .ai-loading-spinner {
            width: 15px;
            height: 15px;
            border-radius: 50%;
            border: 2px solid rgba(29,151,108,0.18);
            border-top-color: var(--chart-today);
            animation: ai-spin 0.8s linear infinite;
            flex-shrink: 0;
        }
        .ai-loading-text {
            min-width: 0;
        }
        @keyframes ai-spin {
            to { transform: rotate(360deg); }
        }

        .cnt.is-streaming {
            position: relative;
            isolation: isolate;
            border-color: rgba(29,151,108,0.14);
            box-shadow: 0 8px 22px rgba(29,151,108,0.05);
        }
        .bot .cnt {
            position: relative;
        }
        .stream-shell {
            display: block;
            position: relative;
        }
        .stream-text {
            white-space: pre-wrap;
            word-break: break-word;
            min-height: 1.8em;
        }
        .assistant-body hr,
        .cnt hr {
            display: none !important;
        }
        .assistant-meta {
            margin-top: 8px;
            min-height: 0;
        }
        .bubble-json-panel {
            position: absolute;
            left: 0;
            top: 0;
            z-index: 5;
            max-width: min(360px, calc(100vw - 72px));
            padding: 10px;
            border-radius: 16px;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(10,15,21,0.94);
            box-shadow: 0 18px 46px rgba(0,0,0,0.26);
            backdrop-filter: blur(14px) saturate(130%);
            -webkit-backdrop-filter: blur(14px) saturate(130%);
            opacity: 0;
            transform: translateY(8px) scale(0.985);
            transform-origin: top left;
            pointer-events: none;
            transition: opacity 0.24s ease, transform 0.24s ease;
        }
        .bubble-json-panel.is-visible {
            opacity: 1;
            transform: translateY(0) scale(1);
            pointer-events: auto;
        }
        .bubble-json-pre {
            margin: 0 !important;
            max-height: min(250px, 38vh);
            overflow: auto;
            padding: 12px 14px !important;
            border-radius: 12px !important;
            background: rgba(255,255,255,0.04) !important;
            border: 1px solid rgba(255,255,255,0.08);
            font-family: "Maple Mono", var(--v-mono) !important;
            font-size: 12px !important;
            line-height: 1.55;
        }
        .bubble-json-pre code {
            font-family: "Maple Mono", var(--v-mono) !important;
            font-size: inherit !important;
            letter-spacing: 0;
            color: #d5e4ef;
        }
        .json-generating-hint {
            margin-top: 10px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 11px;
            line-height: 1.3;
            color: var(--text-dim);
            opacity: 0.88;
            white-space: nowrap;
            vertical-align: middle;
        }
        .json-generating-spinner {
            display: inline-block;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            border: 1.5px solid rgba(29,151,108,0.18);
            border-top-color: var(--chart-today);
            animation: ai-spin 0.9s linear infinite;
            flex-shrink: 0;
            transform-origin: center;
            will-change: transform;
            backface-visibility: hidden;
        }
        .json-generating-text {
            white-space: nowrap;
        }

        .cnt code, .cnt pre, .tech-term {
            font-family: var(--v-mono) !important; font-size: 0.88em;
            background: var(--surface-code); padding: 2px 5px;
            border-radius: 5px; color: #d63384; letter-spacing: -0.2px;
        }
        .cnt pre {
            display: block;
            padding: 16px;
            margin: 12px 0;
            background: #282c34;
            color: #abb2bf;
            overflow-x: auto;
            border-radius: 12px;
            line-height: 1.5;
            font-family: "Maple Mono", var(--v-mono) !important;
        }
        .cnt pre code {
            background: transparent;
            padding: 0;
            color: inherit;
            font-family: "Maple Mono", var(--v-mono) !important;
        }
        .cnt table { width: 100%; border-collapse: collapse; margin: 15px 0; background: var(--surface-table); border-radius: 10px; overflow: hidden; font-size: 14.5px; display: block; overflow-x: auto; white-space: nowrap; }
        .cnt th, .cnt td { padding: 12px; border: 1px solid var(--border-soft); }
        .cnt th { background: var(--surface-code); font-weight: 700; color: var(--text-strong); }

        .bot .cnt { background: var(--surface-bot); border-radius: 24px 24px 24px 4px; border: 1px solid var(--p-line); }
        .me .cnt  { background: var(--v-field); color: #fff; border-radius: 24px 24px 4px 24px; margin-left: auto; box-shadow: 0 15px 35px rgba(29,151,108,0.15); }

        /* ── 输入区 ───────────────────────────────────────────── */
        .input-area {
            padding: 28px 50px calc(32px + env(safe-area-inset-bottom, 0px));
            display: flex;
            gap: 15px;
            align-items: flex-end;
            transition: padding 0.24s ease;
        }
        .input-area.is-raised {
            padding-top: 20px;
        }
        .composer { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
        .composer-row { display: flex; gap: 12px; align-items: flex-end; min-height: 52px; }
        .mode-switch {
            display: inline-flex;
            align-items: center;
            align-self: flex-start;
            gap: 4px;
            padding: 4px;
            border-radius: 16px;
            background: rgba(255,255,255,0.54);
            border: 1px solid var(--border-soft);
            box-shadow: 0 8px 24px rgba(12,24,30,0.04);
            backdrop-filter: blur(18px) saturate(140%);
            -webkit-backdrop-filter: blur(18px) saturate(140%);
            flex-wrap: wrap;
            touch-action: pan-y;
            user-select: none;
            -webkit-user-select: none;
        }
        .mode-switch.is-dragging { cursor: ew-resize; }
        .mode-switch-btn {
            border: none;
            background: transparent;
            color: var(--text-secondary);
            min-height: 34px;
            padding: 0 14px;
            border-radius: 12px;
            font: inherit;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0.2px;
            cursor: pointer;
            transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
        }
        .mode-switch-btn:hover {
            color: var(--text-main);
            transform: translateY(-1px);
        }
        .mode-switch-btn.is-active {
            background: var(--surface-panel);
            color: var(--text-strong);
            box-shadow: 0 10px 22px rgba(12,24,30,0.08);
        }
        .mode-switch-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        .pending-media {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }
        .voice-panel {
            display: flex;
            flex-direction: column;
            gap: 9px;
            padding: 13px 14px;
            border-radius: 22px;
            border: 1px solid rgba(29,151,108,0.12);
            background:
                linear-gradient(180deg, rgba(255,255,255,0.9), rgba(246,250,248,0.88)),
                radial-gradient(circle at top right, rgba(29,151,108,0.1), transparent 44%);
            box-shadow: 0 12px 30px rgba(14,30,22,0.06);
            backdrop-filter: blur(16px) saturate(145%);
            -webkit-backdrop-filter: blur(16px) saturate(145%);
        }
        .voice-panel[hidden] {
            display: none !important;
        }
        .voice-panel.is-error {
            border-color: rgba(204,80,80,0.24);
            background:
                linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,244,244,0.88)),
                radial-gradient(circle at top right, rgba(204,80,80,0.12), transparent 46%);
        }
        .voice-panel.is-starting {
            border-color: rgba(233,165,54,0.28);
            background:
                linear-gradient(180deg, rgba(255,250,242,0.95), rgba(255,245,227,0.9)),
                radial-gradient(circle at top right, rgba(233,165,54,0.18), transparent 48%);
        }
        .voice-panel-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }
        .voice-panel-status-wrap {
            min-width: 0;
            display: flex;
            align-items: center;
            gap: 10px;
            flex: 1 1 auto;
        }
        .voice-panel-status-copy {
            min-width: 0;
            display: flex;
            flex: 1 1 auto;
        }
        .voice-panel-status {
            min-width: 0;
            display: block;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0.02em;
            color: var(--text-secondary);
        }
        .voice-panel-dot {
            width: 9px;
            height: 9px;
            border-radius: 999px;
            background: #1d976c;
            box-shadow: 0 0 0 0 rgba(29,151,108,0.28);
            flex-shrink: 0;
        }
        .voice-panel.is-starting .voice-panel-dot {
            background: #e3a33f;
            box-shadow: 0 0 0 0 rgba(227,163,63,0.26);
            animation: voice-pulse-soft 1.55s ease-out infinite;
        }
        .voice-panel.is-recording .voice-panel-dot {
            background: #ef5b5b;
            box-shadow: 0 0 0 0 rgba(239,91,91,0.32);
            animation: voice-pulse 1.35s ease-out infinite;
        }
        .voice-panel.is-finalizing .voice-panel-dot {
            background: #6b7f88;
        }
        .voice-panel.is-loading .voice-panel-dot {
            background: #e3a33f;
            box-shadow: 0 0 0 0 rgba(227,163,63,0.26);
            animation: voice-pulse-soft 1.55s ease-out infinite;
        }
        .voice-panel.is-error .voice-panel-dot {
            background: #d85454;
        }
        .voice-panel-meta {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }
        .voice-panel-timer {
            font-size: 12px;
            font-family: var(--v-mono);
            color: var(--text-secondary);
            letter-spacing: 0.3px;
        }
        .voice-panel-cancel {
            min-width: 48px;
            height: 28px;
            border-radius: 999px;
            border: 1px solid var(--border-soft);
            background: rgba(255,255,255,0.72);
            color: var(--text-secondary);
            font: inherit;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
        }
        .voice-panel-cancel:hover {
            background: rgba(255,255,255,0.96);
            color: var(--text-main);
            transform: translateY(-1px);
        }
        .voice-panel-cancel:disabled {
            opacity: 0.45;
            cursor: not-allowed;
            transform: none;
        }
        .voice-panel-progress {
            display: flex;
            flex-direction: column;
            gap: 7px;
            padding: 9px 10px;
            border-radius: 15px;
            background: rgba(255,255,255,0.64);
            border: 1px solid rgba(29,151,108,0.08);
        }
        .voice-panel-progress-track {
            position: relative;
            width: 100%;
            height: 6px;
            overflow: hidden;
            border-radius: 999px;
            background: rgba(29,151,108,0.12);
        }
        .voice-panel-progress-bar {
            display: block;
            width: 0%;
            height: 100%;
            border-radius: inherit;
            background: linear-gradient(90deg, #1d976c 0%, #62c28a 100%);
            transition: width 0.18s ease;
        }
        .voice-panel-progress-text {
            font-size: 11px;
            line-height: 1.45;
            color: var(--text-secondary);
        }
        .voice-panel-transcript {
            min-height: 44px;
            max-height: 140px;
            overflow-y: auto;
            padding: 12px 14px;
            border-radius: 18px;
            background: rgba(255,255,255,0.78);
            border: 1px solid rgba(29,151,108,0.1);
            color: var(--text-strong);
            font-size: 14px;
            line-height: 1.65;
            white-space: pre-wrap;
            word-break: break-word;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.78);
        }
        .voice-panel-transcript.is-live {
            color: var(--text-muted);
        }
        .voice-panel-transcript.is-confirmed {
            color: var(--text-strong);
        }
        .voice-panel-transcript.is-loading::after {
            content: '';
            display: inline-block;
            width: 0.88em;
            height: 0.88em;
            margin-left: 8px;
            border-radius: 999px;
            border: 1.8px solid rgba(111,135,144,0.22);
            border-top-color: #5e7781;
            vertical-align: -0.12em;
            animation: token-spin 0.56s linear infinite;
        }
        .pending-item {
            position: relative;
            width: 78px;
            height: 78px;
            border-radius: 18px;
            overflow: hidden;
            border: 1px solid var(--border-soft);
            background: var(--surface-card);
            flex-shrink: 0;
        }
        .pending-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        .pending-remove {
            position: absolute;
            top: 6px;
            right: 6px;
            width: 24px;
            height: 24px;
            border: none;
            border-radius: 999px;
            background: rgba(12,18,23,0.72);
            color: #fff;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
        }
        .upload-btn {
            width: 52px;
            height: 52px;
            border-radius: 16px;
            border: 1px solid var(--border-soft);
            background: var(--surface-soft);
            color: var(--text-main);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
        }
        .upload-btn:hover {
            transform: translateY(-1px);
            background: var(--surface-panel);
            border-color: rgba(29,151,108,0.18);
        }
        .upload-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
            transform: none;
        }
        .upload-btn svg {
            width: 20px;
            height: 20px;
        }
        .tool-toggle-search[aria-pressed="true"] {
            background: rgba(29,151,108,0.12);
            border-color: rgba(29,151,108,0.28);
            color: var(--chart-today);
            box-shadow: 0 10px 24px rgba(29,151,108,0.12);
        }
        .ipt-w {
            flex: 1;
            min-width: 0;
            position: relative;
            display: flex;
            background: var(--surface-input);
            border: 1.5px solid var(--p-line);
            border-radius: 20px;
            transition: 0.4s cubic-bezier(0.2,0,0.2,1);
        }
        .ipt-w:focus-within { background: var(--surface-input-focus); border-color: #1d976c; box-shadow: 0 10px 30px rgba(29,151,108,0.08); transform: translateY(-2px); }
        #ipt {
            width: 100%;
            min-height: 56px;
            max-height: 248px;
            padding: 16px 56px 16px 22px;
            border: none;
            outline: none;
            background: transparent;
            font-size: 16px;
            line-height: 1.6;
            color: var(--text-main);
            resize: none;
            overflow-y: hidden;
            white-space: pre-wrap;
            word-break: break-word;
        }
        #ipt::placeholder { color: var(--text-muted); }
        #ipt::-webkit-scrollbar {
            width: 8px;
        }
        #ipt::-webkit-scrollbar-thumb {
            background: rgba(125, 141, 150, 0.34);
            border-radius: 999px;
        }
        .composer-fullscreen-btn {
            position: absolute;
            right: 10px;
            bottom: 10px;
            width: 34px;
            height: 34px;
            border-radius: 11px;
            border: none;
            background: var(--surface-soft);
            color: var(--text-secondary);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            pointer-events: none;
            transform: translateY(4px);
            transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
        }
        .input-area.is-raised .composer-fullscreen-btn,
        .main-pnl.composer-fullscreen .composer-fullscreen-btn {
            opacity: 1;
            pointer-events: auto;
            transform: translateY(0);
        }
        .composer-fullscreen-btn:hover {
            background: var(--surface-panel);
            color: var(--text-main);
            box-shadow: 0 8px 18px rgba(15,35,26,0.08);
        }
        .composer-fullscreen-btn svg {
            width: 16px;
            height: 16px;
        }
        .composer-fullscreen-btn .icon-collapse {
            display: none;
        }
        .composer-fullscreen-btn.is-active .icon-expand {
            display: none;
        }
        .composer-fullscreen-btn.is-active .icon-collapse {
            display: block;
        }
        .main-pnl.composer-fullscreen::after {
            content: "";
            position: absolute;
            inset: 0;
            background: rgba(8,14,18,0.24);
            backdrop-filter: blur(6px) saturate(130%);
            -webkit-backdrop-filter: blur(6px) saturate(130%);
            z-index: 40;
        }
        .main-pnl.composer-fullscreen .top-nav,
        .main-pnl.composer-fullscreen #chat-list {
            opacity: 0.2;
            filter: blur(1.5px);
            pointer-events: none;
            user-select: none;
            transition: opacity 0.22s ease;
        }
        .main-pnl.composer-fullscreen .input-area {
            position: absolute;
            inset: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
            z-index: 60;
            padding: 0;
            gap: 14px;
            align-items: flex-end;
        }
        .main-pnl.composer-fullscreen .composer {
            height: 100%;
            padding: 14px;
            border-radius: 24px;
            border: 1px solid var(--p-line);
            background: var(--surface-modal);
            box-shadow: 0 26px 68px rgba(10,24,30,0.2);
            backdrop-filter: blur(22px) saturate(160%);
            -webkit-backdrop-filter: blur(22px) saturate(160%);
        }
        .main-pnl.composer-fullscreen .composer-row {
            flex: 1;
            min-height: 0;
            align-items: stretch;
        }
        .main-pnl.composer-fullscreen .upload-btn,
        .main-pnl.composer-fullscreen .tool-toggle-search {
            align-self: flex-end;
        }
        .main-pnl.composer-fullscreen .ipt-w {
            flex: 1;
            min-height: 0;
            border-radius: 18px;
        }
        .main-pnl.composer-fullscreen #ipt {
            min-height: 0;
            max-height: none;
            height: 100% !important;
            padding: 18px 58px 18px 20px;
            overflow-y: auto;
        }
        .main-pnl.composer-fullscreen .btn {
            margin-bottom: 6px;
        }
        .btn {
            position: relative;
            overflow: hidden;
            background: var(--v-field);
            width: 56px;
            height: 56px;
            border-radius: 18px;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.24s ease, background 0.24s ease, box-shadow 0.24s ease, opacity 0.24s ease;
            flex-shrink: 0;
            box-shadow: 0 16px 36px rgba(29,151,108,0.22);
            touch-action: manipulation;
            -webkit-touch-callout: none;
            user-select: none;
            -webkit-user-select: none;
        }
        .btn::after {
            content: "";
            position: absolute;
            inset: 0;
            border-radius: inherit;
            border: 1px solid rgba(255,255,255,0.16);
            pointer-events: none;
        }
        .btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 18px 42px rgba(29,151,108,0.28);
        }
        .btn.is-pressing {
            transform: scale(0.96);
        }
        .btn[data-voice-state="recording"] {
            background: linear-gradient(180deg, #ef6b63 0%, #d94b5f 100%);
            box-shadow: 0 18px 40px rgba(217,75,95,0.32);
        }
        .btn[data-voice-state="finalizing"] {
            background: linear-gradient(180deg, #6f8790 0%, #506a75 100%);
            box-shadow: 0 16px 34px rgba(54,77,86,0.28);
        }
        .btn-icon {
            position: absolute;
            width: 24px;
            height: 24px;
            opacity: 0;
            transform: scale(0.86);
            transition: opacity 0.18s ease, transform 0.18s ease;
        }
        .btn-icon-send {
            opacity: 1;
            transform: scale(1);
        }
        .btn[data-voice-state="recording"] .btn-icon-send,
        .btn[data-voice-state="finalizing"] .btn-icon-send {
            opacity: 0;
            transform: scale(0.86);
        }
        .btn[data-voice-state="recording"] .btn-icon-voice {
            opacity: 1;
            transform: scale(1);
        }
        .btn-spinner {
            width: 22px;
            height: 22px;
            border-radius: 999px;
            border: 2px solid rgba(255,255,255,0.26);
            border-top-color: #fff;
            opacity: 0;
            transform: scale(0.82);
            transition: opacity 0.18s ease, transform 0.18s ease;
            animation: token-spin 0.8s linear infinite;
        }
        .btn[data-voice-state="finalizing"] .btn-spinner {
            opacity: 1;
            transform: scale(1);
        }
        .btn:disabled { opacity: 0.4; cursor: not-allowed; transform: scale(0.95); }

        /* ── 控制确认弹窗 ─────────────────────────────────────── */
        .modal-overlay {
            position: fixed; inset: 0;
            background: var(--overlay);
            backdrop-filter: blur(18px) saturate(160%);
            -webkit-backdrop-filter: blur(18px) saturate(160%);
            display: flex; align-items: center; justify-content: center;
            z-index: 1000; opacity: 0; pointer-events: none;
            transition: opacity 0.35s cubic-bezier(0.2,0,0.2,1);
        }
        .modal-overlay.visible { opacity: 1; pointer-events: all; }

        .modal-card {
            width: 92%; max-width: 540px;
            background: var(--surface-modal);
            border: 1.5px solid var(--p-line);
            border-radius: 28px;
            box-shadow: 0 60px 120px rgba(0,0,0,0.12), 0 8px 24px rgba(29,151,108,0.08);
            display: flex; flex-direction: column;
            overflow: hidden;
            max-height: calc(100dvh - 40px);
            transform: translateY(28px) scale(0.97); opacity: 0;
            transition: transform 0.4s cubic-bezier(0.1,0.9,0.2,1), opacity 0.35s;
        }
        .modal-overlay.visible .modal-card { transform: translateY(0) scale(1); opacity: 1; }

        .lightbox-overlay {
            position: fixed;
            inset: 0;
            z-index: 1100;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background: rgba(8, 14, 18, 0.76);
            backdrop-filter: blur(12px) saturate(130%);
            -webkit-backdrop-filter: blur(12px) saturate(130%);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.24s ease;
            cursor: zoom-out;
        }
        .lightbox-overlay.visible {
            opacity: 1;
            pointer-events: auto;
        }
        .lightbox-image {
            display: block;
            max-width: min(94vw, 1280px);
            max-height: min(90dvh, 920px);
            width: auto;
            height: auto;
            object-fit: contain;
            border-radius: 18px;
            border: 1px solid rgba(255,255,255,0.16);
            box-shadow: 0 28px 72px rgba(0,0,0,0.34);
            background: rgba(255,255,255,0.04);
            cursor: zoom-out;
        }

        .modal-header { padding: 26px 30px 20px; background: var(--modal-header-bg); border-bottom: 1px solid var(--border-faint); display: flex; align-items: flex-start; gap: 14px; }
        .modal-icon { width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0; background: var(--v-field); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(29,151,108,0.25); }
        .modal-title { font-size: 1.05rem; font-weight: 800; color: var(--text-strong); letter-spacing: -0.4px; }
        .modal-device { font-size: 0.72rem; font-family: var(--v-mono); color: var(--text-secondary); margin-top: 4px; letter-spacing: 0.5px; }
        .modal-ts { font-size: 0.68rem; font-family: var(--v-mono); color: var(--text-dim); margin-top: 2px; }

        .modal-body { padding: 22px 30px; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }

        .ctrl-card { border-radius: 18px; padding: 16px 20px; border: 1.5px solid var(--border-soft); display: flex; gap: 14px; align-items: flex-start; background: var(--surface-card); transition: background 0.2s; }
        .ctrl-card:hover { background: var(--surface-card-hover); }
        .ctrl-icon-wrap { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; }
        .ctrl-icon-water { background: linear-gradient(135deg,#e0f4ff,#b8e4ff); }
        .ctrl-icon-heat  { background: linear-gradient(135deg,#fff0e0,#ffd8b0); }
        .ctrl-info { flex: 1; }
        .ctrl-label  { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; margin-bottom: 4px; }
        .ctrl-action { font-size: 1rem; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 6px; }
        .ctrl-action.running { color: #1d976c; }
        .ctrl-action.stopped { color: #636e72; }
        .ctrl-action.alert   { color: #e17055; }
        .ctrl-reason { font-size: 0.85rem; color: var(--text-main); line-height: 1.65; }
        .ctrl-meta   { font-size: 0.72rem; font-family: var(--v-mono); color: var(--text-dim); margin-top: 8px; display: flex; gap: 12px; }

        .modal-footer { padding: 18px 30px 26px; display: flex; gap: 12px; justify-content: flex-end; border-top: 1px solid var(--border-faint); }
        .m-btn { padding: 13px 28px; border-radius: 14px; border: none; font-size: 0.9rem; font-weight: 700; cursor: pointer; transition: all 0.25s cubic-bezier(0.2,0,0.2,1); letter-spacing: -0.2px; }
        .m-btn-cancel  { background: var(--surface-code); color: var(--text-secondary); }
        .m-btn-cancel:hover { background: var(--cancel-bg); }
        .m-btn-confirm { background: var(--v-field); color: #fff; box-shadow: 0 8px 24px rgba(29,151,108,0.25); }
        .m-btn-confirm:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(29,151,108,0.32); }
        .m-btn-confirm:active { transform: translateY(0); }
        .m-btn-confirm:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

        /* 执行状态徽章 */
        .exec-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            margin-top: 8px;
            padding: 4px 8px;
            border-radius: 999px;
            font-family: inherit;
            font-size: 11px;
            line-height: 1.2;
            font-weight: 500;
            border: 1px solid;
            opacity: 0.8;
        }
        .exec-badge.is-toggle {
            cursor: pointer;
            appearance: none;
            -webkit-appearance: none;
            font-family: inherit;
            font-size: 11px;
            font-weight: 500;
            text-align: left;
            transition: opacity 0.18s ease, border-color 0.18s ease, background 0.18s ease;
        }
        .exec-badge.is-toggle::after {
            content: "▾";
            font-size: 8px;
            line-height: 1;
            opacity: 0.45;
            transition: transform 0.18s ease, opacity 0.18s ease;
        }
        .exec-badge.is-toggle:hover {
            opacity: 0.92;
        }
        .exec-badge.is-toggle.is-expanded::after {
            transform: rotate(180deg);
            opacity: 0.7;
        }
        .exec-badge.success { background: rgba(52,199,89,0.08);  color: #1d976c; border-color: rgba(52,199,89,0.2); }
        .exec-badge.fail    { background: rgba(255,59,48,0.07);  color: #c0392b; border-color: rgba(255,59,48,0.18); }
        .exec-badge.skipped { background: rgba(99,110,114,0.07); color: #636e72; border-color: rgba(99,110,114,0.18); }

        @media (max-width: 1100px) {
            body { padding: 12px; align-items: stretch; }
            .main-pnl {
                width: 100%;
                max-width: none;
                height: calc(100vh - 24px);
                height: calc(100dvh - 24px);
                border-radius: 24px;
            }
            .main-pnl { --history-width: 286px; }
            .top-nav { padding: 20px 24px 14px; align-items: flex-start; }
            .nav-right { width: 100%; justify-content: space-between; gap: 12px; min-width: 0; }
            .sensor-strip {
                width: 100%;
                flex: 1 1 100%;
                min-width: 0;
            }
            .sensor-cell {
                flex: 1 1 0;
                justify-content: center;
                padding: 10px 7px;
                gap: 4px;
            }
            .st-tag { min-width: 0; }
            #chat-list { padding: 28px 24px; }
            .cnt { max-width: 92%; }
            .input-area { padding: 20px 24px calc(24px + env(safe-area-inset-bottom, 0px)); }
            .pending-item {
                width: 72px;
                height: 72px;
            }
            .modal-overlay { padding: 16px; }
            .modal-card { width: 100%; }
        }

        @media (max-width: 760px) {
            body { padding: 0; }
            .main-pnl {
                --history-width: min(320px, calc(100% - 32px));
                width: 100%;
                height: 100vh;
                height: 100dvh;
                border-radius: 0;
                border-left: none;
                border-right: none;
                box-shadow: none;
            }
            .history-rail {
                position: absolute;
                inset: 0 auto 0 0;
                width: var(--history-width);
                transform: translateX(0);
                border-right: 1px solid var(--border-faint);
                background: var(--surface-modal);
                box-shadow: 0 30px 80px rgba(5,16,22,0.24);
                touch-action: pan-y;
                transition: transform 0.26s ease;
            }
            .history-rail.is-dragging {
                transition: none;
            }
            .main-pnl.sidebar-hidden .history-rail {
                width: var(--history-width);
                transform: translateX(-104%);
                border-right-color: var(--border-faint);
            }
            .main-pnl:not(.sidebar-hidden) .history-scrim {
                opacity: 1;
                pointer-events: auto;
                z-index: 20;
            }
            .main-pnl.sidebar-hidden .history-panel {
                opacity: 1;
                pointer-events: auto;
            }
            .app-shell { min-height: 0; }
            .top-nav {
                padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 12px;
                gap: 14px;
            }
            .history-panel-head {
                padding: 16px 16px 12px;
            }
            .history-list {
                padding: 10px 10px 14px;
            }
            .nav-left { width: 100%; }
            .logo-box {
                min-width: 0;
                flex: 1;
            }
            .logo-box h1 {
                font-size: 1.15rem;
                line-height: 1.2;
                word-break: break-word;
            }
            .logo-box p {
                font-size: 0.68rem;
                letter-spacing: 0.4px;
            }
            .nav-right {
                width: 100%;
                flex-direction: column;
                align-items: stretch;
                gap: 10px;
                min-width: 0;
            }
            .history-delete {
                opacity: 1;
                pointer-events: auto;
            }
            .sensor-strip {
                width: 100%;
                min-width: 0;
                flex-wrap: nowrap;
            }
            .sensor-cell {
                flex: 1 1 0;
                justify-content: center;
                padding: 9px 4px;
                gap: 3px;
            }
            .sensor-weather-cell { min-width: 0; }
            .sensor-icon { font-size: 11px; }
            .sensor-val { font-size: 11px; }
            .sensor-weather-val { font-size: 9px; letter-spacing: -0.45px; }
            .sensor-unit, .sensor-lbl { font-size: 8px; }
            .sensor-pop {
                width: min(320px, calc(100vw - 16px));
                padding: 12px 10px 10px;
            }
            .sensor-pop-chart,
            .sensor-pop-card,
            .sensor-pop-loading,
            .sensor-pop-empty {
                height: 144px;
            }
            .st-tag {
                display: none;
            }
            .sensor-pop-foot {
                align-items: center;
                gap: 10px;
            }
            .sensor-pop-source-wrap {
                flex-wrap: nowrap;
                gap: 6px;
            }
            #st-t {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            #chat-list { padding: 20px 16px; }
            .row { margin-bottom: 18px; }
            .cnt {
                max-width: 94%;
                padding: 14px 16px;
                font-size: 14px;
                line-height: 1.7;
            }
            .cnt pre {
                padding: 12px;
                margin: 10px 0;
                font-size: 12px;
            }
            .cnt table { font-size: 13px; }
            .cnt th, .cnt td { padding: 10px; }
            .input-area {
                padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
                gap: 10px;
                align-items: flex-end;
            }
            .input-area.is-voice-active {
                flex-wrap: wrap;
                align-items: stretch;
            }
            .input-area.is-voice-active .composer {
                flex: 1 1 100%;
                width: 100%;
            }
            .input-area.is-voice-active .btn {
                margin-left: auto;
            }
            .composer-row {
                gap: 10px;
            }
            .pending-media {
                gap: 8px;
            }
            .pending-item {
                width: 64px;
                height: 64px;
                border-radius: 16px;
            }
            .voice-panel {
                padding: 12px 13px;
                border-radius: 18px;
                gap: 9px;
            }
            .voice-panel-head {
                gap: 10px;
                align-items: center;
            }
            .voice-panel-meta {
                gap: 8px;
            }
            .voice-panel-cancel {
                min-width: 48px;
                height: 28px;
            }
            .voice-panel-progress {
                padding: 9px 10px;
                gap: 7px;
            }
            .voice-panel-transcript {
                min-height: 42px;
                padding: 11px 12px;
                font-size: 13px;
            }
            .mode-switch {
                gap: 3px;
                padding: 3px;
                border-radius: 14px;
                max-width: 204px;
            }
            .mode-switch-btn {
                min-height: 30px;
                padding: 0 12px;
                font-size: 11px;
                text-align: center;
            }
            .upload-btn {
                width: 46px;
                height: 46px;
                border-radius: 14px;
            }
            .ipt-w { border-radius: 16px; }
            #ipt {
                min-height: 50px;
                padding: 14px 48px 14px 16px;
            }
            .composer-fullscreen-btn {
                right: 8px;
                bottom: 8px;
                width: 30px;
                height: 30px;
                border-radius: 10px;
            }
            .composer-fullscreen-btn svg {
                width: 14px;
                height: 14px;
            }
            .main-pnl.composer-fullscreen .input-area {
                inset: calc(10px + env(safe-area-inset-top, 0px)) 10px calc(10px + env(safe-area-inset-bottom, 0px));
                gap: 10px;
            }
            .main-pnl.composer-fullscreen .composer {
                height: auto;
                max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
                padding: 10px;
                border-radius: 18px;
                gap: 8px;
            }
            .main-pnl.composer-fullscreen .mode-switch {
                max-width: 100%;
            }
            .main-pnl.composer-fullscreen .composer-row {
                flex: 0 0 auto;
                align-items: flex-end;
            }
            .main-pnl.composer-fullscreen .ipt-w {
                height: clamp(220px, 56dvh, 520px);
            }
            .main-pnl.composer-fullscreen #ipt {
                min-height: 0;
                max-height: none;
                padding: 14px 46px 14px 14px;
                font-size: 15px;
                height: 100% !important;
                overflow-y: auto;
            }
            .main-pnl.composer-fullscreen .btn {
                margin-bottom: 0;
            }
            .btn {
                width: 50px;
                height: 50px;
                border-radius: 16px;
            }
            .btn svg {
                width: 20px;
                height: 20px;
            }
            .modal-overlay {
                padding: 12px;
                align-items: flex-end;
            }
            .modal-card {
                max-width: none;
                max-height: min(80dvh, 680px);
                border-radius: 24px 24px 18px 18px;
            }
            .modal-header {
                padding: 20px 18px 16px;
                gap: 12px;
            }
            .modal-icon {
                width: 40px;
                height: 40px;
                border-radius: 12px;
            }
            .modal-body {
                padding: 18px;
                gap: 12px;
            }
            .ctrl-card {
                padding: 14px;
                gap: 12px;
            }
            .ctrl-meta {
                flex-direction: column;
                gap: 4px;
            }
            .modal-footer {
                padding: 14px 18px calc(16px + env(safe-area-inset-bottom, 0px));
                gap: 10px;
                flex-direction: column-reverse;
            }
            .m-btn {
                width: 100%;
                padding: 14px 18px;
            }
        }

        @media (max-width: 760px) and (orientation: landscape) and (max-height: 560px) {
            .top-nav {
                padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 6px;
                gap: 8px;
                flex-wrap: nowrap;
                align-items: center;
            }
            .nav-left {
                width: auto;
                flex: 0 0 auto;
                gap: 8px;
            }
            .logo-box h1 {
                font-size: 0.96rem;
            }
            .logo-box p {
                display: none;
            }
            .nav-right {
                width: auto;
                min-width: 0;
                flex: 1 1 auto;
                flex-direction: row;
                align-items: center;
                justify-content: stretch;
                gap: 6px;
            }
            .sensor-strip {
                flex: 1 1 auto;
                min-width: 0;
                display: flex;
                flex-wrap: nowrap;
                overflow: hidden;
            }
            .sensor-cell {
                flex: 1 1 0;
                min-width: 0;
                padding: 7px 3px;
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 2px;
                text-align: center;
            }
            .st-tag {
                display: none;
            }
            .sensor-icon { font-size: 10px; }
            .sensor-val {
                font-size: 10px;
                line-height: 1;
                margin-left: 0;
            }
            .sensor-unit {
                font-size: 8px;
                line-height: 1;
                margin-left: 0;
            }
            .sensor-lbl {
                font-size: 8px;
                line-height: 1;
                margin-left: 0;
            }
            .sensor-weather-val {
                font-size: 8px;
                letter-spacing: -0.5px;
            }
            .history-toggle-btn {
                width: 36px;
                height: 36px;
            }
            #chat-list {
                padding: 10px 12px;
            }
            .row {
                margin-bottom: 10px;
            }
            .cnt {
                max-width: 100%;
                padding: 12px;
                font-size: 13px;
                line-height: 1.55;
            }
            .input-area {
                padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
                gap: 6px;
            }
            .composer-row {
                gap: 6px;
            }
            .mode-switch {
                gap: 2px;
                padding: 2px;
                max-width: 180px;
            }
            .mode-switch-btn {
                min-height: 26px;
                padding: 0 9px;
                font-size: 10px;
                border-radius: 10px;
            }
            .pending-item {
                width: 56px;
                height: 56px;
            }
            .voice-panel {
                padding: 11px 12px;
                border-radius: 16px;
            }
            .voice-panel-head {
                flex-wrap: wrap;
                align-items: center;
                gap: 8px 10px;
            }
            .voice-panel-meta {
                width: 100%;
                justify-content: space-between;
            }
            .voice-panel-progress {
                padding: 9px 10px;
            }
            .voice-panel-transcript {
                min-height: 44px;
                max-height: 128px;
                font-size: 13px;
                line-height: 1.6;
            }
            .upload-btn {
                width: 40px;
                height: 40px;
            }
            #ipt {
                min-height: 42px;
                padding: 10px 42px 10px 12px;
                font-size: 14px;
            }
            .composer-fullscreen-btn {
                right: 7px;
                bottom: 7px;
                width: 28px;
                height: 28px;
            }
            .main-pnl.composer-fullscreen .ipt-w {
                height: clamp(150px, 48dvh, 320px);
            }
            .btn {
                width: 42px;
                height: 42px;
            }
        }

        @keyframes p-in   { from{opacity:0;transform:translateY(40px)}  to{opacity:1;transform:translateY(0)} }
        @keyframes row-in { from{opacity:0;transform:translateY(20px)}  to{opacity:1;transform:translateY(0)} }
        @keyframes blink  { 0%,100%{opacity:1} 50%{opacity:0.3} }
        @keyframes token-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
        @keyframes voice-pulse {
            0% {
                box-shadow: 0 0 0 0 rgba(239,91,91,0.3);
            }
            70% {
                box-shadow: 0 0 0 10px rgba(239,91,91,0);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(239,91,91,0);
            }
        }
        @keyframes voice-pulse-soft {
            0% {
                box-shadow: 0 0 0 0 rgba(227,163,63,0.26);
            }
            70% {
                box-shadow: 0 0 0 9px rgba(227,163,63,0);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(227,163,63,0);
            }
        }
        @media (prefers-reduced-motion: reduce) {
            .bubble-json-panel,
            .exec-badge.is-toggle,
            .exec-badge.is-toggle::after,
            .voice-panel.is-starting .voice-panel-dot,
            .voice-panel.is-recording .voice-panel-dot {
                animation: none !important;
                transition: none !important;
            }
        }
    
