/* ==========================================================================
   Training Optimized — design system + application styles
   Layers: tokens -> base -> primitives -> app shell -> chat -> pages
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  color-scheme: light;

  /* Colour */
  /* Cool, research-led neutrals drawn from the brand mark. */
  --c-canvas:        #F4F7FA;
  --c-surface:       #FFFFFF;
  --c-subtle:        #EAF0F5;   /* code blocks, inset panels */
  --c-sidebar:       #EDF2F6;
  --c-text:          #10202D;
  --c-text-2:        #4A5C69;
  --c-text-3:        #60727E;
  --c-border:        #D7E0E7;   /* decorative separators */
  --c-border-strong: #C4D0D9;   /* decorative chrome: popovers, dialogs */
  --c-border-ui:     #738591;   /* control boundaries — WCAG 1.4.11 (3:1) */
  --c-header:        rgba(244, 247, 250, 0.88);
  --c-canvas-clear:  rgba(244, 247, 250, 0);
  --c-ambient:       rgba(0, 126, 158, 0.12);
  --c-frame-border:  rgba(10, 48, 73, 0.22);

  /* Brand — sampled from the supplied Train Optimized logo */
  --c-accent:        #073B5C;   /* logo navy: primary actions, focus ring */
  --c-accent-hover:  #0A5078;
  --c-accent-soft:   #DCEBF3;
  --c-link:          #006889;   /* logo blue: links and inline accents */
  --c-link-hover:    #004E6A;
  --c-cyan:          #0A8A9F;   /* logo cyan */

  --c-error:         #B42318;
  --c-error-soft:    #FEF3F2;
  --c-user-surface:  #E6EDF2;

  --c-hover:         rgba(7, 59, 92, 0.06);
  --c-active:        rgba(7, 59, 92, 0.10);
  --c-overlay:       rgba(5, 20, 31, 0.48);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --fs-11: 0.6875rem;
  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;
  --fs-14: 0.875rem;
  --fs-15: 0.9375rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-21: 1.3125rem;
  --fs-26: 1.625rem;
  --fs-32: 2rem;

  --lh-tight: 1.25;
  --lh-snug:  1.45;
  --lh-body:  1.65;

  /* Spacing */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px;

  /* Radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-full: 999px;

  /* Elevation — deliberately restrained */
  --sh-1: 0 1px 2px rgba(7, 38, 57, 0.07);
  --sh-2: 0 16px 44px rgba(7, 38, 57, 0.12), 0 2px 8px rgba(7, 38, 57, 0.06);

  /* Motion */
  --dur-1: 110ms;
  --dur-2: 180ms;
  --dur-3: 260ms;
  --ease: cubic-bezier(0.2, 0.6, 0.3, 1);

  /* Layout */
  --sidebar-w: 284px;
  --measure: 820px;
  --page-container: 1040px;
  --header-h: 56px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-canvas:        #0B1118;
  --c-surface:       #111A24;
  --c-subtle:        #16222E;
  --c-sidebar:       #0E1720;
  --c-text:          #ECF4F9;
  --c-text-2:        #B2C1CC;
  --c-text-3:        #899BA8;
  --c-border:        #243441;
  --c-border-strong: #314554;
  --c-border-ui:     #647887;
  --c-header:        rgba(11, 17, 24, 0.88);
  --c-canvas-clear:  rgba(11, 17, 24, 0);
  --c-ambient:       rgba(44, 164, 195, 0.12);
  --c-frame-border:  rgba(119, 205, 228, 0.24);

  --c-accent:        #1D789E;
  --c-accent-hover:  #176E91;
  --c-accent-soft:   rgba(79, 177, 207, 0.16);
  --c-link:          #79CBE5;
  --c-link-hover:    #A7DFF0;
  --c-cyan:          #45B2C5;

  --c-error:         #F08B82;
  --c-error-soft:    rgba(240, 139, 130, 0.12);
  --c-user-surface:  #1B2935;

  --c-hover:         rgba(215, 236, 247, 0.07);
  --c-active:        rgba(215, 236, 247, 0.12);
  --c-overlay:       rgba(0, 0, 0, 0.66);

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.28);
  --sh-2: 0 18px 48px rgba(0, 0, 0, 0.34), 0 2px 10px rgba(0, 0, 0, 0.24);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-15);
  line-height: var(--lh-body);
  color: var(--c-text);
  background: var(--c-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); letter-spacing: -0.011em; }
p { margin: 0; }
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--c-link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--c-link-hover); }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--c-accent-soft); }

/* ---------- 3. Utilities ---------- */
.u-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.u-mt-2 { margin-top: var(--s-2); }
.u-mt-3 { margin-top: var(--s-3); }

.skip-link {
  position: absolute;
  left: var(--s-3); top: -100px;
  z-index: 200;
  padding: var(--s-2) var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
  font-size: var(--fs-14);
  font-weight: 500;
  text-decoration: none;
}
.skip-link:focus { top: var(--s-3); }

/* ---------- 4. Primitives ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.btn, .btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }

.btn--primary { background: var(--c-accent); }
.btn--primary,
.btn--primary:hover,
.btn--primary:focus-visible,
.btn--primary:active,
.btn--primary:visited { color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--c-accent-hover); }

.btn--outline { border-color: var(--c-border-ui); background: var(--c-surface); color: var(--c-text); }
.btn--outline:hover:not(:disabled) { background: var(--c-hover); border-color: var(--c-text-3); }

.btn--ghost { color: var(--c-text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--c-hover); color: var(--c-text); }

.btn--danger { background: var(--c-error); }
.btn--danger,
.btn--danger:hover,
.btn--danger:focus-visible,
.btn--danger:active,
.btn--danger:visited { color: #fff; }
.btn--danger:hover:not(:disabled) { background: #8C3131; }

.btn--sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-13); }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-2);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.icon-btn:hover { background: var(--c-hover); color: var(--c-text); }
.icon-btn:active { background: var(--c-active); }
.icon-btn svg { width: 18px; height: 18px; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 15px; height: 15px; }

/* Brand lockup */
.brand { display: inline-flex; align-items: center; gap: var(--s-3); text-decoration: none; color: var(--c-text); min-width: 0; }
.brand__mark { width: 28px; height: 28px; flex: none; border-radius: 7px; }
:root[data-theme="dark"] .brand__mark {
  padding: 3px;
  background: #F8FBFD;
}
.brand__name { font-size: var(--fs-15); font-weight: 600; letter-spacing: -0.012em; white-space: nowrap; }
.brand__name span { display: block; font-size: var(--fs-11); font-weight: 400; letter-spacing: 0.02em; color: var(--c-text-3); text-transform: uppercase; }

/* A three-state control keeps system preference available alongside explicit
   light and dark choices. It is inserted by the small theme bootstrap. */
.theme-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  min-height: 36px;
  padding-left: 30px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text-2);
  box-shadow: var(--sh-1);
  transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.theme-control::before {
  content: "";
  position: absolute;
  left: 11px;
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
  pointer-events: none;
}
.theme-control:hover { border-color: var(--c-border-ui); color: var(--c-text); }
.theme-control:active { transform: translateY(1px); }
.theme-control:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.theme-select {
  width: 96px;
  height: 34px;
  padding: 0 24px 0 2px;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
}
/* Native option popups do not consistently inherit the select's dark surface
   on Windows. Keep the operating-system menu explicitly light with dark text
   so every option remains legible in both site themes. */
.theme-select option {
  background: #FFFFFF;
  color: #10202D;
  font-weight: 600;
}

/* ---------- 5. App shell ---------- */
/* The shell owns the viewport. Without this the document itself can scroll —
   focus moves inside an overflow:hidden container still scroll it. */
body.app-shell, body.is-chat {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns var(--dur-3) var(--ease);
}
body[data-sidebar="collapsed"] .app { grid-template-columns: 0 minmax(0, 1fr); }

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--c-sidebar);
  border-right: 1px solid var(--c-border);
  overflow: hidden;
}
body[data-sidebar="collapsed"] .sidebar { border-right-color: transparent; }

.sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2) var(--s-4); min-height: var(--header-h); }
.sidebar__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--s-3) var(--s-4); scrollbar-width: thin; }
.sidebar__foot { border-top: 1px solid var(--c-border); padding: var(--s-3); }
.sidebar__section { padding: var(--s-3) var(--s-3) var(--s-2); }

/* Search */
.search { position: relative; }
.search__icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--c-text-3); pointer-events: none; }
.search__input {
  width: 100%;
  min-height: 38px;
  padding: var(--s-2) var(--s-2) var(--s-2) 34px;
  border: 1px solid var(--c-border-ui);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-size: var(--fs-14);
}
.search__input::placeholder { color: var(--c-text-3); }
.search__input:focus-visible { outline-offset: 0; border-color: var(--c-accent); }

/* History */
.history { display: flex; flex-direction: column; gap: var(--s-1); }
.history__group-label {
  padding: var(--s-4) var(--s-2) var(--s-1);
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--c-text-3);
}
.history__group:first-child .history__group-label { padding-top: var(--s-2); }

.thread { position: relative; display: flex; align-items: center; border-radius: var(--r-md); }
.thread:hover { background: var(--c-hover); }
.thread[aria-current="true"] { background: var(--c-surface); box-shadow: inset 0 0 0 1px var(--c-border); }
.thread[aria-current="true"] .thread__title { font-weight: 600; }

.thread__open {
  flex: 1;
  min-width: 0;
  display: block;
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.thread__title {
  display: block;
  font-size: var(--fs-14);
  line-height: 1.35;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread__snippet {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-12);
  color: var(--c-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread__more { flex: none; width: 30px; height: 30px; margin-right: var(--s-1); opacity: 0; }
.thread__more svg { width: 16px; height: 16px; }
.thread:hover .thread__more,
.thread:focus-within .thread__more,
.thread__more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .thread__more { opacity: 1; } }

.thread__rename {
  width: 100%;
  min-height: 34px;
  margin: 1px var(--s-1);
  padding: var(--s-1) var(--s-2);
  border: 1px solid var(--c-accent);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  font-size: var(--fs-14);
}

.history-empty { padding: var(--s-5) var(--s-3); font-size: var(--fs-13); line-height: var(--lh-snug); color: var(--c-text-3); }
.history-empty strong { display: block; color: var(--c-text-2); font-weight: 600; margin-bottom: var(--s-1); }

/* Popover menu */
.menu {
  position: fixed;
  z-index: 90;
  min-width: 168px;
  padding: var(--s-1);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  box-shadow: var(--sh-2);
}
.menu[hidden] { display: none; }
.menu__item {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; min-height: 36px;
  padding: 0 var(--s-2);
  border: 0; border-radius: var(--r-sm);
  background: none;
  font-size: var(--fs-14);
  text-align: left;
  cursor: pointer;
}
.menu__item:hover { background: var(--c-hover); }
.menu__item--danger { color: var(--c-error); }
.menu__item--danger:hover { background: var(--c-error-soft); }

/* Sidebar nav links */
.side-nav { display: flex; flex-wrap: wrap; gap: 2px var(--s-1); }
.side-nav a {
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-12);
  color: var(--c-text-3);
  text-decoration: none;
}
.side-nav a:hover { background: var(--c-hover); color: var(--c-text-2); text-decoration: underline; }
.side-note { margin-top: var(--s-2); padding: 0 var(--s-2); font-size: var(--fs-11); line-height: 1.5; color: var(--c-text-3); }

/* Backdrop for mobile drawer */
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: var(--c-overlay);
  border: 0; padding: 0;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.backdrop[hidden] { display: none; }
.backdrop.is-shown { opacity: 1; }

/* ---------- 6. Main column ---------- */
.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100%;
  background: var(--c-canvas);
}
.main { grid-template-rows: auto auto minmax(0, 1fr) auto; }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  min-height: var(--header-h);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.topbar.is-stuck { border-bottom-color: var(--c-border); background: var(--c-header); backdrop-filter: blur(12px); }
.topbar .theme-control { margin-left: auto; }
.topbar__title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--c-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__brand { display: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.chat-region { position: relative; display: grid; min-height: 0; }
.chat { min-height: 0; }

.status-banner {
  display: flex; align-items: center; gap: var(--s-2);
  margin: 0 var(--s-3) var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--c-border-ui);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-size: var(--fs-13);
  color: var(--c-text-2);
}
.status-banner[hidden] { display: none; }
.status-banner .icon { color: var(--c-error); }

/* ---------- 7. Chat scroll region ---------- */
.chat {
  position: relative;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}
.chat__inner {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s-4) var(--s-5) var(--s-8);
}

/* Empty state + signature "knowledge halo" */
.empty-state {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: min(58vh, 460px);
  padding: var(--s-8) 0 var(--s-6);
  isolation: isolate;
}
.empty-state[hidden] { display: none; }

.halo {
  position: absolute;
  z-index: -1;
  left: 50%; top: 42%;
  width: min(680px, 130%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.9;
  background:
    /* concentric knowledge rings */
    radial-gradient(circle, transparent 0 21%, var(--c-border) 21% calc(21% + 1px), transparent calc(21% + 1px) 33%,
      var(--c-border) 33% calc(33% + 1px), transparent calc(33% + 1px) 45%,
      var(--c-border) 45% calc(45% + 1px), transparent calc(45% + 1px) 100%),
    /* research grid */
    linear-gradient(var(--c-border) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--c-border) 1px, transparent 1px) 0 0 / 44px 44px;
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,0.55) 46%, transparent 70%);
          mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,0.55) 46%, transparent 70%);
}

.empty-state__title { font-size: clamp(var(--fs-21), 4.4vw, var(--fs-32)); letter-spacing: -0.02em; }
.empty-state__lede { max-width: 46ch; margin-top: var(--s-3); font-size: var(--fs-15); color: var(--c-text-2); }

.starters { margin-top: var(--s-6); }
.starters__label { font-size: var(--fs-12); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--c-text-3); }
.starters__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); margin: var(--s-3) 0 0; padding: 0; list-style: none; }
.starter {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 52px;
  padding: var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-subtle);
  font-size: var(--fs-14);
  line-height: 1.35;
  text-align: left;
  color: var(--c-text);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.starter:hover { border-color: var(--c-border-ui); background: var(--c-subtle); transform: translateY(-1px); }
.starter .icon { color: var(--c-text-3); }
.starter:hover .icon { color: var(--c-link); }

/* ---------- 8. Messages ---------- */
.messages { display: flex; flex-direction: column; gap: var(--s-6); padding-top: var(--s-2); }
.messages[hidden] { display: none; }

.msg { display: flex; flex-direction: column; gap: var(--s-2); }
.msg__role {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--c-text-3);
}
.msg__role .brand__mark { width: 18px; height: 18px; border-radius: 5px; }

.msg--user { align-items: flex-end; }
.msg--user .msg__body {
  max-width: min(88%, 62ch);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg) var(--r-lg) var(--r-xs) var(--r-lg);
  background: var(--c-user-surface);
}

.msg--assistant .msg__body { max-width: 72ch; }

.msg__body > * + * { margin-top: 0.85em; }
.msg__body h2 { font-size: var(--fs-18); margin-top: 1.2em; }
.msg__body h3 { font-size: var(--fs-16); margin-top: 1.15em; }
.msg__body ul, .msg__body ol { margin: 0.7em 0 0; padding-left: 1.35em; }
.msg__body li + li { margin-top: 0.35em; }
.msg__body code {
  padding: 0.12em 0.36em;
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
  background: var(--c-subtle);
  font-family: var(--font-mono);
  font-size: 0.88em;
}
.msg__body pre {
  margin: 0.9em 0 0;
  padding: var(--s-3) var(--s-4);
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-subtle);
}
.msg__body pre code { padding: 0; border: 0; background: none; font-size: var(--fs-13); line-height: 1.6; }
.msg__body blockquote {
  margin: 0.9em 0 0;
  padding-left: var(--s-4);
  border-left: 2px solid var(--c-border-strong);
  color: var(--c-text-2);
}
.msg__body hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--c-border); }
.msg__body a { word-break: break-word; }

.msg__tools { display: flex; align-items: center; gap: var(--s-1); min-height: 30px; }
.msg--assistant .msg__tools { opacity: 0; transition: opacity var(--dur-1) var(--ease); }
.msg--assistant:hover .msg__tools,
.msg--assistant:focus-within .msg__tools { opacity: 1; }
@media (hover: none) { .msg--assistant .msg__tools { opacity: 1; } }
.msg__tools .icon-btn { width: 30px; height: 30px; }
.msg__tools .icon-btn svg { width: 15px; height: 15px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--s-2);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-full);
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-3);
}

/* Loading */
.thinking { display: flex; align-items: center; gap: var(--s-3); color: var(--c-text-2); font-size: var(--fs-14); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c-text-3); animation: pulse 1.15s var(--ease) infinite; }
.dots i:nth-child(2) { animation-delay: 0.16s; }
.dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes pulse { 0%, 60%, 100% { opacity: 0.28; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

/* Error card */
.msg-error {
  display: flex; flex-direction: column; gap: var(--s-3);
  max-width: 72ch;
  padding: var(--s-4);
  border: 1px solid #F2C9C4;
  border-radius: var(--r-md);
  background: var(--c-error-soft);
}
.msg-error__head { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; font-size: var(--fs-14); color: var(--c-error); }
.msg-error__text { font-size: var(--fs-14); line-height: var(--lh-snug); color: var(--c-text); }
.msg-error__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* Jump to latest */
.jump {
  position: absolute;
  left: 50%; bottom: var(--s-4);
  transform: translateX(-50%);
  z-index: 20;
  border: 1px solid var(--c-border-ui);
  background: var(--c-surface);
  box-shadow: var(--sh-2);
  border-radius: var(--r-full);
  min-height: 34px;
  padding: 0 var(--s-3);
  font-size: var(--fs-13);
}
.jump[hidden] { display: none; }

/* ---------- 9. Composer ---------- */
.composer-wrap {
  padding: 0 var(--s-5) max(var(--s-4), env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, var(--c-canvas-clear), var(--c-canvas) 22%);
}
.composer {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
}
.composer__field {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border: 1px solid var(--c-border-ui);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--sh-1);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.composer__field:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }

.composer__input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 208px;
  padding: 9px 0;
  border: 0;
  background: none;
  font-size: var(--fs-15);
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}
.composer__input:focus { outline: none; }
.composer__input::placeholder { color: var(--c-text-3); }

.composer__send {
  flex: none;
  width: 40px; height: 40px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--c-accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.composer__send:hover:not(:disabled) { background: var(--c-accent-hover); }
.composer__send:disabled { background: var(--c-border-ui); color: var(--c-surface); cursor: not-allowed; }
.composer__send svg { width: 18px; height: 18px; }
.composer__send .icon--stop { display: none; }
.composer__send.is-busy .icon--send { display: none; }
.composer__send.is-busy .icon--stop { display: block; }

.composer__meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-top: var(--s-2);
  padding: 0 var(--s-1);
}
.composer__notice { font-size: var(--fs-12); line-height: 1.5; color: var(--c-text-3); max-width: 68ch; }
.composer__count { flex: none; font-size: var(--fs-12); color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.composer__count[hidden] { display: none; }
.composer__count.is-over { color: var(--c-error); font-weight: 600; }

/* ---------- 10. Dialog ---------- */
dialog.modal {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--sh-2);
  color: var(--c-text);
}
dialog.modal::backdrop { background: var(--c-overlay); }
.modal__body { padding: var(--s-5); }
.modal__title { font-size: var(--fs-18); }
.modal__text { margin-top: var(--s-2); font-size: var(--fs-14); color: var(--c-text-2); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--s-2); padding: 0 var(--s-5) var(--s-5); }

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: var(--s-6);
  transform: translateX(-50%);
  z-index: 120;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  background: var(--c-accent);
  color: #fff;
  font-size: var(--fs-13);
  box-shadow: var(--sh-2);
}
.toast[hidden] { display: none; }

/* ---------- 11. Content pages ---------- */
.page { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

.page-header {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-header);
  backdrop-filter: blur(14px);
}
.page-header__inner {
  display: flex; align-items: center; gap: var(--s-4);
  max-width: var(--page-container); margin: 0 auto;
  padding: var(--s-3) var(--s-5);
}
.page-nav { flex: 1; min-width: 0; }
.page-nav ul {
  display: flex; align-items: center; gap: var(--s-1);
  margin: 0; padding: 0; list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.page-nav ul::-webkit-scrollbar { display: none; }
.page-nav a {
  display: inline-flex; align-items: center;
  min-height: 36px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-14);
  color: var(--c-text-2);
  text-decoration: none;
  white-space: nowrap;
}
.page-nav a:hover { background: var(--c-hover); color: var(--c-text); }
.page-nav a[aria-current="page"] { color: var(--c-text); font-weight: 600; background: var(--c-hover); }

.page-main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: var(--s-12) var(--s-5) var(--s-16); }

.page-eyebrow { font-size: var(--fs-12); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-text-3); }
.page-title { margin-top: var(--s-3); font-size: clamp(var(--fs-26), 5vw, 2.35rem); line-height: 1.12; letter-spacing: -0.032em; text-wrap: balance; }
.page-lede { margin-top: var(--s-4); font-size: var(--fs-18); line-height: 1.55; color: var(--c-text-2); }
.page-meta { margin-top: var(--s-4); font-size: var(--fs-13); color: var(--c-text-3); }

.prose { margin-top: var(--s-10); }
.prose p, .prose li { text-wrap: pretty; }
.prose > * + * { margin-top: var(--s-4); }
.prose h2 { margin-top: var(--s-10); padding-top: var(--s-5); border-top: 1px solid var(--c-border); font-size: var(--fs-21); }
.prose h3 { margin-top: var(--s-6); font-size: var(--fs-16); }
.prose ul, .prose ol { margin-top: var(--s-3); padding-left: 1.35em; }
.prose li + li { margin-top: var(--s-2); }
.prose strong { font-weight: 600; }

.callout {
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-link);
  border-radius: var(--r-lg);
  background: var(--c-subtle);
  font-size: var(--fs-14);
  line-height: var(--lh-snug);
}
.callout__title { font-weight: 600; margin-bottom: var(--s-1); }

.page-cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-10); padding-top: var(--s-6); border-top: 1px solid var(--c-border); }

.page-footer { border-top: 1px solid var(--c-border); background: var(--c-sidebar); }
.page-footer__inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4);
  max-width: var(--page-container); margin: 0 auto;
  padding: var(--s-6) var(--s-5);
  font-size: var(--fs-13);
  color: var(--c-text-3);
}
.page-footer__brand { display: flex; flex-direction: column; gap: var(--s-2); }
.page-footer__brand img { width: 180px; height: auto; opacity: 0.92; }
:root[data-theme="dark"] .page-footer__brand img {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-lg);
  background: #F8FBFD;
}
.page-footer ul { display: flex; flex-wrap: wrap; gap: var(--s-4); margin: 0; padding: 0; list-style: none; }
.page-footer a { color: var(--c-text-2); text-decoration: none; }
.page-footer a:hover { color: var(--c-text); text-decoration: underline; }

/* ---------- 12. Responsive ---------- */
@media (max-width: 1200px) {
  :root { --sidebar-w: 272px; --measure: 780px; }
}

@media (max-width: 1024px) {
  :root { --measure: 720px; }
}

/* Tablet + mobile: sidebar becomes an off-canvas drawer */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  body[data-sidebar="collapsed"] .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(310px, 86vw);
    border-right: 1px solid var(--c-border);
    box-shadow: var(--sh-2);
    transform: translateX(-102%);
    transition: transform var(--dur-3) var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body[data-drawer="open"] .sidebar { transform: translateX(0); }
  body[data-drawer="open"] { overflow: hidden; }

  .topbar__brand { display: inline-flex; }
  /* Keep the h1 in the accessibility tree; the brand lockup carries it visually. */
  .topbar__title {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .topbar { border-bottom: 1px solid var(--c-border); }

  .chat__inner { padding: var(--s-4) var(--s-4) var(--s-6); }
  .composer-wrap { padding: 0 var(--s-4) max(var(--s-3), env(safe-area-inset-bottom)); }
  .icon-btn { width: 44px; height: 44px; }
  .thread__more { width: 40px; height: 40px; opacity: 1; }
  .thread__open { padding-top: 10px; padding-bottom: 10px; }
  .page-nav a { min-height: 44px; }
}

@media (max-width: 620px) {
  .starters__list { grid-template-columns: minmax(0, 1fr); }
  .empty-state { min-height: 0; padding-top: var(--s-6); }
  .halo { width: 150%; top: 38%; }
  .msg--user .msg__body { max-width: 92%; }
  .composer__meta { flex-direction: column; gap: var(--s-1); }
  .page-main { padding: var(--s-8) var(--s-4) var(--s-12); }
  .page-header__inner { flex-wrap: wrap; padding: var(--s-2) var(--s-4); gap: var(--s-2); }
  .page-header__inner > .brand { margin-right: auto; }
  .page-header__inner > .page-nav { order: 3; flex-basis: 100%; }
  .page-header__inner > .page-nav ul { padding-bottom: 1px; }
  .page-header__inner > .theme-control { margin-left: 0; }
  .brand__name span { display: none; }
  .topbar__brand .brand__name { display: none; }
  .theme-select { width: 94px; }
  .page-footer__inner { padding: var(--s-5) var(--s-4); }
}

@media (max-width: 380px) {
  :root { --fs-15: 0.9rem; }
  .brand__name span { display: none; }
  .chat__inner { padding-left: var(--s-3); padding-right: var(--s-3); }
  .composer-wrap { padding-left: var(--s-3); padding-right: var(--s-3); }
  .composer__field { padding-left: var(--s-3); }
}

/* ---------- 13. Preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .chat { scroll-behavior: auto; }
  .dots i { opacity: 0.55; }
}

@media (forced-colors: active) {
  .thread[aria-current="true"] { outline: 1px solid CanvasText; }
  .composer__field { border: 1px solid CanvasText; }
}

@media print {
  .sidebar, .composer-wrap, .topbar, .jump, .page-header, .page-footer { display: none !important; }
  .app, .chat { height: auto; overflow: visible; }
  body { background: #fff; color: #000; }
}

/* ==========================================================================
   14. Landing page
   ========================================================================== */

.lp-header__cta { flex: none; margin-left: auto; }
.lp-cta__short { display: none; }

.lp { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.lp-main { flex: 1; }

.lp-section { width: 100%; max-width: var(--page-container); margin: 0 auto; padding: var(--s-16) var(--s-5); }
.lp-section + .lp-section { padding-top: 0; }
.lp-section__head { max-width: 60ch; }
.lp-section__eyebrow { font-size: var(--fs-12); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-text-3); }
.lp-section__title { margin-top: var(--s-3); font-size: clamp(var(--fs-21), 3.2vw, var(--fs-26)); letter-spacing: -0.018em; }
.lp-section__lede { margin-top: var(--s-3); font-size: var(--fs-16); color: var(--c-text-2); }

/* --- Hero --- */
.lp-hero {
  position: relative;
  isolation: isolate;
  padding: clamp(var(--s-12), 9vw, 104px) var(--s-5) var(--s-16);
  border-bottom: 1px solid var(--c-border);
  background: radial-gradient(circle at 50% 15%, var(--c-ambient), transparent 46%);
  overflow: hidden;
}
.lp-hero__inner { position: relative; max-width: 780px; margin: 0 auto; text-align: center; }
.lp-hero .halo { top: 34%; width: min(820px, 150%); opacity: 0.85; }

.lp-hero__title {
  font-size: clamp(var(--fs-26), 6.2vw, 3.15rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.lp-hero__lede {
  max-width: 54ch;
  margin: var(--s-5) auto 0;
  font-size: clamp(var(--fs-16), 2.2vw, var(--fs-18));
  line-height: 1.6;
  color: var(--c-text-2);
}

.lp-composer { max-width: 660px; margin: var(--s-8) auto 0; text-align: left; }
.lp-composer .composer__field { box-shadow: var(--sh-2); }
.lp-composer .composer__notice { text-align: center; margin: var(--s-3) auto 0; }

.lp-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); margin: var(--s-5) auto 0; padding: 0; list-style: none; max-width: 700px; }
.lp-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 38px;
  padding: 0 var(--s-4);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  background: var(--c-surface);
  font-size: var(--fs-13);
  color: var(--c-text-2);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.lp-chip:hover { border-color: var(--c-border-ui); color: var(--c-text); transform: translateY(-1px); }
.lp-chip .icon { color: var(--c-link); }

/* --- Card grid --- */
.lp-grid { display: grid; gap: var(--s-4); margin-top: var(--s-8); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lp-grid--quad { gap: var(--s-3); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lp-card {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--c-surface) 68%, var(--c-subtle));
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.lp-card:hover { transform: translateY(-3px); border-color: var(--c-border-strong); box-shadow: var(--sh-1); }
.lp-card__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  margin-bottom: var(--s-2);
  border-radius: var(--r-sm);
  background: var(--c-accent-soft);
  color: var(--c-link);
}
.lp-card__title { font-size: var(--fs-15); }
.lp-grid--quad .lp-card__text { font-size: var(--fs-13); }
.lp-card__text { font-size: var(--fs-14); line-height: var(--lh-snug); color: var(--c-text-2); }

/* --- Steps --- */
.lp-steps { counter-reset: step; display: grid; gap: var(--s-6); margin-top: var(--s-8); padding: 0; list-style: none; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.lp-step { position: relative; padding-top: var(--s-5); border-top: 2px solid var(--c-border-strong); }
.lp-step:first-child { border-top-color: var(--c-cyan); }
.lp-step::before {
  counter-increment: step;
  content: counter(step);
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--c-link);
  font-variant-numeric: tabular-nums;
}
.lp-step h3 { font-size: var(--fs-16); }
.lp-step p { margin-top: var(--s-2); font-size: var(--fs-14); line-height: var(--lh-snug); color: var(--c-text-2); }

/* --- Boundaries panel --- */
.lp-bounds {
  display: grid;
  gap: var(--s-8);
  margin-top: var(--s-8);
  padding: var(--s-8);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-sidebar);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.lp-bounds h3 { font-size: var(--fs-14); letter-spacing: 0.04em; text-transform: uppercase; color: var(--c-text-3); }
.lp-bounds ul { margin: var(--s-4) 0 0; padding: 0; list-style: none; }
.lp-bounds li { position: relative; padding-left: var(--s-6); font-size: var(--fs-14); line-height: var(--lh-snug); color: var(--c-text); }
.lp-bounds li + li { margin-top: var(--s-3); }
.lp-bounds li::before {
  position: absolute; left: 0; top: 0.15em;
  font-size: var(--fs-13);
  font-weight: 700;
}
.lp-bounds--can li::before { content: "\2713"; color: var(--c-link); }
.lp-bounds--cannot li::before { content: "\2715"; color: var(--c-error); }

/* --- Closing call to action --- */
.lp-cta {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-4);
  max-width: var(--page-container);
  margin: 0 auto var(--s-16);
  padding: var(--s-12) var(--s-5);
  border-top: 1px solid var(--c-border);
  text-align: center;
}
.lp-cta h2 { font-size: clamp(var(--fs-21), 3.2vw, var(--fs-26)); letter-spacing: -0.018em; }
.lp-cta p { max-width: 52ch; font-size: var(--fs-15); color: var(--c-text-2); }
.lp-cta .btn { min-height: 46px; padding: 0 var(--s-6); }

@media (max-width: 1000px) {
  .lp-grid--quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .lp-cta__full { display: none; }
  .lp-cta__short { display: inline; }
}

@media (max-width: 620px) {
  .lp-grid, .lp-grid--quad { grid-template-columns: minmax(0, 1fr); }
  .lp-section { padding: var(--s-12) var(--s-4); }
  .lp-hero { padding-left: var(--s-4); padding-right: var(--s-4); }
  .lp-bounds { padding: var(--s-5); gap: var(--s-6); }
  .lp-cta { padding: var(--s-10) var(--s-4); margin-bottom: var(--s-10); }
}

/* ==========================================================================
   15. Voice — dictation and spoken replies
   ========================================================================== */

.composer__mic {
  flex: none;
  align-self: flex-end;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  color: var(--c-text-2);
}
.composer__mic[hidden] { display: none; }
.composer__mic:hover { background: var(--c-hover); color: var(--c-text); }
.composer__mic svg { width: 19px; height: 19px; }

/* Listening: colour plus a ring plus the status line — never colour alone. */
.composer__mic.is-listening {
  position: relative;
  background: var(--c-accent);
  color: #fff;
}
.composer__mic.is-listening::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: var(--r-md);
  border: 2px solid var(--c-accent);
  opacity: 0.35;
  animation: mic-ring 1.6s var(--ease) infinite;
}
@keyframes mic-ring {
  0%   { transform: scale(1);    opacity: 0.40; }
  70%  { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}

.voice-status {
  margin: var(--s-2) var(--s-1) 0;
  font-size: var(--fs-12);
  line-height: 1.5;
  color: var(--c-text-2);
}
.voice-status[hidden] { display: none; }
.voice-status.is-error { color: var(--c-error); font-weight: 500; }

.msg__tools .icon-btn.is-speaking {
  background: var(--c-accent-soft);
  color: var(--c-link);
}
/* Keep the read-aloud control visible while it is actually speaking. */
.msg--assistant:has(.is-speaking) .msg__tools { opacity: 1; }

@media (max-width: 900px) {
  .composer__mic { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .composer__mic.is-listening::after { animation: none; opacity: 0.5; transform: none; }
}

@media (forced-colors: active) {
  .composer__mic.is-listening { outline: 2px solid CanvasText; }
  .msg__tools .icon-btn.is-speaking { outline: 2px solid CanvasText; }
}

/* ==========================================================================
   16. Embedded assistant page (Chatbase iframe)
   ========================================================================== */

.embed {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  background: var(--c-canvas);
}
.embed__header { position: static; }

.embed__main {
  position: relative;
  width: 100%;
  min-height: 0;
  padding: clamp(var(--s-4), 2.2vw, var(--s-6)) var(--s-5) var(--s-5);
  overflow: hidden;
  background:
    radial-gradient(circle at 14% -10%, var(--c-ambient), transparent 34%),
    radial-gradient(circle at 92% 18%, color-mix(in srgb, var(--c-accent-soft) 76%, transparent), transparent 30%),
    var(--c-canvas);
}

.embed__panel {
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr);
  gap: 0;
  width: 100%;
  max-width: var(--page-container);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
}

.embed__panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
  padding: 0 var(--s-1);
}
.embed__copy { min-width: 0; }
.embed__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-1);
  color: var(--c-link);
  font-size: var(--fs-11);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.embed__eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-cyan);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c-cyan) 15%, transparent);
}
.embed__title {
  font-size: clamp(var(--fs-21), 3vw, var(--fs-32));
  line-height: 1.12;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.embed__lede {
  max-width: 66ch;
  margin-top: var(--s-1);
  color: var(--c-text-2);
  font-size: var(--fs-13);
  line-height: 1.5;
  text-wrap: pretty;
}
.embed__badge {
  flex: none;
  margin-bottom: var(--s-1);
  padding: 7px var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--c-surface) 78%, transparent);
  color: var(--c-text-2);
  box-shadow: var(--sh-1);
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.embed__frame-shell {
  position: relative;
  margin-block: clamp(72px, 7vw, 100px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--c-frame-border);
  border-radius: 20px;
  background: #05080C;
  box-shadow: 0 24px 70px rgba(7, 38, 57, 0.18), 0 4px 16px rgba(7, 38, 57, 0.10);
  isolation: isolate;
}
:root[data-theme="dark"] .embed__frame-shell {
  box-shadow: 0 26px 76px rgba(0, 0, 0, 0.48), 0 4px 18px rgba(0, 0, 0, 0.28);
}
.embed__frame-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.10);
  pointer-events: none;
}

/* The shell already guarantees the height, so the frame fills its row rather
   than carrying a fixed min-height that would force the page to scroll on
   short laptop screens. */
.embed__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  color-scheme: dark;
}

.embed__foot {
  border-top: 1px solid var(--c-border);
  background: var(--c-header);
  backdrop-filter: blur(14px);
}
.embed__foot-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-5);
  width: 100%;
  max-width: var(--page-container);
  margin: 0 auto;
  padding: var(--s-3) var(--s-5) max(var(--s-3), env(safe-area-inset-bottom));
}
.embed__notice { display: flex; align-items: center; gap: var(--s-2); max-width: 88ch; font-size: var(--fs-12); line-height: 1.5; color: var(--c-text-3); }
.embed__notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-accent-soft);
  color: var(--c-link);
  font-size: var(--fs-12);
  font-weight: 700;
  font-family: Georgia, serif;
}
.embed__fallback { flex: none; font-size: var(--fs-12); color: var(--c-text-3); }

@media (max-width: 620px) {
  .embed__main { padding: var(--s-4); }
  .embed__panel-head { align-items: flex-start; gap: var(--s-3); padding: 0; }
  .embed__lede { max-width: 48ch; }
  .embed__badge { display: none; }
  .embed__frame-shell { margin-block: var(--s-8); border-radius: var(--r-lg); }
  .embed__foot-inner { padding-left: var(--s-4); padding-right: var(--s-4); }
  .embed__notice { align-items: flex-start; }
}

@media (max-height: 760px) {
  .embed__main { padding-top: var(--s-3); padding-bottom: var(--s-3); }
  .embed__frame-shell { margin-block: var(--s-6); }
  .embed__lede { display: none; }
  .embed__eyebrow { margin-bottom: 0; }
}

/* User-controlled accessibility options */
html[data-a11y-text="large"] { font-size: 112.5%; }
html[data-a11y-text="largest"] { font-size: 125%; }
html[data-a11y-links] a { text-decoration: underline !important; text-underline-offset: .16em; }
html[data-a11y-motion], html[data-a11y-motion] *, html[data-a11y-motion] *::before, html[data-a11y-motion] *::after {
  scroll-behavior: auto !important;
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}
html[data-a11y-contrast] body { color: #111 !important; background-color: #fff !important; }
html[data-a11y-contrast] a { color: #0037a6 !important; text-decoration: underline !important; }
html[data-a11y-contrast] button, html[data-a11y-contrast] input, html[data-a11y-contrast] select, html[data-a11y-contrast] textarea {
  color: #111 !important; background-color: #fff !important; border-color: #111 !important;
}
.a11y-widget { position: fixed; z-index: 99999; left: 1.25rem; top: 50%; transform: translateY(-50%); font: 500 14px/1.4 system-ui, sans-serif; color: #142033; }
.a11y-widget__trigger { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 54px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: #073b5c; box-shadow: 0 2px 12px #0003; cursor: pointer; font: inherit; }
.a11y-widget__trigger::before { position: absolute; inset: 7px; border: 2px solid currentColor; border-radius: 50%; content: ""; pointer-events: none; }
.a11y-widget__trigger:hover { background: #0a4d75; }
.a11y-widget__trigger:focus-visible, .a11y-widget__panel :focus-visible { outline: 3px solid #ffbf47; outline-offset: 3px; }
.a11y-widget__trigger svg { position: relative; z-index: 1; width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.a11y-widget__panel { position: absolute; left: calc(100% + .7rem); top: 50%; transform: translateY(-50%); width: min(19rem, calc(100vw - 7rem)); padding: 1rem; border: 1px solid #c9d2df; border-radius: 12px; background: #fff; box-shadow: 0 8px 30px #0003; }
.a11y-widget__heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; }
.a11y-widget__heading h2 { margin: 0; color: #142033; font-size: 1.05rem; }
.a11y-widget__close { width: 40px; height: 40px; border: 1px solid #8391a4; border-radius: 6px; background: #fff; color: #142033; font: 1.5rem/1 system-ui, sans-serif; cursor: pointer; }
.a11y-widget__field { display: block; margin-bottom: .25rem; font-weight: 650; }
.a11y-widget__select { width: 100%; min-height: 42px; margin-bottom: .6rem; padding: .4rem; border: 1px solid #8391a4; border-radius: 6px; color: #142033; background: #fff; font: inherit; }
.a11y-widget__option { display: flex; align-items: center; gap: .6rem; min-height: 42px; cursor: pointer; }
.a11y-widget__option input { width: 18px; height: 18px; accent-color: #153e75; }
.a11y-widget__reset { width: 100%; min-height: 42px; margin-top: .5rem; border: 1px solid #153e75; border-radius: 6px; color: #153e75; background: #fff; font: inherit; font-weight: 650; cursor: pointer; }
@media (max-width: 420px) { .a11y-widget { left: .65rem; } .a11y-widget__trigger { width: 50px; height: 50px; } .a11y-widget__trigger::before { inset: 6px; } .a11y-widget__trigger svg { width: 25px; height: 25px; } .a11y-widget__panel { left: calc(100% + .55rem); width: min(16rem, calc(100vw - 5.5rem)); } }
