/* Force correct appearance for light mode, even if system is dark */
  [data-bs-theme="light"] .form-control,
  [data-bs-theme="light"] .form-select,
  [data-bs-theme="light"] .accordion-body,
  [data-bs-theme="light"] .modal-content,
  [data-bs-theme="light"] .dropdown-menu,
  [data-bs-theme="light"] .dropdown-item,
  [data-bs-theme="light"] .navbar,
  [data-bs-theme="light"] .bg-body {
    background-color: var(--bs-body-bg, #fff) !important;
    color: var(--bs-body-color, #212529) !important;
    border-color: var(--bs-border-color, #dee2e6) !important;
  }

  [data-bs-theme="light"] pre {
    background-color: var(--bs-body-bg, #e7f1ff) !important;
    color: var(--bs-body-color, #212529) !important;
    border: 0.5px solid var(--bs-border-color, #dee2e6) !important;
    padding: 10px !important;
    border-radius: 0.5rem !important; /* Adjust radius as needed */
    margin-top: 20px !important;
    display: flex;
    align-items: center;
  }
  h1, h3, h4, h5, h6 {
    margin-top: 20px !important;
    margin-bottom: 20px !important;
  }
  [data-bs-theme="light"] [class*="language-"] {
  background-color: var(--bs-body-bg, #e7f1ff) !important;
  color: var(--bs-body-color, #212529) !important;
  }
  [data-bs-theme="dark"] pre {
    background-color: var(--bs-body-bg, #212529) !important;
    color:  var(--bs-body-color, #e7f1ff) !important;
    border: 0.5px solid var(--bs-border-color, #343a40) !important;
    padding: 10px !important;
    border-radius: 0.5rem !important; /* Adjust radius as needed */
    margin-top: 20px !important;
    display: flex;
    align-items: center;
  }
  [data-bs-theme="dark"] [class*="language-"] {
    color: var(--bs-body-color, #212529) !important;
  }
  [data-bs-theme="light"] .accordion-button {
    background-color: var(--bs-body-bg, #e7f1ff) !important;
    color: var(--bs-body-color, #212529) !important;
  }
  [data-bs-theme="light"] .modal-content {
    box-shadow: var(--bs-box-shadow) !important;
  }
  [data-bs-theme="light"] .dropdown-menu {
    box-shadow: var(--bs-box-shadow) !important;
  }
  [data-bs-theme="light"] .toast {
    box-shadow: var(--bs-box-shadow) !important;
  }
  [data-bs-theme="light"] .navbar {
    background-color: var(--bs-primary, #0d6efd) !important;
    color: #fff !important;
  }
  [data-bs-theme="dark"] .bg-body {
    background-color: var(--bs-body-bg, #212529) !important;
    color: var(--bs-body-color, #f8f9fa) !important;
    border-color: var(--bs-border-color, #343a40) !important;
  }
  [data-bs-theme="dark"] .modal-content,
  [data-bs-theme="dark"] .dropdown-menu,
  [data-bs-theme="dark"] .toast {
    box-shadow: var(--bs-box-shadow) !important;
  }
  [data-bs-theme="dark"] .form-control::placeholder {
    color: var(--bs-secondary-color, #adb5bd) !important;
  }
  [data-bs-theme="dark"] .accordion-button {
    background-color: var(--bs-body-bg, #343a40) !important;
    color: var(--bs-body-color, #f8f9fa) !important;
  }
  [data-bs-theme="dark"] .accordion-body,
  [data-bs-theme="dark"] .accordion-header,
  [data-bs-theme="dark"] .accordion-collapse,
  [data-bs-theme="dark"] .accordion-item {
    background-color: var(--bs-body-bg, #343a40) !important;
    color: var(--bs-light, #f8f9fa) !important;
  }
    body {
      font-family: 'Segoe UI', 'Inter', Arial, sans-serif;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      background-color: var(--bs-body-bg);
      color: var(--bs-body-color);
    }
    .centered-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 80vh;
      margin-bottom: 2rem;
    }
    .chat-title {
      font-size: 1.6rem;
      font-weight: 600;
      margin-bottom: 2.5rem;
      letter-spacing: 0.01em;
      text-align: center;
      color: var(--bs-body-color);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      max-width: 90%;
    }
    #chat-title-text {
      cursor: pointer;
      transition: opacity 0.2s ease, transform 0.2s ease;
    }
    #chat {
      width: 100%;
      max-width: 55%;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 2.2rem;
      padding: 2.2rem 0 1.2rem 0;
      min-height: 200px;
      background-color: var(--bs-body-bg);
      color: var(--bs-body-color);
    }
    .bubble {
      max-width: 100%;
      padding: 1.25rem 1.5rem;
      border-radius: 1.25rem;
      margin: 0;
      font-size: 1.08rem;
      line-height: 1.7;
      word-break: break-word;
      white-space: normal;
      position: relative;
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      background-color: var(--bs-body-bg);
      color: var(--bs-body-color);
    }
    .bubble.user {
      align-self: flex-end;
      border: 1px solid var(--bs-light-text-emphasis);
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    .bubble.bot {
      align-self: flex-start;
      background: var(--bs-body-bg);
      border: 1px solid var(--bs-border-color);
      color: var(--bs-body-color) !important;
    }
    
    [data-bs-theme="dark"] #chat {
      color: var(--bs-light);
      background-color: var(--bs-body-bg, #212529);
    }

    [data-bs-theme="dark"] .bubble,
    [data-bs-theme="dark"] .typing {
      color: var(--bs-light);

    }
    [data-bs-theme="light"] #chat,
    [data-bs-theme="light"] .bubble,
    [data-bs-theme="light"] .typing {
      color: var(--bs-dark);
    }

    [data-bs-theme="dark"] .accordion-header,
    [data-bs-theme="dark"] .accordion-body {
      background: var(--bs-light);
      border: 1px solid var(--bs-light-border, #dee2e6);
      color: var(--bs-dark);
    }

    .user-controls {
      position: absolute;
      right: 0.7em;
      bottom: 0.5em;
      display: flex;
      gap: 0.3em;
      align-items: flex-end;
      z-index: 2;
      height: 0;
      min-height: 0;
    }

    .bot-controls {
      position: absolute;
      right: -1.2em;
      bottom: -1.2em;
      display: flex;
      gap: 0.3em;
      align-items: flex-end;
      z-index: 2;
      height: 0;
      min-height: 0;
    }
    .user-controls {
      flex-direction: column;
    }
    .bot-controls {
      flex-direction: row;
    }
    .bot-controls .feedback-star {
      align-self: center;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 32px;
      min-height: 32px;
    }
    .bubble.user:hover .user-edit-btn {
      display: inline-flex;
    }
  .user-edit-btn, .edit-btn, .save-btn, .cancel-btn, .pre-copy-btn {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    min-width: 32px;
    min-height: 32px;
    align-items: center;
    justify-content: center;
  }
  .copy-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    min-width: 32px;
    min-height: 32px;
    align-items: center;
    justify-content: center;
    display: inline-flex;
  }
  .pre-copy-btn:hover, .pre-copy-btn:focus, .pre-copy-btn:active {
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 20;
  }
  pre code {
    min-height: 80px;
    display: flex;
    align-items: center;
  }

  .bubble.user:hover .user-edit-btn,
  .bubble.bot:hover .bot-controls .copy-btn,
  .edit-btn,
  .save-btn,
  .cancel-btn {
    opacity: 1;
    pointer-events: auto;
    display: inline-flex;
  }
    pre:hover .pre-copy-btn,
    code[class^="language-"]:hover .pre-copy-btn,
    code[class*=" language-"]:hover .pre-copy-btn {
      opacity: 1;
      pointer-events: auto;
      display: inline-flex;
    }
    .user-edit-btn .tooltip, .copy-btn .tooltip, .edit-btn .tooltip, .save-btn .tooltip, .cancel-btn .tooltip, .pre-copy-btn .tooltip {
      visibility: hidden;
      opacity: 0;
      width: max-content;
      background: var(--bs-primary, #0d6efd);
      color: var(--bs-white, #fff);
      text-align: center;
      border-radius: 4px;
      padding: 0.25em 0.7em;
      position: absolute;
      z-index: 10;
      bottom: 140%;
      left: 50%;
      transform: translateX(-50%);
      font-size: 0.93em;
      pointer-events: none;
      transition: opacity 0.2s;
      white-space: nowrap;
    }
  .user-edit-btn:hover .tooltip, .copy-btn:hover .tooltip, .edit-btn:hover .tooltip, .save-btn:hover .tooltip, .cancel-btn:hover .tooltip, .pre-copy-btn:hover .tooltip,
  .pre-copy-btn:focus .tooltip,
  .pre-copy-btn:active .tooltip {
    visibility: visible;
    opacity: 1;
    }

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

.tooltip {
  margin-bottom: 0.5em;
  background: var(--bs-primary, #0d6efd);
  color: var(--bs-body-bg, #fff);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
    .edit-area {
      font-family: inherit;
      font-size: 1em;
      border-radius: 0.5rem;
      border: 1px solid var(--bs-primary-border-subtle, var(--bs-border-color));
      padding: 0.5em;
      margin-top: 0.5em;
      margin-bottom: 0.5em;
      background: var(--bs-body-bg);
      color: var(--bs-body-color);
      resize: vertical;
    }
    .save-cancel-controls {
      display: flex;
      flex-direction: row;
      gap: 0.3em;
      position: absolute;
      right: 0.7em;
      bottom: -1em;
      z-index: 3;
      align-items: center;
    }
    .sources-list {
      margin-top: 0.5em;
      font-size: 0.97em;
      color: var(--bs-body-color);
      background: var(--bs-body-bg);
    }
    .sources-list ul li {
      margin: 0.3em 0 0 1.2em;
      padding: 0;
      color: var(--bs-body-color);
      background: var(--bs-body-bg);
      font-size: 0.7em;
    }
    .src-title {
      color: var(--bs-body-color);
      background-color: var(--bs-body-bg-subtle, #f8f9fa);
      font-size: 0.8em;
      font-weight: 500;
    }
    .src-path {
      font-weight: 500;
      color: var(--bs-body-color, #212529);
    }
    [data-bs-theme="light"] .accordion-header,
    [data-bs-theme="light"] .accordion-collapse
    {
      font-size: 0.9em;
      color: var(--bs-body-color, #212529);
      background-color: var(--bs-body-bg, #f8f9fa);
      border: 1px solid var(--bs-secondary-border, #6c757d);
    }
    .accordion-body
    {
      font-size: 1.0em;
      color: var(--bs-body-color, #212529);
      background-color: var(--bs-body-bg, #f8f9fa);
      border: 1px solid var(--bs-secondary-border, #6c757d);
    }
    #form-container {
      width: 100%;
      max-width: 700px;
      margin: 0 auto 3.5rem auto;
      display: flex;
      align-items: center;
      background: var(--bs-body-bg);
      border-radius: 2rem;
      box-shadow: var(--bs-box-shadow);
      border: 1px solid var(--bs-border-color);
      padding: 0.5rem 1.2rem;
      gap: 0.7rem;
      position: relative;
    }

    button {
      padding: 0.9rem 1.5rem;
      border: none;
      border-radius: 2rem;
      font-weight: bold;
      font-size: 1.1rem;
      cursor: pointer;
      transition: background 0.2s;
    }

    .typing {
      align-self: flex-start;
      color: var(--bs-body-color);
      padding: 1rem;
      border-radius: 12px;
      font-style: italic;
      animation: pulse 1s infinite;
      max-width: 80%;
      box-shadow: var(--bs-box-shadow-sm);
    }

    @keyframes pulse {
      0% { opacity: 0.4; }
      50% { opacity: 1; }
      100% { opacity: 0.4; }
    }
    .bubble.user {
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
    }
    .user-controls {
      height: 0;
      min-height: 0;
    }
    .user-question-text {
      margin: 0 !important;
      padding: 0 !important;
      line-height: 1.7;
      display: block;
    }
    #toast-container.toast-top-right {
      top: 80px !important;  /* Push notifications down by 80px */
      right: 20px; /* Keep it aligned to the right */
    }

    /* --- Admin Panel Redesign --- */
    .admin-layout {
      display: flex;
      gap: 1rem;
      max-height: 60vh;
      overflow: hidden;
    }
    .admin-nav {
      min-width: 175px;
      padding: 0.25rem 0.5rem;
      background: var(--bs-body-bg);
      border: 1px solid var(--bs-border-color);
      border-radius: 0.75rem;
      box-shadow: var(--bs-box-shadow-sm);
      overflow-y: auto;
      scrollbar-width: thin;
    }
    .admin-nav .nav-link {
      text-align: left;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-weight: 500;
      font-size: 0.9rem;
      color: var(--bs-body-color);
      border-radius: 0.55rem;
      margin: 4px 0;
      padding: 0.5rem 0.75rem;
      position: relative;
      transition: background 0.15s, color 0.15s;
    }
    .admin-nav .nav-link i { width: 16px; height: 16px; }
    .admin-nav .nav-link.active {
      background: linear-gradient(135deg, var(--bs-primary), var(--bs-primary-border-subtle, #4d8dff));
      color: #fff;
      box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    }
    .admin-nav .nav-link:not(.active):hover {
      background: var(--bs-body-bg-subtle, rgba(0,0,0,0.05));
      color: var(--bs-body-color);
    }
    .admin-tab-content {
      flex: 1;
      background: var(--bs-body-bg);
      border: 1px solid var(--bs-border-color);
      border-radius: 0.75rem;
      padding: 1.5rem;
      overflow: auto;
      box-shadow: var(--bs-box-shadow-sm);
    }
    .admin-table-wrapper { border: 1px solid var(--bs-border-color); border-radius: 0.5rem; background: var(--bs-body-bg); }
    .admin-table-wrapper table thead th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
    .admin-table-wrapper table tbody td { font-size: 0.78rem; }
    .section-header { border-bottom: 1px solid var(--bs-border-color); padding-bottom: 0.25rem; }
    .section-header h6 { font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; opacity: 0.9; }
    .admin-tab-content label.form-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
    .admin-tab-content .form-check-label { font-size: 0.65rem; font-weight: 500; }
    .admin-tab-content select.form-select-sm, .admin-tab-content input.form-control-sm { font-size: 0.7rem; }
    .admin-tab-content textarea#admin-llm-json { font-size: 0.7rem; }
    .admin-tab-content .badge { font-size: 0.6rem; }
    #admin-status-msg { min-height: 1rem; }

    @media (max-width: 992px) {
      .admin-layout { flex-direction: column; max-height: none; }
      .admin-nav { flex-direction: row; min-width: 100%; border-radius: 0.5rem; }
      .admin-nav .nav-link { flex: 1; justify-content: center; font-size: 0.7rem; }
      .admin-tab-content { max-height: 50vh; }
    }

    [data-bs-theme="dark"] .admin-nav { background: var(--bs-body-bg,#212529); }
    [data-bs-theme="dark"] .admin-tab-content { background: var(--bs-body-bg,#212529); }
    [data-bs-theme="dark"] .admin-nav .nav-link:not(.active):hover { background: rgba(255,255,255,0.08); }
    [data-bs-theme="dark"] .admin-nav .nav-link.active { background: linear-gradient(135deg, var(--bs-primary), #1f4d99); }

    /* Pipeline stepper */
    #pipeline-preview {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      flex-wrap: nowrap;
      overflow-x: auto;
      padding: 0.25rem 0.5rem;
    }
    .pipeline-step {
      display: flex;
      flex-direction: column;
      align-items: center;
      min-width: 60px;
      position: relative;
      font-size: 0.7rem;
      text-align: center;
      transition: opacity .25s ease, transform .25s ease;
      opacity: .55;
    }
    .pipeline-step.active { opacity: 1; }
    .pipeline-step.done { opacity: .9; }
    .pipeline-step .pipeline-circle {
      width: 18px; height: 18px; border-radius: 50%;
      background: var(--bs-secondary-bg, #ced4da);
      border: 2px solid var(--bs-border-color);
      position: relative;
      margin-bottom: 0.25rem;
      box-shadow: inset 0 0 0 2px var(--bs-body-bg);
    }
    .pipeline-step.active .pipeline-circle { background: var(--bs-primary); }
    .pipeline-step.done .pipeline-circle { background: var(--bs-success); }
    .pipeline-step.pending .pipeline-circle { background: var(--bs-tertiary-bg,#e9ecef); }
    .pipeline-connector {
      flex: 0 0 40px;
      height: 2px;
      background: linear-gradient(90deg,var(--bs-border-color) 0%, var(--bs-border-color) 50%, transparent 50%, transparent 100%);
      background-size: 8px 2px;
      background-repeat: repeat-x;
      margin-top: -14px;
    }
    @media (prefers-reduced-motion: no-preference) {
      .pipeline-step.active .pipeline-circle { animation: pulseGlow 1.2s ease-in-out infinite alternate; }
    }
    @keyframes pulseGlow {
      from { box-shadow: 0 0 0 0 var(--bs-primary); }
      to { box-shadow: 0 0 6px 2px var(--bs-primary); }
    }
    .pipeline-label { white-space: nowrap; }

    /* Live source badges */
    .live-sources { min-height: 0.5rem; }
    .live-source-badge { font-size: 0.65rem; }
    .toast-success { background-color: var(--bs-success, #51a351) !important; color: #fff !important;}
    .toast-error { background-color: var(--bs-danger, #bd362f) !important; color: #fff !important;}
    .toast-info { background-color: var(--bs-primary, #0d6efd) !important; color: #fff !important;}
    .toast-warning { background-color: var(--bs-warning, #f89406) !important; color: #fff !important;}
    .toast-title { font-weight: bold !important; color: #fff !important; font-size: 1.2rem !important; margin-bottom: 0.2rem !important; } 
    .toast { opacity: 1 !important; }
    
    [data-bs-theme="light"] #query {
      color: var(--bs-dark, #212529) !important;
      background-color: var(--bs-light, #f8f9fa) !important;
    }

    [data-bs-theme="dark"] #query {
      color: var(--bs-light) !important;
      background-color: var(--bs-dark, #212529) !important;
    }

    [data-bs-theme="light"] .dropdown-item {
      color: var(--bs-dark, #212529) !important;
      background-color: var(--bs-light, #f8f9fa) !important;
    }

    [data-bs-theme="light"] .dropdown-item:hover {
      color: var(--bs-dark, #212529) !important;
      background-color: var(--bs-light-bg-subtle, #e7f1ff) !important;
    }

    [data-bs-theme="dark"] .dropdown-item {
      color: var(--bs-light) !important;
      background-color: var(--bs-dark, #212529) !important;
    }

    [data-bs-theme="dark"] .dropdown-item:hover {
      color: var(--bs-light) !important;
      background-color: var(--bs-dark-bg-subtle, #343a40) !important;
    }

    .animated-icon {
      transition: opacity 0.2s ease, transform 0.2s ease;
    }

    .fade-out {
      opacity: 0;
      transform: scale(0.8);
    }

    .fade-in {
      opacity: 1;
      transform: scale(1);
    }
  .tippy-box {
    min-width: 70px !important;
    text-align: center !important;
  }


  /* Fix modal overlay and z-index for load chat modal */
  /* Remove forced display for modal, let Bootstrap handle show/hide */
  /* Fix delete button style in chat list */
  #saved-chats-list .delete-chat-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--bs-danger, #dc3545);
    transition: background 0.2s;
  }
  #saved-chats-list .delete-chat-btn:hover {
    background: var(--bs-danger-bg-subtle, #f8d7da);
    color: var(--bs-danger, #dc3545);
  }
  #saved-chats-list .chat-name {
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }
  #saved-chats-list .list-group-item {
    cursor: pointer;
    transition: background-color 0.15s;
  }

  [data-bs-theme="light"] #saved-chats-list .list-group-item {
    background-color: var(--bs-body-bg, #fff) !important;
    color: var(--bs-body-color, #212529) !important;
    border-color: var(--bs-border-color, #dee2e6) !important;
  }

  [data-bs-theme="dark"] #saved-chats-list .list-group-item {
    background-color: var(--bs-dark, #212529) !important;
    color: var(--bs-light, #f8f9fa) !important;
    border-color: var(--bs-border-color, #343a40) !important;
  }

  [data-bs-theme="light"] #saved-chats-list .list-group-item:hover {
    background-color: var(--bs-light-bg-subtle, #e7f1ff) !important;
  }

  [data-bs-theme="dark"] #saved-chats-list .list-group-item:hover {
    background-color: var(--bs-dark-bg-subtle, #343a40) !important;
  }

  /* Folder tree styling */
  #folder-tree ul {
    list-style: none;
    padding-left: 1.2em;
  }
  #folder-tree label {
    display: flex;
    align-items: center;
    gap: 0.35em;
    margin-bottom: 0.2em;
  }
  #folder-tree i {
    color: var(--bs-warning, #f0ad4e);
  }

  .floating-chat-controls {
    position: fixed;
    bottom: 60px;
    right: 30px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 1rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.13);
    padding: 1.1rem 1.2rem 1.1rem 1.2rem;
    gap: 0.5rem;
    min-width: 160px;
    max-width: 220px;
    opacity: 0.98;
  }
  .floating-chat-controls .btn {
    width: 100%;
    text-align: left;
    margin-bottom: 0.3rem;
  }
  .floating-chat-controls .dropdown-menu {
    min-width: 180px;
    max-width: 220px;
  }

  .model-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.2em;
    font-size: 0.8em;
    margin-left: 0.4rem;
  }
  .model-meta i {
    width: 0.9em;
    height: 0.9em;
  }
  .model-table {
    width: 100%;
    font-size: 0.9em;
  }
  .model-table th, .model-table td {
    padding: 0.25rem;
    text-align: center;
  }
  .model-table td:first-child {
    text-align: left;
  }
  .model-table .form-check {
    margin: 0;
  }
  .modal-md {
    --bs-modal-width: 600px;
  }
  
  /* Scroll navigation buttons */
  #scroll-nav {
    position: fixed;
    bottom: 6rem; /* keep above footer */
    right: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 1050;
  }
  #scroll-nav .btn {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .workspace-widget {
    position: fixed;
    bottom: 6rem;
    right: 4.25rem;
    width: 270px;
    background-color: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 0.85rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 1049;
  }

  .workspace-widget .btn {
    text-align: center;
  }

  .workspace-widget .text-truncate {
    max-width: 100%;
  }

  @media (min-width: 768px) {
    .workspace-widget {
      display: flex;
    }
  }

  @media (max-width: 768px) {
    .floating-chat-controls {
      right: 10px;
      left: 10px;
      min-width: unset;
      max-width: unset;
      padding: 0.7rem 0.5rem;
      bottom: 70px;
    }
    #chat,
    #form-container,
    #suggestions-container {
      max-width: 98% !important;
      width: 100% !important;
      padding-left: 0.5rem;
      padding-right: 0.5rem;
    }
    .bubble {
      font-size: 1rem;
      padding: 0.8rem 1rem;
    }
    .chat-title {
      font-size: 1.2rem;
      padding-left: 0.5rem;
      padding-right: 0.5rem;
    }
    .centered-container {
      min-height: 60vh;
      margin-bottom: 1rem;
      padding-left: 0.5rem;
      padding-right: 0.5rem;
    }
    /* Scroll navigation buttons */
    #scroll-nav {
      position: fixed;
      bottom: 1rem;
      right: 1rem;
      display: none;
      flex-direction: column;
      gap: 0.4rem;
      z-index: 1050;
    }
    #scroll-nav .btn {
      width: 2rem;
      height: 2rem;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .workspace-widget {
      bottom: 1rem;
      right: 1rem;
      width: calc(100% - 2rem);
      max-width: 360px;
    }
  }

.settings-fieldset {
  border: 1px solid var(--bs-border-color);
  padding: 0.75rem 1rem 1rem;
  border-radius: 0.5rem;
}

.settings-fieldset legend {
  width: auto;
  padding: 0 0.5em;
}

#temperature {
  max-width: 250px;
}

.rating-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
  margin: 0.2em auto;
}

.model-table thead tr { border-bottom: 2px solid #dee2e6; }
.model-table tbody tr:last-child { border-bottom: none; }
.model-table tbody td { padding-top: 1em; padding-bottom: 1em; }
.model-table tbody tr {
  transition: background-color 0.15s;
}
.model-table tbody tr:hover {
  background-color: var(--bs-body-bg-subtle, #f8f9fa);
}

/* Model Flags modal accordion */
#admin-models .accordion-button {
  font-size: 0.95rem;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#admin-models .list-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  border: none;
  background: transparent;
}
[data-bs-theme="light"] #admin-models .list-group-item {
  background-color: var(--bs-body-bg, #fff) !important;
  color: var(--bs-body-color, #212529) !important;
}
[data-bs-theme="dark"] #admin-models .list-group-item {
  background-color: var(--bs-dark, #212529) !important;
  color: var(--bs-light, #f8f9fa) !important;
}

.modal,
.offcanvas-backdrop {
    backdrop-filter: blur(6px);
}

/* Apply blurred backdrop to modals and offcanvas */
.modal-backdrop.show,
.offcanvas-backdrop.show {
  backdrop-filter: blur(6px);
  opacity: 0.5;
}

/* Light and dark theme backdrop colors */
[data-bs-theme="light"] .modal-backdrop.show,
[data-bs-theme="light"] .offcanvas-backdrop.show {
  backdrop-filter: blur(6px);
  opacity: 0.5;
}

[data-bs-theme="dark"] .modal-backdrop.show,
[data-bs-theme="dark"] .offcanvas-backdrop.show {
  backdrop-filter: blur(6px);
  opacity: 0.5;
}

/* SSE status history styles */
.status-history {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.status-item {
  font-size: 0.85em;
  opacity: 1;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.status-item.fade-out-up {
  opacity: 0;
  transform: translateY(-5px);
}

:root {
  --focus-ring: 0 0 0 0.2rem rgba(13,110,253,.35);
}
:focus-visible {
  outline: 2px solid var(--bs-primary); /* fallback */
  outline-offset: 2px;
}
button:focus-visible, .btn:focus-visible {
  box-shadow: var(--focus-ring) !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
.max-content-width { max-width: 1200px; margin-left: auto; margin-right: auto; }

#model-summary-bar { 
  font-size: 0.8rem; 
  letter-spacing: .03em; 
  position: sticky; 
  top: 0; 
  z-index: 1020;     
  font-size: 0.7rem;
  text-align: center;
  transition: opacity .25s ease, transform .25s ease;
  opacity: .55; }
#query { line-height:1.4; }
textarea#query { overflow:hidden; }

/* Wider admin offcanvas panel */
#settings-panel.offcanvas-end {
  width: min(90vw, 900px);
}
@media (max-width: 768px) {
  #settings-panel.offcanvas-end { width: 100%; }
}

/* Keyboard accessibility for file input */
#file-input:focus + #file-label {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  border-color: #86b7fe;
  z-index: 5;
}
