@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap'); * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

/* This hides the white box at the corner intersection */
::-webkit-scrollbar-corner {
  background: transparent;
}

*::-webkit-scrollbar-track {
    background: #1a1a1a;
}

*::-webkit-scrollbar-thumb {
    background: #313131;
    border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

body.light-mode *::-webkit-scrollbar-track {
    background: #f5f5f7;
}

body.light-mode *::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

body.light-mode *::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

hr {
    margin-bottom: 1rem;
    margin-top: 1rem;
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    overflow: hidden;
    overflow-x: hidden;
    overflow-y: hidden;
}

/*  Sidebar  */
.sidebar {
    width: 280px;
    min-width: 281px;
    background-color: #141414;
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: width 0.3s ease, min-width 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 52px;
    min-width: 52px;
}

/*  Sidebar Top  */
.sidebar-top {
    margin-top: 5px;
    margin-bottom: 5px;
    padding: 18px 18px 28px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    flex-shrink: 0;
    position: relative;
}

/* Collapsed: centre everything, become a crossfade zone */
.sidebar.collapsed .sidebar-top {
    padding: 0;
    justify-content: center;
}

.sidebar-logo img {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    transform: translate(5%, 20%);
}

.sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Collapsed: logo becomes an absolute centred element that fades out on hover */
.sidebar.collapsed .sidebar-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-52%, -60%);
    opacity: 1;
    pointer-events: none;
    transition: opacity 0.18s;
}

.sidebar.collapsed:hover .sidebar-logo {
    opacity: 0;
}

/* Toggle  normal state */
.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    transform: translate(-15%, 25%);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, opacity 0.18s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: #252525;
    color: #d2d2d2;
}

/* Collapsed: toggle becomes absolute at same spot as logo, hidden until hover */
.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s, background 0.2s, color 0.2s;
}

.sidebar.collapsed:hover .sidebar-toggle {
    opacity: 1;
    pointer-events: all;
}

/*  Sidebar Nav  */
.sidebar-nav {
    padding: 0px 8px 0px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: none;
    color: #D2D2D2;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    text-align: left;
}

.sidebar-btn svg {
    flex-shrink: 0;
    color: #D2D2D2;
    transition: color 0.2s;
}

.sidebar-btn:hover {
    background: #252525;
    color: #d2d2d2;
}

.sidebar-btn:hover svg {
    color: #50c878;
}

.sidebar-btn.new-chat:hover {
    color: #f0f0f0;
}

.sidebar-btn-label {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.18s;
}

.sidebar.collapsed .sidebar-btn-label {
    opacity: 0;
    width: 0;
}

/*  Section Title  */
.sidebar-section-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: #d2d2d2;
    padding: 12px 10px 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.18s;
}

.sidebar.collapsed .sidebar-section-title {
    opacity: 0;
}

/*  Sidebar History  */
.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    transition: opacity 0.18s;
}

/* Hide entire history when collapsed */
.sidebar.collapsed .sidebar-history {
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    flex: 0;
    padding: 0;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    color: #D2D2D2;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.86rem;
    font-weight: 400;
    transition: border-color 0.2s, box-shadow 0.2s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background: #252525;
    color: #d2d2d2;
}

.history-item svg {
    flex-shrink: 0;
    color: #D2D2D2;
}

.history-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.18s;
}

.sidebar.collapsed .history-item-text {
    opacity: 0;
    width: 0;
}

/*  Sidebar Footer  Settings  */
.sidebar-footer {
    padding: 10px 8px 14px;
    margin-top: auto;
    /* border-top: 1px solid #1f1f1f; */
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    color: #D2D2D2;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.settings-btn svg {
    flex-shrink: 0;
    color: #D2D2D2;
    transition: color 0.2s;
}

.settings-btn:hover {
    background: #252525;
    color: #d2d2d2;
}

.settings-btn:hover svg {
    color: #50c878;
}

.settings-btn-label {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.18s;
}

.sidebar.collapsed .settings-btn-label {
    opacity: 0;
    width: 0;
}

/*  Main Chat Area  */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/*  Topbar  absolute overlay with fade gradient  */
.chat-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 14px;
    height: 56px;
    /* Gradient fades content as it scrolls under the bar */
    background: transparent;
    pointer-events: none;
}

.chat-topbar > * {
    pointer-events: all;
}

/*  Model Selector (top-left of chat topbar)  */
.model-selector {
    position: relative;
    display: flex;
    align-items: center;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: none;
    color: #d2d2d2;
    padding: 7px 9px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.86rem;
    font-weight: 500;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    -webkit-user-select: none;
    user-select: none;
    max-width: 260px;
}

.model-selector-btn:hover {
    background: #232323;
    color: #f0f0f0;
}

.model-selector-btn:active {
    transform: translateY(0.5px);
}

.model-selector-glyph {
    display: none; /* hidden — match minimal list-item aesthetic */
}

.model-selector-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-selector-chevron {
    color: #888;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s;
}

.model-selector.open .model-selector-chevron {
    transform: rotate(180deg);
    color: #50c878;
}

/* Active-model pulse removed — selector no longer lights up during generation. */

/*  Dropdown panel — matches .history-item list aesthetic  */
.model-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 248px;
    max-width: 320px;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25);
    padding: 5px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transform-origin: top left;
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
}

.model-selector.open .model-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.model-dropdown-item:hover {
    background: #252525;
}

.model-dropdown-item.active {
    background: rgba(80, 200, 120, 0.07);
    border-color: rgba(80, 200, 120, 0.15);
}

.model-dropdown-text {
    flex: 1;
    min-width: 0;
}

.model-dropdown-title {
    font-size: 0.86rem;
    font-weight: 500;
    color: #d2d2d2;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-dropdown-item:hover .model-dropdown-title {
    color: #f0f0f0;
}

.model-dropdown-item.active .model-dropdown-title {
    color: #f0f0f0;
}

.model-dropdown-desc {
    font-size: 0.74rem;
    color: #888;
    margin-top: 2px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-dropdown-item.active .model-dropdown-desc {
    color: #a8a8a8;
}

/* ── Locked / disabled model ─────────────────────────────────
   Rendered at the bottom of the dropdown. Cannot be selected,
   hovered, or focused. Visibly grayed out with a lock icon and
   a "Locked" badge so it's clearly intentional, not a bug. */
.model-dropdown-item.disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.model-dropdown-item.disabled .model-dropdown-title {
    color: #707070;
    display: flex;
    align-items: center;
    gap: 6px;
}

.model-dropdown-item.disabled .model-dropdown-desc {
    color: #5a5a5a;
}

.model-dropdown-lock {
    display: inline-flex;
    align-items: center;
    color: #888;
    flex-shrink: 0;
}

/* Light mode overrides — matches existing light-mode list aesthetic */
body.light-mode .model-selector-btn {
    background: transparent;
    color: #1a1a1a;
}

body.light-mode .model-selector-btn:hover {
    background: #f0f0f0;
    color: #000;
}

body.light-mode .model-selector-name { color: #1a1a1a; }

body.light-mode .model-dropdown {
    background: #ffffff;
    border-color: #e8e8e8;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
}

body.light-mode .model-dropdown-item:hover {
    background: #f0f0f0;
}

body.light-mode .model-dropdown-item.active {
    background: rgba(80, 200, 120, 0.08);
    border-color: rgba(80, 200, 120, 0.2);
}

body.light-mode .model-dropdown-title { color: #1a1a1a; }
body.light-mode .model-dropdown-item:hover .model-dropdown-title { color: #000; }
body.light-mode .model-dropdown-item.active .model-dropdown-title { color: #000; }
body.light-mode .model-dropdown-desc { color: #888; }
body.light-mode .model-dropdown-item.active .model-dropdown-desc { color: #666; }

/* Light mode overrides for locked model */
body.light-mode .model-dropdown-item.disabled .model-dropdown-title { color: #aaa; }
body.light-mode .model-dropdown-item.disabled .model-dropdown-desc { color: #b0b0b0; }
body.light-mode .model-dropdown-lock { color: #aaa; }

/* Mobile: shrink selector */
@media (max-width: 640px) {
    .model-selector-btn {
        padding: 6px 8px;
        font-size: 0.82rem;
        gap: 5px;
        max-width: 180px;
    }
    .model-dropdown {
        min-width: 230px;
        max-width: calc(100vw - 24px);
    }
}

@media (max-width: 380px) {
    .model-selector-btn .model-selector-name { max-width: 110px; }
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 7px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.83rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: #232323;
    color: #d2d2d2;
}

.icon-btn .btn-label {
    color: #666;
    transition: color 0.2s;
    font-family: 'DM Sans', sans-serif;
}

.icon-btn:hover .btn-label {
    color: #d2d2d2;
}

/*  Chat Content  */
.chat-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
}

.welcome-screen {
    margin: 0; 
    /* Subtracts the top header and bottom input heights so it never overflows */
    min-height: calc(100vh - 140px); 

    display: flex;
    flex-direction: column;
    align-items: center;      
    justify-content: center;   

    padding: 20px;
    text-align: center;
    gap: 26px;
    box-sizing: border-box; 
}
.rightclick-menu {
    position: fixed;
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    min-width: 240px;
    z-index: 10000;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(3px);
    padding: 8px 0;
    animation: ctxFadeIn 0.2s ease-out;
  }
  .context-section {
    padding: 4px 0;
  }
  .context-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #444;
    padding: 6px 16px 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    pointer-events: none;
  }
  .context-text {
    padding: 0 16px 8px;
    font-size: 0.85rem;
    color: #333;
    line-height: 1.4;
    white-space: pre-wrap;
  }
  .rightclick-menu a {
    display: block;
    padding: 10px 16px;
    color: #000;
    text-decoration: none;
    transition: background 0.2s ease;
    font-size: 0.9rem;
    cursor: pointer;
  }
  .rightclick-menu a:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
  }
  .rightclick-menu a svg {
    color: #333;
  }
  .rightclick-menu a.ctx-danger,
  .rightclick-menu a.ctx-danger svg {
    color: #d93025;
  }
  .rightclick-menu a.ctx-danger:hover {
    background: rgba(217, 48, 37, 0.06);
  }
  .ctx-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 4px 0;
  }
  @keyframes ctxFadeIn {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
.custom-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  white-space: normal;
  word-break: break-word;
  max-width: 80vw;
  text-align: left;
}
  .custom-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
  }

.welcome-icon {
    width: 50px;
    height: 50px;
    border-radius: 13px;
    background: linear-gradient(135deg, #1e6b3c, #50c878);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 28px #50c87828;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 18px #50c87818;
    }

    50% {
        box-shadow: 0 0 38px #50c87848;
    }
}

.welcome-text-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: center;
}

.welcome-heading {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.85rem;
    font-weight: 700;
    background: linear-gradient(90deg, rgb(210, 210, 210), rgb(140, 140, 140), rgb(210, 210, 210));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.25;
}

.welcome-sub {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    color: #4e4e4e;
}

/*  Quick Action Cards  */
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 2500px;
}

.quick-card {
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 80px;
    padding: 10px 16px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 175px;
    flex: 1;
    max-width: 2500px;
}

.quick-card:hover {
    border-color: rgba(80, 200, 120, 0.25);
    box-shadow: 0 0 0 1px rgba(80, 200, 120, 0.08), 0 4px 16px rgba(0, 0, 0, 0.22);
}

.quick-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 25px;
    background: #252525;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #50c878;
    flex-shrink: 0;
}

.quick-card-text {
    text-align: left;
}

.quick-card-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.87rem;
    color: #d2d2d2;
    min-width: 125px;
}

.quick-card-desc {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.77rem;
    font-weight: 400;
    color: #D2D2D2;
    margin-top: 2px;
}

/*  Messages  */
.messages-area {
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-width: 730px;
    width: 100%;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 13px;
    align-items: flex-start;
}

/* User messages align right */
.message--user {
    flex-direction: row-reverse;
}

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

.message--user .message-sender {
    text-align: right;
}

.message--user .message-text.user-text {
    max-width: 80%;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
}

.message-avatar-user {
    width: 30px;
    height: 30px;
    background: #2b2b2b;
    border-radius: 25px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
}

body.light-mode .message-avatar-user {
    width: 30px;
    height: 30px;
    background: #FFF;
    border-radius: 25px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
}

.message-avatar.ai {
    overflow: hidden;
}

.message-avatar.ai img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.message-body {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.message-sender {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.message-text {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.93rem;
    font-weight: 400;
    color: #c8c8c8;
    line-height: 1.65;
    min-width: 0;
    overflow-x: hidden;
}

.message-text.user-text {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 11px 15px;
    color: #e0e0e0;
}

.message-actions {
    display: flex;
    gap: 2px;
    margin-top: 8px;
}

.msg-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    padding: 5px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.msg-action-btn:hover {
    color: #50c878;
    background: rgba(80, 200, 120, 0.08);
}

.msg-action-btn.rated-like {
    color: #50c878;
}

.msg-action-btn.rated-dislike {
    color: #e05555;
}

/*  Typing indicator  */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #50c878;
    opacity: 0.35;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/*  Input Area  */
.chat-input-wrap {
    padding: 0px 20px 18px;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-spacer {
    flex-shrink: 0;
    height: 0;
    transition: height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.chat-input-box {
    max-width: 720px;
    margin: 0 auto;
}

.input-container {
    background: #1e1e1e;
    border: 1px solid #2e2e2e;
    border-radius: 28px;
    padding: 10px 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-box.drag-over .input-container {
    border-color: rgba(80, 200, 120, 0.7);
    box-shadow: 0 0 0 3px rgba(80, 200, 120, 0.15);
}

.input-container:focus-within {
    border-color: rgba(80, 200, 120, 0.38);
    box-shadow: 0 0 0 3px rgba(80, 200, 120, 0.06);
}

.input-attach-btn {
    width: 33px;
    height: 33px;
    background: none;
    border: none;
    cursor: pointer;
    color: #D2D2D2;
    padding: 5px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.input-attach-btn:hover {
    color: #c0c0c0;
    background: #282828;
}

#webSearchBtn.active {
    color: #4caf7d;
}

#webSearchBtn.active:hover {
    color: #5de09a;
    background: rgba(76,175,125,0.12);
}

/* ── Web search citation chips ─── */
.esb-citations {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #232323;
}

.esb-citations-query {
    font-size: 0.72rem;
    color: #555;
    width: 100%;
    margin-bottom: 2px;
}

.esb-citation-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px 3px 7px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 20px;
    font-size: 0.72rem;
    color: #888;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: break-all;
}

.esb-citation-chip:hover {
    background: #222;
    color: #bbb;
    border-color: #3a3a3a;
}

body.light-mode .esb-citations { border-top-color: #eee; }
body.light-mode .esb-citations-query { color: #aaa; }
body.light-mode .esb-citation-chip { background: #f5f5f5; border-color: #e0e0e0; color: #666; }
body.light-mode .esb-citation-chip:hover { background: #ebebeb; color: #333; }

.chat-textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    color: #D2D2D2;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.93rem;
    font-weight: 400;
    line-height: 1.5;
    min-height: 28px;
    max-height: 180px;
    overflow-y: auto;
}

.chat-textarea::placeholder {
    color: #444;
    font-family: 'DM Sans', sans-serif;
}

.send-btn {
    width: 33px;
    height: 33px;
    border-radius: 80px;
    background: #019100;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px #50c87828;
    margin-bottom: 2px;
}

.send-btn:hover {
    opacity: 0.88;
    box-shadow: 0 4px 14px #50c87840;
}

.send-btn:active {
    transform: scale(0.95);
}

.input-footer-note {
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.71rem;
    font-weight: 400;
    color: #D2D2D2;
    padding-top: 14px;
}

/*  Topbar extras  */
.topbar-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82rem;
    color: #555;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 340px;
    flex: 1;
    padding-left: 14px;
}

.temp-badge {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: #50c878;
    background: rgba(80,200,120,0.1);
    border: 1px solid rgba(80,200,120,0.2);
    border-radius: 20px;
    padding: 2px 10px;
}

.icon-btn.active {
    color: #50c878;
    background: rgba(80,200,120,0.08);
}

/*  Sidebar extras  */
.sidebar-empty {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    color: #444;
    padding: 10px 12px;
}

.history-item.active {
    background: rgba(80,200,120,0.07);
    border-color: rgba(80,200,120,0.15);
    color: #d2d2d2;
}

.proj-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/*  Attachment preview  */
.attach-preview {
    max-width: 720px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 2px;
    overflow: hidden;
    background: transparent;
}

.attach-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2c2c2c;
    flex-shrink: 0;
}

.attach-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-file {
    display: flex;
    align-items: center;
    height: 4rem;
    gap: 6px;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    padding: 6px 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    color: #bbb;
    max-width: 180px;
    position: relative;
}

.attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attach-rm {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3a3a3a;
    border: 1px solid #252525;
    color: #D2D2D2;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s;
}

.attach-rm:hover {
    background: #cc3333;
    color: #fff;
}

/*  Message file cards  */
.msg-files {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.msg-file-img img {
    max-width: 240px;
    max-height: 200px;
    border-radius: 10px;
    border: 1px solid #2c2c2c;
    object-fit: cover;
}

.msg-file-card {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    padding: 6px 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    color: #bbb;
}

/*  Toast  */
.ai-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    padding: 13px 22px;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
    z-index: 99999;
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.18);
    border: 1px solid rgba(0,0,0,0.08);
    max-width: 420px;
    text-align: left;
    white-space: pre-line;
}

.ai-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

.ai-toast.ai-toast--error {
    background: #fff0f0;
    color: #c0392b;
    border-color: rgba(192,57,43,0.2);
}

.ai-toast.ai-toast--info {
    background: #f0fff6;
    color: #1a7a47;
    border-color: rgba(26,122,71,0.2);
}

/*  Context Menu  */
.ai-context-menu {
    position: fixed;
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    min-width: 240px;
    z-index: 10000;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(3px);
    padding: 8px 0;
    animation: ctxFadeIn 0.2s ease-out;
}

.ai-context-menu a {
    display: block;
    padding: 10px 16px;
    color: #000;
    text-decoration: none;
    transition: background 0.2s ease;
    font-size: 0.9rem;
    cursor: pointer;
}

.ai-context-menu a:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
}

.ai-context-menu a svg {
    color: #333;
}

.ai-context-menu a.ctx-danger,
.ai-context-menu a.ctx-danger svg {
    color: #d93025;
}

.ai-context-menu a.ctx-danger:hover {
    background: rgba(217, 48, 37, 0.06);
}

.ctx-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #444;
    padding: 6px 16px 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    pointer-events: none;
}

.ctx-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 4px 0;
}

/*  Modals  */
.ai-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeInOverlay 0.3s ease;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ai-modal-overlay.open {
    display: flex;
}

.ai-modal {
    background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgb(0 0 0 / 60%);
    animation: slideUpModal 0.22s cubic-bezier(0.34,1.2,0.64,1);
    overflow: hidden;
    position: relative;
}

body.light-mode .ai-modal {
    box-shadow: 0 20px 60px rgb(70 70 70 / 30%);
}

.ai-modal--sm {
    max-width: 400px;
}

.ai-modal--lg {
    max-width: 480px;
}

@keyframes slideUpModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.ai-modal-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #e8e8e8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.ai-modal-close:hover {
    color: #e0e0e0;
    background: rgba(255,255,255,0.07);
}

/* Absolute close for centered modals */
.ai-modal-close--abs {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
}

.ai-modal-body {
    padding: 24px;
    max-height: 55vh;
    overflow-y: auto;
}

/* Centered body (delete/confirm modals) */
.ai-modal-body--centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 50rem;
    padding: 32px 28px 20px;
}

.ai-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ai-modal-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 9px 22px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    min-width: 90px;
}

.ai-modal-btn.primary {
    background: #019100;
    color: #fff;
    border-color: #019100;
}

.ai-modal-btn.primary:hover {
    background: #017a00;
    box-shadow: 0 4px 12px rgba(1,145,0,0.35);
}

.ai-modal-btn.secondary {
    background: rgba(108,117,125,0.1);
    color: rgba(210,210,210,0.9);
    border: 1px solid rgba(108,117,125,0.2);
}

.ai-modal-btn.secondary:hover {
    background: rgba(108,117,125,0.18);
    color: #e0e0e0;
}

.ai-modal-btn.danger {
    background: #ee5a52;
    color: #fff;
    border-color: rgba(238,90,82,0.3);
}

.ai-modal-btn.danger:hover {
    background: #e53935;
    box-shadow: 0 4px 12px rgba(238,90,82,0.4);
}

/*  Centered modal elements  */
.modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    flex-shrink: 0;
}

.modal-icon--danger {
    background: #ee5a52;
    color: #fff;
}

.modal-icon--info {
    background: #019100;
    color: #fff;
}

.modal-centered-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #e8e8e8;
    margin: 0 0 16px;
    line-height: 1.3;
}

.modal-centered-text,
.modal-centered-body {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: rgba(180,180,180,0.8);
    text-align: center;
    margin: 0 0 12px;
    line-height: 1.55;
}

.modal-centered-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

.ai-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 0 28px 28px;
    flex-shrink: 0;
}

/* Form body inside centered modals */
.modal-form-body {
    width: 100%;
    text-align: left;
}

/* Library modal helpers */
.lib-filter-row {
    width: 100%;
    margin-bottom: 14px;
}

.lib-filter-select {
    width: 100%;
    background: #141414;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    padding: 9px 36px 9px 12px;
    color: #e0e0e0;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.2s;
}

.lib-filter-select:focus {
    border-color: rgba(80,200,120,0.4);
}

.lib-filter-select option {
    background: #1e1e1e;
    color: #e0e0e0;
}

.lib-scroll-area {
    width: 100%;
    max-height: 46vh;
    overflow-y: auto;
}

/* Settings form */
.sett-group {
    margin-bottom: 18px;
}

.sett-group:last-child {
    margin-bottom: 0;
}

.sett-label {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: #aaa;
    font-weight: 500px;
    margin-bottom: 6px;
}

.sett-input {
    width: 100%;
    background: #141414;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    padding: 9px 12px;
    color: #e0e0e0;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.sett-input:focus {
    border-color: rgba(80,200,120,0.4);
}

.sett-select {
    height: 38px;
    cursor: pointer;
}

.sett-hint {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    color: #444;
    margin-top: 5px;
}

.sett-hint a {
    color: #50c878;
    text-decoration: none;
}

.sett-hint a:hover {
    text-decoration: underline;
}

.sett-readonly {
    background: #141414;
    border: 1px solid #1f1f1f;
    border-radius: 8px;
    padding: 9px 12px;
    color: #555;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.86rem;
}

.modal-warn-text {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: #888;
}

/*  Library/Projects modal lists  */
.lib-empty {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: #444;
    text-align: center;
    padding: 30px 20px;
    line-height: 1.7;
}

.lib-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-radius: 6px;
    border-bottom: 1px solid #1f1f1f;
    transition: all 0.2s ease
}

.lib-item:last-child {
    border-bottom: none;
}

.lib-item-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.lib-item-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: #d2d2d2;
    font-weight: 500;
}

.lib-item-meta {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    color: #555;
    margin-top: 2px;
}

/* Projects modal */
.proj-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid #1f1f1f;
}

.proj-card:last-child {
    border-bottom: none;
}

.proj-dot-lg {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.proj-card-info {
    flex: 1;
}

.proj-card-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #d2d2d2;
}

.proj-card-meta {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    color: #555;
    margin-top: 2px;
}

.proj-card-actions {
    display: flex;
    gap: 6px;
}

.icon-sm-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.icon-sm-btn:hover {
    color: #d2d2d2;
    background: #252525;
}

.icon-sm-btn.ctx-danger {
    color: #e05555;
}

.icon-sm-btn.ctx-danger:hover {
    background: rgba(220,60,60,0.1);
}

.proj-create-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid #1f1f1f;
}

.proj-create-row .sett-input {
    flex: 1;
}

.proj-color-picker {
    width: 38px;
    height: 38px;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    padding: 3px;
    background: #141414;
    cursor: pointer;
    flex-shrink: 0;
}

/* Search modal */
.search-result {
    padding: 11px 4px;
    border-bottom: 1px solid #1f1f1f;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 6px;
}

.search-result:hover {
    background: rgba(255,255,255,0.04);
}

.search-result:last-child {
    border-bottom: none;
}

.search-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    color: #d2d2d2;
}

.search-snippet {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    color: #555;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/*  Message actions rated state  */
.msg-action-btn.rated svg {
    color: #50c878;
}

.msg-action-btn.rated {
    color: #50c878;
}

/*  Markdown rendered content  */
.md-content {
    line-height: 1.7;
    overflow-y: hidden;
}

.md-content p {
    margin: 0 0 0.75em;
}

.md-content p:last-child {
    margin-bottom: 0;
}

.md-content strong {
    color: #e8e8e8;
    font-weight: 700;
}

.md-content em {
    font-style: italic;
    color: #c0c0c0;
}

.md-content a {
    color: #50c878;
    text-decoration: underline;
}

.md-content ul, .md-content ol {
    padding-left: 22px;
    margin: 0.5em 0 0.75em;
}

.md-content li {
    margin: 0.25em 0;
}

.md-content h1, .md-content h2, .md-content h3, .md-content h4, .md-content h5 {
    font-family: 'DM Sans', sans-serif;
    color: #e8e8e8;
    font-weight: 700;
    margin: 1em 0 0.4em;
    line-height: 1.3;
}

.md-content h1 {
    font-size: 1.3em;
}

.md-content h2 {
    font-size: 1.15em;
}

.md-content h3 {
    font-size: 1.05em;
}

.md-content h4, .md-content h5 {
    font-size: 0.95em;
}

.md-content code {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 5px;
    padding: 1px 6px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.84em;
    color: #50c878;
}

body.light-mode .md-content code {
    background: #ffffff;
    border: 1px solid transparent;
}

.md-code-block {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #242424;
    margin: 0.75em 0;
    background: #141414;
}

body.light-mode .md-code-block {
    border: 1px solid #aaa;
    margin: 0.75em 0;
    background: #ffffff;
}

.md-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    background: #1a1a1a;
    border-bottom: 1px solid #222;
}

body.light-mode .md-code-header {
    background: #f5f5f7;
    border-bottom: 1px solid #aaa;
}

.md-code-lang {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.73rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.md-code-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.md-copy-btn,
.md-run-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #555;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 5px;
    transition: color 0.15s, background 0.15s;
}

.md-copy-btn:hover,
.md-run-btn:hover {
    color: #50c878;
    background: rgba(80,200,120,0.08);
}

.md-code-block pre {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
    font-size: 0.84em;
    line-height: 1.55;
}

.md-code-block pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: 1em;
}

.md-table-wrap {
    overflow-x: auto;
    margin: 0.75em 0;
    border-radius: 8px;
    border: 1px solid #242424;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.86em;
}

.md-table th {
    background: #1a1a1a;
    color: #d2d2d2;
    font-weight: 600;
    padding: 8px 14px;
    border-bottom: 1px solid #242424;
    text-align: left;
}

.md-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #1e1e1e;
    color: #c0c0c0;
}

.md-table tr:last-child td {
    border-bottom: none;
}

.md-table tr:hover td {
    background: rgba(255,255,255,0.025);
}

.md-blockquote {
    border-left: 3px solid #50c878;
    padding: 6px 14px;
    margin: 0.75em 0;
    background: rgba(80,200,120,0.04);
    border-radius: 0 6px 6px 0;
    color: #999;
    font-style: italic;
}

.md-math-block {
    overflow-x: auto;
    margin: 0.75em 0;
    text-align: center;
    padding: 8px 0;
}

/* Unified error style — used for response cancelled, "An error occurred",
   "Something went wrong", AND image generation failures so every error in
   the chat looks the same: plain red text, no background box. */
.md-error {
    color: #e05555;
    font-size: 0.88em;
}

/*  Responsive  */
@media (max-width: 768px) {
    .quick-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-card {
        max-width: none;
    }

    .welcome-heading {
        font-size: 1.4rem;
    }

    .ai-modal {
        max-width: 100% !important;
    }

    .ai-modal-body {
        max-height: 60vh;
    }
}

/*  Modal close animation  */
@keyframes slideDownModal {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
}

@keyframes fadeOutOverlay {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.ai-modal-overlay.closing {
    animation: fadeOutOverlay 0.23s ease forwards;
    pointer-events: none;
}

.ai-modal-overlay.closing .ai-modal {
    animation: slideDownModal 0.23s ease-in forwards;
}

/*  Streaming word animation  */
@keyframes wordReveal {
    from {
        opacity: 0;
        filter: blur(5px);
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

.stream-word {
    display: inline-block;
    vertical-align: baseline;
    animation: wordReveal 0.45s ease-out forwards;
    white-space: pre-wrap;
}

/*  Library filter custom dropdown  */
.ai-lib-dropdown {
    position: relative;
    width: 100%;
    margin-bottom: 14px;
}

.ai-lib-dropdown-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 9px 14px;
    color: #c0c0c0;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    text-align: left;
    backdrop-filter: blur(4px);
}

.ai-lib-dropdown-btn:hover, .ai-lib-dropdown.open .ai-lib-dropdown-btn {
    border-color: rgba(80,200,120,0.35);
    background: rgba(80,200,120,0.05);
}

.ai-lib-dropdown-btn svg {
    flex-shrink: 0;
    color: #555;
    transition: transform 0.2s ease;
}

.ai-lib-dropdown.open .ai-lib-dropdown-btn svg {
    transform: rotate(180deg);
}

.ai-lib-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 9px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    z-index: 10001;
    display: none;
    overflow: hidden;
    animation: dropLibFade 0.18s ease;
}

.ai-lib-dropdown.open .ai-lib-dropdown-menu {
    display: block;
}

@keyframes dropLibFade {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-lib-dropdown-item {
    padding: 10px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    color: #bbb;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.ai-lib-dropdown-item:last-child {
    border-bottom: none;
}

.ai-lib-dropdown-item:hover {
    background: rgba(80,200,120,0.08);
    color: #e0e0e0;
}

/*  Library Pill Tabs  */
.lib-tabs {
    display: flex;
    justify-content: center;
    flex-direction: row;
    position: relative;
    margin-bottom: 14px;
    width: 100%;
    flex-shrink: 0;
}

.lib-tab {
    background: transparent;
    justify-content: center;
    border: none;
    color: #666;
    padding: 8px 14px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.84rem;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
    white-space: nowrap;
}

.lib-tab:hover {
    color: #d0d0d0;
}

.lib-tab.active {
    color: #f0f0f0;
    font-weight: 600;
}

.lib-tab-indicator {
    position: absolute;
    bottom: -1px;
    height: 3px;
    width: 28px;
    left: 0;
    background: #50c878;
    border-radius: 2px;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1), width 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.2s;
    pointer-events: none;
}

/*  Library File Icons  */
.lib-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    flex-shrink: 0;
}

.lib-icon--img {
    background: rgba(80,200,120,0.09);
    border: 1px solid rgba(80,200,120,0.18);
    color: #50c878;
}

.lib-icon--file {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
}

.lib-icon--file img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.lib-icon--other {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    color: #888;
}

.lib-icon--code {
    background: rgba(100,140,255,0.09);
    border: 1px solid rgba(100,140,255,0.18);
    color: #7ba7ff;
}

.lib-icon--img-thumb {
    width: 44px;
    height: 44px;
    border-radius: 9px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}
.lib-icon--img-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}
.attach-icon-wrap svg {
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
}
.attach-icon-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
}

.msg-file-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}
.msg-file-icon-wrap svg {
    color: rgba(255,255,255,0.6);
}
.msg-file-icon-wrap img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/*  Search Results Scroll Container  */
.search-results-scroll {
    max-height: 44vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/*  Streaming: entrance + cursor  */
@keyframes streamReveal {
    from {
        opacity: 0;
        filter: blur(6px);
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

.stream-reveal {
    animation: streamReveal 0.4s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes cursorBlink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.stream-cursor {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #50c878;
    vertical-align: middle;
    margin-left: 3px;
    flex-shrink: 0;
    animation: cursorBlink 0.9s step-end infinite;
}

/* ====================================================
   UNIFORM ATTACHMENT CARDS (Issue 1)
   ==================================================== */
.msg-file-card {
    display: inline-flex;
    align-items: center;
    height: 3rem;
    gap: 7px;
    background: #1c1c1c;
    border: 1px solid #2c2c2c;
    border-radius: 10px;
    padding: 6px 12px 6px 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    color: #c0c0c0;
    cursor: pointer;
    max-width: 220px;
    overflow: hidden;
    transition: background 0.15s, border-color 0.15s;
}

.msg-file-card:hover {
    background: #232323;
    border-color: #3c3c3c;
}

.msg-file-card--img .msg-file-thumb {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
}

.msg-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-file-img {
    display: none;
}

/* ====================================================
   FILE PREVIEW MODAL (Issue 3)
   ==================================================== */
.ai-modal--file-preview {
    background: #171717;
    border: 1px solid #2a2a2a;
    border-radius: 14px;
    width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-left: 18px;
    padding-right: 14px;
    flex-shrink: 0;
}

.file-preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 40px);
}

.file-preview-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.file-preview-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.file-preview-body {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.fp-img-wrap {
    display: block;
    width: 100%;
    overflow: visible;
}

.fp-img-wrap img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    transition: width 0.15s ease;
}

.fp-pdf-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    border: none;
    border-radius: 8px;
    background: #1a1a1a;
    display: block;
}

.fp-text {
    font-family: 'DM Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    color: #c8c8c8;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    background: #141414;
    border-radius: 8px;
    padding: 16px;
    margin: 0;
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #222;
}

.fp-nopreview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 180px;
    color: #666;
    font-size: 0.9rem;
    text-align: center;
}

.fp-nopreview p {
    margin: 0;
    color: #888;
    font-size: 0.9rem;
}

.fp-nopreview small {
    color: #555;
    font-size: 0.78rem;
}

/* ====================================================
   SETTINGS REDESIGN (Issue 5)
   ==================================================== */
.ai-modal--settings {
    background: #171717;
    border: 1px solid #262626;
    border-radius: 16px;
    width: min(92vw, 420px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sett-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 18px;
    flex-shrink: 0;
}

.sett-title {
    font-size: 1rem;
    font-weight: 700;
    color: #f0f0f0;
    letter-spacing: -0.01em;
}

.sett-close-btn {
    background: none;
    border: none;
    color: #777;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}

.sett-close-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.sett-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.sett-section-label {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: #888;
    font-weight: 500px;
    margin-bottom: 6px;
}

.sett-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sett-avatar-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a3a24, #50c878);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid #2a2a2a;
    transition: border-color 0.15s;
}

.sett-avatar-circle:hover {
    border-color: #50c878;
}

.sett-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
}

#settAvatarInitials {
    font-size: 1.4rem;
    font-weight: 700;
    color: #e8f5ec;
    z-index: 1;
}

.sett-avatar-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sett-avatar-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e0e0e0;
}

.sett-avatar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sett-avatar-action-btn {
    font-size: 0.76rem;
    color: #50c878;
    background: rgba(80,200,120,0.08);
    border: 1px solid rgba(80,200,120,0.2);
    border-radius: 6px;
    padding: 3px 10px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: background 0.15s;
}

.sett-avatar-action-btn:hover {
    background: rgba(80,200,120,0.15);
}

.sett-avatar-action-btn--remove {
    color: #e05555;
    background: rgba(224,85,85,0.07);
    border-color: rgba(224,85,85,0.2);
}

.sett-avatar-action-btn--remove:hover {
    background: rgba(224,85,85,0.14);
}

.sett-group--inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sett-theme-row {
    display: flex;
    gap: 8px;
}

.sett-theme-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: #1e1e1e;
    border: 1.5px solid #2c2c2c;
    border-radius: 10px;
    padding: 12px 8px;
    color: #888;
    font-size: 0.78rem;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.sett-theme-btn:hover {
    border-color: #444;
    color: #ccc;
    background: #222;
}

.sett-theme-btn.active {
    border-color: #50c878;
    color: #50c878;
    background: rgba(80,200,120,0.06);
}

.sett-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 8px;
    padding-bottom: 18px;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar--img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ====================================================
   LIGHT MODE (Issue 5)
   ==================================================== */
body.light-mode {
    background: #f5f5f7;
    color: #1a1a1a;
}

body.light-mode .sidebar {
    background: #ffffff;
    border-right: 1px solid #e8e8e8;
}

body.light-mode .sidebar-btn {
    color: #444;
}

body.light-mode .sidebar-btn:hover {
    background: #f0f0f0;
    color: #1a1a1a;
}

body.light-mode .sidebar-btn:hover svg {
    color: #1a1a1a;
}

body.light-mode .sidebar-btn.new-chat:hover {
    background: #f0f0f0
}

body.light-mode .sidebar-btn svg {
    color: #666;
}

body.light-mode .sidebar-section-title {
    color: #aaa;
}

body.light-mode .history-item {
    color: #444;
}

body.light-mode .history-item:hover {
    background: #f0f0f0;
}

body.light-mode .history-item.active {
    background: #ebfaf1;
    color: #239a4d;
}

body.light-mode .history-item svg {
    color: #555;
}

body.light-mode .sidebar-empty {
    color: #bbb;
}

body.light-mode .settings-btn {
    color: #555;
}

body.light-mode .settings-btn:hover {
    background: #f0f0f0;
}

body.light-mode .settings-btn svg {
    color: #555;
}

body.light-mode .topbar-title {
    color: #1a1a1a;
}

body.light-mode .topbar-btn {
    color: #666;
}

body.light-mode .topbar-btn:hover {
    background: #eee;
    color: #1a1a1a;
}

body.light-mode .message-text {
    color: #1a1a1a;
}

body.light-mode .message--user .message-bubble {
    background: #e9e9e9;
    border-color: #ddd;
}

body.light-mode .message--ai .message-bubble {
    background: #ffffff;
    border-color: #e4e4e4;
}

body.light-mode .message-meta {
    color: #999;
}

body.light-mode .message-actions button {
    color: #999;
}

body.light-mode .message-actions button:hover {
    color: #1a1a1a;
    background: #eee;
}

body.light-mode .input-bar {
    background: #ffffff;
    border-top: 1px solid #e8e8e8;
}

body.light-mode .input-box {
    background: #f0f0f2;
    border: 1px solid #e0e0e0;
    color: #1a1a1a;
}

body.light-mode .input-box:focus-within {
    border-color: #50c878;
}

body.light-mode .md-content h1, body.light-mode .md-content h2, body.light-mode .md-content h3, body.light-mode .md-content h4, body.light-mode .md-content h5 {
    color: #000000;
}

body.light-mode #chatInput {
    color: #1a1a1a;
}

body.light-mode #chatInput::placeholder {
    color: #aaa;
}

body.light-mode .input-attach-btn {
    color: #888;
}

body.light-mode .input-attach-btn:hover {
    background: #e8e8e8;
    color: #555;
}

body.light-mode .send-btn {
    background: #258946;
}

body.light-mode .disclaimer {
    color: #bbb;
}

body.light-mode .msg-file-card {
    background: #ececec;
    border-color: #ddd;
    color: #444;
}

body.light-mode .msg-file-card:hover {
    background: #e4e4e4;
}

body.light-mode .welcome-screen {
    background: #f5f5f7;
}

body.light-mode .welcome-heading {
    color: #1a1a1a;
}

body.light-mode .welcome-btn {
    background: #ffffff;
    border-color: #e0e0e0;
    color: #444;
}

body.light-mode .welcome-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

body.light-mode .ai-modal {
    background: #ffffff;
    border-color: #e0e0e0;
}

body.light-mode .ai-modal--settings {
    background: #fafafa;
    border-color: #e0e0e0;
}

body.light-mode .sett-header {
    border-color: #eee;
}

body.light-mode .sett-title {
    color: #1a1a1a;
}

body.light-mode .sett-section-label {
    color: #aaa;
}

body.light-mode .sett-input {
    background: #f0f0f2;
    border-color: #ddd;
    color: #1a1a1a;
}

body.light-mode .sett-input:focus {
    border-color: #50c878;
}

body.light-mode .sett-theme-btn {
    background: #f0f0f2;
    border-color: #ddd;
    color: #888;
}

body.light-mode .sett-theme-btn:hover {
    background: #e8e8e8;
    color: #444;
}

body.light-mode .sett-theme-btn.active {
    background: rgba(80,200,120,0.1);
}

body.light-mode .sett-footer {
    border-color: #eee;
    background: #fafafa;
}

body.light-mode .ai-modal-btn.secondary {
    background: #f0f0f2;
    color: #555;
    border-color: #ddd;
}

body.light-mode .ai-modal-btn.secondary:hover {
    background: #e8e8e8;
}

body.light-mode .quick-card:hover {
    border-color: rgb(42 113 65 / 25%);
    box-shadow: 0 0 0 1px rgba(80, 200, 120, 0.08), 0 4px 16px rgb(144 144 144 / 22%);
}

body.light-mode .icon-btn:hover {
    background: #eaeaea;
    color: #4b4b4b;
}

body.light-mode .message-text.user-text {
    background: #ffffff;
    border: 1px solid #cdcdcd;
    border-radius: 12px;
    padding: 11px 15px;
    color: #1a1a1a;
}

body.light-mode .quick-card-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.87rem;
    color: #868686;
    min-width: 125px;
}

body.light-mode .welcome-heading {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.85rem;
    font-weight: 700;
    background: linear-gradient(90deg, rgb(26, 26, 26), rgb(90, 90, 90), rgb(26, 26, 26)) text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.25;
}

body.light-mode .quick-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 25px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #50c878;
    flex-shrink: 0;
}

body.light-mode .lib-tab.active {
    color: #000000;
    font-weight: 600;
}

body.light-mode .sett-avatar-name {
    color: #5f5f5f;
}

body.light-mode .quick-card {
    background: #ffffff;
    border: 1px solid #d6d6d6;
    border-radius: 80px;
    padding: 10px 16px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 175px;
    flex: 1;
    max-width: 2500px;
}

body.light-mode .ai-modal-close:hover {
    color: #333;
    background: #eee;
}

body.light-mode .input-container {
    background: #ffffff;
    border: 1px solid #d6d6d6;
    border-radius: 28px;
    padding: 10px 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-mode .sidebar-toggle:hover {
    background: #ffffff;
    color: #000000;
}

body.light-mode .sett-avatar-circle {
    border: 2px solid #e9e9e9;
}

body.light-mode .modal-centered-title {
    color: #1a1a1a;
}

body.light-mode .modal-form-body .sett-label {
    color: #555;
}

body.light-mode .modal-centered-content {
    color: #444;
}

body.light-mode .ai-modal--file-preview {
    background: #fafafa;
    border-color: #e0e0e0;
}

body.light-mode .file-preview-header {
    border-color: #eee;
}

body.light-mode .file-preview-title {
    color: #1a1a1a;
}

body.light-mode .file-preview-close {
    color: #999;
}

body.light-mode .file-preview-close:hover {
    color: #333;
    background: #eee;
}

body.light-mode .fp-text {
    background: #f0f0f2;
    border-color: #ddd;
    color: #333;
}

body.light-mode .fp-nopreview {
    color: #aaa;
}

body.light-mode .code-block-wrap {
    background: #f0f0f2;
    border-color: #ddd;
}

body.light-mode .code-block-header {
    background: #e8e8e8;
    border-color: #ddd;
    color: #666;
}

body.light-mode .md-content em {
    color: #000000;
}

body.light-mode .md-blockquote {
    color: #666;
    background: rgba(80,200,120,0.05);
}

body.light-mode .md-table-wrap {
    border-color: #e0e0e0;
}

body.light-mode .md-table th {
    background: #f0f0f2;
    color: #444;
    border-color: #e0e0e0;
}

body.light-mode .md-content strong {
    color: #000000;
}

body.light-mode .md-table td {
    border-color: #e8e8e8;
    color: #555;
}

body.light-mode .md-table tr:hover td {
    background: rgba(0,0,0,0.025);
}

body.light-mode .toast {
    background: #ffffff;
    border-color: #e0e0e0;
    color: #333;
}

body.light-mode .toast.error {
    background: #fff0f0;
    border-color: #f5c0c0;
}

body.light-mode .topbar-logo-text {
    color: #1a1a1a;
}

body.light-mode .lib-tab:hover {
    color: #000000;
}

body.light-mode .search-modal {
    background: #fafafa;
    border-color: #e0e0e0;
}

body.light-mode .search-input {
    background: #f0f0f2;
    border-color: #ddd;
    color: #1a1a1a;
}

body.light-mode .search-input::placeholder {
    color: #aaa;
}

body.light-mode .search-result {
    border-color: #eee;
    color: #444;
}

body.light-mode .search-result:hover {
    background: #f0f0f0;
}

body.light-mode .attach-file {
    background: #f0f0f2;
    border-color: #ddd;
    color: #555;
}

body.light-mode .attach-thumb {
    border-color: #ddd;
}

body.light-mode .lib-item {
    background: #ffffff;
    border-color: #eeeeee;
    color: #444;

}

body.light-mode .lib-item:hover {
    background: #f5f5f5;
}
.lib-item:hover {
    background: rgba(255,255,255,0.04);
}

/* ====================================================
   MOBILE RESPONSIVE (Issue 6)
   ==================================================== */
.mobile-hamburger {
    display: none;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.mobile-hamburger:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

body.light-mode .mobile-hamburger {
    color: #666;
}

body.light-mode .mobile-hamburger:hover {
    color: #222;
    background: #eee;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
        width: 260px !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 260px !important;
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
    }

    .chat-main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .mobile-hamburger {
        display: flex;
    }

    .chat-topbar {
        gap: 8px;
        padding: 0 10px;
    }

    .topbar-title {
        font-size: 0.85rem;
    }

    .topbar-btn span {
        display: none;
    }

    .messages-area {
        padding: 12px 10px 80px 10px;
    }

    .message {
        gap: 8px;
    }

    .message-bubble {
        max-width: 100% !important;
        font-size: 0.88rem;
    }

    .input-bar {
        padding: 8px 10px;
    }

    .input-box {
        font-size: 0.9rem;
    }

    .ai-modal {
        width: 95vw !important;
        margin: 10px;
    }

    .ai-modal--settings {
        width: 95vw !important;
        max-height: 88vh;
    }

    .ai-modal--file-preview {
        width: 97vw !important;
        max-height: 88vh;
    }

    .sett-theme-row {
        gap: 6px;
    }

    .sett-theme-btn {
        padding: 10px 4px;
        font-size: 0.74rem;
    }

    .welcome-btns {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .welcome-btn {
        justify-content: center;
    }

    .welcome-heading {
        font-size: 1.4rem;
    }

    .msg-files {
        gap: 6px;
    }

    .msg-file-card {
        max-width: 170px;
    }

    .library-modal, .search-modal {
        width: 97vw !important;
        max-height: 88vh;
    }

    .disclaimer {
        font-size: 0.7rem;
    }

    .attach-preview {
        gap: 6px;
    }

    .attach-thumb {
        width: 52px;
        height: 52px;
    }
}

/*  Avatar img default state  */
#settAvatarImg {
    display: none;
}

.sett-avatar-circle img {
    display: none;
}

.sett-avatar-circle img[src]:not([src=""]) {
    display: block;
}

/*  Light mode welcome buttons  */
body.light-mode .welcome-btn {
    background: #f0f0f2 !important;
    border-color: #ddd !important;
    color: #333 !important;
}

body.light-mode .welcome-btn:hover {
    background: #e6e6e9 !important;
    border-color: #ccc !important;
}

body.light-mode .welcome-btn svg, body.light-mode .welcome-btn .btn-icon {
    color: #50c878 !important;
}

/*  Light mode input bar fix  */
body.light-mode .input-bar {
    background: #f5f5f7 !important;
    border-top: 1px solid #e8e8e8;
}

body.light-mode .input-box {
    background: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    color: #1a1a1a !important;
}

body.light-mode #chatInput {
    color: #1a1a1a !important;
}

body.light-mode #chatInput::placeholder {
    color: #aaa !important;
}

body.light-mode .input-attach-btn {
    color: #888 !important;
}

body.light-mode .input-attach-btn:hover {
    background: #eee !important;
    color: #555 !important;
}

/*  Ensure message bubble has class  */
.message-avatar--img {
    overflow: hidden;
}

.message-avatar--img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
/* ====================================================
   FILE PREVIEW SIDE PANEL
   ==================================================== */
.file-preview-panel {
    width: 0;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    background: #171717;
    border-left: 1px solid #242424;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: opacity 0.28s ease,
                transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(24px);
}

.file-preview-panel.open {
    width: 600px;
    min-width: 600px;
    overflow: hidden;
    opacity: 1;
    transform: translateX(0);
}

.fp-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid #242424;
    flex-shrink: 0;
    white-space: nowrap;
}

.fp-panel-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #d0d0d0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 36px);
}

.fp-panel-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    touch-action: manipulation;
}

.fp-panel-close:hover {
    color: #e0e0e0;
    background: rgba(255,255,255,0.08);
}

.fp-panel-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: auto;
    padding: 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

body.light-mode .file-preview-panel {
    background: #fafafa;
    border-color: #e0e0e0;
}

body.light-mode .fp-panel-header {
    border-color: #eee;
}

body.light-mode .fp-panel-title {
    color: #1a1a1a;
}

body.light-mode .fp-panel-close {
    color: #999;
}

body.light-mode .fp-panel-close:hover {
    color: #333;
    background: #eee;
}

/* ====================================================
   CODE PREVIEW SIDE PANEL
   ==================================================== */
.code-preview-panel {
    width: 0;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    background: #171717;
    border-left: 1px solid #242424;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: opacity 0.28s ease,
                transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(24px);
}

.code-preview-panel.open {
    width: 600px;
    min-width: 600px;
    overflow: hidden;
    opacity: 1;
    transform: translateX(0);
}

.code-preview-panel.closing {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0 !important;
    transform: translateX(24px) !important;
    overflow: hidden !important;
}

.code-preview-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.code-preview-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

body.light-mode .code-preview-panel {
    background: #fafafa;
    border-color: #e0e0e0;
}

@media (max-width: 768px) {
    .code-preview-panel.open {
        position: fixed;
        inset: 0;
        width: 100vw !important;
        min-width: 100vw !important;
        z-index: 200;
        transform: none;
    }
}

/* ====================================================
   MOBILE FIXES
   ==================================================== */
@media (max-width: 768px) {
    /* Fix iOS viewport height */
    body {
        height: -webkit-fill-available;
    }

    .sidebar {
        height: 100vh;
        height: -webkit-fill-available;
    }

    /* Remove tap delay on all interactive elements */
    button, .quick-card, .history-item, .msg-file-card,
    .sidebar-btn, .settings-btn, .send-btn, .input-attach-btn,
    .mobile-hamburger, .attach-rm, .msg-action-btn {
        touch-action: manipulation;
    }

    /* Prevent iOS zoom on textarea focus (must be >= 16px) */
    .chat-textarea {
        font-size: 16px !important;
    }

    /* Side panel on mobile: slides in from right, full-screen */
    .file-preview-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100vw !important;
        min-width: unset !important;
        height: 100vh;
        height: -webkit-fill-available;
        z-index: 200;
        opacity: 1;
        transform: translateX(100%);
        transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.28s ease;
        overflow: hidden;
        border-left: none;
    }

    .file-preview-panel.open {
        transform: translateX(0);
        overflow: visible;
    }

    .fp-panel-header {
        padding: 14px 16px 12px;
    }

    .fp-pdf-frame {
        flex: 1;
        min-height: 200px;
    }
}

/* ====================================================
   PPTX SLIDE VIEWER
   ==================================================== */
.pptx-viewer {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    flex: 1;
    min-height: 0;
    gap: 10px;
    padding: 8px 0;
    overflow-x: auto;
}

.pptx-wrap {
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #111;
    border-radius: 8px;
    flex-shrink: 0;
}

.pptx-slide {
    font-family: Calibri, 'Segoe UI', Arial, sans-serif;
    user-select: text;
    cursor: text;
}

.pptx-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 4px 0;
    flex-shrink: 0;
    width: 100%;
}

.pptx-btn {
    background: #252525;
    border: 1px solid #333;
    color: #d0d0d0;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s;
    touch-action: manipulation;
}

.pptx-btn:hover { background: #333; color: #fff; }

.pptx-ctr {
    font-size: 0.82rem;
    color: #888;
    min-width: 56px;
    text-align: center;
}

.fp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    color: #888;
    font-size: 0.9rem;
    min-height: 120px;
}

.fp-spin {
    animation: fp-spin 1s linear infinite;
    stroke-dashoffset: 0;
}

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

body.light-mode .pptx-btn {
    background: #f0f0f0;
    border-color: #ddd;
    color: #333;
}
body.light-mode .pptx-btn:hover { background: #e0e0e0; }
body.light-mode .pptx-ctr { color: #666; }
body.light-mode .pptx-wrap { background: #e8e8e8; }

/* ====================================================
   PDF CUSTOM VIEWER + DOCX READER
   ==================================================== */
.doc-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-height: 0;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* fills remaining height; letterboxes canvas inside */
.doc-canvas-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* canvas is contained inside wrap - never overflows */
.doc-canvas-wrap canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 6px;
}

/* PDF text layer for selectable text */
.pdfTextLayer {
    position: absolute;
    left: 0;
    top: 0;
    overflow: hidden;
    pointer-events: auto;
    line-height: 1;
}

.pdfTextLayer span {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 100%;
    user-select: text;
}

.pdfTextLayer span::selection,
.pdfTextLayer span::-moz-selection {
    background: rgba(0, 100, 255, 0.25);
    color: transparent;
}

/* DOCX reader */
.docx-body {
    background: #fff;
    color: #1a1a1a;
    padding: 28px 32px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
}

.docx-p {
    margin: 0 0 6px;
    padding: 0;
}

.docx-spacer {
    height: 8px;
}

.docx-h {
    margin: 16px 0 8px;
    font-weight: 700;
    line-height: 1.2;
}

h1.docx-h { font-size: 20pt; color: #1f3864; }
h2.docx-h { font-size: 16pt; color: #2e5090; }
h3.docx-h { font-size: 13pt; color: #2e5090; }
h4.docx-h, h5.docx-h, h6.docx-h { font-size: 11pt; color: #1a1a1a; }

.docx-tbl {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 10pt;
}

.docx-td {
    border: 1px solid #c8c8c8;
    padding: 4px 8px;
    vertical-align: top;
}

body.light-mode .pptx-wrap,
body.light-mode .doc-viewer { background: transparent; }


/* ====================================================
   FILE PREVIEW ZOOM CONTROLS
   ==================================================== */
.fp-zoom-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
    margin-right: 0.9rem;
}

.fp-zoom-btn {
    background: none;
    border: 1px solid #333;
    color: #888;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.fp-zoom-btn:hover { color: #d0d0d0; background: #242424; border-color: #444; }

.fp-zoom-label {
    font-size: 0.72rem;
    color: #666;
    min-width: 36px;
    text-align: center;
    font-family: 'DM Sans', sans-serif;
    user-select: none;
}

body.light-mode .fp-zoom-btn { border-color: #ccc; color: #555; }
body.light-mode .fp-zoom-btn:hover { background: #f0f0f0; }
body.light-mode .fp-zoom-label { color: #888; }

/* ====================================================
   TEXT FILE VIEWER
   ==================================================== */
.fp-text-viewer {
    display: block;
    width: 100%;
    min-width: max-content;
    min-height: 100%;
    box-sizing: border-box;
    padding: 0;
}

.fp-text-code {
    margin: 0;
    padding: 16px 20px;
    font-size: 0.82rem;
    line-height: 1.6;
    background: #111;
    border-radius: 0;
    white-space: pre;
    word-break: normal;
    overflow-x: visible;
    min-height: 100%;
    width: 100%;
    box-sizing: border-box;
}

body.light-mode .fp-text-code {
    background: #fafafa;
    color: #1a1a1a;
}

/* ====================================================
   MEMORY BADGE + MEMORIES MODAL
   ==================================================== */
.memory-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(76, 175, 125, 0.12);
    border: 1px solid rgba(76, 175, 125, 0.3);
    color: #4caf7d;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 20px;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    width: fit-content;
}

.ai-modal--memories {
    max-width: 680px;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
}

.ai-modal-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 25px 20px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ai-modal-header-icon {
    width: 32px; height: 32px;
    background: #019100;
    border-radius: 20px;
    padding-bottom: 1px;
    padding-left: 1px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.ai-modal-header-title {
    font-size: 15px;
    font-weight: 600;
    justify-content: center;
    align-items: center;
}

.ai-modal-close {
    background: none; border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.ai-modal-close:hover { background: var(--hover); color: var(--text); }

.ai-modal-body--scroll {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    min-height: 0;
}

.memories-desc {
    font-size: 13px;
    color: #aaa;
    margin: 0 0 14px;
    justify-content: center;
    align-items: center;
    display: flex;
    line-height: 1.5;
}

.memories-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--text-muted);
    text-align: center;
}
.memories-empty p { margin: 0; font-size: 14px; }
.memories-empty small { font-size: 12px; opacity: .7; }

.memory-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

.memory-item-text {
    flex: 1;
    font-size: 13.5px;
    line-height: 1.45;
}

.memory-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    margin-top: 2px;
}

.memory-item-del {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.memory-item-del:hover { color: #e05555; background: rgba(224,85,85,.12); }

.ai-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.ai-modal-btn.danger {
    background: #c0392b;
    color: #fff;
    border: none;
}
.ai-modal-btn.danger:hover { background: #e74c3c; }

/* Settings data buttons */


/* ====================================================
   INTERACTIVE QUIZ WIDGET
   ==================================================== */
.quiz-widget {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: auto;
    margin: 12px 0;
}

.quiz-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(76, 175, 125, 0.08);
    border-bottom: 1px solid var(--border);
    color: #4caf7d;
    font-weight: 600;
    font-size: 14px;
}

.quiz-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.quiz-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.quiz-question { display: flex; flex-direction: column; gap: 8px; }

.quiz-q-text {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

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

.quiz-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    width: 100%;
    font-family: 'DM Sans';
}
.quiz-opt:hover:not(:disabled) { border-color: #4caf7d; background: rgba(76,175,125,.06); }
.quiz-opt.selected { border-color: #4caf7d; background: rgba(76,175,125,.12); color: #4caf7d; }
.quiz-opt.correct  { border-color: #27ae60; background: rgba(39,174,96,.15); color: #27ae60; }
.quiz-opt.wrong    { border-color: #e74c3c; background: rgba(231,76,60,.12); color: #e74c3c; }
.quiz-opt:disabled { cursor: default; }

.quiz-opt-letter {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--border);
    font-size: 11px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.quiz-opt.selected .quiz-opt-letter { background: #4caf7d; color: #fff; }
.quiz-opt.correct  .quiz-opt-letter { background: #27ae60; color: #fff; }
.quiz-opt.wrong    .quiz-opt-letter { background: #e74c3c; color: #fff; }

.quiz-explanation {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    background: rgba(76,175,125,.06);
    border-left: 3px solid #4caf7d;
    padding: 8px 10px;
    border-radius: 0 6px 6px 0;
    line-height: 1.5;
}

.quiz-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.quiz-progress {
    font-size: 12px;
    color: var(--text-muted);
}

.quiz-submit-btn {
    padding: 8px 18px;
    border-radius: 8px;
    background: #4caf7d;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity .15s, background .15s;
    font-family: 'DM Sans';
}
.quiz-submit-btn:disabled { opacity: .45; cursor: not-allowed; }
.quiz-submit-btn:not(:disabled):hover { background: #3d9e6e; }

.quiz-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 7px;
  vertical-align: middle;
}
.quiz-type-fill  { background: rgba(76,175,125,.15); color: #4caf7d; }
.quiz-type-essay { background: rgba(99,179,237,.15); color: #63b3ed; }

.quiz-q-fill-text {
  line-height: 2;
}
.quiz-fill-inline {
  display: inline-block;
  vertical-align: middle;
  padding: 3px 10px;
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: inherit;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  width: 140px;
  text-align: center;
  transition: border-color .15s, color .15s;
  border-radius: 0;
  margin: 0 2px;
}
.quiz-fill-inline:focus { border-bottom-color: #4caf7d; }
.quiz-fill-inline::placeholder { color: var(--text-muted); opacity: .5; font-style: italic; }
.quiz-fill-inline.quiz-fill-inline-correct {
  border-bottom-color: #27ae60;
  color: #27ae60;
  font-weight: 600;
}
.quiz-fill-inline.quiz-fill-inline-wrong {
  border-bottom-color: #e74c3c;
  color: #e74c3c;
  font-weight: 600;
}
.quiz-fill-inline:disabled { cursor: default; }

.quiz-fill-correct-ans {
  display: block;
  color: #e74c3c;
  font-size: 12.5px;
  margin-top: 4px;
  margin-bottom: 3px;
  font-weight: 500;
}
.quiz-fill-correct-ans strong { color: #27ae60; }
.quiz-fill-correct-ans-ok { color: #27ae60 !important; }

.quiz-essay-wrap  { margin-top: 8px; }
.quiz-essay-input {
  width: 100%;
  padding: 10px 13px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  resize: vertical;
  min-height: 80px;
  transition: border-color .15s;
  outline: none;
  box-sizing: border-box;
  line-height: 1.5;
}
.quiz-essay-input:focus { border-color: #4caf7d; }
.quiz-essay-input.quiz-essay-submitted { border-color: #4caf7d; opacity: .85; }
.quiz-essay-input:disabled { cursor: default; }

.quiz-result {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

.quiz-score-num {
    font-size: 28px;
    font-weight: 700;
    color: #4caf7d;
}

.quiz-ask-btn {
    padding: 8px 18px;
    font-family: 'DM Sans';
    border-radius: 8px;
    border: 1.5px solid #4caf7d;
    background: transparent;
    color: #4caf7d;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
    margin-bottom: 1rem;
}
.quiz-ask-btn:hover { background: rgba(76,175,125,.1); }


/* ====================================================
   QUIZ SIDE PANEL
   ==================================================== */
.quiz-panel {
    width: 0;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    background: #171717;
    border-left: 1px solid #242424;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: opacity 0.28s ease,
                transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(24px);
}

.quiz-panel.open {
    width: 44rem;
    min-width: 44rem;
    overflow: hidden;
    opacity: 1;
    transform: translateX(0);
}
.file-preview-panel.closing,
.quiz-panel.closing {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0 !important;
    transform: translateX(24px) !important;
    overflow: hidden !important;
}




.quiz-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.quiz-panel-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 10px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-right: auto;
}

/* Quiz card (inline in message) */
.quiz-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: #1e1e1e;
    cursor: pointer;
    margin: 8px 0;
    transition: border-color .15s, background .15s;
    max-width: 320px;
}
body.light-mode .quiz-card {
    background: #ffffff;
}

body.light-mode .quiz-card:hover {
    background: rgba(76,175,125,.07);
}

.quiz-card:hover { border-color: #4caf7d; background: rgba(76,175,125,.07); }

.quiz-card-icon {
    width: 36px; height: 36px;
    background: rgba(76,175,125,.15);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #4caf7d;
    flex-shrink: 0;
}

.quiz-card-info { flex: 1; min-width: 0; }
.quiz-card-title { font-size: 13.5px; font-weight: 600; }
.quiz-card-meta  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.quiz-card-arrow { color: var(--text-muted); flex-shrink: 0; }

/* Quiz widget inside panel */
.quiz-panel-body .quiz-widget {
    border: none;
    border-radius: 0;
    background: transparent;
}

/* Light mode quiz panel */
body.light-mode .quiz-panel {
    background: #fff;
    border-left-color: #e5e5e5;
}
body.light-mode .quiz-panel .fp-panel-header { border-bottom-color: #e5e5e5; }
body.light-mode .quiz-panel-count { color: #888; }

/* Mobile quiz panel */
@media (max-width: 768px) {
    .quiz-panel.open {
        position: fixed;
        inset: 0;
        width: 100% !important;
        min-width: 0 !important;
        z-index: 200;
        transform: none;
    }
}

/* ====================================================
   SETTINGS DATA & MEMORY IMPROVEMENTS
   ==================================================== */
.sett-scroll-extra {
    padding: 0 20px 20px;
}

.sett-data-btns {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.sett-data-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 10px;
    border: 1px solid #2b2b2b;
    background: #1e1e1e;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex: 1;
    min-width: 130px;
    justify-content: center;
}
.sett-data-btn:hover { background: #222222; border: 1px solid  #444444 }
.sett-data-btn--danger { color: #e05555; background: #311616 }
.sett-data-btn--danger:hover { background: rgb(165 10 10 / 50%); border-color: rgba(224,85,85,.3); }

body.light-mode .sett-data-btn {
    border: 1px solid #dddddd;
    background: #f0f0f2;
    color: #a6a6a6
}

body.light-mode .sett-data-btn:hover { color: #676767; background: #E8E8E8; border: 1px solid  #dddddd }
body.light-mode .sett-data-btn--danger { color: #da6e6e; background: #ffeaec; }
body.light-mode .sett-data-btn--danger:hover { color: #dc7373; background: rgb(165 10 10 / 25%); border-color: rgba(224,85,85,.3); }

/* ====================================================
   MEMORY MODAL EDIT SUPPORT
   ==================================================== */
.memory-item {
    align-items: flex-start;
}

.memory-item-content { flex: 1; min-width: 0; }
.memory-item-btns { display: flex; gap: 4px; flex-shrink: 0; padding-top: 2px; }

.memory-item-btn {
    background: none; border: none;
    cursor: pointer; padding: 4px;
    border-radius: 5px;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s;
}
.memory-item-edit:hover { color: #4caf7d; background: rgba(76,175,125,.12); }
.memory-item-del:hover  { color: #e05555; background: rgba(224,85,85,.12); }

.memory-edit-input {
    width: 100%;
    height: 300px;
    background: var(--bg);
    border: 1.5px solid #4caf7d;
    border-radius: 7px;
    color: var(--text);
    font-size: 13px;
    padding: 7px 10px;
    resize: none;
    font-family: inherit;
    line-height: 1.45;
    outline: none;
    box-sizing: border-box;
}

.memory-edit-actions {
    display: flex;
    flex-direction: row;
    gap: 5px;
    margin-top: 6px;
    justify-content: flex-end;
    align-items: center;
}

.memory-edit-save, .memory-edit-cancel {
    width: 30px; height: 30px;
    border-radius: 7px;
    cursor: pointer;
    border: none;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .13s, color .13s;
}
.memory-edit-save { background: rgba(76,175,125,.15); color: #4caf7d; }
.memory-edit-save:hover { background: #4caf7d; color: #fff; }
.memory-edit-cancel { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border); }
.memory-edit-cancel:hover { background: var(--hover); color: var(--text); }


/* Quiz loading card (shown while quiz JSON streams) */
.quiz-loading-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1.5px dashed var(--border);
    background: var(--bg-secondary);
    margin: 8px 0;
    max-width: 320px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
}

.quiz-loading-icon {
    width: 36px; height: 36px;
    background: rgba(76,175,125,.12);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.quiz-loading-dots {
    display: flex; gap: 4px; align-items: center;
}
.quiz-loading-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4caf7d;
    animation: quizDotPulse 1.2s ease-in-out infinite;
}
.quiz-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.quiz-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes quizDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Force all elements to stay within the screen width */
html, body {
    max-width: 100vw;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    /* 1. Fix the File Preview Panel width */
    .file-preview-panel.open {
        width: 100vw !important;
        min-width: 100vw !important;
    }

    /* 2. Fix the Modal widths */
    .ai-modal, 
    .ai-modal--file-preview, 
    .ai-modal--settings {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 0 auto;
    }

    /* 3. Fix the Quick Action Cards */
    .quick-actions {
        width: 100%;
        padding: 0 10px;
    }

    .quick-card {
        width: 100%;
        min-width: unset;
    }

    /* 4. Fix Messages area to not push the page */
    .messages-area {
        width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box;
    }

    /* 5. Prevent long words/URLs from breaking the layout */
    .message-text, .md-content {
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
}

/* ONBOARDING Full Screen */
.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  font-family: 'DM Sans', sans-serif;
}
.ob-overlay.ob-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Left Branding Panel */
.ob-left {
  width: 380px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #0b1f14 0%, #12332100 40%, #0e2619 100%);
  background-color: #0d1e14;
  border-right: 1px solid rgba(80,200,120,0.12);
  display: flex;
  flex-direction: column;
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
}
.ob-left-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1;
}
.ob-brand-logo-wrap {
  width: 68px; height: 68px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1a5c34, #2a8a52);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 40px rgba(80,200,120,0.3), 0 8px 24px rgba(0,0,0,0.5);
  animation: obLogoPulse 3s ease-in-out infinite;
  margin-bottom: 4px;
}
@keyframes obLogoPulse {
  0%,100% { box-shadow: 0 0 24px rgba(80,200,120,0.22), 0 8px 24px rgba(0,0,0,0.5); }
  50%      { box-shadow: 0 0 52px rgba(80,200,120,0.48), 0 8px 24px rgba(0,0,0,0.5); }
}
.ob-brand-logo { width: 42px; height: 42px; object-fit: contain; }
.ob-brand-name {
  font-size: 1.7rem; font-weight: 700;
  color: #fff; letter-spacing: -0.02em;
}
.ob-brand-tag { font-size: 0.8rem; color: rgba(255,255,255,0.35); }

.ob-left-feats {
  display: flex; flex-direction: column; gap: 14px;
  margin-top: auto; padding-top: 40px; z-index: 1;
}
.ob-lf {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.84rem; color: rgba(255,255,255,0.65);
  line-height: 1.4;
}
.ob-lf-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #50c878; flex-shrink: 0;
  box-shadow: 0 0 6px rgba(80,200,120,0.7);
}
.ob-left-footer {
  margin-top: 36px; font-size: 0.74rem;
  color: rgba(255,255,255,0.22); z-index: 1;
}

/* Decorative orbs */
.ob-bg-orb {
  position: absolute; border-radius: 50%; pointer-events: none;
}
.ob-bg-orb1 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(80,200,120,0.12) 0%, transparent 70%);
  top: -80px; left: -80px;
  animation: obOrb1 8s ease-in-out infinite;
}
.ob-bg-orb2 {
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(80,200,120,0.08) 0%, transparent 70%);
  bottom: 60px; right: -60px;
  animation: obOrb2 10s ease-in-out infinite;
}
@keyframes obOrb1 {
  0%,100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(20px,15px) scale(1.08); }
}
@keyframes obOrb2 {
  0%,100% { transform: translate(0,0) scale(1); }
  50%      { transform: translate(-15px,-20px) scale(1.12); }
}

/* Right Steps Panel */
.ob-right {
  flex: 1;
  background: #1a1a1ad5;
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 60px;
  overflow-y: auto;
  position: relative;
}

/* Progress dots */
.ob-dots {
  position: absolute;
  top: 32px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
}
.ob-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.3s, width 0.3s, border-radius 0.3s;
}
.ob-dot.ob-dot--active {
  background: #50c878;
  width: 24px; border-radius: 4px;
}

/* Step content */
.ob-step {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.ob-step.ob-step--active {
  display: flex;
  animation: obSlideIn 0.32s cubic-bezier(0.22,1,0.36,1) both;
}
.ob-step.ob-step--from-back {
  animation: obSlideInBack 0.32s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes obSlideIn     { from{opacity:0;transform:translateX(28px)} to{opacity:1;transform:translateX(0)} }
@keyframes obSlideInBack { from{opacity:0;transform:translateX(-28px)} to{opacity:1;transform:translateX(0)} }

.ob-step-head { display: flex; flex-direction: column; gap: 8px; }

.ob-heading {
  font-size: 1.55rem; font-weight: 700;
  color: #f0f0f0; line-height: 1.2; margin: 0;
}
.ob-sub {
  font-size: 0.87rem; color: rgba(255,255,255,0.42);
  line-height: 1.55; margin: 0;
}

/* Avatar picker */
.ob-avatar-wrap {
  cursor: pointer; display: flex; flex-direction: column; align-items: center;
}
.ob-avatar-circle {
  width: 90px; height: 90px; border-radius: 50%;
  background: linear-gradient(135deg, #1e3a28, #2a5c38);
  border: 2px solid rgba(80,200,120,0.3);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.ob-avatar-circle:hover { border-color: #50c878; box-shadow: 0 4px 24px rgba(80,200,120,0.25); }
.ob-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ob-avatar-initials {
  font-size: 1.8rem; font-weight: 700; color: #50c878; user-select: none;
}
.ob-avatar-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 0.72rem; color: #fff; opacity: 0;
  transition: opacity 0.2s; border-radius: 50%;
}
.ob-avatar-circle:hover .ob-avatar-overlay { opacity: 1; }
.ob-avatar-hint { font-size: 0.76rem; color: rgba(255,255,255,0.3); margin-top: -10px; }

/* Name field */
.ob-field {
  width: 100%; display: flex; flex-direction: column; gap: 7px; text-align: left;
}
.ob-label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45); letter-spacing: 0.03em;
}
.ob-input {
  width: 100%; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 13px 16px;
  font-size: 0.95rem; color: #f0f0f0; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box; font-family: 'DM Sans', sans-serif;
}
.ob-input::placeholder { color: rgba(255,255,255,0.2); }
.ob-input:focus {
  border-color: rgba(80,200,120,0.5);
  box-shadow: 0 0 0 3px rgba(80,200,120,0.1);
}

/* Buttons */
.ob-btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #2a7a46, #50c878);
  color: #fff; border: none; border-radius: 12px;
  padding: 13px 26px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: opacity 0.2s, transform 0.15s; width: 100%;
}
.ob-btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.ob-btn-primary:active { transform: translateY(0); }
.ob-btn-glow { box-shadow: 0 6px 28px rgba(80,200,120,0.4); }
.ob-btn-secondary {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 13px 20px;
  font-size: 0.9rem; font-weight: 500; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s, color 0.2s;
}
.ob-btn-secondary:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }
.ob-row { display: flex; gap: 10px; width: 100%; }
.ob-row .ob-btn-primary { flex: 1; }

/* Features grid */
.ob-features {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; width: 100%; text-align: left;
}
.ob-feat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.2s, background 0.2s;
}
.ob-feat:hover { background: rgba(255,255,255,0.07); border-color: rgba(80,200,120,0.2); }
.ob-feat-icon {
  width: 36px; height: 36px; border-radius: 9px;
  background: rgba(80,200,120,0.12);
  display: flex; align-items: center; justify-content: center;
  color: #50c878; flex-shrink: 0;
}
.ob-feat-text { display: flex; flex-direction: column; gap: 3px; }
.ob-feat-title { font-size: 0.85rem; font-weight: 600; color: #e8e8e8; }
.ob-feat-desc  { font-size: 0.75rem; color: rgba(255,255,255,0.38); line-height: 1.45; }

/* Memory Import */
.ob-import-wrap { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.ob-import-textarea {
  width: 100%; min-height: 140px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 13px 15px;
  font-size: 0.875rem; color: #e0e0e0; outline: none;
  font-family: 'DM Sans', sans-serif; line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: none;
}
.ob-import-textarea::placeholder { color: rgba(255,255,255,0.22); }
.ob-import-textarea:focus {
  border-color: rgba(80,200,120,0.4);
  box-shadow: 0 0 0 3px rgba(80,200,120,0.08);
}
/* Theme Picker */
.ob-themes { display: flex; gap: 12px; width: 100%; }
.ob-theme {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 9px; padding: 16px 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 16px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; position: relative;
}
.ob-theme:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.18); }
.ob-theme.ob-theme--active { border-color: #50c878; background: rgba(80,200,120,0.08); }
.ob-theme-preview {
  width: 60px; height: 42px; border-radius: 9px;
  background: #1a1a1a; overflow: hidden; display: flex;
  border: 1px solid rgba(255,255,255,0.1);
}
.ob-theme-preview--dark  { background: #141414; }
.ob-theme-preview--light { background: #f5f5f5; border-color: rgba(0,0,0,0.1); }
.ob-tp-half  { flex: 1; }
.ob-tp-dark  { background: #1a1a1a; }
.ob-tp-light { background: #f0f0f0; }
.ob-theme-label { font-size: 0.8rem; font-weight: 500; color: rgba(255,255,255,0.5); }
.ob-theme.ob-theme--active .ob-theme-label { color: #50c878; }
.ob-theme-check {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #50c878; display: none; align-items: center;
  justify-content: center; color: #fff;
}
.ob-theme.ob-theme--active .ob-theme-check { display: flex; }

/* Theme Picker */
body.light-mode .ob-right { background: #f7f8fa; }
body.light-mode .ob-heading { color: #111; }
body.light-mode .ob-sub { color: rgba(0,0,0,0.45); }
body.light-mode .ob-label { color: rgba(0,0,0,0.45); }
body.light-mode .ob-input {
  background: #fff; border-color: rgba(0,0,0,0.12); color: #111;
}
body.light-mode .ob-input::placeholder { color: rgba(0,0,0,0.3); }
body.light-mode .ob-input:focus { border-color: rgba(40,160,80,0.5); box-shadow: 0 0 0 3px rgba(40,160,80,0.1); }
body.light-mode .ob-avatar-hint { color: rgba(0,0,0,0.35); }
body.light-mode .ob-feat { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.07); }
body.light-mode .ob-feat:hover { background: rgba(0,0,0,0.06); }
body.light-mode .ob-feat-title { color: #111; }
body.light-mode .ob-feat-desc  { color: rgba(0,0,0,0.4); }
body.light-mode .ob-feat-icon  { background: rgba(40,160,80,0.1); color: #28a050; }
body.light-mode .ob-import-textarea {
  background: #fff; border-color: rgba(0,0,0,0.12); color: #111;
}
body.light-mode .ob-import-textarea::placeholder { color: rgba(0,0,0,0.3); }
body.light-mode .ob-import-textarea:focus { border-color: rgba(40,160,80,0.4); }
body.light-mode .ob-import-item { background: rgba(0,0,0,0.04); color: rgba(0,0,0,0.65); }
body.light-mode .ob-theme { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.1); }
body.light-mode .ob-theme:hover { background: rgba(0,0,0,0.07); }
body.light-mode .ob-theme.ob-theme--active { border-color: #28a050; background: rgba(40,160,80,0.07); }
body.light-mode .ob-theme-label { color: rgba(0,0,0,0.5); }
body.light-mode .ob-theme.ob-theme--active .ob-theme-label { color: #28a050; }
body.light-mode .ob-theme.ob-theme--active .ob-theme-check { background: #28a050; }
body.light-mode .ob-dot { background: rgba(0,0,0,0.15); }
body.light-mode .ob-dot.ob-dot--active { background: #28a050; }
body.light-mode .ob-btn-secondary {
  background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); color: rgba(0,0,0,0.5);
}
body.light-mode .ob-btn-secondary:hover { background: rgba(0,0,0,0.1); color: rgba(0,0,0,0.75); }

/* Theme Picker */
@media (max-width: 760px) {
  .ob-overlay { flex-direction: column; }
  .ob-brand-logo-wrap { width: 44px; height: 44px; border-radius: 12px; }
  .ob-brand-logo { width: 28px; height: 28px; }
  .ob-brand-name { font-size: 1.2rem; }
  .ob-brand-tag, .ob-left-feats, .ob-left-footer, .ob-bg-orb { display: none; }
  .ob-right { padding: 40px 24px 32px; }
  .ob-features { grid-template-columns: 1fr; }
  .ob-themes { gap: 8px; }
  .ob-dots { top: 16px; }
}
/* Theme Picker */
.user-msg-edit-wrap {
  width: 100%;
  margin-top: 4px;
}
.user-msg-edit-input {
  width: 20rem;
  min-height: 52px;
  padding: 7px 12px;
  background: var(--bg-secondary, #1e1e1e);
  color: var(--text, #e0e0e0);
  border-color: rgb(27 31 28 / 0%);
  border-radius: 14px;
  font-size: 0.92rem;
  font-family: inherit;
  line-height: 1.65;
  resize: none;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.18s;
    overflow: hidden;
}
.user-msg-edit-input:focus {
  border-color: rgb(30 30 30);
}
body.light-mode .user-msg-edit-input {
  background: #ffffff;
  color: #1a1a1a;
}
body.light-mode .user-msg-edit-input:focus {
  border-color: rgb(255 255 255 / 28%);
}
.user-msg-edit-actions {
  display: flex;
  gap: 7px;
  margin-top: 8px;
  justify-content: flex-end;
  align-items: center;
}
.user-edit-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 10px;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.16s, background 0.16s, transform 0.12s, box-shadow 0.16s;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.01em;
font-family: 'DM Sans';
}
.user-edit-btn--submit {
  background: #2f9e58;
  color: #fff;
}
.user-edit-btn--submit:hover {
  background: #35b363;
}
.user-edit-btn--submit:active { transform: scale(0.96); }
.user-edit-btn--cancel {
  background: transparent;
  color: var(--text-muted, #888);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
}
.user-edit-btn--cancel:hover {
  background: var(--hover, rgba(255,255,255,0.06));
  color: var(--text, #e0e0e0);
  border-color: var(--border, rgba(255,255,255,0.18));
}
body.light-mode .user-edit-btn--cancel {
  border-color: rgba(0,0,0,0.14);
  color: #666;
}
body.light-mode .user-edit-btn--cancel:hover {
  background: rgba(0,0,0,0.05);
  color: #333;
}

/* Branch Navigation */
.branch-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}
.message[data-ai="1"] .branch-nav {
  justify-content: flex-start;
}
.branch-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: #1e1e1e;
  color: #aaa;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
body.light-mode .branch-nav-btn {
  background: #ffffff;
}
.branch-nav-btn:hover:not(:disabled) {
  background: var(--accent, #aaa);
  color: #1e1e1e;
}
body.light-mode .branch-nav-btn:hover:not(:disabled) {
  background: var(--accent, #aaa);
  color: #676767;
}
.branch-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.branch-nav-count {
  font-size: 0.76rem;
  color: var(--text-secondary, #aaa);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: center;
}

/* Image Generation */
.img-gen-loading {
  margin-top: 14px;
}
.img-gen-loading-inner {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 13px 18px;
  background: var(--bg-secondary, #1e1e1e);
  border-radius: 12px;
  min-width: 200px;
}
body.light-mode .img-gen-loading-inner {
  background: #ffffff;
}
.img-gen-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(80,200,120,0.2);
  border-top-color: #50c878;
  border-radius: 50%;
  animation: img-gen-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes img-gen-spin { to { transform: rotate(360deg); } }
.img-gen-loading-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.img-gen-loading-title {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
body.light-mode .img-gen-loading-title {
  color: var(--text, #1a1a1a);
}
.img-gen-loading-sub {
  font-size: 0.75rem;
  color: var(--text-muted, #888);
}
.img-gen-result {
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  display: inline-block;
  position: relative;
  max-width: 100%;
}
.img-gen-image {
  display: block;
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  border-radius: 12px;
  object-fit: contain;
}
.img-gen-download {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #ffffff;
  text-decoration: none;
  transition: background 0.18s, transform 0.14s;
  opacity: 0;
  pointer-events: none;
}
.img-gen-result:hover .img-gen-download {
  opacity: 1;
  pointer-events: auto;
}
.img-gen-download:hover {
  background: rgb(0 191 18 / 85%);
}
/* .img-gen-error removed — image-gen errors now use the unified .md-error class
   so they look identical to "response cancelled" and "An error occurred" errors. */

/* Keyboard Shortcuts */
.ws-searching-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-secondary, #1e1e2e);
  border: 1px solid rgba(80,200,120,0.2);
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  animation: ws-badge-pulse 1.4s ease-in-out infinite;
}
@keyframes ws-badge-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
body.light-mode .ws-searching-badge {
  background: #f5f5f5;
  color: #666;
}