    :root {
      --bg-deep: #041824;
      --bg-mid: #0a3050;
      --bg-light: #15608a;
      --surface: rgba(255, 255, 255, 0.09);
      --surface2: rgba(255, 255, 255, 0.14);
      --glass: rgba(255, 255, 255, 0.06);
      --border: rgba(135, 206, 235, 0.22);
      --border-light: rgba(255, 255, 255, 0.28);
      --text: #ecf8ff;
      --text-muted: #7eb8d4;
      --primary: #28b8e8;
      --primary-light: #6dd5fa;
      --primary-dark: #1488b8;
      --primary-glow: rgba(40, 184, 232, 0.35);
      --success: #34d399;
      --danger: #f87171;
      --warning: #fbbf24;
      --radius: 14px;
      --shadow: 0 8px 32px rgba(0, 20, 45, 0.45);
      --btn-highlight: rgba(255, 255, 255, 0.45);
      --btn-shadow: rgba(0, 25, 50, 0.55);
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
      background:
        radial-gradient(ellipse 120% 80% at 10% -10%, rgba(45, 180, 220, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse 90% 60% at 90% 10%, rgba(20, 120, 180, 0.28) 0%, transparent 50%),
        radial-gradient(ellipse 70% 50% at 50% 100%, rgba(10, 80, 130, 0.4) 0%, transparent 60%),
        linear-gradient(165deg, var(--bg-deep) 0%, var(--bg-mid) 45%, #0c4a6e 100%);
      background-attachment: fixed;
      color: var(--text);
      min-height: 100vh;
      min-height: 100dvh;
      line-height: 1.5;
    }

    .app-root:not([hidden]) {
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      min-height: 100dvh;
    }

    .app-header {
      background: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.06) 100%);
      backdrop-filter: blur(24px) saturate(180%);
      -webkit-backdrop-filter: blur(24px) saturate(180%);
      border-bottom: 1px solid var(--border);
      padding: 14px 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      flex-wrap: wrap;
      position: sticky;
      top: 0;
      z-index: 100;
      box-shadow: 0 4px 24px rgba(0, 20, 50, 0.25), inset 0 1px 0 rgba(255,255,255,0.12);
    }

    .app-header h1 {
      font-size: 1.35rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 10px;
      letter-spacing: -0.02em;
    }

    .app-logo {
      width: 38px;
      height: 38px;
      object-fit: contain;
      border-radius: 10px;
      filter: drop-shadow(0 2px 8px rgba(0, 40, 80, 0.35));
    }

    .app-header h1 span {
      background: linear-gradient(135deg, #a5f3fc 0%, var(--primary-light) 40%, var(--primary) 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .api-config {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      padding: 6px 12px;
      border-radius: 20px;
      background: rgba(255,255,255,0.06);
      border: 1px solid var(--border);
      transition: background .2s;
    }

    .api-config:hover { background: rgba(255,255,255,0.1); }

    .conn-text { font-size: 0.82rem; color: var(--text-muted); }

    .tabs {
      display: flex;
      gap: 6px;
      padding: 10px 24px 0;
      background: rgba(255,255,255,0.04);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-bottom: 1px solid var(--border);
      overflow-x: auto;
    }

    .tab-btn {
      padding: 10px 18px;
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 0.9rem;
      border-bottom: 2px solid transparent;
      transition: all .2s;
      white-space: nowrap;
      border-radius: 10px 10px 0 0;
    }

    .tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
    .tab-btn.active {
      color: var(--primary-light);
      border-bottom-color: var(--primary);
      background: rgba(40, 184, 232, 0.1);
    }

    .main {
      padding: 24px;
      max-width: 1400px;
      margin: 0 auto;
      width: 100%;
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
    }

    .panel { display: none; }
    .panel.active { display: block; }
    #panel-chat.panel.active {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
    }

    .card {
      background: linear-gradient(160deg, rgba(255,255,255,0.13) 0%, rgba(255,255,255,0.05) 100%);
      backdrop-filter: blur(20px) saturate(160%);
      -webkit-backdrop-filter: blur(20px) saturate(160%);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 20px;
      margin-bottom: 16px;
      box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.12);
    }

    .card-title {
      font-size: 1rem;
      font-weight: 600;
      margin-bottom: 16px;
      padding-bottom: 12px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

    @media (max-width: 900px) {
      .grid-2, .grid-3 { grid-template-columns: 1fr; }
    }

    .form-group { margin-bottom: 14px; }
    .form-group label {
      display: block;
      font-size: 0.82rem;
      color: var(--text-muted);
      margin-bottom: 6px;
    }

    .field-hint {
      display: block;
      font-size: 0.75rem;
      font-weight: 400;
      color: rgba(126, 184, 212, 0.75);
      margin-top: 3px;
      line-height: 1.4;
    }

    input, textarea, select {
      width: 100%;
      padding: 10px 14px;
      background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.04) 100%);
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--text);
      font-size: 0.9rem;
      font-family: inherit;
      box-shadow: inset 0 2px 6px rgba(0, 20, 50, 0.2), 0 1px 0 rgba(255,255,255,0.08);
    }

    textarea { resize: vertical; min-height: 80px; }
    input:focus, textarea:focus, select:focus {
      outline: none;
      border-color: var(--primary-light);
      box-shadow: inset 0 2px 6px rgba(0, 20, 50, 0.2), 0 0 0 3px var(--primary-glow);
    }

    .btn {
      padding: 9px 18px;
      border-radius: 12px;
      cursor: pointer;
      font-size: 0.85rem;
      font-weight: 600;
      transition: all .15s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      border: 1px solid var(--border-light);
      background: linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.08) 48%, rgba(0,30,60,0.12) 100%);
      box-shadow:
        0 1px 0 var(--btn-highlight) inset,
        0 -1px 0 rgba(0,0,0,0.12) inset,
        0 4px 14px var(--btn-shadow),
        0 1px 3px rgba(0,0,0,0.25);
      color: var(--text);
      text-shadow: 0 1px 1px rgba(0,20,50,0.35);
      position: relative;
    }

    .btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(0.3); }
    .btn:not(:disabled):active { transform: translateY(1px); filter: brightness(0.95); }

    .btn-primary {
      background: linear-gradient(180deg, #7ee8ff 0%, var(--primary) 42%, var(--primary-dark) 100%);
      color: #fff;
      border-color: rgba(255,255,255,0.4);
      text-shadow: 0 1px 2px rgba(0,60,90,0.5);
    }

    .btn-primary:hover:not(:disabled) {
      background: linear-gradient(180deg, #9ef0ff 0%, #3ecbf0 42%, #1a9fd0 100%);
      box-shadow:
        0 1px 0 rgba(255,255,255,0.55) inset,
        0 -1px 0 rgba(0,0,0,0.1) inset,
        0 6px 20px var(--primary-glow),
        0 2px 6px rgba(0,0,0,0.3);
    }

    .btn-secondary {
      background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.06) 50%, rgba(0,40,70,0.15) 100%);
      color: var(--text);
    }

    .btn-secondary:hover:not(:disabled) {
      background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.1) 50%, rgba(0,40,70,0.2) 100%);
    }

    .btn-danger {
      background: linear-gradient(180deg, #fca5a5 0%, var(--danger) 45%, #dc2626 100%);
      color: #fff;
      border-color: rgba(255,255,255,0.35);
    }

    .btn-danger:hover:not(:disabled) { filter: brightness(1.06); }

    .btn-success {
      background: linear-gradient(180deg, #6ee7b7 0%, var(--success) 45%, #059669 100%);
      color: #fff;
      border-color: rgba(255,255,255,0.35);
    }

    .btn-sm { padding: 6px 12px; font-size: 0.78rem; border-radius: 10px; }

    .btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

    .chat-layout {
      display: grid;
      grid-template-columns: 280px 1fr;
      gap: 16px;
      flex: 1;
      min-height: 0;
      height: calc(100vh - 160px);
      height: calc(100dvh - 160px);
    }

    .chat-layout > .card {
      min-height: 0;
      overflow: hidden;
      margin-bottom: 0;
    }

    .session-sidebar {
      display: flex;
      flex-direction: column;
    }

    .session-drawer-mask { display: none; }
    .session-menu-btn { display: none; }
    .session-drawer-close { display: none; }

    .chat-title-block {
      display: flex;
      align-items: center;
      gap: 10px;
      min-width: 0;
      flex: 1;
    }

    .chat-title-text { min-width: 0; }
    .chat-session-id {
      font-size: 0.75rem;
      color: var(--text-muted);
      font-weight: 400;
      margin-top: 2px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .session-list {
      overflow-y: auto;
      max-height: 100%;
      flex: 1;
      min-height: 0;
    }

    .session-item {
      padding: 12px;
      border-radius: 8px;
      cursor: pointer;
      margin-bottom: 6px;
      border: 1px solid transparent;
      transition: all .15s;
    }

    .session-item:hover { background: rgba(255,255,255,0.08); }
    .session-item.active {
      background: linear-gradient(135deg, rgba(40,184,232,0.22) 0%, rgba(40,184,232,0.08) 100%);
      border-color: var(--primary);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
    }

    .session-item .name { font-weight: 500; font-size: 0.9rem; }
    .session-item .meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

    .chat-area {
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 0;
      overflow: hidden;
    }

    .chat-area > .card-title {
      flex-shrink: 0;
    }

    .messages {
      flex: 1 1 0;
      min-height: 0;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 16px;
      background: linear-gradient(180deg, rgba(0,40,70,0.35) 0%, rgba(0,25,50,0.25) 100%);
      border-radius: var(--radius);
      margin-bottom: 12px;
      border: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      box-shadow: inset 0 2px 12px rgba(0,20,50,0.3);
      -webkit-overflow-scrolling: touch;
    }

    .chat-footer {
      flex-shrink: 0;
    }

    @media (max-width: 900px) {
      .app-header {
        padding: 10px 12px;
        gap: 8px;
        flex-shrink: 0;
      }
      .app-header h1 { font-size: 1.1rem; gap: 8px; }
      .app-logo { width: 32px; height: 32px; }
      .conn-text { font-size: 0.75rem; }
      .btn-logout { font-size: 0.75rem; padding: 5px 10px; }
      .tabs {
        padding: 6px 8px 0;
        gap: 2px;
        justify-content: space-around;
        flex-shrink: 0;
      }
      .tab-btn {
        flex: 1;
        padding: 8px 4px;
        font-size: 0.78rem;
        text-align: center;
        border-radius: 10px 10px 0 0;
      }
      .tab-txt { display: block; margin-top: 2px; font-size: 0.72rem; }
      .tab-ico { font-size: 1rem; }

      .main {
        padding: 8px;
        max-width: none;
      }

      .card {
        padding: 12px;
        border-radius: 12px;
      }

      .card-title {
        margin-bottom: 10px;
        padding-bottom: 8px;
        font-size: 0.92rem;
        gap: 8px;
        flex-wrap: wrap;
      }

      .chat-layout {
        display: block;
        position: relative;
        height: auto;
        flex: 1;
        min-height: calc(100dvh - 118px);
      }

      .session-drawer-mask {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 180;
        background: rgba(4, 16, 28, 0.55);
      }
      .session-drawer-mask[hidden] { display: none !important; }

      .session-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 320px);
        z-index: 190;
        margin: 0 !important;
        border-radius: 0 16px 16px 0;
        transform: translateX(-105%);
        transition: transform .28s ease;
        box-shadow: 12px 0 40px rgba(0,0,0,0.35);
      }
      .session-sidebar.open {
        transform: translateX(0);
      }
      .session-menu-btn { display: inline-flex; flex-shrink: 0; }
      .session-drawer-close { display: inline-flex; }

      .chat-area {
        height: calc(100dvh - 126px);
        min-height: 420px;
      }

      .messages {
        padding: 12px;
        margin-bottom: 8px;
      }

      .message { max-width: 92%; }

      .chat-mode-bar {
        flex-wrap: wrap;
        gap: 6px;
      }
      .doc-link { display: none; }

      .chat-input-area {
        gap: 8px;
        align-items: stretch;
      }
      .chat-input-area textarea {
        min-height: 44px;
        max-height: 120px;
        font-size: 16px; /* 避免 iOS 自动放大 */
      }
      .chat-input-area .btn {
        flex-shrink: 0;
        align-self: stretch;
        min-width: 64px;
      }

      body.session-drawer-open {
        overflow: hidden;
      }
    }

    .message {
      margin-bottom: 16px;
      display: flex;
      flex-direction: column;
      max-width: 85%;
      position: relative;
    }

    .message.user { align-self: flex-end; align-items: flex-end; margin-left: auto; }
    .message.assistant { align-self: flex-start; }

    .message .bubble {
      padding: 10px 14px;
      border-radius: 12px;
      font-size: 0.9rem;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .message.user .bubble {
      background: linear-gradient(180deg, #6ee8ff 0%, var(--primary) 50%, var(--primary-dark) 100%);
      color: #fff;
      border-bottom-right-radius: 4px;
      box-shadow: 0 2px 10px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.35);
    }

    .message.assistant .bubble {
      background: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.06) 100%);
      border: 1px solid var(--border);
      border-bottom-left-radius: 4px;
      white-space: pre-wrap;
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
    }
    .message.streaming .bubble::after { content: '▋'; animation: blink 1s step-end infinite; color: var(--primary); margin-left: 2px; }
    @keyframes blink { 50% { opacity: 0; } }
    .message.system .bubble {
      background: linear-gradient(180deg, rgba(251,191,36,0.18) 0%, rgba(251,191,36,0.08) 100%);
      border: 1px solid rgba(251,191,36,0.35);
      font-size: 0.82rem;
      color: var(--warning);
    }

    .message .meta {
      font-size: 0.72rem;
      color: var(--text-muted);
      margin-top: 4px;
      padding: 0 4px;
      padding-right: 36px;
    }

    .msg-retry-btn {
      position: absolute;
      right: 0;
      bottom: 0;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.1);
      color: var(--primary-light);
      cursor: pointer;
      font-size: 0.95rem;
      line-height: 1;
      display: none;
      align-items: center;
      justify-content: center;
      transition: all .15s;
      z-index: 2;
    }

    .message.has-retry .msg-retry-btn { display: inline-flex; }

    .msg-retry-btn:hover {
      border-color: var(--primary);
      background: rgba(40, 184, 232, 0.2);
      transform: rotate(-30deg);
    }

    .msg-retry-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none;
    }

    .msg-retry-btn.spinning {
      animation: retry-spin 0.8s linear infinite;
    }

    @keyframes retry-spin {
      to { transform: rotate(360deg); }
    }

    .chat-input-area {
      display: flex;
      gap: 8px;
      align-items: flex-end;
    }

    .chat-input-area textarea { flex: 1; min-height: 60px; max-height: 150px; }

    .image-preview-bar {
      display: none;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 10px;
      padding: 8px;
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
    }

    .image-preview-bar.show { display: flex; }

    .file-preview-item {
      position: relative;
      border-radius: 8px;
      overflow: hidden;
      border: 1px solid var(--border);
      background: var(--surface);
    }

    .file-preview-item.image { width: 72px; height: 72px; }

    .file-preview-item.image img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .file-preview-item.doc {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      min-width: 140px;
      max-width: 220px;
    }

    .file-preview-item .file-icon { font-size: 1.4rem; flex-shrink: 0; }

    .file-preview-item .file-name {
      font-size: 0.78rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .file-preview-item .file-type {
      font-size: 0.68rem;
      color: var(--text-muted);
    }

    .file-preview-item button {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 20px;
      height: 20px;
      border: none;
      border-radius: 50%;
      background: rgba(0,0,0,.6);
      color: #fff;
      cursor: pointer;
      font-size: 12px;
      line-height: 1;
    }

    .file-preview-item.doc button { position: static; margin-left: auto; flex-shrink: 0; }

    .message-attachments {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 8px;
    }

    .message-file-tag {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      background: rgba(255,255,255,.08);
      border-radius: 6px;
      font-size: 0.78rem;
    }

    .message.user .message-file-tag { background: rgba(255,255,255,.15); }

    .message-images {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-bottom: 8px;
    }

    .message-images img {
      max-width: 200px;
      max-height: 160px;
      border-radius: 8px;
      border: 1px solid var(--border);
      object-fit: cover;
    }

    .chat-input-tools {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .btn-icon {
      padding: 8px 12px;
      min-width: 44px;
    }

    #fileInput { display: none; }

    .chat-options {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 10px;
      align-items: center;
    }

    .chat-options .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }

    .checkbox-label {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 0.85rem;
      color: var(--text-muted);
      cursor: pointer;
    }

    .checkbox-label input { width: auto; }

    .table-wrap { overflow-x: auto; }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.85rem;
    }

    th, td {
      padding: 10px 12px;
      text-align: left;
      border-bottom: 1px solid var(--border);
    }

    th { color: var(--text-muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }
    tr:hover td { background: rgba(255,255,255,.02); }

    .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 20px;
      font-size: 0.72rem;
      font-weight: 500;
    }

    .badge-success { background: rgba(52,211,153,.18); color: var(--success); }
    .badge-danger { background: rgba(248,113,113,.18); color: var(--danger); }
    .badge-info { background: rgba(40,184,232,.18); color: var(--primary-light); }

    .toast-container {
      position: fixed;
      top: 80px;
      right: 24px;
      z-index: 1000;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .toast {
      padding: 12px 18px;
      border-radius: 12px;
      font-size: 0.85rem;
      animation: slideIn .3s ease;
      max-width: 360px;
      box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.12);
      backdrop-filter: blur(12px);
    }

    .toast.success { background: rgba(6, 78, 59, 0.92); border: 1px solid var(--success); }
    .toast.error { background: rgba(69, 10, 10, 0.92); border: 1px solid var(--danger); }
    .toast.info { background: rgba(8, 47, 73, 0.92); border: 1px solid var(--primary); }

    @keyframes slideIn {
      from { transform: translateX(100%); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }

    .loading { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
    @keyframes spin { to { transform: rotate(360deg); } }

    .empty-state {
      text-align: center;
      padding: 40px;
      color: var(--text-muted);
      font-size: 0.9rem;
    }

    .vector-preview {
      font-family: "Cascadia Code", "Fira Code", monospace;
      font-size: 0.75rem;
      background: rgba(0, 30, 55, 0.5);
      padding: 12px;
      border-radius: 10px;
      max-height: 200px;
      overflow-y: auto;
      word-break: break-all;
      color: var(--text-muted);
      border: 1px solid var(--border);
      box-shadow: inset 0 2px 8px rgba(0,20,50,0.25);
    }

    .result-box {
      background: rgba(0, 30, 55, 0.5);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px;
      font-size: 0.85rem;
      white-space: pre-wrap;
      max-height: 300px;
      overflow-y: auto;
      margin-top: 12px;
      box-shadow: inset 0 2px 8px rgba(0,20,50,0.25);
    }

    .modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(4, 24, 36, 0.72);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      z-index: 200;
      align-items: center;
      justify-content: center;
      padding: 24px;
    }

    .modal-overlay.show { display: flex; }

    .modal {
      background: linear-gradient(160deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.06) 100%);
      backdrop-filter: blur(24px) saturate(160%);
      -webkit-backdrop-filter: blur(24px) saturate(160%);
      border: 1px solid var(--border-light);
      border-radius: var(--radius);
      padding: 24px;
      width: 100%;
      max-width: 560px;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.15);
    }

    .modal h3 { margin-bottom: 16px; }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      display: inline-block;
      margin-right: 6px;
    }

    .status-dot.online { background: var(--success); box-shadow: 0 0 8px rgba(52,211,153,0.6); }
    .status-dot.offline { background: var(--danger); box-shadow: 0 0 8px rgba(248,113,113,0.5); }

    .chat-context-menu {
      position: fixed;
      z-index: 1200;
      min-width: 120px;
      padding: 6px;
      border-radius: 12px;
      background: linear-gradient(160deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.08) 100%);
      backdrop-filter: blur(20px) saturate(160%);
      -webkit-backdrop-filter: blur(20px) saturate(160%);
      border: 1px solid var(--border-light);
      box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.12);
    }

    .chat-context-menu.hidden { display: none; }

    .chat-context-item {
      width: 100%;
      padding: 10px 14px;
      border: none;
      border-radius: 8px;
      background: transparent;
      color: var(--text);
      font-size: 0.88rem;
      text-align: left;
      cursor: pointer;
      transition: background .15s;
    }

    .chat-context-item:hover {
      background: rgba(248, 113, 113, 0.18);
      color: #fecaca;
    }

    .message.assistant.streaming .bubble {
      cursor: context-menu;
    }

    .doc-link {
      font-size: 0.78rem;
      font-weight: 400;
      color: var(--primary-light);
      text-decoration: none;
    }

    .doc-link:hover { text-decoration: underline; }

    .video-status {
      font-size: 0.92rem;
      margin-bottom: 10px;
      color: var(--text);
    }

    .chat-mode-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 10px;
      flex-wrap: wrap;
    }

    .video-mode-toggle {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      user-select: none;
      padding: 6px 12px;
      border-radius: 20px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.06);
      transition: all .2s;
    }

    .video-mode-toggle:has(input:checked) {
      border-color: var(--primary);
      background: rgba(40, 184, 232, 0.15);
      box-shadow: 0 0 0 2px var(--primary-glow);
    }

    .video-mode-toggle input { width: auto; margin: 0; }

    .video-mode-label { font-size: 0.85rem; color: var(--text); }

    .video-options-panel {
      margin-bottom: 10px;
      padding: 10px 12px;
      border-radius: 12px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .video-options-panel.hidden { display: none; }

    .video-opt-group {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .video-opt-label {
      font-size: 0.78rem;
      color: var(--text-muted);
      min-width: 52px;
      flex-shrink: 0;
    }

    .video-opt-btns {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }

    .video-opt-btn {
      padding: 4px 10px;
      font-size: 0.78rem;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.06);
      color: var(--text);
      cursor: pointer;
      transition: all .15s;
    }

    .video-opt-btn:hover {
      border-color: var(--primary);
      color: var(--primary-light);
    }

    .video-opt-btn.active {
      border-color: var(--primary);
      background: rgba(40, 184, 232, 0.18);
      color: var(--primary-light);
      box-shadow: 0 0 0 1px var(--primary-glow);
    }

    .video-image-hint {
      font-size: 0.76rem;
      color: var(--text-muted);
      padding: 4px 0 0;
    }

    .video-image-hint.hidden { display: none; }

    .msg-badge {
      display: inline-block;
      font-size: 0.72rem;
      padding: 2px 8px;
      border-radius: 999px;
      margin-bottom: 6px;
      background: rgba(40, 184, 232, 0.18);
      color: var(--primary-light);
      border: 1px solid rgba(40, 184, 232, 0.35);
    }

    .chat-video {
      width: 100%;
      max-width: 420px;
      margin-top: 8px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: #000;
    }

    .chat-gen-image {
      width: 100%;
      max-width: 420px;
      margin-top: 8px;
      border-radius: 10px;
      border: 1px solid var(--border);
      display: block;
      background: rgba(0,0,0,0.2);
      cursor: zoom-in;
      transition: opacity .15s ease, transform .15s ease;
    }

    .chat-gen-image:hover {
      opacity: 0.92;
      transform: scale(1.01);
    }

    .image-preview-overlay {
      z-index: 300;
      padding: 40px 24px;
      background: rgba(2, 12, 20, 0.88);
      cursor: zoom-out;
    }

    .image-preview-overlay.show {
      display: flex;
    }

    .image-preview-full {
      max-width: min(96vw, 1200px);
      max-height: 88vh;
      width: auto;
      height: auto;
      object-fit: contain;
      border-radius: 12px;
      border: 1px solid rgba(255,255,255,0.12);
      box-shadow: 0 20px 60px rgba(0,0,0,0.45);
      cursor: default;
    }

    .image-preview-close {
      position: fixed;
      top: 18px;
      right: 22px;
      width: 40px;
      height: 40px;
      border: 1px solid rgba(255,255,255,0.2);
      border-radius: 50%;
      background: rgba(255,255,255,0.1);
      color: #fff;
      font-size: 1.5rem;
      line-height: 1;
      cursor: pointer;
      z-index: 301;
    }

    .image-preview-close:hover {
      background: rgba(255,255,255,0.2);
    }

    .video-progress-wrap {
      height: 10px;
      border-radius: 999px;
      background: rgba(255,255,255,0.08);
      overflow: hidden;
      border: 1px solid var(--border);
      margin-bottom: 12px;
    }

    .video-progress-bar {
      height: 100%;
      background: linear-gradient(90deg, var(--primary-dark), var(--primary-light));
      transition: width .4s ease;
    }

    .video-meta {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin-bottom: 12px;
      line-height: 1.6;
    }

    .video-player-wrap { margin-top: 8px; }

    .video-status.failed,
    .video-status[style*="danger"] {
      color: var(--danger);
    }

    .chat-footer.video-mode-active .chat-input-area textarea {
      border-color: rgba(40, 184, 232, 0.45);
    }

    /* —— 登录页 —— */
    .app-root[hidden],
    .login-gate[hidden] {
      display: none !important;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }

    .btn-logout {
      border: 1px solid rgba(255,255,255,0.18);
      background: rgba(255,255,255,0.08);
      color: var(--text-muted);
      border-radius: 999px;
      padding: 6px 14px;
      font-size: 0.8rem;
      cursor: pointer;
      transition: background .2s, color .2s;
    }
    .btn-logout:hover {
      background: rgba(248, 113, 113, 0.18);
      color: #fecaca;
      border-color: rgba(248, 113, 113, 0.35);
    }

    .login-gate {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px 16px;
      overflow: auto;
    }

    .login-bg {
      position: absolute;
      inset: 0;
      background:
        radial-gradient(ellipse 100% 80% at 20% 0%, rgba(62, 201, 232, 0.32) 0%, transparent 55%),
        radial-gradient(ellipse 80% 60% at 90% 80%, rgba(110, 217, 184, 0.18) 0%, transparent 50%),
        linear-gradient(165deg, #041824 0%, #0a3050 48%, #0c4a6e 100%);
      animation: loginGlow 10s ease-in-out infinite alternate;
    }

    @keyframes loginGlow {
      from { filter: saturate(1) brightness(1); }
      to { filter: saturate(1.15) brightness(1.06); }
    }

    .login-panel {
      position: relative;
      z-index: 1;
      width: min(100%, 420px);
      padding: clamp(28px, 5vw, 40px) clamp(22px, 4vw, 36px);
      border-radius: 28px;
      background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.05) 100%);
      border: 1px solid rgba(126, 214, 240, 0.22);
      box-shadow: 0 24px 64px rgba(0, 20, 45, 0.45), inset 0 1px 0 rgba(255,255,255,0.16);
      backdrop-filter: blur(22px) saturate(160%);
      -webkit-backdrop-filter: blur(22px) saturate(160%);
      animation: loginIn .55s cubic-bezier(.2,.8,.2,1) both;
    }

    @keyframes loginIn {
      from { opacity: 0; transform: translateY(18px) scale(.98); }
      to { opacity: 1; transform: none; }
    }

    .login-brand {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-bottom: 28px;
    }

    .login-logo {
      width: clamp(56px, 14vw, 72px);
      height: clamp(56px, 14vw, 72px);
      border-radius: 18px;
      object-fit: contain;
      box-shadow: 0 10px 28px rgba(40, 184, 232, 0.35);
      animation: logoFloat 4s ease-in-out infinite;
    }

    @keyframes logoFloat {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-4px); }
    }

    .login-title {
      font-size: clamp(1.75rem, 6vw, 2.15rem);
      font-weight: 700;
      letter-spacing: 0.12em;
      line-height: 1;
      color: #b6f2ff;
    }

    .login-ver {
      margin-left: 8px;
      font-size: 0.7em;
      letter-spacing: 0;
      font-weight: 600;
      color: #6ed9b8;
      vertical-align: middle;
    }

    .login-slogan {
      margin-top: 8px;
      font-size: 0.9rem;
      color: var(--text-muted);
      letter-spacing: 0.08em;
    }

    .login-form {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .login-field {
      display: flex;
      flex-direction: column;
      gap: 8px;
      font-size: 0.85rem;
      color: #9fc3d1;
    }

    .login-field input {
      width: 100%;
      height: 48px;
      padding: 0 16px;
      border-radius: 14px;
      border: 1px solid rgba(126, 214, 240, 0.22);
      background: rgba(0, 0, 0, 0.28);
      color: var(--text);
      font-size: 1rem;
      outline: none;
      transition: border-color .2s, box-shadow .2s;
    }

    .login-field input:focus {
      border-color: rgba(40, 184, 232, 0.65);
      box-shadow: 0 0 0 3px rgba(40, 184, 232, 0.18);
    }

    .login-field input::placeholder {
      color: rgba(126, 184, 212, 0.55);
    }

    .login-error {
      margin: 0;
      font-size: 0.85rem;
      color: #ff9a9a;
      text-align: center;
    }

    .login-submit {
      margin-top: 4px;
      height: 50px;
      border: none;
      border-radius: 16px;
      font-size: 1.05rem;
      font-weight: 700;
      color: #043041;
      cursor: pointer;
      background: linear-gradient(180deg, #7defff, #3ec9e8);
      box-shadow: 0 10px 24px rgba(40, 184, 232, 0.35);
      transition: transform .15s, filter .15s;
    }

    .login-submit:hover { filter: brightness(1.05); }
    .login-submit:active { transform: scale(0.98); }

    @media (max-width: 480px) {
      .login-gate { padding: 12px; align-items: flex-end; }
      .login-panel {
        width: 100%;
        border-radius: 24px 24px 18px 18px;
        margin-bottom: env(safe-area-inset-bottom, 0);
      }
      .login-brand { flex-direction: column; text-align: center; }
      .login-slogan { letter-spacing: 0.04em; }
      .btn-logout { padding: 6px 12px; }
    }