:root {
    --bg: #ffffff;
    --bg-message-user: rgba(0, 0, 0, 0.06);
    --bg-message-ai: rgba(0, 0, 0, 0.04);
    --bg-input: rgba(255, 255, 255, 0.8);
    --bg-sidebar: rgba(250, 250, 250, 0.95);
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-active: rgba(0, 0, 0, 0.08);
    --bg-code: rgba(0, 0, 0, 0.06);
    --text: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #555555;
    --border: rgba(0, 0, 0, 0.08);
    --radius: 24px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 180ms ease;
}

[data-theme="dark"] {
    --bg: #000000;
    --bg-message-user: rgba(255, 255, 255, 0.08);
    --bg-message-ai: rgba(255, 255, 255, 0.05);
    --bg-input: rgba(20, 20, 20, 0.8);
    --bg-sidebar: rgba(10, 10, 10, 0.95);
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-active: rgba(255, 255, 255, 0.08);
    --bg-code: rgba(255, 255, 255, 0.06);
    --text: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #666666;
    --border: rgba(255, 255, 255, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    height: -webkit-fill-available;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.workspace {
    display: flex;
    width: 100vw;
    height: -webkit-fill-available;
    height: 100dvh;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.workspace.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    flex: 2;
    min-width: 0;
    height: 100%;
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    transition: transform var(--transition);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 12px;
    padding-top: max(16px, env(safe-area-inset-top));
}

.new-chat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 12px;
}

.new-chat:hover {
    background: var(--bg-hover);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-list::-webkit-scrollbar {
    width: 4px;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.conv-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    gap: 6px;
}

.conv-item:hover {
    background: var(--bg-hover);
}

.conv-item.active {
    background: var(--bg-active);
}

.conv-name {
    flex: 1;
    font-size: 16px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-item.active .conv-name {
    color: var(--text);
}

.conv-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.conv-item:hover .conv-actions {
    opacity: 1;
}

.conv-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 11px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.conv-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Canvas */
.canvas {
    flex: 5;
    min-width: 0;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: flex var(--transition);
}

.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 20px;
    padding-top: 0;
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
    justify-content: center;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Edge spacing - dynamic */
.messages::before,
.messages::after {
    content: '';
    display: block;
    height: 0;
}

/* Messages */
.message {
    display: flex;
    padding: 12px 0;
    animation: fadeIn 200ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    justify-content: flex-end;
}

.message.peer {
    justify-content: flex-start;
}

.message-surface {
    max-width: 80%;
    min-width: 0;
    padding: 16px 18px;
    border-radius: var(--radius);
    font-size: 17px;
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    box-sizing: border-box;
}

.message.user .message-surface {
    background: var(--bg-message-user);
    border-bottom-right-radius: var(--radius-xs);
}

.message.peer .message-surface {
    background: var(--bg-message-ai);
    border-bottom-left-radius: var(--radius-xs);
}

/* Streaming indicator */
.streaming-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-tertiary);
    font-size: 14px;
    padding: 14px 18px;
}

.streaming-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: pulse 1.2s ease infinite;
}

.streaming-dot:nth-child(2) { animation-delay: 0.2s; }
.streaming-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* Empty state */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.empty-state h1 {
    font-size: 64px;
    font-weight: 200;
    color: #999999;
    letter-spacing: -3px;
    user-select: none;
    -webkit-user-select: none;
}

/* Floating Input */
.input-float {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: calc((2 / 7) * 100vw);
    right: 16px;
    z-index: 100;
    pointer-events: none;
}

.input-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(128, 128, 128, 0.05);
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
    border-radius: 50px;
    border: 1px solid rgba(128, 128, 128, 0.06);
    pointer-events: all;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05), 0 1px 4px rgba(0, 0, 0, 0.03);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.input-inner:hover {
    background: rgba(128, 128, 128, 0.12);
    border-color: rgba(128, 128, 128, 0.15);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.input-inner:focus-within {
    background: rgba(128, 128, 128, 0.15);
    border-color: rgba(128, 128, 128, 0.2);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
}

.input-inner:focus-within {
    border-color: var(--text-tertiary);
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 17px;
    line-height: 1.5;
    resize: none;
    max-height: 160px;
    font-family: inherit;
    padding: 4px 0;
}

#messageInput::placeholder {
    color: var(--text-tertiary);
}

#sendBtn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--text);
    color: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#sendBtn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

#sendBtn:active:not(:disabled) {
    transform: scale(0.95);
}

#sendBtn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#sendBtn:not(:disabled):hover {
    opacity: 0.8;
}

/* Markdown content */
.message-surface,
.message-surface *:not(.code-copy-btn):not(button) {
    user-select: text !important;
    -webkit-user-select: text !important;
    -webkit-touch-callout: default !important;
}

.message-surface .code-copy-btn,
.message-surface button {
    user-select: none !important;
    -webkit-user-select: none !important;
}

.message-surface p {
    margin-bottom: 16px;
}

.message-surface p:last-child {
    margin-bottom: 0;
}

.message-surface h1,
.message-surface h2,
.message-surface h3,
.message-surface h4 {
    margin: 20px 0 10px;
    font-weight: 600;
}

.message-surface h1 { font-size: 20px; }
.message-surface h2 { font-size: 18px; }
.message-surface h3 { font-size: 16px; }

.message-surface ul,
.message-surface ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-surface li {
    margin: 6px 0;
}

.message-surface code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-code);
}

.message-surface pre {
    background: var(--bg-code);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    max-width: 100%;
    position: relative;
}

.message-surface pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.6;
}

.message-surface blockquote {
    border-left: 2px solid var(--border);
    padding-left: 14px;
    margin: 16px 0;
    color: var(--text-secondary);
}

.message-surface table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    display: block;
    overflow-x: auto;
}

.message-surface th,
.message-surface td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.message-surface th {
    background: var(--bg-code);
    font-weight: 600;
}

/* Code block copy button */
.code-block-wrapper {
    position: relative;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition);
}

.code-block-wrapper:hover .code-copy-btn {
    opacity: 1;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 200;
        border-right: none;
    }

    .sidebar.open {
        transform: translateX(0);
        border-right: 1px solid var(--border);
    }

    .canvas {
        width: 100vw;
        min-height: 0;
    }

    .messages {
        padding: 0 16px;
        padding-top: 15vh;
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .message-surface {
        max-width: 90%;
        min-width: 60%;
    }

    .input-float {
        left: 16px;
        right: 16px;
        bottom: max(20px, env(safe-area-inset-bottom));
    }

    .empty-state h1 {
        font-size: 48px;
        color: #666666;
    }

    .settings-content {
        max-width: 100%;
        padding: 20px;
    }

    .theme-options,
    .lang-options {
        gap: 6px;
    }

    .theme-option,
    .lang-option {
        padding: 12px 6px;
        font-size: 12px;
    }

    /* 移动端右侧面板：全屏无边，右滑呼出 */
    .right-panel {
        position: fixed;
        inset: 0;
        z-index: 400;
        transform: translateX(100%);
        transition: transform var(--transition);
    }

    .right-panel.open {
        transform: translateX(0);
    }

    .right-panel-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .right-panel-content {
        position: relative;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg);
        border-left: none;
    }

    .right-panel-content svg {
        width: 48px;
        height: 48px;
        color: var(--text-tertiary);
        opacity: 0.5;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Settings Button */
.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 8px auto 0;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.settings-btn svg {
    width: 18px;
    height: 18px;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.settings-panel.open {
    opacity: 1;
    pointer-events: all;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.settings-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 70vh;
    background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 24px;
    transform: translateY(100%);
    transition: transform var(--transition);
    overflow-y: auto;
}

.settings-panel.open .settings-content {
    transform: translateY(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.settings-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.settings-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section label {
    display: block;
    margin-bottom: 12px;
}

.settings-section:last-child {
    margin-bottom: 24px;
}

/* User Info Section */
.settings-user-info {
    padding: 12px 14px;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 24px;
}

.user-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.user-info-row + .user-info-row {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, rgba(128, 128, 128, 0.15));
}

.user-info-lock-icon {
    flex-shrink: 0;
    opacity: 0.5;
    color: var(--text-secondary);
}

.user-info-address {
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background 0.15s;
}

.user-info-address:hover {
    background: var(--bg-active, rgba(128, 128, 128, 0.1));
}

.user-info-address:active {
    background: var(--bg-active, rgba(128, 128, 128, 0.18));
}

.user-info-address-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
}

.user-info-pay-label {
    opacity: 0.5;
    font-size: 12px;
    color: var(--text-secondary);
}

.user-info-pay-value {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    color: var(--text);
    opacity: 0.8;
}

.settings-section-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.theme-options,
.lang-options {
    display: flex;
    gap: 8px;
}

.theme-option,
.lang-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
}

.theme-option:hover,
.lang-option:hover {
    background: var(--bg-hover);
}

.theme-option.active,
.lang-option.active {
    border-color: var(--text);
    color: var(--text);
    background: var(--bg-active);
}

.theme-option svg {
    width: 20px;
    height: 20px;
}

/* ═══════════════════════════════════════════════════════════════════
   Right Panel — 右侧面板
   ═══════════════════════════════════════════════════════════════════ */

/* 电脑端：默认隐藏，展开时 workspace 变为三栏 2:5:3 */
.right-panel {
    flex: 0;
    min-width: 0;
    overflow: hidden;
    transition: flex var(--transition);
}

.workspace.has-right-panel .right-panel {
    flex: 3;
    min-width: 0;
}

.workspace.has-right-panel .sidebar {
    flex: 2;
}

.workspace.has-right-panel .canvas {
    flex: 5;
}

/* 面板内部：backdrop + content 结构，复制设置页视觉风格 */
.right-panel-backdrop {
    display: none;
}

.right-panel-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-left: none;
}

/* 锁图标 */
.right-panel-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-message-user);
    color: var(--text);
}

.right-panel-content svg {
    width: 48px;
    height: 48px;
    color: var(--text);
    opacity: 1;
}

/* High contrast */
@media (prefers-contrast: high) {
    :root {
        --bg-message-user: rgba(0, 0, 0, 0.12);
        --bg-message-ai: rgba(0, 0, 0, 0.08);
        --border: rgba(0, 0, 0, 0.2);
    }

    [data-theme="dark"] {
        --bg-message-user: rgba(255, 255, 255, 0.15);
        --bg-message-ai: rgba(255, 255, 255, 0.1);
        --border: rgba(255, 255, 255, 0.2);
    }
}

/* ─── Status Layer ─────────────────────────────────────────────── */
/* 全局状态显示层 — 应用唯一的状态通知入口 */
/* 由 showStatus() 函数动态创建，后端大模型可通过 postMessage 调用 */

.status-layer {
    position: fixed;
    top: env(safe-area-inset-top, 16px);
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(40px) saturate(120%);
    -webkit-backdrop-filter: blur(40px) saturate(120%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
    opacity: 0;
    transition: opacity 240ms ease, transform 240ms ease;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.status-layer--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* 水滴呼吸圆点 */
.status-dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    animation: status-dot-breathe 2.4s ease-in-out infinite;
}

@keyframes status-dot-breathe {
    0%, 100% {
        opacity: 0.35;
        transform: scale(1);
    }
    50% {
        opacity: 0.85;
        transform: scale(1.15);
    }
}

/* 文字 */
.status-text {
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    color: rgba(0, 0, 0, 0.75);
    letter-spacing: 0.01em;
}

/* ─── 暗色模式 ─────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .status-layer {
        background: rgba(30, 30, 30, 0.78);
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(255, 255, 255, 0.04);
    }

    .status-text {
        color: rgba(255, 255, 255, 0.85);
    }
}

/* 手动主题切换支持 — 亮色主题显式覆盖（解决设备暗模式下媒体查询冲突） */
[data-theme="light"] .status-layer {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .status-text {
    color: rgba(0, 0, 0, 0.75);
}

[data-theme="light"] .status-layer[role="status"]:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

/* 手动主题切换支持 — 暗色主题 */
[data-theme="dark"] .status-layer {
    background: rgba(30, 30, 30, 0.78);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .status-text {
    color: rgba(255, 255, 255, 0.85);
}

/* ─── 减少动画偏好 ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .status-layer {
        transition: opacity 120ms ease;
    }

    .status-dot {
        animation: none;
        opacity: 0.7;
    }
}

/* ─── T9JU 节点状态胶囊增强 ──────────────────────────────────────── */
/* 节点胶囊点击反馈 */
.status-layer[role="status"]:hover {
    transform: translateX(-50%) translateY(0) scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.status-layer[role="status"]:active {
    transform: translateX(-50%) translateY(0) scale(0.98);
    transition: transform 80ms ease;
}

[data-theme="dark"] .status-layer[role="status"]:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
}

/* 终端绿呼吸圆点增强 */
.status-dot[style*="#4cd964"],
.status-dot[style*="rgb(76, 217, 100)"] {
    box-shadow: 0 0 6px rgba(76, 217, 100, 0.4);
}

/* ═══════════════════════════════════════════════════════════════════
   连通遮罩层 - 唯一入口
   ═══════════════════════════════════════════════════════════════════ */

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.login-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 36px 32px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
    max-width: 360px;
    width: calc(100vw - 48px);
    animation: loginCardIn 0.5s ease;
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-message-user);
    color: var(--text);
    margin-bottom: 20px;
}

.login-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 8px;
    letter-spacing: 0.02em;
}

.login-desc {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0 0 28px;
}

.login-btn-enter {
    width: 100%;
    padding: 12px 0;
    border: none;
    border-radius: var(--radius-xs);
    background: var(--text);
    color: var(--bg);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition);
}

.login-btn-enter:hover {
    opacity: 0.85;
}

.login-btn-enter:active {
    opacity: 0.7;
}

.login-btn-enter.loading {
    pointer-events: none;
    opacity: 0.6;
}

.login-divider {
    width: 100%;
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.login-create-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.login-create-hint {
    font-size: 13px;
    color: var(--text-tertiary);
}

.login-btn-create {
    padding: 8px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.login-btn-create:hover {
    border-color: var(--text-tertiary);
    color: var(--text);
}

.login-btn-create:active {
    background: var(--bg-hover);
}

/* ═══════════════════════════════════════════════════════════════════
   创建通行密钥页面
   ═══════════════════════════════════════════════════════════════════ */

.create-key-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.create-key-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.create-key-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 36px 32px 28px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
    max-width: 360px;
    width: calc(100vw - 48px);
    animation: loginCardIn 0.4s ease;
}

.create-key-back {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.create-key-back:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.create-key-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-message-user);
    color: var(--text);
    margin-bottom: 16px;
}

.create-key-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 6px;
}

.create-key-rp {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    font-family: monospace;
    letter-spacing: 0.5px;
}

.create-key-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0 0 24px;
    text-align: center;
    line-height: 1.5;
}

.create-key-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
}

.create-key-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.create-key-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.create-key-field input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-message-ai);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.create-key-field input:focus {
    border-color: var(--text-tertiary);
}

.create-key-field input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.create-key-btn {
    width: 100%;
    padding: 12px 0;
    margin-bottom: 24px;
    border: none;
    border-radius: var(--radius-xs);
    background: var(--text);
    color: var(--bg);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition);
}

.create-key-btn:hover {
    opacity: 0.85;
}

.create-key-btn:active {
    opacity: 0.7;
}

.create-key-note {
    margin: 16px 0 0;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ─── 暗色主题微调 ─────────────────────────────────────────────── */
[data-theme="dark"] .login-overlay,
[data-theme="dark"] .create-key-overlay {
    background: rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .login-card,
[data-theme="dark"] .create-key-card {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

/* ─── 减少动画偏好 ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .login-card,
    .create-key-card {
        animation: none;
    }

    .login-overlay,
    .create-key-overlay {
        transition: opacity 120ms ease, visibility 120ms ease;
    }
}


/* Blocks 组件样式（节点服务展示：文本/卡片/列表） */
.block-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.block-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin: 8px 0;
    background: var(--bg);
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.block-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.block-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.block-card-image {
    max-width: 100%;
    border-radius: var(--radius-xs);
    margin-bottom: 10px;
    display: block;
}

.block-card-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 100%;
}

.block-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--transition);
}

.block-btn:hover {
    background: var(--bg-hover);
}

.block-btn:active {
    background: var(--bg-active);
}

.block-list {
    margin: 8px 0;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.block-list-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.block-list-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    transition: background var(--transition);
}

.block-list-item:hover {
    background: var(--bg-hover);
}

.block-list-item:active {
    background: var(--bg-active);
}

/* Blocks 组件禁用状态（节点断开时） */
.block-btn-disabled,
.block-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.block-list-item-disabled,
.block-list-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
