/* Chat_Agent design layer (POC).
   Loaded after portal-v4.html's own stylesheet and layered on top of it: the
   portal's rules, markup ids and scripts are unchanged, this file only restyles
   them into the Chat_Agent prototype (sidebar + rounded panel, hero empty state,
   compact composer, output sliding in beside the chat, Figtree + navy/teal).
   Light and dark themes: dark is derived from the Jockibox_Branding style tile
   (Figma 28:220) — navy #102A43 panels, #E4EAF0 text, teal #37B3A6 accents. */

/* Fonts ship with the portal (latin subsets, SIL OFL): a facility Mini should
   not depend on a third-party CDN for its own type. Figtree is variable. */
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap; src: url("/js/design/fonts/figtree.woff2") format("woff2"); }
@font-face { font-family: "Lato"; font-style: normal; font-weight: 400; font-display: swap; src: url("/js/design/fonts/lato-400.woff2") format("woff2"); }
@font-face { font-family: "Lato"; font-style: italic; font-weight: 400; font-display: swap; src: url("/js/design/fonts/lato-400-italic.woff2") format("woff2"); }

:root {
  --jb-bg: #e4eaf0;
  --jb-teal: #37b3a6;
  --jb-teal-hover: #2e9c90;
  --jb-teal-text: #1a756b;            /* teal as text: 4.5:1 on the sidebar grey */
  --jb-navy: #102a43;
  --jb-navy-hover: #1b3a57;
  --jb-text: #333333;
  --jb-muted: #516a81;                /* secondary text: 4.5:1 on every light surface */
  --jb-placeholder: #bbbbbb;
  --jb-line: #e4e7ed;
  --jb-hover: rgba(16, 42, 67, 0.06);
  --jb-chip-hover: #d8e0e8;
  --jb-card: #f9f9fa;
  --jb-error: #c0392b;
  /* Roles, so each theme sets a colour once. Light values are the originals. */
  --jb-ink: var(--jb-navy);            /* headings, labels, icons */
  --jb-fill: var(--jb-navy);           /* solid buttons */
  --jb-fill-hover: var(--jb-navy-hover);
  --jb-on-fill: #fff;
  --jb-surface: #fff;                  /* the panel, composer, output, cards */
  --jb-strong: #000;
  --jb-card-hover: #dadee6;
  --jb-btn-hover: #f1f3f6;
  --jb-glass: rgba(255, 255, 255, 0.6);
  --jb-glass-strong: rgba(255, 255, 255, 0.85);
  --jb-input-bg: #fff;
  --jb-input-line: #bdc0c1;
  --jb-input-line-hover: #aab0b3;
  --jb-login-title: #7d94aa;          /* large type, so 3:1 is its floor */
  --jb-login-label: #555555;
  --jb-sidebar-w: 239px;
  --jb-gutter: 24px;
  --jb-font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* The portal's own tokens, re-pointed at the design palette so modals, drawers
   and menus that still use them (POC Builder, Settings, What's New…) match. */
:root[data-theme="light"] {
  --base: var(--jb-bg);
  --bg: var(--jb-bg);
  --card2: #f3f5f8;
  --card-hover: #eef1f5;
  --surface2: #f3f5f8;
  --border: var(--jb-line);
  --border2: #d3d9e0;
  --text: var(--jb-text);
  --text2: #52667a;
  --text3: var(--jb-muted);
  --accent: var(--jb-navy);
  --accent2: var(--jb-navy-hover);
  --accent-bg: rgba(55, 179, 166, 0.12);
  --accent-text: var(--jb-teal-text);
  --on-accent: var(--jb-on-fill);
  --green: var(--jb-teal-text);
  --green-bg: rgba(55, 179, 166, 0.12);
  --red: var(--jb-error);
  --amber: #c4841e;
  --shadow: rgba(16, 42, 67, 0.08);
  --input-bg: #fff;
}

/* Dark: the style tile's navy is the panel, a deeper navy the page around it.
   Teal carries on navy (5.7:1), so it is both the accent text and the solid
   button, with navy type on it. */
:root[data-theme="dark"] {
  --jb-bg: #0a1d30;
  --jb-surface: #102a43;
  --jb-teal-hover: #4cc2b5;
  --jb-teal-text: #37b3a6;
  --jb-ink: #f0f4f8;
  --jb-fill: #37b3a6;
  --jb-fill-hover: #4cc2b5;
  --jb-on-fill: #102a43;
  --jb-text: #e4eaf0;
  --jb-muted: #95abc0;                /* 4.5:1 on the tool cards, the lightest surface */
  --jb-placeholder: #5f7891;
  --jb-line: #22405d;
  --jb-hover: rgba(228, 234, 240, 0.08);
  --jb-chip-hover: #1b3a57;
  --jb-card: #16324e;
  --jb-card-hover: #2a4a69;
  --jb-btn-hover: #1f3f5e;
  --jb-strong: #f0f4f8;
  --jb-glass: rgba(255, 255, 255, 0.05);
  --jb-glass-strong: rgba(16, 42, 67, 0.85);
  --jb-error: #e5786b;
  --jb-input-bg: #0a1d30;
  --jb-input-line: #2e4d6b;
  --jb-input-line-hover: #40607f;
  --jb-login-title: #8fa6bc;
  --jb-login-label: #c9d4de;

  --base: var(--jb-bg);
  --bg: var(--jb-bg);
  --card: var(--jb-surface);
  --card2: #16324e;
  --card-hover: #1b3a57;
  --surface: var(--jb-surface);
  --surface2: #16324e;
  --border: var(--jb-line);
  --border2: #2e4d6b;
  --scrollbar-thumb: #2e4d6b;
  --text: var(--jb-text);
  --text2: #b7c5d3;
  --text3: var(--jb-muted);
  --accent: var(--jb-teal);
  --accent2: var(--jb-teal-hover);
  --accent-bg: rgba(55, 179, 166, 0.14);
  --accent-text: var(--jb-teal-text);
  --on-accent: var(--jb-on-fill);
  --green: var(--jb-teal-text);
  --green-bg: rgba(55, 179, 166, 0.14);
  --red: var(--jb-error);
  --amber: #e0a54a;
  --shadow: rgba(0, 0, 0, 0.35);
  --input-bg: var(--jb-input-bg);
}
/* Artwork drawn in navy: one-colour icons and wordmarks go off-white; two-tone
   marks swap to their -dark.svg (design.js); the face and dividers follow the theme. */
.jb-face-body { stroke: var(--jb-ink); }
:root[data-theme="dark"] .jb-sidebar .jb-icon img,
:root[data-theme="dark"] .jb-toggle-show img,
:root[data-theme="dark"] .jb-chat-item img,
:root[data-theme="dark"] .jb-brand img:not([data-src-dark]),
:root[data-theme="dark"] .jb-login-logo img:not([data-src-dark]) { filter: brightness(0) invert(0.95); }
:root[data-theme="dark"] .jb-divider,
:root[data-theme="dark"] .jb-login-divider { opacity: 0.3; }
:root[data-theme="dark"] .msg-row.in:not(.will-msg) .msg-avatar,
:root[data-theme="dark"] .typing-row::before { background-image: url("/js/design/jb-avatar-dark.svg"); }

html, body { font-family: var(--jb-font); }
body { flex-direction: row; background: var(--jb-bg); color: var(--jb-ink); }
button, input, textarea, select { font-family: inherit; }
html.jb-enter [data-enter] { opacity: 0; }
html.jb-no-transition * { transition: none !important; }

/* Menus and modals: brand chips instead of the maroon ones the markup inlines. */
.waffle-icon { background: rgba(55, 179, 166, 0.14) !important; color: var(--jb-ink) !important; }
.send-btn, .jb-login-button, .sys-connect-btn { box-shadow: none; }

/* ================= Sidebar ================= */
.topbar { display: none; }

.jb-sidebar {
  flex: none;
  width: var(--jb-sidebar-w);
  height: 100%;
  overflow: hidden;
  transition: width .25s ease, visibility 0s;
}
.jb-sidebar-inner {
  display: flex;
  flex-direction: column;
  width: var(--jb-sidebar-w);
  height: 100%;
  padding: 40px 32px 40px;
}
.jb-sidebar img { display: block; }
.jb-brand { display: flex; align-items: center; gap: 10.5px; height: 32.675px; }

/* Facility · agent, and the signed-in row, under the logo. */
.jb-sidebar .top-info { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; min-width: 0; }
.jb-sidebar .top-name {
  font-size: 12px; font-weight: 600; color: var(--jb-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.jb-sidebar .top-user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0; }
.jb-sidebar .user-name { font-size: 11px; font-weight: 500; color: var(--jb-muted); }
.jb-sidebar .top-status { font-size: 11px; color: var(--jb-teal-text); }
.jb-sidebar .top-status.typing { color: var(--jb-teal-text); }
.jb-sidebar .typing-dots span { background: var(--jb-teal); }
.jb-sidebar .top-version { font-size: 11px; color: var(--jb-muted); }
.jb-sidebar .jb-channel:not([hidden]) { margin: 0; padding: 1px 6px; font-size: 10px; }

.jb-new-chat {
  display: flex; align-items: center; justify-content: center;
  width: 175px; height: 30px; margin-top: 16px; padding: 8px 16px;
  border: 0; border-radius: 4px; background: var(--jb-fill); color: var(--jb-on-fill);
  font: 400 14px/1 var(--jb-font); cursor: pointer;
  transition: background-color .15s ease;
}
.jb-new-chat:hover { background: var(--jb-fill-hover); }

.jb-side-row {
  display: flex; align-items: center; gap: 8px;
  width: 175px; height: 32px; padding: 0 8px;
  border: 0; border-radius: 6px; background: none; color: var(--jb-ink);
  font: 400 14px/1 var(--jb-font); text-align: left; white-space: nowrap; cursor: pointer;
  transition: background-color .15s ease;
}
.jb-side-row:hover { background: var(--jb-hover); }
.jb-side-row[hidden] { display: none; }
.jb-icon { display: grid; place-items: center; flex: none; width: 16px; height: 18px; }
.jb-toggle-hide { margin-top: 8px; }
.jb-divider { flex: none; margin: 8px 0; }
.jb-new-chat:focus-visible, .jb-side-row:focus-visible, .jb-chat-item:focus-visible,
.jb-chip:focus-visible, .jb-tool-card:focus-visible, .jb-toggle-show:focus-visible {
  outline: 2px solid var(--jb-teal); outline-offset: 2px;
}

.jb-history {
  flex: 1; min-height: 0;
  margin: 0 -4px; padding: 0 4px;
  overflow-y: auto; scrollbar-width: thin;
}
.jb-history ul { margin: 0; padding: 0; list-style: none; }
.jb-chat-item {
  display: flex; align-items: center; gap: 7px;
  width: 175px; height: 30px; padding: 0 8px;
  border: 0; border-radius: 6px; background: none; color: var(--jb-strong);
  font: 400 14px/1 var(--jb-font); text-align: left; cursor: pointer;
  transition: background-color .15s ease;
}
.jb-chat-item:hover { background: var(--jb-hover); }
.jb-chat-item.is-active { font-weight: 600; }
.jb-chat-item img { flex: none; }
.jb-chat-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jb-history-empty { padding: 6px 8px; font-size: 12px; line-height: 1.4; color: var(--jb-muted); }

.jb-side-bottom { flex: none; margin-top: 16px; }
.jb-side-bottom .jb-divider:first-child { margin-top: 0; }
.jb-account-menu:not([hidden]) {
  display: flex; flex-direction: column; gap: 6px;
  width: 175px; margin: 2px 0 6px; padding: 8px;
  border-radius: 6px; background: var(--jb-glass);
}
.jb-account-email { font-size: 12px; color: var(--jb-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jb-account-signout {
  align-self: flex-start; padding: 5px 10px;
  border: 1px solid var(--jb-ink); border-radius: 4px; background: transparent;
  color: var(--jb-ink); font: 500 12px/1 var(--jb-font); cursor: pointer;
}
.jb-account-signout:hover { background: var(--jb-fill); border-color: var(--jb-fill); color: var(--jb-on-fill); }

/* ================= Main panel ================= */
.main-split {
  position: relative;
  flex: 1; min-width: 0;
  display: block;
  margin: var(--jb-gutter) var(--jb-gutter) var(--jb-gutter) 0;
  padding: 0; gap: 0;
  background: var(--jb-surface);
  border-radius: 40px;
  overflow: hidden;
  container: jbpanel / inline-size;
  transition: margin .25s ease;
}

.jb-toggle-show {
  position: absolute; z-index: 4; top: 24px; left: 24px;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 6px; background: none; cursor: pointer;
  opacity: 0; visibility: hidden;
  transition: background-color .15s ease, opacity .2s ease, visibility 0s linear .2s;
}
.jb-toggle-show:hover { background: var(--jb-hover); }

/* The chat column: centred at 523px, moves to a 353px column on the left when the
   output opens beside it. */
.panel-chat {
  position: absolute; top: 0; bottom: 0;
  left: calc((100% - min(523px, 100% - 48px)) / 2);
  width: min(523px, calc(100% - 48px));
  flex: none;
  background: transparent; border-radius: 0; box-shadow: none;
  overflow: visible;
}
.panel-chat-main {
  height: 100%;
  display: flex; flex-direction: column;
  padding-bottom: 25px;
  overflow-x: hidden; overflow-y: auto;
  scrollbar-width: none;
}
.panel-chat-main > .panel-header { display: none; }

/* Empty state */
.jb-hero {
  flex: 1 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 74px 0 48px;
}
.jb-hero-title { margin: 19px 0 0; font-weight: 600; font-size: 32px; line-height: 33px; color: var(--jb-teal); text-align: center; }
.jb-hero-title strong { font-weight: 600; color: var(--jb-ink); }
.jb-hero-line { display: block; }
.jb-hero-mark-wrap { position: relative; }
.jb-hero-glow {
  position: absolute; inset: -56px; border-radius: 50%;
  background: radial-gradient(circle, rgba(55, 179, 166, 0.22) 0%, rgba(55, 179, 166, 0.08) 38%, transparent 68%);
  filter: blur(14px); opacity: 0; pointer-events: none;
}
/* A small 3D rig: the navy mark is a flat card and the eye floats in front of it,
   so turning the head gives real perspective. */
.jb-hero-mark { position: relative; width: 109px; height: 112.879px; perspective: 360px; }
.jb-face-rig { position: absolute; inset: 0; transform-style: preserve-3d; transform-origin: 50% 100%; }
.jb-face-rig svg { position: absolute; top: 0; left: 0; overflow: visible; }
.jb-face-eye-layer { transform: translateZ(16px) scale(0.9556); transform-origin: 54.5px 56.44px; }
.jb-face-eye-layer * { transform-box: fill-box; }
.jb-face-eye { transform-origin: 50% 50%; }
.jb-face-happy { transform-origin: 50% 100%; opacity: 0; }

.jb-chips { flex: none; display: flex; flex-wrap: wrap; gap: 8px; }
.jb-chip {
  height: 30px; padding: 8px 16px;
  border: 0; border-radius: 1000px; background: var(--jb-bg); color: var(--jb-text);
  font: 400 14px/1 var(--jb-font); white-space: nowrap; cursor: pointer;
  transition: background-color .15s ease;
}
.jb-chip:hover { background: var(--jb-chip-hover); }

.jb-tools { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.jb-tool-card {
  display: flex; gap: 8px; min-height: 95px; padding: 13px 12px 12px;
  border: 0; border-radius: 4px; background: var(--jb-line);
  font: 400 14px/1.23 var(--jb-font); color: var(--jb-ink); text-align: left; cursor: pointer;
  transition: background-color .15s ease;
}
.jb-tool-card:hover { background: var(--jb-card-hover); }
.jb-tool-card .jb-icon { place-items: start center; height: 14.4px; }
.jb-tool-card strong { display: block; font-weight: 700; line-height: 1; color: var(--jb-ink); }
.jb-tool-desc { display: block; max-width: 201px; margin-top: 5px; color: var(--jb-muted); }

.jb-disclaimer { display: none; flex: none; margin: 3px 0 0; font: 400 10px/12px "Lato", var(--jb-font); color: var(--jb-muted); text-align: center; }

/* ================= Composer ================= */
/* The box is a wrapping flex row: the textarea takes the first line full-width,
   the model toggle + Tools and attach / mic / send share the line under it. In
   flow rather than absolutely placed, so the Tools menu can anchor to the box. */
.input-bar {
  position: relative; flex: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-top: 8px; padding: 0 10px 3px 8px;
  border: 1px solid var(--jb-line); border-radius: 10px;
  background: var(--jb-surface);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-bar:focus-within {
  border-color: rgba(55, 179, 166, 0.5);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(55, 179, 166, 0.12);
}
.input-bar .msg-input {
  order: 0; flex: 0 0 calc(100% + 18px);
  margin: 0 -10px 0 -8px;
  min-height: 89px; max-height: none;
  padding: 8px 15px 4px;
  border: 0; border-radius: 10px;
  background: transparent;
  font: 400 14px/1.3 var(--jb-font); color: var(--jb-ink);
}
.input-bar .msg-input:focus { background: transparent; }
.input-bar .msg-input::placeholder { font-family: "Lato", var(--jb-font); font-style: italic; color: var(--jb-placeholder); opacity: 1; }
.input-bar #attachBtn, .input-bar #micBtn, .input-bar .send-btn {
  position: static; flex: none;
  width: 26px; height: 26px; border-radius: 6px;
  background: transparent; color: var(--jb-ink); box-shadow: none;
}
.input-bar #attachBtn { order: 2; }
.input-bar #micBtn { order: 3; }
.input-bar .send-btn { order: 4; }
.input-bar #attachBtn:hover, .input-bar #micBtn:hover, .input-bar .send-btn:hover { background: var(--jb-hover); color: var(--jb-ink); transform: none; box-shadow: none; }
.input-bar .input-icon-btn svg, .input-bar .send-btn svg { width: 16px; height: 16px; }
.input-bar #micBtn.listening { color: var(--jb-teal-text); background: rgba(55, 179, 166, 0.12); }
/* The design's paper plane; the stop square stays the portal's own. */
.input-bar .send-btn .send-icon { display: none; }
.input-bar .send-btn:not(.stopping) { background: url("/js/design/icon-send.svg") center / 16px 16px no-repeat; }
.input-bar .send-btn:not(.stopping):hover { background-color: var(--jb-hover); }
.input-bar .send-btn.stopping { color: var(--jb-ink); }

/* Model toggle + Tools, bottom-left inside the box. */
.jb-composer-tools { order: 1; margin-right: auto; display: flex; align-items: center; gap: 4px; }
.jb-composer-tools .tools-menu { position: static; }
.jb-composer-tools .model-toggle-group { margin: 0; padding: 1px; border-radius: 7px; background: var(--jb-hover); }
.jb-composer-tools .model-btn { width: 26px; height: 22px; border-radius: 6px; color: var(--jb-muted); }
.jb-composer-tools .model-btn svg { width: 14px; height: 14px; }
.jb-composer-tools .model-btn.active { background: var(--jb-fill); color: var(--jb-on-fill); box-shadow: none; }
.jb-composer-tools .model-btn .model-tooltip { bottom: auto; top: -28px; }
.jb-composer-tools .icon-btn { width: 26px; height: 26px; border-radius: 6px; color: var(--jb-ink); }
.jb-composer-tools .icon-btn svg { width: 16px; height: 16px; }
.jb-composer-tools .icon-btn:hover { background: var(--jb-hover); color: var(--jb-ink); }
.jb-composer-tools .waffle-dropdown { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; width: 280px; border: 1px solid var(--jb-line); border-radius: 10px; box-shadow: 0 10px 36px rgba(16, 42, 67, 0.16); }
.slash-popup { bottom: calc(100% + 6px); left: 0; right: 0; border: 1px solid var(--jb-line); border-radius: 10px; }
.slash-cmd { color: var(--jb-teal-text); }
.image-preview { margin: 8px 0 0; }

/* ================= Conversation mode ================= */
.main-split[data-mode="empty"] .chat { display: none; }
.main-split[data-mode="chat"] .panel-chat-main { padding-bottom: 9px; overflow-y: hidden; }
.main-split[data-mode="chat"] .jb-hero,
.main-split[data-mode="chat"] .jb-chips,
.main-split[data-mode="chat"] .jb-tools { display: none; }
.main-split[data-mode="chat"] .input-bar { margin-top: 0; }
.main-split[data-mode="chat"] .input-bar .msg-input { min-height: 28px; }
.main-split[data-mode="chat"] .jb-disclaimer { display: block; }

.chat {
  flex: 1; min-height: 0;
  margin: 0 -8px; padding: 24px 8px 16px;
  gap: 0;
  scrollbar-width: thin;
}
.chat > :first-child { margin-top: auto; }

/* User: a soft grey bubble on the right. */
.msg-row { max-width: 88%; }
.msg-row.out .bubble {
  padding: 8px 16px;
  border-radius: 18px 18px 4px 18px;   /* round, but for the corner nearest the sender */
  background: var(--jb-bg);
  color: var(--jb-text); font-weight: 400; font-size: 14px; line-height: 1.3;
  letter-spacing: 0;
}
/* JB: the logo mark as the avatar, no name line, plain text beside it. */
.msg-row.in { max-width: 100%; gap: 16px; padding-left: 8px; }
.msg-row.in:not(.will-msg) .msg-avatar {
  align-self: flex-start;
  width: 19px; height: 20px; margin-top: 3px;
  border-radius: 0;
  background: url("/js/design/jb-avatar.svg") center / contain no-repeat;
  color: transparent; font-size: 0;
}
.msg-row.in:not(.will-msg) .agent-name { display: none; }
.msg-row.in .bubble { padding: 0; color: var(--jb-text); font-weight: 400; font-size: 14px; line-height: 1.45; letter-spacing: 0; }
/* The logo lines up with the first line of the reply, so nothing may push that
   line down: a leading button or report bar drops its top margin (formatMsg
   also trims leading line breaks). */
.msg-row.in .bubble > :first-child { margin-top: 0 !important; }
.ts { margin: 4px 0 14px; font-size: 10px; color: var(--jb-muted); }
.ts.left { padding-left: 43px !important; }

/* "Thinking…": the mini face breathes while a light sweeps the status text; the
   portal's elapsed-time counter stays beside it. */
.typing-row { gap: 16px; margin: 4px 0 16px 8px; font-size: 14px; }
.typing-row::before {
  content: ""; flex: none; width: 19px; height: 20px;
  background: url("/js/design/jb-avatar.svg") center / contain no-repeat;
  animation: jb-breathe 1.4s ease-in-out infinite alternate;
}
.typing-row .typing-bar { display: none; }
.typing-row::after {
  content: "Thinking…"; order: 1;
  color: transparent;
  background: linear-gradient(90deg, var(--jb-muted) 0 38%, var(--jb-teal) 50%, var(--jb-muted) 62% 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  animation: jb-shimmer 1.8s linear infinite;
}
.typing-row .typing-timer { order: 2; margin-left: 0 !important; color: var(--jb-muted) !important; }
@keyframes jb-shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes jb-breathe { from { transform: scale(1); opacity: 1; } to { transform: scale(1.08); opacity: .7; } }

/* Report / download controls under a message: the design's report card. */
button.jb-dl, button.jb-open {
  height: 30px; margin: 8px 6px 0 0; padding: 0 12px;
  border: 1px solid var(--jb-line); border-radius: 4px; background: var(--jb-card);
  color: var(--jb-text); font-size: 12px; font-weight: 500;
}
button.jb-dl:hover, button.jb-open:hover { background: var(--jb-btn-hover); }
button.jb-dl:focus-visible, button.jb-open:focus-visible { outline-color: var(--jb-teal); }

/* History overlay inside the column */
.chat-history-overlay { background: var(--jb-surface); border-radius: 0; }
.chat-history-overlay .overlay-session:hover { background: var(--jb-hover); }
.chat-history-overlay .overlay-session.active { background: var(--jb-hover); }

/* ================= Output: slides over the right of the panel ================= */
.panel-output {
  position: absolute !important;
  z-index: 1;
  top: 0; right: 0; bottom: 0; left: 385px;
  flex: none; height: auto;
  background: var(--jb-surface); border-radius: 40px; box-shadow: none;
}
.panel-output.empty-output { display: none; }
/* hairline between the chat and the output */
.panel-output::before {
  content: ""; position: absolute; top: 32px; bottom: 32px; left: 0; width: 1px; background: var(--jb-line);
}
.panel-output > .panel-header { height: auto; padding: 24px 24px 8px 36px; border-bottom: 0; }
.panel-output .jb-dash-close { width: 32px; height: 32px; justify-content: center; border-radius: 6px; color: var(--jb-ink); }
.panel-output .jb-dash-close svg { width: 16px; height: 16px; }
.panel-output .jb-dash-close:hover { background: var(--jb-hover); color: var(--jb-ink); }
.panel-output .output-scroll { margin: 0 24px 24px 36px; border: 1px solid var(--jb-line); border-radius: 16px; overflow: hidden; }
.panel-output.report-flows .output-scroll { overflow-y: auto; }
.output-frame iframe { border-radius: 0; }
.output-chips { border-radius: 0; }
.visual-actions .va-btn { background: var(--jb-glass-strong) !important; color: var(--jb-ink) !important; border: 1px solid var(--jb-line); }
.visual-actions .va-btn:hover { background: var(--jb-surface) !important; }

.main-split[data-dash="open"] .panel-chat { left: 16px; width: 353px; }

/* Not enough room beside the chat: the output covers the whole panel instead. */
@container jbpanel (max-width: 1000px) {
  .main-split[data-dash="open"] .panel-chat { left: calc((100% - min(523px, 100% - 48px)) / 2); width: min(523px, calc(100% - 48px)); }
  .panel-output { left: 0; z-index: 3; }
  .panel-output::before { display: none; }
  .panel-output > .panel-header { padding: 20px 20px 8px 24px; }
  /* clear the show-sidebar button, which sits over this corner */
  html[data-sidebar="hidden"] .panel-output > .panel-header { padding-left: 64px; }
  .panel-output .output-scroll { margin: 0 16px 16px; }
}

/* ================= Hidden sidebar ================= */
html[data-sidebar="hidden"] .jb-sidebar {
  width: 0; visibility: hidden;
  transition: width .25s ease, visibility 0s linear .25s;
}
html[data-sidebar="hidden"] .main-split { margin-left: var(--jb-gutter); }
html[data-sidebar="hidden"] .jb-toggle-show {
  opacity: 1; visibility: visible;
  transition: background-color .15s ease, opacity .2s ease .12s, visibility 0s;
}
.jb-scrim { display: none; }

/* ================= Narrow screens: the sidebar becomes a drawer ================= */
@media (max-width: 767px) {
  :root { --jb-gutter: 12px; }
  .jb-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    background: var(--jb-bg); box-shadow: 0 10px 36px rgba(0, 0, 0, 0.16);
  }
  .main-split { margin-left: var(--jb-gutter); padding: 0; border-radius: 28px; flex-direction: row; }
  .panel-chat { left: 16px; width: calc(100% - 32px); border-radius: 0; }
  .main-split[data-dash="open"] .panel-chat { left: 16px; width: calc(100% - 32px); }
  .panel-chat-main { padding-bottom: 16px; }
  .panel-output { height: auto; border-radius: 28px; }
  .jb-toggle-show { top: 16px; left: 16px; }
  .jb-scrim {
    display: block; position: fixed; inset: 0; z-index: 59;
    background: rgba(16, 42, 67, 0.25); transition: opacity .25s ease;
  }
  html[data-sidebar="hidden"] .jb-scrim { opacity: 0; pointer-events: none; }
  html[data-sidebar="hidden"] .jb-sidebar { box-shadow: none; }
  .jb-hero { padding-top: 64px; }
  .jb-hero-title { font-size: 26px; line-height: 29px; }
  .jb-tools { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .jb-sidebar, .main-split, .jb-toggle-show, .jb-scrim { transition: none !important; }
  .typing-row::before, .typing-row::after { animation: none; }
  .typing-row::after { color: var(--jb-muted); }
}

/* ================= Sign-in ================= */
#jbLogin:not([hidden]) {
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: hidden;
  background: var(--jb-bg); box-shadow: none;
  font-family: var(--jb-font);
}
#jbLogin img { display: block; }
.jb-login-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.jb-login-card {
  position: relative; z-index: 1;
  width: min(370px, 100%); min-height: 338px;
  margin: 0; padding: 32px 35px 28px;
  border: 0; border-radius: 10px;
  background: var(--jb-surface); box-shadow: 0 10px 36px rgba(0, 0, 0, 0.16);
}
.jb-login-logo { display: flex; align-items: flex-end; gap: 6.8px; height: 21.23px; }
.jb-login-title {
  margin: 15.77px 0 0;
  font-family: var(--jb-font); font-weight: 600; font-size: 36px; line-height: 24px;
  color: var(--jb-login-title); white-space: nowrap;
}
.jb-login-form { margin: 35px 0 0; }
.jb-login-field:not([hidden]) { display: block; margin-top: 14px; }
.jb-login-field:first-child { margin-top: 0; }
.jb-login-label { display: block; font-weight: 600; font-size: 14px; line-height: 10px; color: var(--jb-login-label); }
.jb-login-input {
  display: block; width: 100%; height: 40px; margin-top: 4px; padding: 8px;
  border: 1px solid var(--jb-input-line); border-radius: 4px; background: var(--jb-input-bg);
  font: 400 14px/normal var(--jb-font); color: var(--jb-ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.jb-login-input:hover { border-color: var(--jb-input-line-hover); }
.jb-login-input:focus { border-color: var(--jb-teal); background: var(--jb-input-bg); box-shadow: 0 0 0 3px rgba(55, 179, 166, 0.15); }
.jb-login-code { letter-spacing: .2em; }
/* The portal's status line (anti-enumeration copy, errors) sits in the gap under
   the input, where the prototype put its validation message. */
.jb-login-message {
  min-height: 0; margin: 6px 0 0; padding: 0;
  border: 0; border-radius: 0; background: none;
  font-size: 12px; line-height: 15px; color: var(--jb-muted);
}
.jb-login-button {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 40px; min-height: 0; margin-top: 14px; padding: 8px 16px;
  border: 1px solid var(--jb-fill); border-radius: 4px;
  background: var(--jb-fill); color: var(--jb-on-fill);
  font: 500 14px/24px var(--jb-font);
  transition: background-color .15s ease, border-color .15s ease, transform .08s ease;
}
.jb-login-button:hover:not(:disabled) { background: var(--jb-fill-hover); border-color: var(--jb-fill-hover); box-shadow: none; }
.jb-login-button:active:not(:disabled) { transform: translateY(1px); }
.jb-login-button:focus-visible { outline: 2px solid var(--jb-teal); outline-offset: 2px; }
.jb-login-divider { margin-top: 19px; height: 1px; max-width: 100%; }
.jb-login-device-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 20px; }
.jb-login-device-note img { flex: none; }
.jb-login-device-note span { font-weight: 500; font-size: 14px; line-height: 14px; color: var(--jb-muted); }

@media (max-width: 480px) {
  #jbLogin:not([hidden]) { align-items: center; padding: 16px; }
  .jb-login-card { padding-left: 24px; padding-right: 24px; }
  .jb-login-title { font-size: 32px; }
  .jb-login-input { font-size: 16px; }
  .jb-login-device-note span { width: auto; }
}
