* { box-sizing: border-box; }
    :root {
      color-scheme: light;
      --bg: #f4f7fb;
      --shell: #edf2f8;
      --panel: #ffffff;
      --panel-2: #f8fafd;
      --panel-3: #eef5ff;
      --line: #e2e8f0;
      --line-strong: #cfd8e5;
      --text: #1d2533;
      --muted: #667085;
      --soft: #98a2b3;
      --accent: #2563eb;
      --accent-2: #14b88a;
      --danger: #d92d20;
      --warn: #b7791f;
      --shadow: 0 18px 52px rgba(31, 41, 55, .08);
      --radius: 8px;
      --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }
    html, body { height: 100%; }
    body {
      margin: 0;
      background:
        radial-gradient(circle at 48% -12%, rgba(37, 99, 235, .16), transparent 34%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #f2f5fa 100%);
      color: var(--text);
      overflow: hidden;
    }
    button, textarea, input { font: inherit; }
    button {
      border: 1px solid var(--line);
      background: var(--panel);
      color: var(--text);
      border-radius: 7px;
      height: 34px;
      padding: 0 11px;
      cursor: pointer;
      transition: background .16s, border-color .16s, color .16s, box-shadow .16s;
    }
    button:hover { background: var(--panel-3); border-color: #c8d8f3; }
    button.primary { background: var(--accent); border-color: var(--accent); color: white; box-shadow: 0 8px 20px rgba(37, 99, 235, .22); }
    button.primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
    button.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
    button.icon { width: 34px; padding: 0; display: inline-grid; place-items: center; }
    button:disabled { opacity: .55; cursor: default; }
    .app { height: 100%; min-height: 0; display: grid; grid-template-columns: 284px minmax(0, 1fr) 352px; }
    .sidebar, .detail {
      background: rgba(255, 255, 255, .78);
      border-color: var(--line);
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      backdrop-filter: blur(18px);
    }
    .sidebar { border-right: 1px solid var(--line); background: #f7f9fc; }
    .detail { border-left: 1px solid var(--line); }
    .brand, .detail-head, .topbar { height: 64px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--line); gap: 10px; flex-shrink: 0; }
    .brand { height: 58px; padding: 0 14px; border-bottom: 0; }
    .brand-title { min-width: 0; }
    .brand strong { display: block; font-size: 15px; }
    .brand span, .muted { color: var(--muted); font-size: 12px; }
    .dot {
      width: 30px;
      height: 30px;
      border-radius: 8px;
      background: linear-gradient(135deg, #2563eb, #14b88a);
      color: #fff;
      display: grid;
      place-items: center;
      flex: none;
      box-shadow: none;
    }
    .dot::after { content: "KB"; font-size: 11px; font-weight: 800; letter-spacing: 0; }
    .sidebar-actions { padding: 0 10px 8px; }
    .new-chat {
      width: 100%;
      height: 38px;
      border: 1px solid transparent;
      background: transparent;
      color: #111827;
      font-weight: 650;
      text-align: left;
      padding: 0 12px;
      box-shadow: none;
    }
    .new-chat:hover { background: #eef2f7; border-color: transparent; }
    .sidebar-body { min-height: 0; padding: 6px 10px 14px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
    .sidebar-body section { display: grid; gap: 6px; }
    .section-title { display: flex; align-items: center; justify-content: space-between; color: #717b8c; font-size: 12px; font-weight: 600; padding: 0 4px; margin-bottom: 0; }
    .section-title button { height: 28px; padding: 0 8px; border: 0; background: transparent; color: var(--muted); }
    .section-title button:hover { background: #eef2f7; color: #111827; }
    .stats { display: grid; gap: 1px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); overflow: hidden; }
    .stat {
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-height: 32px;
      padding: 6px 9px;
      background: transparent;
      border: 0;
      border-radius: 0;
      box-shadow: none;
    }
    .stat + .stat { border-top: 1px solid #eef2f7; }
    .stat b { order: 2; display: block; font-size: 13px; line-height: 1; color: #111827; margin: 0; font-weight: 700; }
    .stat span { order: 1; color: var(--muted); font-size: 12px; }
    .dropzone { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 9px; display: grid; gap: 8px; }
    .dropzone.drag { border-color: var(--accent); background: rgba(37, 99, 235, .07); }
    .drop-row { display: flex; align-items: center; gap: 8px; }
    .drop-row input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
    .file-picker {
      height: 30px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0 10px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: #f8fafc;
      color: #111827;
      font-size: 12px;
      cursor: pointer;
      flex: none;
    }
    .file-picker:hover { background: #eef2f7; }
    .file-name { min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .drop-hint { color: var(--soft); font-size: 11px; line-height: 1.45; padding: 0 2px; }
    .doc-list, .history-list { display: grid; gap: 2px; }
    .doc, .history { border: 1px solid transparent; background: transparent; color: var(--text); text-align: left; height: auto; min-height: 42px; padding: 8px 9px; display: grid; gap: 3px; width: 100%; box-shadow: none; }
    .doc:hover, .history:hover, .doc.active, .history.active { background: #eef2f7; border-color: transparent; box-shadow: none; }
    .history.active { background: #eaf2ff; border-color: transparent; }
    .doc-name, .history-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
    .doc-meta, .history-meta { color: var(--soft); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: rgba(248, 250, 253, .58); }
    .topbar { justify-content: space-between; background: rgba(255,255,255,.72); backdrop-filter: blur(18px); }
    .top-left, .top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
    .top-title { min-width: 0; }
    .top-title b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .top-title span { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
    .mobile-only { display: none; }
    .chat { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 32px 28px; scrollbar-color: #c7d2e3 transparent; scrollbar-width: thin; }
    .chat::-webkit-scrollbar, .detail-body::-webkit-scrollbar, .sidebar-body::-webkit-scrollbar, .snippet::-webkit-scrollbar { width: 8px; }
    .chat::-webkit-scrollbar-thumb, .detail-body::-webkit-scrollbar-thumb, .sidebar-body::-webkit-scrollbar-thumb, .snippet::-webkit-scrollbar-thumb { background: #c7d2e3; border-radius: 999px; }
    .empty { height: 100%; display: grid; align-items: start; justify-items: center; color: var(--muted); padding-top: 9vh; }
    .empty-inner { width: min(760px, 100%); display: grid; gap: 18px; justify-items: stretch; text-align: left; }
    .empty h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); line-height: 1.14; letter-spacing: 0; color: #111827; }
    .suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .suggestions button { height: 44px; color: #344054; background: rgba(255,255,255,.82); border-color: var(--line); text-align: left; box-shadow: 0 10px 34px rgba(31,41,55,.05); }
    .messages { max-width: 900px; margin: 0 auto; display: grid; gap: 18px; }
    .message { display: grid; gap: 8px; }
    .message.user { justify-items: end; }
    .bubble { max-width: min(760px, 92%); line-height: 1.65; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
    .user .bubble { background: #edf4ff; border: 1px solid #cfe0ff; border-radius: 8px; padding: 10px 14px; }
    .assistant .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; box-shadow: 0 12px 34px rgba(31, 41, 55, .06); }
    .assistant-tools { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
    .cite { height: 28px; color: var(--muted); font-size: 12px; }
    .composer { border-top: 1px solid var(--line); padding: 14px 18px 18px; background: rgba(248, 250, 253, .78); flex-shrink: 0; backdrop-filter: blur(18px); }
    .composer-inner { max-width: 900px; margin: 0 auto; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; box-shadow: var(--shadow); }
    textarea { width: 100%; min-height: 52px; max-height: 180px; resize: vertical; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.55; }
    textarea::placeholder { color: var(--soft); }
    .composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .kbd { font-family: var(--mono); color: var(--soft); font-size: 11px; }
    .detail-head { justify-content: space-between; }
    .detail-title { min-width: 0; }
    .detail-title b { display: block; font-size: 14px; }
    .detail-title span { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
    .detail-body { min-height: 0; overflow: auto; padding: 14px; display: grid; gap: 12px; align-content: start; }
    .source-item, .doc-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; box-shadow: 0 10px 28px rgba(31, 41, 55, .05); }
    .source-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
    .path { font-family: var(--mono); color: #175cd3; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .snippet { color: #344054; white-space: pre-wrap; line-height: 1.55; font-size: 13px; max-height: 260px; overflow: auto; }
    .toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #111827; border: 1px solid #111827; border-radius: var(--radius); padding: 10px 13px; color: #fff; font-size: 13px; box-shadow: 0 16px 50px rgba(15,23,42,.22); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 20; }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
    .hidden { display: none !important; }
    @media (max-width: 1080px) {
      .app { grid-template-columns: 290px minmax(0, 1fr); }
      .detail { position: fixed; right: 0; top: 0; bottom: 0; width: min(380px, 92vw); z-index: 10; transform: translateX(100%); transition: transform .18s; box-shadow: -18px 0 40px rgba(15,23,42,.14); }
      .detail.open { transform: translateX(0); }
      .mobile-only { display: inline-grid; }
    }
    @media (max-width: 760px) {
      .app { grid-template-columns: 1fr; }
      .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(310px, 90vw); z-index: 11; transform: translateX(-100%); transition: transform .18s; box-shadow: 18px 0 40px rgba(15,23,42,.14); }
      .sidebar.open { transform: translateX(0); }
      .topbar { padding: 0 10px; }
      .chat { padding: 18px 12px; }
      .composer { padding: 10px; }
      .bubble { max-width: 100%; }
      .suggestions { grid-template-columns: 1fr; }
    }
