/*
  EKB theme for LibreChat: the portal's "Ink & Brass" (apps/portal/src/index.css) laid over an unmodified
  LibreChat build. Loaded after LibreChat's own stylesheet by one <link> that librechat/theme/apply.mjs adds to
  client/dist/index.html. No component, class or script of LibreChat is changed.

  How it is built
  1. The portal's tokens, copied by value (--ekb-*), per theme. LibreChat puts `dark` / `light` on <html>.
  2. LibreChat's own semantic tokens (R G B triplets) pointed at those values: most of the app follows from this.
  3. A short list of surfaces restyled by hand, each addressed by a stable hook of LibreChat's DOM
     (data-testid, role, aria-*, id), so they are raised, lit and marked the way the portal does it.

  Rules kept from the portal (docs/demo-2511/ui-feedback.md, G3, G4, G10, G11): surfaces are raised (gradient,
  top highlight, shadow); what is chosen is a lit brass surface with ink text, never a coloured stripe or an
  outline alone; icons stand bare; no upper-case spaced labels; brass only for the chosen thing and the primary
  action; VIB blue for links and data; no purple, cyan or indigo.
*/

/* Plus Jakarta Sans, the portal's face (same files as the Keycloak login theme; OFL.txt beside them) */
@font-face {
  font-family: "Plus Jakarta Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("fonts/plus-jakarta-sans-vietnamese-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301,
    U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: "Plus Jakarta Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ───────────── 1. the portal's tokens ───────────── */

html {
  color-scheme: light;
  --ekb-font: "Plus Jakarta Sans Variable", "Plus Jakarta Sans", system-ui, sans-serif;
  --ekb-bg: #e8ebf2;
  --ekb-card-a: #ffffff;
  --ekb-card-b: #f6f8fc;
  --ekb-tile-a: #ffffff;
  --ekb-tile-b: #f2f5fa;
  --ekb-inner: #f1f3f7;
  --ekb-active: #e9ecf1;
  --ekb-line: rgba(22, 34, 66, 0.09);
  --ekb-line2: rgba(22, 34, 66, 0.18);
  --ekb-fg: #0e1420;
  --ekb-fg2: #485164;
  --ekb-fg3: #5f697d;
  --ekb-brass: #e08a00;
  --ekb-brass-text: #8a5200;
  --ekb-brass-wash: rgba(224, 138, 0, 0.12);
  --ekb-brass-glow: rgba(230, 126, 10, 0.34);
  --ekb-sel-a: #ffe9b5;
  --ekb-sel-b: #ffcd72;
  --ekb-sel-ink: #241703;
  --ekb-sel-ink2: #574110;
  --ekb-sel-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 14px 26px -14px rgba(214, 130, 10, 0.55), 0 1px 3px rgba(22, 34, 66, 0.16);
  --ekb-blue: #2f62d9;
  --ekb-blue-text: #1f4cb8;
  --ekb-blue-wash: rgba(47, 98, 217, 0.1);
  --ekb-green-text: #17703f;
  --ekb-green-wash: rgba(31, 138, 82, 0.11);
  --ekb-red: #c4320a;
  --ekb-red-text: #b42318;
  --ekb-red-wash: rgba(196, 50, 10, 0.1);
  --ekb-rise: inset 0 1px 0 #ffffff, 0 22px 44px -18px rgba(22, 34, 66, 0.26), 0 2px 5px rgba(22, 34, 66, 0.07);
  --ekb-rise-sm: inset 0 1px 0 #ffffff, 0 10px 20px -10px rgba(22, 34, 66, 0.28), 0 1px 2px rgba(22, 34, 66, 0.08);
  --ekb-sink: inset 0 1px 3px rgba(22, 34, 66, 0.1);
  --ekb-well: #e9ecf1;
  --ekb-pop-shadow: 0 24px 60px rgba(20, 28, 45, 0.2), inset 0 1px 0 #ffffff;
  --ekb-focal-glow: 0 34px 64px -28px rgba(230, 126, 10, 0.45), 0 0 70px -30px rgba(230, 126, 10, 0.28);
  --ekb-glow:
    radial-gradient(1100px 560px at 62% -12%, rgba(52, 104, 228, 0.16), transparent 70%),
    radial-gradient(820px 520px at 108% 58%, rgba(242, 150, 40, 0.14), transparent 70%),
    radial-gradient(760px 520px at -8% 104%, rgba(52, 104, 228, 0.1), transparent 70%);
  --ekb-tip: #0e1420;
  --ekb-tip-fg: #ffffff;
  --ekb-focus: #b56f00;
  --ekb-overlay: rgba(22, 30, 48, 0.36);
  --ekb-logo: url("vib-logo-light.png");
}

html.dark {
  color-scheme: dark;
  --ekb-bg: #090d14;
  --ekb-card-a: #1a2436;
  --ekb-card-b: #0f1622;
  --ekb-tile-a: #202b40;
  --ekb-tile-b: #141c2b;
  --ekb-inner: #151c2a;
  --ekb-active: #1c2536;
  --ekb-line: rgba(255, 255, 255, 0.08);
  --ekb-line2: rgba(255, 255, 255, 0.15);
  --ekb-fg: #eef1f6;
  --ekb-fg2: #a9b2c3;
  --ekb-fg3: #8c96a9;
  --ekb-brass: #f2a93b;
  --ekb-brass-text: #f5b95a;
  --ekb-brass-wash: rgba(242, 169, 59, 0.14);
  --ekb-brass-glow: rgba(242, 150, 40, 0.42);
  --ekb-sel-a: #f9e8c0;
  --ekb-sel-b: #e6b765;
  --ekb-sel-ink: #21170a;
  --ekb-sel-ink2: #493713;
  --ekb-sel-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 16px 30px -14px rgba(240, 176, 80, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
  --ekb-blue: #5b95ff;
  --ekb-blue-text: #93bbff;
  --ekb-blue-wash: rgba(91, 149, 255, 0.14);
  --ekb-green-text: #5fd9a3;
  --ekb-green-wash: rgba(63, 207, 142, 0.13);
  --ekb-red: #ff6b5e;
  --ekb-red-text: #ff9d94;
  --ekb-red-wash: rgba(255, 107, 94, 0.14);
  --ekb-rise:
    inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 1px 0 0 rgba(255, 255, 255, 0.04), 0 24px 48px -16px rgba(0, 0, 0, 0.75),
    0 3px 8px rgba(0, 0, 0, 0.4);
  --ekb-rise-sm: inset 0 1px 0 rgba(255, 255, 255, 0.11), 0 10px 22px -8px rgba(0, 0, 0, 0.7), 0 1px 3px rgba(0, 0, 0, 0.4);
  --ekb-sink: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  --ekb-well: rgba(9, 13, 20, 0.55);
  --ekb-pop-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --ekb-focal-glow: 0 34px 70px -28px rgba(242, 150, 40, 0.5), 0 0 80px -30px rgba(242, 150, 40, 0.3);
  --ekb-glow:
    radial-gradient(1100px 560px at 62% -12%, rgba(52, 104, 228, 0.26), transparent 70%),
    radial-gradient(820px 520px at 108% 58%, rgba(242, 150, 40, 0.13), transparent 70%),
    radial-gradient(760px 520px at -8% 104%, rgba(52, 104, 228, 0.14), transparent 70%);
  --ekb-tip: #f1f3f8;
  --ekb-tip-fg: #0e1420;
  --ekb-focus: #f2a93b;
  --ekb-overlay: rgba(4, 7, 12, 0.66);
  --ekb-logo: url("vib-logo-dark.png");
}

/* ───────────── 2. LibreChat's tokens, pointed at the portal's values ───────────── */

html {
  --presentation: 232 235 242;
  --text-primary: 14 20 32;
  --text-secondary: 72 81 100;
  --text-secondary-alt: 95 105 125;
  --text-tertiary: 95 105 125;
  --text-muted: 95 105 125;
  --text-warning: 138 82 0;
  --text-destructive: 180 35 24;
  --link: 31 76 184;
  --link-hover: 36 79 192;
  --link-visited: 31 76 184;
  --accent-primary: 47 98 217;
  --accent-primary-hover: 36 79 192;
  --brand-purple: 47 98 217;
  --ring-primary: 181 111 0;
  --header-primary: 255 255 255;
  --header-hover: 244 245 248;
  --header-button-hover: 244 245 248;
  --surface-active: 223 227 235;
  --surface-active-alt: 223 227 235;
  --surface-hover: 226 230 237;
  --surface-hover-alt: 212 217 227;
  --surface-composer-hover: 233 236 241;
  --surface-primary: 255 255 255;
  --surface-primary-alt: 232 235 242;
  --surface-primary-contrast: 233 236 241;
  --surface-secondary: 244 245 248;
  --surface-secondary-alt: 233 236 241;
  --surface-tertiary: 233 236 241;
  --surface-tertiary-alt: 255 255 255;
  --surface-dialog: 255 255 255;
  --surface-overlay: 22 30 48;
  --surface-submit: 236 154 38;
  --surface-submit-hover: 241 165 53;
  --surface-destructive: 196 50 10;
  --surface-destructive-hover: 170 42 8;
  --surface-chat: 255 255 255;
  --surface-code: 241 243 247;
  --border-light: 22 34 66;
  --border-light-alpha: 0.09;
  --border-medium: 22 34 66;
  --border-medium-alt: 22 34 66;
  --border-medium-alpha: 0.18;
  --border-heavy: 22 34 66;
  --border-heavy-alpha: 0.26;
  --border-xheavy: 22 34 66;
  --border-xheavy-alpha: 0.36;
  --border-destructive: 196 50 10;
  --status-success: 23 112 63;
  --status-success-subtle: 230 242 236;
  --status-success-border: 170 214 190;
  --status-info: 31 76 184;
  --status-info-subtle: 234 239 251;
  --status-info-border: 170 192 240;
  --status-warning: 138 82 0;
  --status-warning-subtle: 251 241 224;
  --status-warning-border: 240 200 130;
  --status-error: 180 35 24;
  --status-error-subtle: 249 235 230;
  --status-error-border: 235 170 150;
  --status-neutral: 72 81 100;
  --status-neutral-subtle: 244 245 248;
  --status-neutral-border: 205 210 221;
  --status-verified: 47 98 217;
  --syntax-text: 14 20 32;
  --syntax-comment: 95 105 125;
  --syntax-meta: 72 81 100;
  --syntax-builtin: 138 82 0;
  --syntax-keyword: 31 76 184;
  --syntax-string: 23 112 63;
  --syntax-attr: 138 82 0;
  --syntax-title: 180 35 24;
  --surface-inverted: 14 20 32;
  --surface-inverted-hover: 28 37 54;
  --text-inverted: 255 255 255;
  --switch-unchecked: 180 189 205;
  --radius: 0.625rem;
  --theme-control-radius: 0.625rem;
  --theme-round-control-radius: 0.75rem;
  --theme-surface-radius: 1rem;
  --theme-large-surface-radius: 1rem;
  --theme-font-family: var(--ekb-font);
  --theme-elevation-surface: var(--ekb-rise-sm);
}

html.dark {
  --presentation: 9 13 20;
  --text-primary: 238 241 246;
  --text-secondary: 169 178 195;
  --text-secondary-alt: 140 150 169;
  --text-tertiary: 140 150 169;
  --text-muted: 140 150 169;
  --text-warning: 245 185 90;
  --text-destructive: 255 157 148;
  --link: 147 187 255;
  --link-hover: 125 176 255;
  --link-visited: 147 187 255;
  --accent-primary: 91 149 255;
  --accent-primary-hover: 125 176 255;
  --brand-purple: 91 149 255;
  --ring-primary: 242 169 59;
  --header-primary: 28 37 54;
  --header-hover: 37 47 68;
  --header-button-hover: 28 37 54;
  --surface-active: 37 47 68;
  --surface-active-alt: 28 37 54;
  --surface-hover: 28 37 54;
  --surface-hover-alt: 37 47 68;
  --surface-composer-hover: 37 47 68;
  --surface-primary: 15 21 32;
  --surface-primary-alt: 9 13 20;
  --surface-primary-contrast: 21 28 42;
  --surface-secondary: 21 28 42;
  --surface-secondary-alt: 21 28 42;
  --surface-tertiary: 28 37 54;
  --surface-tertiary-alt: 28 37 54;
  --surface-dialog: 20 28 43;
  --surface-overlay: 4 7 12;
  --surface-submit: 236 154 38;
  --surface-submit-hover: 241 165 53;
  --surface-destructive: 196 50 10;
  --surface-destructive-hover: 170 42 8;
  --surface-chat: 26 36 54;
  --surface-code: 12 17 26;
  --border-light: 255 255 255;
  --border-light-alpha: 0.08;
  --border-medium: 255 255 255;
  --border-medium-alt: 255 255 255;
  --border-medium-alpha: 0.15;
  --border-heavy: 255 255 255;
  --border-heavy-alpha: 0.22;
  --border-xheavy: 255 255 255;
  --border-xheavy-alpha: 0.3;
  --border-destructive: 255 107 94;
  --status-success: 95 217 163;
  --status-success-subtle: 21 45 46;
  --status-success-border: 31 82 68;
  --status-info: 147 187 255;
  --status-info-subtle: 26 39 63;
  --status-info-border: 44 72 128;
  --status-warning: 245 185 90;
  --status-warning-subtle: 47 42 36;
  --status-warning-border: 110 80 36;
  --status-error: 255 157 148;
  --status-error-subtle: 49 33 41;
  --status-error-border: 120 55 55;
  --status-neutral: 169 178 195;
  --status-neutral-subtle: 21 28 42;
  --status-neutral-border: 44 52 68;
  --status-verified: 91 149 255;
  --syntax-text: 238 241 246;
  --syntax-comment: 140 150 169;
  --syntax-meta: 169 178 195;
  --syntax-builtin: 245 185 90;
  --syntax-keyword: 147 187 255;
  --syntax-string: 95 217 163;
  --syntax-attr: 245 185 90;
  --syntax-title: 255 157 148;
  --surface-inverted: 241 243 248;
  --surface-inverted-hover: 226 230 238;
  --text-inverted: 14 20 32;
  --switch-unchecked: 70 84 110;
}

/* the border tokens are also used as fills and rings, where their alpha does not apply */
.bg-border-light {
  background-color: var(--ekb-line) !important;
}
.bg-border-medium,
.before\:bg-border-medium::before {
  background-color: var(--ekb-line2) !important;
}
.bg-border-heavy,
.bg-border-xheavy,
.hover\:bg-border-medium:hover,
.active\:bg-border-heavy:active {
  background-color: color-mix(in srgb, var(--ekb-fg3) 55%, transparent) !important;
}
.divide-border-light > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--ekb-line) !important;
}
.ring-border-light,
.ring-border-medium {
  --tw-ring-color: var(--ekb-line2) !important;
}

/* ───────────── 3. the page ───────────── */

/*
  G10: LibreChat marks the active row of a list, a failed step and a hand-off with a thin bar on the left
  (a 2px pseudo-element or a left border). None of them is drawn; the surface carries the state instead.
*/
.before\:w-0\.5::before {
  content: none !important;
}
.border-l-2 {
  border-left-width: 0 !important;
}

/* G11: no upper-case spaced labels (section names in Cài đặt, group names in menus) */
.uppercase {
  text-transform: none !important;
  letter-spacing: 0 !important;
}
.tracking-wide,
.tracking-wider,
.tracking-widest {
  letter-spacing: 0 !important;
}

html:root,
html:root body {
  background: var(--ekb-bg);
}
html:root body {
  background: var(--ekb-glow), var(--ekb-bg);
  background-attachment: fixed;
  font-family: var(--ekb-font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  color: var(--ekb-fg);
}
html,
button,
input,
select,
textarea,
.font-sans,
.font-theme-ui {
  font-family: var(--ekb-font);
}
#loading-container {
  background: var(--ekb-bg) !important;
}
@media (prefers-color-scheme: dark) {
  html:not(.light) #loading-container {
    background: #090d14 !important;
  }
}
::selection {
  background: color-mix(in srgb, var(--ekb-blue) 40%, transparent);
}
:focus-visible {
  outline-color: var(--ekb-focus);
}
* {
  scrollbar-color: var(--ekb-line2) transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--ekb-line2) !important;
  border-radius: 999px;
}
::-webkit-scrollbar-track {
  background-color: transparent !important;
}

/*
  The lit background runs under the sidebar and the conversation alike (the portal's sidebar has no panel of its
  own): the structural wrappers stop painting a flat colour.
*/
aside[aria-label] > div > div,
aside[aria-label] nav,
div.bg-presentation:has(#messages-view),
#messages-view,
main[role="main"] .bg-presentation:not(button):not(a) {
  background-color: transparent !important;
}
/* the strip behind the header buttons: the conversation blurs out under it, no flat band of colour */
main[role="main"] .from-presentation {
  --tw-gradient-from: transparent !important;
  --tw-gradient-stops: transparent, transparent !important;
  background-image: none !important;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(#000 55%, transparent);
  mask-image: linear-gradient(#000 55%, transparent);
}

/* ───────────── 4. sidebar ───────────── */

/* the icon rail: no hairline between it and the list */
aside[aria-label] > div > div.border-r {
  border-right-color: transparent !important;
}
aside[aria-label] .border-b.border-border-light {
  border-color: transparent !important;
}

/* the brand, as in the portal: logo, product label on the wordmark's baseline, then what this app is for */
aside[aria-label] nav,
#mobile-drawer nav {
  display: flex;
  flex-direction: column;
}
aside[aria-label] nav::before,
#mobile-drawer nav::before {
  content: "EKB";
  flex: none;
  display: flex;
  align-items: flex-end;
  box-sizing: border-box;
  height: 34px;
  margin: 22px 0 0 14px;
  padding-left: 50px;
  background: var(--ekb-logo) left bottom / auto 32px no-repeat;
  color: var(--ekb-fg);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.3em;
}
aside[aria-label] nav > div,
#mobile-drawer nav > div {
  flex: 1 1 0;
  height: auto !important;
  min-height: 0;
}
aside[aria-label] nav > div::before,
#mobile-drawer nav > div::before {
  content: "Hỏi đáp";
  flex: none;
  display: block;
  padding: 7px 0 14px 15px;
  color: var(--ekb-fg2);
  font-size: 12.5px;
}

/* rail buttons: the panel you are on is a raised key with a brass icon (the portal's .nav-on) */
aside[aria-label] [data-testid^="nav-panel-"],
aside[aria-label] [data-testid="new-chat-button"],
aside[aria-label] [data-testid="close-sidebar-button"] {
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ekb-fg2);
}
aside[aria-label] [data-testid^="nav-panel-"]:hover,
aside[aria-label] [data-testid="new-chat-button"]:hover,
aside[aria-label] [data-testid="close-sidebar-button"]:hover {
  background: var(--ekb-inner) !important;
  color: var(--ekb-fg);
}
aside[aria-label] [data-testid^="nav-panel-"].bg-surface-active-alt {
  background: linear-gradient(160deg, var(--ekb-tile-a), var(--ekb-tile-b)) !important;
  border-color: var(--ekb-line);
  box-shadow: var(--ekb-rise-sm);
  color: var(--ekb-brass) !important;
}
/* not part of EKB: uploads are off, the MCP server is fixed by the administrator */
[data-testid="nav-panel-files"],
[data-testid="nav-panel-mcp-builder"] {
  display: none !important;
}

/* "Projects" (folders of chats) is not part of EKB: the list starts at the conversations */
nav [role="region"] > div > div > div.flex.flex-col.px-3.text-sm:first-child {
  display: none !important;
}

/* phone: the drawer is the same lit page; "Trò chuyện mới" is its primary action */
#mobile-drawer {
  background: var(--ekb-glow), var(--ekb-bg) !important;
}
#mobile-drawer nav {
  background-color: transparent !important;
}
[data-testid="nav-new-chat-fab"] {
  border-radius: 12px !important;
  background: linear-gradient(180deg, #f9c15e, #ec9a26) !important;
  color: #1a1002 !important;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 10px 24px -8px var(--ekb-brass-glow);
}
[data-testid="nav-new-chat-fab"] * {
  color: #1a1002 !important;
  font-weight: 700;
}

/* conversation list */
[data-testid="convo-list-row"] h2 {
  color: var(--ekb-fg3);
  font-size: 12px;
  font-weight: 500;
}
[data-testid="convo-item"] {
  border-radius: 10px !important;
  transition:
    background-color 120ms ease,
    box-shadow 120ms ease;
}
[data-testid="convo-item"]::before {
  content: none !important;
}
[data-testid="convo-item"],
[data-testid="convo-item"] > button {
  background-color: transparent !important;
}
[data-testid="convo-item"]:hover,
[data-testid="convo-item"]:focus-within {
  background: linear-gradient(160deg, var(--ekb-tile-a), var(--ekb-tile-b)) !important;
  box-shadow: var(--ekb-rise-sm);
}
/* the conversation in view: one lit brass surface, its words in deep ink (the portal's .sel-key) */
[data-testid="convo-item"]:has(> [aria-current="page"]) {
  background: linear-gradient(160deg, var(--ekb-sel-a), var(--ekb-sel-b)) !important;
  box-shadow: var(--ekb-sel-shadow);
  --text-primary: 33 23 10;
  --text-secondary: 73 55 19;
  --text-secondary-alt: 73 55 19;
  --surface-hover: 205 160 80;
  color: var(--ekb-sel-ink);
}
[data-testid="convo-item"]:has(> [aria-current="page"]) > button {
  color: var(--ekb-sel-ink);
  font-weight: 600;
}
[data-testid="convo-item"]:has(> [aria-current="page"]) svg {
  color: var(--ekb-sel-ink);
}
[data-testid="convo-item"]:has(> [aria-current="page"]) > div button {
  background: transparent !important;
}
[data-testid="convo-item"]:has(> [aria-current="page"]) > div button:hover,
[data-testid="convo-item"]:has(> [aria-current="page"]) > div button[aria-expanded="true"] {
  background: rgba(60, 38, 0, 0.14) !important;
}

/* ───────────── 5. header ───────────── */

/* secondary actions are raised keys (the portal's .btn-quiet) */
main[role="main"] button.border.border-border-light.bg-presentation,
main[role="main"] a.border.border-border-light.bg-presentation,
[data-testid="model-selector-button"],
#bookmark-menu-button,
#export-menu-button {
  background: linear-gradient(160deg, var(--ekb-tile-a), var(--ekb-tile-b)) !important;
  border-color: var(--ekb-line) !important;
  border-radius: 10px !important;
  box-shadow: var(--ekb-rise-sm);
  color: var(--ekb-fg);
}
main[role="main"] button.border.border-border-light.bg-presentation:hover,
[data-testid="model-selector-button"]:hover,
#bookmark-menu-button:hover,
#export-menu-button:hover {
  border-color: var(--ekb-line2) !important;
}
main[role="main"] button.border.border-border-light.bg-presentation:active,
[data-testid="model-selector-button"]:active {
  background: var(--ekb-active) !important;
  box-shadow: var(--ekb-sink);
}
[data-testid="model-selector-button"] {
  font-weight: 600;
}

/* the welcome line: the portal's page title */
.split-parent {
  font-size: 30px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  letter-spacing: -0.025em;
}
/* the EKB mark stands bare: no round crop, no chip */
:has(> img[src*="/assets/ekb/"]) {
  overflow: visible !important;
  border-radius: 0 !important;
  background: transparent !important;
}
img[src*="/assets/ekb/"] {
  object-fit: contain !important;
  border-radius: 0 !important;
}
/* the portal's favicon keeps a sliver of the wordmark in its lower left corner; at 20 to 40 px it shows, so it is cut */
img[src*="/assets/ekb/favicon"] {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 15% 100%, 15% 58%, 0 58%);
}

/* ───────────── 6. conversation ───────────── */

/* the question: a small raised tile */
.user-turn [data-testid="message-body"] {
  background: linear-gradient(160deg, var(--ekb-tile-a), var(--ekb-tile-b)) !important;
  border: 1px solid var(--ekb-line);
  border-radius: 14px !important;
  box-shadow: var(--ekb-rise-sm);
}
/* the answer: a raised card, as "Câu trả lời" in the portal */
.agent-turn {
  box-sizing: border-box;
  padding: 16px 22px 10px;
  background: linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b));
  border: 1px solid var(--ekb-line);
  border-radius: 16px;
  box-shadow: var(--ekb-rise);
}
.agent-turn > h2 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.message-timestamp {
  color: var(--ekb-fg3) !important;
}

.markdown {
  font-size: 15px;
  line-height: 1.6;
}
.markdown strong {
  font-weight: 700;
}
.markdown li::marker {
  color: var(--ekb-fg3);
}
.markdown a {
  color: var(--ekb-blue-text);
  font-weight: 500;
  text-decoration-color: color-mix(in srgb, var(--ekb-blue-text) 45%, transparent);
  text-underline-offset: 3px;
}
/* a citation opens the page of the source document: a blue chip, in the line or in the list of sources */
.markdown a[href*="/viewer/"] {
  display: inline;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ekb-blue-wash);
  color: var(--ekb-blue-text);
  font-size: 0.86em;
  font-weight: 700;
  text-decoration: none;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-color 120ms ease;
}
.markdown a[href*="/viewer/"]:hover {
  background: color-mix(in srgb, var(--ekb-blue) 26%, transparent);
}
.markdown hr {
  margin: 14px 0 10px;
  border-color: var(--ekb-line);
}
/* the closing note under the rule (AI disclosure) reads as small print */
.markdown hr + p,
.markdown hr + p em {
  color: var(--ekb-fg3);
  font-size: 12.5px;
  font-style: normal;
}

/* a quotation: recessed, no bar on its left */
.markdown blockquote {
  margin: 12px 0;
  padding: 10px 14px !important;
  border: 0 !important;
  border-radius: 10px;
  background: var(--ekb-well);
  box-shadow: var(--ekb-sink);
  color: var(--ekb-fg2);
  line-height: 1.55 !important;
}

.markdown blockquote p {
  margin: 0 !important;
}

/* an answer that failed: a red-tinted surface and red words, not a red outline */
.agent-turn [role="alert"],
[role="alert"].bg-status-error-subtle {
  border-color: transparent !important;
  border-radius: 12px !important;
  background: var(--ekb-red-wash) !important;
  color: var(--ekb-red-text) !important;
  font-weight: 500;
}

/* tables: a recessed sheet with sentence-case column heads */
.markdown table {
  overflow: hidden;
  border: 1px solid var(--ekb-line) !important;
  border-radius: 12px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--ekb-well);
  box-shadow: var(--ekb-sink);
  font-size: 13.5px;
}
.markdown th {
  border: 0 !important;
  border-bottom: 1px solid var(--ekb-line2) !important;
  background: var(--ekb-inner) !important;
  color: var(--ekb-fg2) !important;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}
.markdown td {
  border: 0 !important;
  border-bottom: 1px solid var(--ekb-line) !important;
  background: transparent !important;
}
.markdown tr:last-child td {
  border-bottom: 0 !important;
}

/* code: recessed */
.markdown pre,
.markdown pre > div {
  border-radius: 12px !important;
}
.markdown pre > div {
  border: 1px solid var(--ekb-line);
  box-shadow: var(--ekb-sink);
}
.markdown :not(pre) > code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--ekb-inner) !important;
  color: var(--ekb-fg) !important;
  font-size: 0.88em;
}

/* message actions: bare icons */
.hover-button {
  border-radius: 8px !important;
  color: var(--ekb-fg3) !important;
}
.hover-button:hover {
  background: var(--ekb-inner) !important;
  color: var(--ekb-fg) !important;
}
/* a rating that has been given */
.hover-button.hover-button-active {
  color: var(--ekb-brass) !important;
}

/* ───────────── 7. composer ───────────── */

/* the one focal surface of the screen: warmed with brass from its lit corner (the portal's .card.focal) */
[data-testid="composer-surface"] {
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--ekb-brass) 14%, transparent), transparent 62%),
    linear-gradient(160deg, color-mix(in srgb, var(--ekb-brass) 5%, var(--ekb-card-a)), var(--ekb-card-b)) !important;
  border: 1px solid var(--ekb-line) !important;
  border-radius: 16px !important;
  box-shadow: var(--ekb-rise), var(--ekb-focal-glow) !important;
}
[data-testid="text-input"] {
  font-size: 15px;
}
[data-testid="text-input"]::placeholder {
  color: var(--ekb-fg3) !important;
}
/* the primary action: brass */
#send-button,
[data-testid="send-button"],
[data-testid="stop-generation-button"] {
  border-radius: 12px !important;
  background: linear-gradient(180deg, #f9c15e, #ec9a26) !important;
  color: #1a1002 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 10px 24px -8px var(--ekb-brass-glow);
  opacity: 1 !important;
}
#send-button svg,
[data-testid="send-button"] svg,
[data-testid="stop-generation-button"] svg {
  color: #1a1002 !important;
}
#send-button:hover:not(:disabled),
[data-testid="stop-generation-button"]:hover {
  background: linear-gradient(180deg, #fccb72, #f1a535) !important;
}
#send-button:disabled {
  background: var(--ekb-active) !important;
  box-shadow: none;
}
#send-button:disabled svg {
  color: var(--ekb-fg3) !important;
}
/* nothing to choose there for EKB (no tools, no uploads) */
#tools-dropdown-button {
  display: none !important;
}

/* footer line under the composer */
[role="contentinfo"],
[role="contentinfo"] a {
  color: var(--ekb-fg3) !important;
}

/* ───────────── 8. menus, dialogs, tooltips, toasts ───────────── */

[role="menu"],
[role="listbox"],
[role="dialog"]:not([data-testid="composer-surface"]),
[role="alertdialog"],
.popover-ui,
[data-radix-popper-content-wrapper] > [role="dialog"],
[data-radix-menu-content] {
  background: linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b)) !important;
  border: 1px solid var(--ekb-line2) !important;
  border-radius: 14px !important;
  box-shadow: var(--ekb-pop-shadow) !important;
  color: var(--ekb-fg);
}
[role="menuitem"],
[role="menuitemradio"],
[role="menuitemcheckbox"],
[role="option"] {
  border-radius: 9px !important;
}
[role="menuitem"]:hover,
[role="menuitem"][data-active-item],
[role="menuitem"][data-highlighted],
[role="menuitemradio"]:hover,
[role="menuitemradio"][data-active-item],
[role="option"]:hover,
[role="option"][data-active-item],
[role="option"][data-highlighted] {
  background: var(--ekb-inner) !important;
}
/* the option in use (model, theme, language): the lit brass surface, as everywhere */
[role="option"][aria-selected="true"] {
  background: linear-gradient(160deg, var(--ekb-sel-a), var(--ekb-sel-b)) !important;
  box-shadow: var(--ekb-sel-shadow);
  --text-primary: 33 23 10;
  --text-secondary: 73 55 19;
  --text-secondary-alt: 73 55 19;
  --text-tertiary: 73 55 19;
  color: var(--ekb-sel-ink) !important;
}
[role="option"][aria-selected="true"] svg {
  color: var(--ekb-sel-ink);
}
[role="tooltip"] {
  background: var(--ekb-tip) !important;
  border: 0 !important;
  border-radius: 8px !important;
  color: var(--ekb-tip-fg) !important;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.45) !important;
}
[role="tooltip"] svg {
  fill: var(--ekb-tip) !important;
  stroke: none !important;
}

/* toasts: a raised popup tinted by what happened, the icon carries the colour */
.alert-root {
  border: 1px solid var(--ekb-line2) !important;
  border-radius: 12px !important;
  background: linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b)) !important;
  box-shadow: var(--ekb-pop-shadow);
  color: var(--ekb-fg) !important;
  font-weight: 600 !important;
}
.alert-root.bg-status-success-strong {
  background: linear-gradient(var(--ekb-green-wash), var(--ekb-green-wash)), linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b)) !important;
}
.alert-root.bg-status-info-strong {
  background: linear-gradient(var(--ekb-blue-wash), var(--ekb-blue-wash)), linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b)) !important;
}
.alert-root.bg-status-warning-strong {
  background: linear-gradient(var(--ekb-brass-wash), var(--ekb-brass-wash)), linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b)) !important;
}
.alert-root.bg-status-error-strong {
  background: linear-gradient(var(--ekb-red-wash), var(--ekb-red-wash)), linear-gradient(160deg, var(--ekb-card-a), var(--ekb-card-b)) !important;
}
.alert-root.bg-status-success-strong > div:first-child svg {
  color: var(--ekb-green-text);
}
.alert-root.bg-status-info-strong > div:first-child svg {
  color: var(--ekb-blue-text);
}
.alert-root.bg-status-warning-strong > div:first-child svg {
  color: var(--ekb-brass-text);
}
.alert-root.bg-status-error-strong > div:first-child svg {
  color: var(--ekb-red-text);
}

/* buttons inside dialogs: confirm is brass with ink text, cancel a raised key, delete solid red */
.bg-surface-submit,
.btn-primary {
  border: 0 !important;
  background: linear-gradient(180deg, #f9c15e, #ec9a26) !important;
  color: #1a1002 !important;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 10px 24px -8px var(--ekb-brass-glow);
}
.bg-surface-submit:hover,
.btn-primary:hover {
  background: linear-gradient(180deg, #fccb72, #f1a535) !important;
}
.bg-surface-submit *,
.btn-primary * {
  color: #1a1002 !important;
}
.bg-surface-destructive {
  border: 0 !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 10px 22px -10px rgba(196, 50, 10, 0.7);
}
[role="dialog"] button.border,
[role="alertdialog"] button.border,
.btn-neutral {
  background: linear-gradient(160deg, var(--ekb-tile-a), var(--ekb-tile-b));
  border-color: var(--ekb-line) !important;
  border-radius: 10px !important;
  box-shadow: var(--ekb-rise-sm);
  color: var(--ekb-fg);
}
[role="dialog"] input:not([type="checkbox"]):not([type="radio"]),
[role="dialog"] textarea,
[role="dialog"] [role="combobox"] {
  background: var(--ekb-well) !important;
  border: 1px solid var(--ekb-line2) !important;
  border-radius: 10px !important;
  box-shadow: var(--ekb-sink);
  color: var(--ekb-fg);
}

/* Cài đặt: each group of rows is a raised tile, not a hairline box */
[role="tabpanel"] section > .rounded-xl.border {
  background: linear-gradient(160deg, var(--ekb-tile-a), var(--ekb-tile-b));
  border-color: var(--ekb-line) !important;
  border-radius: 14px;
  box-shadow: var(--ekb-rise-sm);
}

/* switches: on is brass */
[role="switch"][data-state="checked"],
[role="switch"][aria-checked="true"] {
  background: linear-gradient(180deg, #f9c15e, #ec9a26) !important;
  box-shadow: 0 0 14px -2px var(--ekb-brass-glow);
}

/* tabs (Cài đặt): the group in view is the lit brass surface */
[role="tab"] {
  border-radius: 10px !important;
}
[role="tab"][aria-selected="true"],
[role="tab"][data-state="active"] {
  background: linear-gradient(160deg, var(--ekb-sel-a), var(--ekb-sel-b)) !important;
  box-shadow: var(--ekb-sel-shadow);
  color: var(--ekb-sel-ink) !important;
  font-weight: 600;
}
[role="tab"][aria-selected="true"] svg,
[role="tab"][data-state="active"] svg {
  color: var(--ekb-sel-ink) !important;
}

/* the logo wherever LibreChat shows its own (sign-in page) */
img[src$="assets/logo.svg"] {
  content: var(--ekb-logo);
  object-fit: contain;
}

/* ───────────── 9. light / dark button and the source drawer (ekb-chat.js) ───────────── */

/* the portal's header button: a bare icon, a lit surface only under the pointer; the tooltip is its title */
.ekb-mode {
  box-sizing: border-box;
  position: fixed;
  z-index: 40;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ekb-fg2);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.ekb-mode:hover {
  color: var(--ekb-fg);
  background: linear-gradient(180deg, var(--ekb-tile-a), var(--ekb-tile-b));
  box-shadow: var(--ekb-rise-sm);
}
.ekb-mode:focus-visible {
  outline: 2px solid var(--ekb-focus);
  outline-offset: 2px;
}

/* the drawer: one panel from the right over the chat, the chat dimmed behind it */
.ekb-src {
  position: fixed;
  inset: 0;
  z-index: 1000;
  font-family: var(--ekb-font);
}
.ekb-src[hidden] {
  display: none;
}
.ekb-src-backdrop {
  position: absolute;
  inset: 0;
  background: var(--ekb-overlay);
  opacity: 0;
  transition: opacity 200ms ease;
}
.ekb-src-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(940px, 68vw);
  padding: 14px 16px 16px;
  border-radius: 22px 0 0 22px;
  color: var(--ekb-fg);
  background: var(--ekb-glow), linear-gradient(180deg, var(--ekb-card-a), var(--ekb-card-b));
  box-shadow: var(--ekb-pop-shadow), -30px 0 70px -30px rgba(0, 0, 0, 0.45);
  transform: translateX(104%);
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ekb-src-open .ekb-src-backdrop {
  opacity: 1;
}
.ekb-src-open .ekb-src-panel {
  transform: none;
}
.ekb-src-edge {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.ekb-src-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 2px 12px 6px;
}
.ekb-src-titles {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}
.ekb-src-kicker {
  color: var(--ekb-fg3);
  font-size: 12.5px;
  font-weight: 500;
}
.ekb-src-title {
  margin: 0;
  overflow: hidden;
  color: var(--ekb-fg);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ekb-src-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ekb-fg2);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.ekb-src-btn:hover {
  color: var(--ekb-fg);
  background: linear-gradient(180deg, var(--ekb-tile-a), var(--ekb-tile-b));
  box-shadow: var(--ekb-rise-sm);
}
.ekb-src-btn:focus-visible {
  outline: 2px solid var(--ekb-focus);
  outline-offset: 1px;
}
/* the page itself: a raised sheet (the viewer draws its own light page) */
.ekb-src-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--ekb-tile-a), var(--ekb-tile-b));
  box-shadow: var(--ekb-rise);
}
.ekb-src-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #e9edf2;
  opacity: 0;
  transition: opacity 160ms ease;
}
.ekb-src-ready .ekb-src-frame {
  opacity: 1;
}
.ekb-src-wait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ekb-fg2);
  font-size: 14px;
}
.ekb-src-ready .ekb-src-wait {
  display: none;
}
.ekb-src-spin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 25%, var(--ekb-blue) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: ekb-src-spin 0.9s linear infinite;
}
@keyframes ekb-src-spin {
  to {
    transform: rotate(1turn);
  }
}
/* tablet: most of the width; phone: the whole screen */
@media (max-width: 1100px) {
  .ekb-src-panel {
    width: calc(100vw - 56px);
  }
}
@media (max-width: 767px) {
  .ekb-src-panel {
    width: 100vw;
    padding: 8px 8px 10px;
    border-radius: 0;
  }
  .ekb-src-body {
    border-radius: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ekb-src-panel,
  .ekb-src-backdrop,
  .ekb-src-frame {
    transition: none;
  }
  .ekb-src-spin {
    animation: none;
  }
}
