 :root {
    --bg:        #0f0f0f;
    --surface:   #161616;
    --surface2:  #1e1e1e;
    --surface3:  #252525;
    --border:    #2a2a2a;
    --border2:   #333;
    --gold:      #c9a84c;
    --gold-dim:  #7a6230;
    --text:      #e8e3d9;
    --text-dim:  #8a8278;
    --text-faint:#4a4540;
    --accent:    #2d6a4f;
    --accent2:   #1b4332;
    --red:       #8b2020;
    --radius: 10px;
    --shadow:    0 4px 24px rgba(0,0,0,.5);

    /* Ð›Ð¾ÐºÐ°Ð»ÑŒÐ½Ñ‹Ðµ ÑˆÑ€Ð¸Ñ„Ñ‚Ñ‹ â€” Ð±ÐµÐ· Ð¿Ð¾Ð´Ð³Ñ€ÑƒÐ·ÐºÐ¸ Ñ Google */
    --font-serif:  Georgia, 'Times New Roman', 'PT Serif', serif;
    --font-mono:   'Courier New', 'Lucida Console', 'Consolas', monospace;
    --font-ui:     -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue',
                   Arial, 'Liberation Sans', sans-serif;
  }

  /* â”€â”€â”€ Ð¡Ð’Ð•Ð¢Ð›ÐÐ¯ Ð¢Ð•ÐœÐ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  [data-theme="light"] {
    --bg:        #f0f0ed;
    --surface:   #fafaf8;
    --surface2:  #f0eeea;
    --surface3:  #e8e5e0;
    --border:    #dedad4;
    --border2:   #ccc8c0;
    --gold:      #8a6a20;
    --gold-dim:  #b8922e;
    --text:      #1e1c18;
    --text-dim:  #5a5650;
    --text-faint:#9a9590;
    --accent:    #1f6b47;
    --accent2:   #d4ede2;
    --red:       #b83030;
    --shadow:    0 4px 24px rgba(0,0,0,.12);
  }

  /* Ð¡Ð²ÐµÑ‚Ð»Ð°Ñ Ñ‚ÐµÐ¼Ð° â€” Ñ‚Ð¾Ñ‡ÐµÑ‡Ð½Ñ‹Ðµ Ð¿ÐµÑ€ÐµÐ¾Ð¿Ñ€ÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ */
  [data-theme="light"] .msg-avatar-ai {
    background: #d4ede2;
    border-color: #86c9a8;
    color: #1f6b47;
  }
  [data-theme="light"] .msg-bubble {
    background: var(--surface);
    border-color: var(--border);
  }
  [data-theme="light"] .msg-user .msg-bubble {
    background: #e8e5df;
    border-color: var(--border2);
  }
  [data-theme="light"] .chunk-body {
    background: var(--surface2);
  }
  [data-theme="light"] #msg-input {
    background: #fff;
    border-color: var(--border2);
  }
  [data-theme="light"] #msg-input:focus {
    border-color: var(--gold-dim);
  }
  [data-theme="light"] .msg-bubble code {
    background: #e8e5df;
    color: #1f6b47;
  }
  [data-theme="light"] .typing-dot {
    background: #b0aba4;
  }
  [data-theme="light"] #settings-panel,
  [data-theme="light"] .slide-panel {
    background: var(--surface);
  }
  [data-theme="light"] .field input,
  [data-theme="light"] .field textarea,
  [data-theme="light"] .field select {
    background: #fff;
    border-color: var(--border2);
  }
  [data-theme="light"] #btn-send {
    background: var(--gold);
    color: #fff;
  }
  [data-theme="light"] #btn-send:hover {
    background: var(--gold-dim);
  }
  [data-theme="light"] .suggestion-btn {
    background: #fff;
    border-color: var(--border);
    color: var(--text-dim);
  }
  [data-theme="light"] .suggestion-btn:hover {
    background: var(--surface2);
    border-color: var(--gold-dim);
    color: var(--text);
  }

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

  html, body {
    height: 100%; width: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* â”€â”€â”€ Ð¨ÐÐŸÐšÐ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  #header {
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
  }

  .logo {
    /* font-family: var(--font-serif); */
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: .04em;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
  }

  .logo-sep {
    width: 1px;
    height: 20px;
    background: var(--border2);
  }

  .logo-sub {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 400;
    color: var(--text-dim);
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .header-spacer { flex: 1; }

  #status-indicator {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--text-dim);
  }

  .status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
    transition: background .3s;
  }
  .status-dot.connected { background: #4ade80; box-shadow: 0 0 6px #4ade8080; }
  .status-dot.loading   { background: var(--gold); animation: pulse-dot 1s infinite; }
  .status-dot.error     { background: #f87171; }

  @keyframes pulse-dot {
    0%,100% { opacity:1; } 50% { opacity:.3; }
  }

  #btn-settings {
    width: 34px; height: 34px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    font-size: 16px;
  }
  #btn-settings:hover { background: var(--surface2); color: var(--gold); border-color: var(--gold-dim); }

  /* â”€â”€â”€ ÐžÐ¡ÐÐžÐ’ÐÐžÐ™ LAYOUT â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  #app {
    display: flex;
    height: calc(100vh - 52px);
    overflow: hidden;
  }

  /* â”€â”€â”€ Ð§ÐÐ¢ÐžÐ’ÐÐ¯ ÐšÐžÐ›ÐžÐÐšÐ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  #chat-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border);
    background: var(--bg);
  }

  /* Ð¢ÑƒÐ»Ð±Ð°Ñ€ Ñ‡Ð°Ñ‚Ð° */
  #chat-toolbar {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
  }

  .toolbar-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-dim);
  }

  .toolbar-sep { flex: 1; }

  .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
  }

  .chip-scope {
    border-color: var(--border2);
    color: var(--text-dim);
    background: var(--surface2);
  }
  .chip-scope:hover, .chip-scope.active {
    border-color: var(--gold-dim);
    color: var(--gold);
    background: rgba(201,168,76,.08);
  }

  .btn-icon-sm {
    width: 28px; height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: all .2s;
  }
  .btn-icon-sm:hover { background: var(--surface2); color: var(--text); }

  /* Ð¡Ð¿Ð¸ÑÐ¾Ðº ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ð¹ */
  #messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    scroll-behavior: smooth;
  }
  #messages::-webkit-scrollbar { width: 4px; }
  #messages::-webkit-scrollbar-track { background: transparent; }
  #messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  /* ÐŸÑƒÑÑ‚Ð¾Ðµ ÑÐ¾ÑÑ‚Ð¾ÑÐ½Ð¸Ðµ */
  #empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    padding: 40px;
    text-align: center;
  }

  .empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: .6;
  }
  .empty-icon i{
    font-size: 64px;
    opacity: 0.4;
    color: #000000;
  }

  .empty-title {
    /* font-family: var(--font-serif); */
    /* font-size: 22px; */
    /* color: var(--text-dim); */
    /* font-family: 'LocalSerif', Georgia, serif; */
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
  }

  .empty-desc {
    /* font-size: 13px; */
    /* color: var(--text-faint); */
    /* max-width: 320px; */
    line-height: 1.7;
    font-size: 14px;
    color: var(--text-dim);
    max-width: 400px;
    margin-bottom: 30px;
  }

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 600px;
  }

  .suggestion-btn {
    padding: 10px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
  }
  .suggestion-btn:hover {
    background: var(--surface3);
    border-color: var(--gold-dim);
    color: var(--text);
    transform: translateY(-1px);
  }

  /* Ð¡Ð¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ */
  .msg {
    display: flex;
    gap: 12px;
    padding: 10px 20px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    animation: msg-in .25s ease;
  }

  @keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .msg-user { flex-direction: row-reverse; }

  .msg-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-top: 2px;
  }

  .msg-avatar-user {
    background: var(--gold);
    color: #1a1200;
  }

  .msg-avatar-ai {
    background: var(--accent2);
    border: 1px solid var(--accent);
    color: #a7f3d0;
    font-size: 14px;
  }

  .msg-body { flex: 1; min-width: 0; }

  .msg-user .msg-body { display: flex; flex-direction: column; align-items: flex-end; }

  .msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
  }

  .msg-name {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  .msg-user .msg-name { color: var(--gold-dim); }
  .msg-ai   .msg-name { color: var(--accent); }

  .msg-time {
    font-size: 10px;
    color: var(--text-faint);
    font-family: var(--font-mono);
  }

  .msg-bubble {
    padding: 12px 15px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.7;
    max-width: 100%;
    word-break: break-word;
  }

  .msg-user .msg-bubble {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-top-right-radius: 2px;
    color: var(--text);
  }

  .msg-ai .msg-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top-left-radius: 2px;
    color: var(--text);
    width: 100%;
  }

  .msg-bubble p { margin-bottom: 8px; }
  .msg-bubble p:last-child { margin-bottom: 0; }
  .msg-bubble strong { color: var(--gold); font-weight: 600; }
  .msg-bubble em { color: var(--text-dim); }
  .msg-bubble code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--surface3);
    padding: 2px 6px;
    border-radius: 3px;
    color: #a7f3d0;
  }
  .msg-bubble ul, .msg-bubble ol {
    padding-left: 20px;
    margin: 6px 0;
  }
  .msg-bubble li { margin-bottom: 3px; }
  .msg-bubble h3, .msg-bubble h4 {
    font-family: var(--font-serif);
    color: var(--gold);
    margin: 10px 0 5px;
  }
  .msg-bubble blockquote {
    border-left: 2px solid var(--gold-dim);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-dim);
    font-style: italic;
  }

  /* Ð˜ÑÑ‚Ð¾Ñ‡Ð½Ð¸ÐºÐ¸ Ð¿Ð¾Ð´ ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸ÐµÐ¼ */
  .msg-sources {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .source-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text-dim);
    cursor: pointer;
    transition: all .2s;
    max-width: 220px;
  }

  .source-tag:hover {
    border-color: var(--gold-dim);
    color: var(--gold);
    background: rgba(201,168,76,.06);
  }

  .source-tag .src-icon { font-size: 10px; }
  .source-tag .src-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .source-tag .src-pct {
    font-family: var(--font-mono);
    color: var(--gold-dim);
    flex-shrink: 0;
  }

  /* Ð˜Ð½Ð´Ð¸ÐºÐ°Ñ‚Ð¾Ñ€ Ð½Ð°Ð±Ð¾Ñ€Ð° */
  .typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
  }
  .typing-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
    animation: typing 1.2s infinite;
  }
  .typing-dot:nth-child(2) { animation-delay: .2s; }
  .typing-dot:nth-child(3) { animation-delay: .4s; }
  @keyframes typing {
    0%,60%,100% { opacity: .3; transform: translateY(0); }
    30%  { opacity: 1; transform: translateY(-4px); }
  }

  /* â”€â”€â”€ Ð’Ð’ÐžÐ” Ð¡ÐžÐžÐ‘Ð©Ð•ÐÐ˜Ð¯ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  #input-area {
    border-top: 1px solid var(--border);
    padding: 14px 16px;
    background: var(--surface);
    flex-shrink: 0;
  }

  #input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    /* max-width: 900px; */
    margin: 0 auto;
  }

  #input-wrap {
    flex: 1;
    position: relative;
  }

  #msg-input {
    width: 100%;
    min-height: 44px;
    max-height: 180px;
    padding: 11px 44px 11px 14px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color .2s;
    overflow-y: auto;
    line-height: 1.5;
  }
  #msg-input:focus { border-color: var(--gold-dim); }
  #msg-input::placeholder { color: var(--text-faint); }
  #msg-input::-webkit-scrollbar { width: 3px; }
  #msg-input::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  #btn-send {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    border: none;
    background: var(--gold);
    color: #1a1200;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    font-weight: 700;
    margin: -7px 0 6px 0px;
  }
  #btn-send:hover { background: #dbb85a; transform: translateY(-1px); }
  #btn-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

  .input-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    max-width: 900px;
    margin: 8px auto 0;
  }

  .input-hint {
    font-size: 11px;
    color: var(--text-faint);
    flex: 1;
  }

  /* â”€â”€â”€ ÐŸÐÐÐ•Ð›Ð¬ Ð˜Ð¡Ð¢ÐžÐ§ÐÐ˜ÐšÐžÐ’ (Ð¿Ñ€Ð°Ð²Ð°Ñ ÐºÐ¾Ð»Ð¾Ð½ÐºÐ°) â€” Ñ€ÐµÐ·Ð¸Ð½Ð¾Ð²Ð°Ñ â”€â”€â”€â”€â”€â”€â”€â”€ */
  #docs-col {
    width: 42%;
    min-width: 260px;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    flex-shrink: 0;
    position: relative;
    /* transition ÑƒÐ±Ñ€Ð°Ð½ Ð¿Ñ€Ð¸ resize, Ð´Ð¾Ð±Ð°Ð²Ð»ÑÐµÑ‚ÑÑ Ð¾Ð±Ñ€Ð°Ñ‚Ð½Ð¾ Ñ‡ÐµÑ€ÐµÐ· ÐºÐ»Ð°ÑÑ */
  }

  #docs-col.animate {
    transition: width .3s ease, min-width .3s ease;
  }

  #docs-col.collapsed {
    width: 0 !important;
    min-width: 0;
    overflow: hidden;
  }

  /* Ð ÑƒÑ‡ÐºÐ° Ð´Ð»Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ ÑˆÐ¸Ñ€Ð¸Ð½Ñ‹ Ð¿Ð°Ð½ÐµÐ»Ð¸ */
  #docs-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    border-left: 1px solid var(--border);
    transition: border-color .15s;
  }
  #docs-resize-handle:hover,
  #docs-resize-handle.dragging {
    border-left-color: var(--gold-dim);
    background: rgba(201,168,76,.06);
  }

  #docs-toolbar {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .docs-title {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-dim);
    flex: 1;
  }

  /* Ð¢Ð°Ð±Ñ‹ Ð¸ÑÑ‚Ð¾Ñ‡Ð½Ð¸ÐºÐ¾Ð² */
  #docs-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
  }
  #docs-tabs::-webkit-scrollbar { height: 2px; }
  #docs-tabs::-webkit-scrollbar-thumb { background: var(--border2); }

  .docs-tab {
    padding: 9px 14px;
    font-size: 12px;
    color: var(--text-faint);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex; align-items: center; gap: 6px;
    transition: all .15s;
    background: transparent;
    border-left: none; border-right: none; border-top: none;
    font-family: var(--font-ui);
    flex-shrink: 0;
  }
  .docs-tab:hover { color: var(--text-dim); }
  .docs-tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
  }
  .docs-tab .tab-badge {
    background: var(--surface3);
    color: var(--text-dim);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    font-family: var(--font-mono);
  }
  .docs-tab.active .tab-badge {
    background: rgba(201,168,76,.15);
    color: var(--gold-dim);
  }

  /* ÐšÐ¾Ð½Ñ‚ÐµÐ½Ñ‚ Ð¸ÑÑ‚Ð¾Ñ‡Ð½Ð¸ÐºÐ¾Ð² */
  #docs-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
  }
  #docs-content::-webkit-scrollbar { width: 4px; }
  #docs-content::-webkit-scrollbar-track { background: transparent; }
  #docs-content::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  /* ÐŸÑƒÑÑ‚Ð°Ñ Ð¿Ð°Ð½ÐµÐ»ÑŒ */
  #docs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    padding: 40px;
    text-align: center;
  }
  #docs-empty .empty-icon { font-size: 32px; opacity: .2; }
  #docs-empty .empty-title { font-size: 14px; color: var(--text-faint); }

  /* Ð¡Ð¿Ð¸ÑÐ¾Ðº Ñ‡Ð°Ð½ÐºÐ¾Ð² */
  #chunks-list { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

  .chunk-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color .2s;
    cursor: pointer;
  }
  .chunk-card:hover { border-color: var(--border2); }
  .chunk-card.highlighted {
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 1px var(--gold-dim), 0 4px 16px rgba(201,168,76,.1);
  }

  .chunk-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
  }

  .chunk-relevance {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 3px;
    background: var(--surface3);
    margin-top: 1px;
  }
  .chunk-relevance.high { color: #4ade80; background: rgba(74,222,128,.08); }
  .chunk-relevance.med  { color: var(--gold); background: rgba(201,168,76,.08); }
  .chunk-relevance.low  { color: var(--text-dim); }

  .chunk-meta { flex: 1; min-width: 0; }

  .chunk-docname {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chunk-info {
    display: flex;
    gap: 8px;
    margin-top: 3px;
    flex-wrap: wrap;
  }

  .chunk-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    background: var(--surface3);
    color: var(--text-dim);
    white-space: nowrap;
  }
  .chunk-badge.page { color: #93c5fd; background: rgba(147,197,253,.08); }
  .chunk-badge.type { color: #c4b5fd; background: rgba(196,181,253,.08); }
  .chunk-badge.source { color: #6ee7b7; background: rgba(110,231,183,.08); }

  .chunk-expand-btn {
    width: 22px; height: 22px;
    border-radius: 3px;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    transition: all .15s;
    flex-shrink: 0;
    margin-top: 1px;
  }
  .chunk-expand-btn:hover { color: var(--gold); border-color: var(--gold-dim); }
  .chunk-expand-btn.open { color: var(--gold); border-color: var(--gold-dim); }

  .chunk-body {
    display: none;
    padding: 12px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-dim);
    background: var(--bg);
    border-top: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: var(--font-ui);
  }
  .chunk-body.open { display: block; }
  .chunk-body::-webkit-scrollbar { width: 3px; }
  .chunk-body::-webkit-scrollbar-thumb { background: var(--border2); }

  .chunk-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
  }

  .btn-view-doc {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: all .2s;
  }
  .btn-view-doc:hover {
    border-color: var(--gold-dim);
    color: var(--gold);
    background: rgba(201,168,76,.05);
  }

  /* Ð’ÑŒÑŽÐ²ÐµÑ€ Ð´Ð¾ÐºÑƒÐ¼ÐµÐ½Ñ‚Ð° */
  #doc-viewer {
    display: none;
    flex-direction: column;
    height: 100%;
  }
  #doc-viewer.active { display: flex; }

  #doc-viewer-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    background: var(--surface2);
  }

  .doc-viewer-title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #doc-viewer-frame {
    flex: 1;
    border: none;
    background: #fff;
    width: 100%;
  }

  #doc-viewer-md {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-dim);
    white-space: pre-wrap;
    font-family: var(--font-ui);
    background: var(--bg);
  }
  #doc-viewer-md::-webkit-scrollbar { width: 4px; }
  #doc-viewer-md::-webkit-scrollbar-thumb { background: var(--border2); }

  .highlight-chunk {
    background: rgba(201,168,76,.12) !important;
    border-left: 2px solid var(--gold) !important;
    padding-left: 10px;
  }

  /* â”€â”€â”€ ÐŸÐÐÐ•Ð›Ð¬ ÐÐÐ¡Ð¢Ð ÐžÐ•Ðš â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  #settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
  }
  #settings-overlay.open { display: flex; }

  #settings-panel {
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    animation: slide-in .2s ease;
  }

  @keyframes slide-in {
    from { opacity: 0; transform: translateY(-16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  #settings-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .settings-title {
    font-family: var(--font-serif);
    font-size: 17px;
    flex: 1;
  }

  #settings-body {
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  #settings-body::-webkit-scrollbar { width: 4px; }
  #settings-body::-webkit-scrollbar-thumb { background: var(--border2); }

  .settings-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .settings-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--gold-dim);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }

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

  .field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
  }

  .field input, .field textarea, .field select {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 9px 12px;
    outline: none;
    transition: border-color .2s;
    width: 100%;
  }
  .field input:focus, .field textarea:focus, .field select:focus {
    border-color: var(--gold-dim);
  }
  .field textarea { min-height: 70px; resize: vertical; font-family: var(--font-ui); font-size: 13px; }
  .field select option { background: var(--surface2); }
  .field input::placeholder { color: var(--text-faint); }

  .field-hint {
    font-size: 11px;
    color: var(--text-faint);
  }

  .field-row {
    display: flex;
    gap: 10px;
  }
  .field-row .field { flex: 1; }

  #settings-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
  }

  .btn-secondary {
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
  }
  .btn-secondary:hover { background: var(--surface2); color: var(--text); }

  .btn-primary {
    padding: 8px 20px;
    border-radius: var(--radius);
    border: none;
    background: var(--gold);
    color: #1a1200;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
  }
  .btn-primary:hover { background: #dbb85a; }

  /* â”€â”€â”€ ÐÐ”ÐÐŸÐ¢Ð˜Ð’ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  /* ÐšÐ½Ð¾Ð¿ÐºÐ° "Ð¿Ð¾ÐºÐ°Ð·Ð°Ñ‚ÑŒ Ð¸ÑÑ‚Ð¾Ñ‡Ð½Ð¸ÐºÐ¸" â€” Ð²ÑÐµÐ³Ð´Ð° Ð²Ð¸Ð´Ð½Ð° Ð² Ñ…ÐµÐ´ÐµÑ€Ðµ Ð½Ð° Ð¼Ð¾Ð±Ð¸Ð»ÑŒÐ½Ð¾Ð¼ */
  #toggle-docs-btn {
    display: none;
    width: 30px; height: 30px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    align-items: center; justify-content: center;
    font-size: 14px;
    transition: all .2s;
    flex-shrink: 0;
  }
  #toggle-docs-btn:hover { color: var(--gold); border-color: var(--gold-dim); }

  /* ÐŸÐ»Ð°Ð²Ð°ÑŽÑ‰Ð°Ñ ÐºÐ½Ð¾Ð¿ÐºÐ° Ð¿Ð¾ÐºÐ°Ð·Ð° Ð¿Ð°Ð½ÐµÐ»Ð¸ Ð½Ð° Ð¼Ð¾Ð±Ð¸Ð»ÑŒÐ½Ð¾Ð¼ (Ð²ÑÐµÐ³Ð´Ð° Ð´Ð¾ÑÑ‚ÑƒÐ¿Ð½Ð°) */
  #btn-docs-float {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 250;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--gold-dim);
    background: var(--surface2);
    color: var(--gold);
    cursor: pointer;
    align-items: center; justify-content: center;
    font-size: 16px;
    box-shadow: var(--shadow);
    transition: all .2s;
  }
  #btn-docs-float:hover { background: var(--surface3); transform: scale(1.08); }

  @media (max-width: 900px) {
    #docs-col {
      position: fixed;
      right: 0; top: 52px; bottom: 0;
      z-index: 200;
      width: 95vw !important;
      max-width: 95vw;
      min-width: 0;
      box-shadow: -4px 0 24px rgba(0,0,0,.5);
    }
    #docs-col.animate {
      transition: transform .3s ease !important;
    }
    #docs-col.collapsed {
      transform: translateX(100%);
      width: 95vw !important;
      overflow: visible; /* Ñ‡Ñ‚Ð¾Ð±Ñ‹ resize handle Ð½Ðµ Ð¼ÐµÑˆÐ°Ð» */
    }
    /* ÐÐ° Ð¼Ð¾Ð±Ð¸Ð»ÑŒÐ½Ð¾Ð¼ Ñ€ÑƒÑ‡ÐºÐ° resize ÑÐºÑ€Ñ‹Ñ‚Ð° */
    #docs-resize-handle { display: none; }
    #toggle-docs-btn { display: flex; }
    #btn-docs-float { display: flex; }
    #app { position: relative; }
  }

  @media (max-width: 600px) {
    .msg { padding: 8px 12px; }
    #input-area { padding: 10px 12px; }
    .logo-sub { display: none; }
    .logo-sep { display: none; }
  }

  /* â”€â”€â”€ MISC â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .meta-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-faint);
    padding: 2px 7px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 3px;
  }

  .divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
  }

  /* â”€â”€â”€ RAG ÐžÐŸÐ¦Ð˜Ð˜ â€” Ð¼Ð¾Ð´Ð°Ð»ÑŒÐ½Ñ‹Ð¹ Ð¿Ð¾Ð¿Ð°Ð¿ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  #rag-opts-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px);
    align-items: center;
    justify-content: center;
    padding-bottom: 0;
  }
  #rag-opts-overlay.open {display: flex;}

  #rag-opts-panel {
    width: 100%;
    max-width: 720px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-bottom: none;
    border-radius: 14px;
    padding: 0 0 24px;
    box-shadow: 0 -8px 40px rgba(0,0,0,.4);
    animation: panel-up .22s cubic-bezier(.22,.8,.4,1);
    overflow: hidden;
  }
  @keyframes panel-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
  }

  #rag-opts-header {
    display: flex;
    align-items: center;
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
  }
  #rag-opts-header .panel-title {
    font-family: var(--font-serif);
    font-size: 15px;
    color: var(--text);
    flex: 1;
  }
  #rag-opts-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: all .15s;
  }
  #rag-opts-close:hover { background: var(--surface2); color: var(--text); }

  .rag-opts-body {
    padding: 12px 20px 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  .rag-opts-row {
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .rag-opts-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    min-width: 88px;
    flex-shrink: 0;
  }

  /* â”€â”€â”€ ÐŸÐžÐ›Ð—Ð£ÐÐšÐ˜ â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .range-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
  }

  input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border2);
    outline: none;
    cursor: pointer;
    transition: background .2s;
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    border: 3px solid var(--surface);
    box-shadow: 0 1px 6px rgba(0,0,0,.3);
    transition: transform .15s;
  }
  input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
  }
  input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    border: 3px solid var(--surface);
    box-shadow: 0 1px 6px rgba(0,0,0,.3);
  }
  input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(201,168,76,.25);
  }

  .range-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--gold);
    min-width: 28px;
    text-align: center;
    background: rgba(201,168,76,.1);
    border: 1px solid rgba(201,168,76,.2);
    border-radius: 5px;
    padding: 2px 6px;
    flex-shrink: 0;
  }

  .rag-opts-select {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    padding: 10px 14px;
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a8278' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
  }
  .rag-opts-select:focus { border-color: var(--gold-dim); }
  .rag-opts-select option { background: var(--surface2); }

  .rag-opts-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    padding: 10px 14px;
    outline: none;
    transition: border-color .2s;
  }
  .rag-opts-input:focus { border-color: var(--gold-dim); }
  .rag-opts-input::placeholder { color: var(--text-faint); }