        :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: "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: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: wrap; }

        /* 传感器状态条 */
        .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%;
        }
        .sensor-cell {
            display: flex; align-items: center; gap: 5px;
            padding: 8px 13px;
            border-right: 1px solid var(--border-soft);
            min-width: 0;
            position: relative;
            cursor: pointer;
            transition: background 0.22s ease, transform 0.22s ease;
        }
        .sensor-cell:last-child { border-right: none; }
        .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; }
        .sensor-unit { color: var(--text-dim); font-size: 10px; margin-left: 1px; }
        .sensor-lbl  { color: var(--text-muted); font-size: 10px; margin-left: 2px; }

        .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;
        }
        .sensor-pop-title {
            font-size: 12px;
            font-weight: 800;
            letter-spacing: 0.2px;
            color: var(--text-strong);
        }
        .sensor-pop-sub {
            font-size: 10px;
            color: var(--text-muted);
            font-family: var(--v-mono);
            white-space: nowrap;
        }
        .sensor-pop-chart {
            width: 100%;
            height: 156px;
        }
        .sensor-pop-card {
            width: 100%;
            height: 156px;
            border-radius: 14px;
            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-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-card-copy {
            color: var(--text-main);
            font-size: 12px;
            line-height: 1.6;
        }
        .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: space-between;
            align-items: center;
            gap: 12px;
        }
        .sensor-pop-meta {
            font-size: 10px;
            color: var(--text-muted);
            font-family: var(--v-mono);
        }
        .sensor-pop-source {
            font-size: 10px;
            color: var(--text-secondary);
            text-decoration: none;
            transition: color 0.2s ease;
        }
        .sensor-pop-source:hover {
            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; }

        /* 连接状态标签 */
        .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%;
            border: none;
            background: transparent;
            padding: 14px 50px 14px 14px;
            text-align: left;
            color: inherit;
            cursor: pointer;
            display: block;
        }
        .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;
            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 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; }
        .cnt pre code { background: transparent; padding: 0; color: inherit; }
        .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; }
        .composer { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
        .composer-row { display: flex; gap: 12px; align-items: center; }
        .pending-media {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }
        .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;
        }
        .ipt-w { flex: 1; 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%; padding: 16px 22px; border: none; outline: none; background: transparent; font-size: 16px; color: var(--text-main); }
        #ipt::placeholder { color: var(--text-muted); }
        .btn { background: var(--v-field); width: 56px; height: 56px; border-radius: 18px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.3s; flex-shrink: 0; }
        .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: 7px; margin-top: 10px; padding: 7px 14px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; border: 1px solid; }
        .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; }
            .sensor-strip {
                width: 100%;
                flex: 1 1 100%;
            }
            .sensor-cell {
                flex: 1 1 0;
                justify-content: center;
                padding: 10px 8px;
            }
            .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;
            }
            .history-delete {
                opacity: 1;
                pointer-events: auto;
            }
            .sensor-strip { width: 100%; }
            .sensor-cell {
                flex: 1 1 0;
                justify-content: center;
                padding: 10px 8px;
            }
            .sensor-icon { font-size: 12px; }
            .sensor-val { font-size: 12px; }
            .sensor-unit, .sensor-lbl { font-size: 9px; }
            .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;
            }
            #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;
            }
            .composer-row {
                gap: 10px;
            }
            .pending-media {
                gap: 8px;
            }
            .pending-item {
                width: 64px;
                height: 64px;
                border-radius: 16px;
            }
            .upload-btn {
                width: 46px;
                height: 46px;
                border-radius: 14px;
            }
            .ipt-w { border-radius: 16px; }
            #ipt { padding: 14px 16px; }
            .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: grid;
                grid-template-columns: repeat(3, minmax(0, 1fr));
                overflow: hidden;
            }
            .sensor-cell {
                min-width: 0;
                padding: 7px 4px;
                display: grid;
                grid-template-columns: auto auto;
                grid-template-rows: auto auto;
                justify-content: center;
                align-content: center;
                gap: 1px 2px;
                text-align: center;
            }
            .st-tag {
                display: none;
            }
            .sensor-icon {
                display: none;
            }
            .sensor-val,
            .sensor-unit,
            .sensor-lbl {
                display: block;
                margin-left: 0;
                white-space: nowrap;
                justify-self: center;
            }
            .sensor-val {
                grid-column: 1;
                grid-row: 1;
                font-size: 11px;
                line-height: 1;
            }
            .sensor-unit {
                grid-column: 2;
                grid-row: 1;
                font-size: 8px;
                line-height: 1;
                align-self: end;
            }
            .sensor-lbl {
                grid-column: 1 / span 2;
                grid-row: 2;
                font-size: 8px;
                line-height: 1.05;
            }
            .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;
            }
            .pending-item {
                width: 56px;
                height: 56px;
            }
            .upload-btn {
                width: 40px;
                height: 40px;
            }
            #ipt {
                padding: 10px 12px;
                font-size: 14px;
            }
            .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); } }
    
