/* Shared styles for every page, in Preditic's brand.
 *
 * In a file rather than a <style> block so the Content-Security-Policy can
 * say style-src 'self' and mean it. Inline styles would need
 * 'unsafe-inline', which also permits anything an attacker injects.
 *
 * The brand is preditic.com's: Montserrat for headings, Nunito for text, the
 * blue #0098DB and the navy #182B49 on a white and #F5F7FA ground. The fonts are
 * served from /static/fonts (SIL Open Font License, texts alongside) because
 * the CSP allows fonts from this origin only.
 *
 * Mirrored by deploy/keycloak-theme/qwen-chat/login/resources/css/qwen-chat.css
 * so the Keycloak login page matches. Change one, change the other.
 */

/* --- brand fonts ---------------------------------------------------------- */

@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("/static/fonts/nunito-latin-ext.woff2") format("woff2");
  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: "Nunito"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("/static/fonts/nunito-latin.woff2") format("woff2");
  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;
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("/static/fonts/montserrat-latin-ext.woff2") format("woff2");
  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: "Montserrat"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url("/static/fonts/montserrat-latin.woff2") format("woff2");
  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;
}

/* --- tokens ----------------------------------------------------------------
 * Two blues on purpose. --brand is Preditic's #0098DB, used where colour marks
 * something: the active tab, focus, progress, indicators. --accent is the same
 * hue a step deeper, used wherever text sits on it or it is text: white on
 * #0098DB is 3.2:1 and fails WCAG AA, white on #007BB8 is 4.6:1 and passes.
 * Buttons turn navy on hover, as they do on preditic.com. */

:root {
  color-scheme: light dark;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #dfe5ec;
  --line-strong: #c8d2dd;
  --text: #091326;
  --heading: #182b49;
  --muted: #5b6b80;
  --brand: #0098db;
  --accent: #007bb8;
  --accent-hover: #182b49;
  --accent-soft: #e6f4fb;
  --on-accent: #ffffff;
  --navy: #182b49;
  --user: #eef2f6;
  --err: #c62828;
  --ok: #2e7d32;
  /* Warnings were the accent while the accent was orange. Blue says "this is
     where you are", not "check this", so they have a colour of their own. */
  --warn: #b25e09;
  --font-body: "Nunito", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Montserrat", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgb(9 19 38 / 6%);
  --shadow: 0 1px 2px rgb(9 19 38 / 5%), 0 8px 24px rgb(24 43 73 / 7%);
  /* A surface raised above --user: the selected segment of a switch. */
  --raised: #ffffff;
  --shadow-pop: 0 2px 6px rgb(9 19 38 / 8%), 0 16px 40px rgb(9 19 38 / 16%);
}
/* Dark, in two places on purpose. The reader picks Light, Dark or System in
 * the account menu (shell.js); theme.js puts the choice on <html> as
 * data-theme before anything paints. With no attribute (System) the OS
 * decides; an explicit choice beats the OS either way. One block cannot sit
 * under both a media query and a plain selector, so the dark tokens are
 * written twice: change one, change the other. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1526;
    --panel: #111f36;
    --line: #22324b;
    --line-strong: #30435f;
    --text: #e6edf5;
    --heading: #f3f7fb;
    --muted: #97a6bb;
    --brand: #38b6ee;
    --accent: #38b6ee;
    --accent-hover: #7fd0f5;
    --accent-soft: rgb(56 182 238 / 12%);
    --on-accent: #06121f;
    --navy: #214573;   /* lifted: the brand navy disappears on a navy ground */
    --user: #182a45;
    --err: #f07167;
    --ok: #5cc98b;
    --warn: #f2a93b;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow: 0 1px 2px rgb(0 0 0 / 25%), 0 10px 28px rgb(0 0 0 / 30%);
    --raised: #243d63;
    --shadow-pop: 0 2px 6px rgb(0 0 0 / 30%), 0 18px 44px rgb(0 0 0 / 45%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1526;
  --panel: #111f36;
  --line: #22324b;
  --line-strong: #30435f;
  --text: #e6edf5;
  --heading: #f3f7fb;
  --muted: #97a6bb;
  --brand: #38b6ee;
  --accent: #38b6ee;
  --accent-hover: #7fd0f5;
  --accent-soft: rgb(56 182 238 / 12%);
  --on-accent: #06121f;
  --navy: #214573;   /* lifted: the brand navy disappears on a navy ground */
  --user: #182a45;
  --err: #f07167;
  --ok: #5cc98b;
  --warn: #f2a93b;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 25%), 0 10px 28px rgb(0 0 0 / 30%);
  --raised: #243d63;
  --shadow-pop: 0 2px 6px rgb(0 0 0 / 30%), 0 18px 44px rgb(0 0 0 / 45%);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--font-heading); color: var(--heading); letter-spacing: -0.005em; }
::selection { background: var(--accent-soft); }

/* Sidebar beside the conversation; the composer stays under the conversation
   only, so it does not stretch across the whole window. */
.main { flex: 1; display: flex; min-height: 0; }
.column { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* --- the app bar -----------------------------------------------------------
 * White, like preditic.com's header: the logo, the product name, the tools as
 * a segmented control, then the app launcher and the account menu (shell.js).
 * One line, never wrapping: when the tools do not fit, the last ones step out
 * of the bar and stay reachable in the launcher. */

header {
  position: relative; z-index: 30;
  min-height: 64px; padding: 0 20px 0 24px;
  background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px; flex-wrap: nowrap;
}
.brand { display: inline-flex; align-items: center; padding: 6px 2px; border-radius: 6px; flex: none; }
/* The logo file has generous padding of its own, so it is set taller than it looks. */
.brand img { display: block; height: 46px; width: auto; margin: -6px 0; }
.brand:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.brand-divider { width: 1px; height: 26px; background: var(--line); flex: none; }
h1 { font-size: 16px; margin: 0; font-weight: 700; }
.product { margin: 0; font: 700 15px/1 var(--font-heading); color: var(--heading); white-space: nowrap; flex: none; }
.product-link { text-decoration: none; }
.product-link:hover { color: var(--accent); }
.product-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
/* Which tool you are in, named in the bar. The separator is decorative; the
   name is the page's real h1, unhidden rather than duplicated. */
.crumb-sep { color: var(--muted); flex: none; font-size: 15px; }
.module-name {
  display: flex; align-items: center; gap: 6px; flex: none;
  margin: 0; font: 700 15px/1 var(--font-heading); color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.module-name svg { flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Each logo in the theme it is drawn for. */
.logo-on-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block !important; }
}
:root[data-theme="dark"] .logo-on-light { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }

/* The tools: a segmented control, icon and name, the current one raised. */
.modules {
  display: flex; align-items: center; gap: 2px; min-width: 0; flex: 0 1 auto;
  margin-left: 6px; padding: 4px; border-radius: 12px; background: var(--user);
  overflow: hidden;
}
.modules:empty { display: none; }
.module-link {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 7px 13px 7px 11px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.module-link svg { flex: none; opacity: .85; }
.module-link:hover { color: var(--heading); background: color-mix(in srgb, var(--raised) 55%, transparent); }
.module-link[aria-current="page"] {
  color: var(--accent); background: var(--raised); box-shadow: var(--shadow-sm);
}
.module-link[aria-current="page"] svg { opacity: 1; }
.module-link:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Square icon buttons at the right of the bar. */
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 18px; line-height: 1;
}
.icon-btn:hover:not(:disabled) { background: var(--user); color: var(--heading); border: 0; }
.icon-btn[aria-expanded="true"],
.icon-btn[aria-expanded="true"]:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }

.menu { position: relative; flex: none; }
.avatar-btn {
  display: grid; place-items: center; padding: 2px; border: 0; border-radius: 50%;
  background: transparent;
}
.avatar-btn:hover:not(:disabled) { background: transparent; border: 0; }
.avatar-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #0098db 0%, #182b49 100%);
  color: #fff; font: 700 12.5px/1 var(--font-heading); letter-spacing: .03em;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%);
  transition: box-shadow .15s ease;
  user-select: none;
}
.avatar.anonymous { background: var(--user); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.avatar-btn:hover .avatar { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%), 0 0 0 3px var(--accent-soft); }
.avatar-btn[aria-expanded="true"] .avatar { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%), 0 0 0 3px var(--brand); }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; flex: none; }

/* A menu under its button. */
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 12px); z-index: 40;
  width: min(300px, calc(100vw - 20px)); padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-pop);
  transform-origin: top right;
}
.menu-panel[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .menu-panel { transition: opacity .14s ease, transform .14s ease; }
  @starting-style { .menu-panel { opacity: 0; transform: translateY(-4px) scale(.98); } }
}
.menu-head { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 8px 10px; }
.menu-label {
  display: block; font: 700 11px/1 var(--font-heading); letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.menu-count { font-size: 12px; color: var(--muted); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none;
}
.menu-item svg { color: var(--muted); flex: none; }
.menu-item:hover:not(:disabled) { background: var(--user); color: var(--heading); border: 0; }
.menu-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.menu-item[hidden] { display: none; }

/* The account menu: who, appearance, sign out. */
.account-panel .who {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.account-panel .who[hidden] { display: none; }
.who-text { display: grid; gap: 3px; min-width: 0; }
.who-text b {
  font: 700 14.5px/1.25 var(--font-heading); color: var(--heading);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-user, .who-session { font-size: 12.5px; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; }
.who-user:empty, .who-session:empty { display: none; }
.menu-section { padding: 8px 8px 12px; }
.menu-section .menu-label { margin-bottom: 10px; }
.menu-section:has(+ .menu-item:not([hidden])) { border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 4px; border-radius: 11px; background: var(--user);
}
.theme-option {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 9px 4px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.theme-option:hover:not(:disabled) { background: transparent; color: var(--heading); border: 0; }
.theme-option[aria-pressed="true"],
.theme-option[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--raised); color: var(--accent); box-shadow: var(--shadow-sm);
}
.theme-option:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* The launcher: every tool, as rows with an icon badge. */
.launcher-panel { width: min(340px, calc(100vw - 20px)); }
.launcher-grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 2px;
  max-height: min(60vh, 460px); overflow-y: auto;
}
.launch-tile {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px;
  color: inherit; text-decoration: none;
}
.launch-tile:hover { background: var(--user); }
.launch-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.launch-tile[aria-current="page"] { background: var(--accent-soft); }
.launch-mark {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}
.launch-tile[aria-current="page"] .launch-mark { background: var(--accent); color: var(--on-accent); }
.launch-text { display: grid; gap: 2px; min-width: 0; }
.launch-name { font: 700 14px/1.2 var(--font-heading); color: var(--heading); }
.launch-summary { font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.launcher-grid + .menu-item {
  margin-top: 6px; padding-top: 11px; border-top: 1px solid var(--line); border-radius: 0 0 9px 9px;
}

.status {
  font-size: 12.5px; line-height: 1; color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px; background: var(--user);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgb(46 125 50 / 15%); }
.dot.bad { background: var(--err); box-shadow: 0 0 0 3px rgb(198 40 40 / 15%); }
.spacer { flex: 1; }

/* --- controls -------------------------------------------------------------- */

input, select, textarea, button {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 11px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
button {
  cursor: pointer; background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); font-weight: 600; padding: 9px 18px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
/* Hover rules wrapped in :where() so they weigh no more than `button` itself:
   written plainly they outweighed every page's own row and tab styles, and
   hovering a project in the list painted it navy. */
button:where(:hover:not(:disabled)) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
/* The conversation line under the composer turns red as the context window
   fills: past it, the engine refuses the request. */
.meta.warn { color: var(--err); }
/* .ghost applies to links too, not only buttons: a header carries both, and
   they have to look the same or it reads as two unrelated rows of controls. */
button.ghost, a.ghost {
  background: var(--panel); color: var(--heading); border-color: var(--line-strong);
  font-weight: 600;
}
a.ghost {
  /* Links do not inherit the button rules above, so they need the shape. */
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 12px; text-decoration: none; font-size: 14px;
}
button.ghost:where(:hover:not(:disabled)), a.ghost:where(:hover) {
  background: var(--accent-soft); border-color: var(--brand); color: var(--accent);
}
#log { flex: 1; overflow-y: auto; padding: 28px 24px; }

/* --- the sidebar ------------------------------------------------------------ */

#sidebar {
  width: 272px; flex: none; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; background: var(--panel);
}
#sidebar h2 {
  margin: 0; padding: 20px 18px 10px;
  font: 700 11px/1 var(--font-heading); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
}
.sidebar-actions { padding: 0 12px 8px; }
.sidebar-actions button { width: 100%; }
#sessionList {
  list-style: none; margin: 0; padding: 0 10px 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
#sessionList li {
  /* Relative, so the delete button can be taken out of the layout entirely.
     As a grid column it stole ~22px from the meta line even while invisible,
     which is what pushed "6 turns · Qwen3-4B · just now" onto a second line. */
  position: relative;
  border-radius: var(--radius-sm); padding: 9px 11px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: background 0.12s ease;
}
#sessionList li:hover { background: var(--user); }
#sessionList li.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--brand); }
.s-preview {
  font-size: 13.5px; line-height: 1.35; font-weight: 600; color: var(--heading);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 20px;   /* keeps the title clear of the delete button */
}
/* Never wraps: a second line would make rows uneven and the list hard to
   scan. Anything too long is cut with an ellipsis instead. */
.s-meta {
  font-size: 11.5px; line-height: 1.4; color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.s-del {
  position: absolute; top: 7px; right: 6px;
  background: none; border: 0; padding: 2px 6px; border-radius: 6px;
  color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 0.12s ease;
}
#sessionList li:hover .s-del, .s-del:focus-visible { opacity: 1; }
.s-del:hover:not(:disabled) { color: var(--err); background: var(--panel); border: 0; }

/* Deleting a conversation is irreversible and they now persist indefinitely,
   so it asks. Inline rather than a browser confirm(): it keeps the row you are
   acting on in front of you. */
#sessionList li.confirming { background: var(--user); cursor: default; }
#sessionList li.confirming .s-del { display: none; }
.s-confirm { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.s-confirm span { flex: 1; font-size: 12px; color: var(--muted); }
.s-confirm button { padding: 3px 10px; font-size: 12px; border-radius: 6px; font-weight: 600; }
.s-confirm .no { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.s-confirm .yes { background: var(--err); border-color: var(--err); color: #fff; }
.s-empty { padding: 4px 11px; color: var(--muted); font-size: 13px; }
#sidebarToggle { display: none; }

@media (max-width: 760px) {
  /* Overlay rather than squeeze: 272px of a phone screen is most of it. */
  #sidebar {
    position: fixed; inset: 64px auto 0 0; z-index: 5; width: min(290px, 86vw);
    transform: translateX(-100%); transition: transform 0.18s ease;
    box-shadow: 0 0 24px rgb(9 19 38 / 20%);
  }
  #sidebar.open { transform: none; }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 4;
    /* Dimmed, not blurred: blurring a whole page costs a phone real frames,
       and the drawer reads as in front without it. */
    background: rgb(9 19 38 / 45%);
  }
  #sidebarToggle { display: inline-grid; }
  /* The launcher carries the tools on a phone; the bar keeps logo and menus. */
  /* The tool tabs go, but the module name stays: on a phone it is the only
     thing on screen that says which tool this is. "AI Tools ›" goes with the
     tabs -- the launcher and the logo are both still a tap away. */
  .modules, .product, .brand-divider, .crumb-sep { display: none; }
  .status #statusText { display: none; }
  .status { padding: 8px; }
  header { padding: 0 10px 0 14px; gap: 8px; }
}
@media (max-width: 420px) {
  /* The logo is three times as wide as it is tall: at full height it alone
     took 138px of a 320px bar, and the header spilled off the screen. */
  .brand img { height: 34px; margin: -4px 0; }
  header { gap: 6px; padding: 0 8px 0 10px; min-height: 58px; }
  .icon-btn { width: 34px; height: 34px; }
  #sidebar { inset: 58px auto 0 0; }
}
/* Only a drawer has a backdrop; beside the workspace it would swallow clicks. */
.sidebar-backdrop { display: none; }
@media (max-width: 760px) { .sidebar-backdrop:not([hidden]) { display: block; } }

@media (prefers-reduced-motion: reduce) {
  #sidebar, #sessionList li, .s-del, button, .module-link, .avatar { transition: none; }
}

/* --- the conversation -------------------------------------------------------- */

.wrap { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; flex-direction: column; gap: 6px; }
.who-label {
  font: 700 11px/1 var(--font-heading); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.09em;
}
.body { white-space: pre-wrap; word-wrap: break-word; line-height: 1.65; }
.msg:not(.user):not(.error) .body {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.msg.user { align-items: flex-end; }
.msg.user .body {
  background: var(--navy); color: #fff; padding: 11px 15px;
  border-radius: 14px 14px 4px 14px; max-width: 85%;
}
.msg.error .body {
  color: var(--err); font-family: var(--mono); font-size: 13px;
  background: color-mix(in srgb, var(--err) 7%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--err) 35%, transparent);
  border-radius: var(--radius); padding: 10px 14px;
}
.hint { color: var(--muted); font-size: 14px; }
.hint code, .body code { font: 13px var(--mono); background: var(--user); padding: 1px 5px; border-radius: 4px; }
footer { border-top: 1px solid var(--line); padding: 12px 24px 16px; background: var(--panel); }
/* The chat settings sit with the message they apply to, not in the header:
   there they wrapped the bar onto two lines as soon as the window narrowed. */
.composer-tools {
  max-width: 780px; margin: 0 auto 10px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.composer-tools select, .composer-tools input { padding: 6px 9px; font-size: 13px; }
.composer-tools label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.composer-tools input[type="checkbox"] { accent-color: var(--brand); width: 15px; height: 15px; }
.composer { max-width: 780px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
textarea { flex: 1; resize: none; min-height: 46px; max-height: 180px; line-height: 1.5; border-radius: var(--radius); }
.composer button { min-height: 46px; padding: 0 22px; border-radius: var(--radius); }
.meta {
  max-width: 780px; margin: 8px auto 0; font-size: 12px; line-height: 1.4; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.sources {
  margin-top: 2px; font-size: 13px; line-height: 1.5;
  display: flex; flex-direction: column; gap: 3px;
}
.sources a { color: var(--muted); text-decoration: none; }
.sources a:hover { color: var(--accent); text-decoration: underline; }
.sources .n { font-weight: 700; color: var(--accent); margin-right: 6px; font-variant-numeric: tabular-nums; }
.note { margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.cursor::after { content: "▍"; color: var(--brand); }

/* --- the sign-in gate --------------------------------------------------------- */

#gate {
  position: fixed; inset: 0; background: var(--bg);
  display: none; align-items: center; justify-content: center; padding: 24px;
  z-index: 50;
}
#gate.show { display: flex; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 40px 36px 34px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: var(--shadow); border-top: 4px solid var(--brand);
}
.card-logo { display: block; height: 72px; width: auto; margin: -14px auto 8px; }
.card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.card p { color: var(--muted); font-size: 14.5px; margin: 0 0 24px; }
.card button { width: 100%; padding: 12px; font-size: 15px; }
.card .why { margin: 18px 0 0; font: 12px/1.5 var(--mono); color: var(--err); }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 20px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
[hidden] { display: none !important; }

/* --- administration ----------------------------------------------------------
 * Operations is not a fourth tool. It is how whoever runs the deployment
 * watches the other three, so it is never in the tool bar and never a tile
 * the same size as Chat: a quieter row under its own heading, and absent
 * entirely for anyone without the role. */

/* No width of its own: .hub already sets one, and `margin: auto` on a flex
   column child turns off stretch and shrinks it to its content -- which is
   how this ended up a narrow box floating under the tiles. */
.hub-admin { margin-top: 6px; }
.hub-admin-title {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.admin-row + .admin-row { margin-top: 8px; }
.admin-row:hover { border-color: var(--brand); }
.admin-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.admin-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--user);
  color: var(--muted);
}
.admin-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-text b { font-size: 14px; color: var(--heading); }
.admin-text span { font-size: 12.5px; color: var(--muted); }
.admin-go { flex: none; color: var(--muted); }

/* The same idea in the launcher and the account menu: a rule, a heading, and
   the entry below everything people actually work in. */
.launcher-admin, .account-admin { border-top: 1px solid var(--line); margin-top: 6px; }
