/* ================================================================
   SayIntentions.AI Knowledge Base — Material MkDocs-inspired CSS
   ================================================================ */

/* ── Variables — Light theme (default) ── */
:root,
[data-theme="light"] {
  /* Brand interactive colour — light blue */
  --primary:        #33B1EB;
  --primary-light:  #5bc5f5;
  --primary-dark:   #1a8fc4;
  --primary-tint:   rgba(51, 177, 235, 0.09);
  --primary-tint2:  rgba(51, 177, 235, 0.17);
  /* Accessible text version of primary for use on white/light backgrounds (5.4:1 contrast ratio) */
  --primary-text:   #1567a3;

  /* Nav header background — dark blue */
  --nav-bg:         #203864;
  --nav-bg-row2:    rgba(0, 0, 0, 0.22);

  --text:           #1a1f2e;
  --text-secondary: #4a5568;
  /* Darkened from #718096 (3.7:1) to #576478 (5.6:1 on white) to meet WCAG AA */
  --text-muted:     #576478;
  --border:         #e2e8f0;
  --bg:             #ffffff;
  --bg-soft:        #f7f9fc;
  --bg-sidebar:     #f8fafd;

  --code-bg:        #f0f4f8;
  --code-color:     #b83232;
  --pre-bg:         #1e2a3a;
  --pre-color:      #cdd8e8;
  --table-stripe:   #f7f9fc;
  --blockquote-bg:  rgba(51, 177, 235, 0.07);

  --nav-h:          108px;   /* row-1 (60px) + row-2 (48px) */
  --nav-row1-h:     60px;
  --nav-row2-h:     48px;
  --sidebar-w:      268px;
  --content-max:    900px;

  --radius:         6px;
  --shadow-sm:      0 1px 4px rgba(0,0,0,.10);
  --shadow-md:      0 4px 16px rgba(0,0,0,.12);
  --transition:     0.18s ease;
}

/* ── Variables — Dark theme ── */
[data-theme="dark"] {
  /* Brand interactive colour — gold */
  --primary:        #E0B651;
  --primary-light:  #eac96c;
  --primary-dark:   #c9a248;
  --primary-tint:   rgba(224, 182, 81, 0.10);
  --primary-tint2:  rgba(224, 182, 81, 0.20);
  /* In dark mode gold is bright enough to use directly as text (9.5:1 on #121212) */
  --primary-text:   #E0B651;

  /* Nav header background — deep navy */
  --nav-bg:         #1a2540;
  --nav-bg-row2:    rgba(0, 0, 0, 0.35);

  /* Industry-standard dark surfaces */
  --text:           #e8eaed;
  --text-secondary: #bdc1c6;
  --text-muted:     #9aa0a6;
  --border:         #333a47;
  --bg:             #121212;
  --bg-soft:        #1e1e1e;
  --bg-sidebar:     #181818;

  --code-bg:        #252a30;
  --code-color:     #f48fb1;
  --pre-bg:         #0f1117;
  --pre-color:      #c8d0e0;
  --table-stripe:   #1e1e1e;
  --blockquote-bg:  rgba(224, 182, 81, 0.08);

  --shadow-sm:      0 1px 4px rgba(0,0,0,.45);
  --shadow-md:      0 4px 16px rgba(0,0,0,.55);
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}


/* ── Material Icons global alignment fix ──
   Forces every icon glyph to self-center inside its own box,
   so parent flex `align-items: center` works correctly.       */
.material-icons {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  vertical-align: middle !important;
  font-size: inherit;
}

body {
  font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Smooth theme transition on every themed element */
*, *::before, *::after {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease;
}
/* But don't slow down interaction-specific transitions */
button, a, .quick-card, .article-row, .cat-card, .sb-link, .nav-links a,
.sb-category-header, .support-card, .btn-back, .btn-primary {
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.15s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

/* ── Screen reader only utility (visually hides labels for assistive tech) ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Keyboard focus indicators (WCAG 2.4.7) ── */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
/* On dark nav surface, use white outline */
.top-nav :focus-visible {
  outline-color: #fff;
}

a { cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; }

/* ================================================================
   TOP NAVIGATION  — two-row layout
   ================================================================ */
.top-nav {
  position: fixed;
  inset: 0 0 auto 0;
  background: var(--nav-bg);
  color: #fff;
  z-index: 900;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

/* ── Row 1: brand + search ── */
.nav-row-1 {
  display: flex;
  align-items: center;
  height: var(--nav-row1-h);
  padding: 0 16px;
  gap: 12px;
}

/* ── Row 2: main nav links ── */
.nav-row-2 {
  height: var(--nav-row2-h);
  background: var(--nav-bg-row2);
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

/* Left side of row 1 */
.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Brand */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.nav-brand:hover { background: rgba(255,255,255,.1); }

.brand-logo-img {
  height: 36px;
  width: auto;
  display: block;
  border-radius: 6px;
}
/* Light mode: logo-blue.png icon is dark — invert to white so it stands out on navy nav */
[data-theme="light"] .brand-logo-img {
  filter: brightness(0) invert(1);
}
/* Dark mode: logo.png has a black bg — blend it into the dark nav seamlessly */
[data-theme="dark"] .brand-logo-img {
  filter: none;
  mix-blend-mode: lighten;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand-sub  { font-size: 11px; font-weight: 400; opacity: .75; letter-spacing: .03em; white-space: nowrap; }

/* Row-2 nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}
.nav-links a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  letter-spacing: .01em;
}
.nav-links a:hover  { color: #fff; background: rgba(255,255,255,.08); }
.nav-links a.active { color: #fff; border-bottom-color: var(--primary); }

/* Right side of row 1 */
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon buttons */
.icon-btn {
  background: none;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  transition: background var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.15); }
.icon-btn .material-icons { font-size: 22px; }

.icon-btn-sm {
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  padding: 2px;
}
.icon-btn-sm .material-icons { font-size: 16px; }

/* Search */
.nav-search { position: relative; }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 24px;
  padding: 6px 12px;
  transition: background var(--transition), border-color var(--transition);
  min-width: 220px;
}
.search-box.focused,
.search-box:focus-within {
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.55);
}
.search-ico  { color: rgba(255,255,255,.7); font-size: 18px !important; flex-shrink: 0; }
.search-inp  {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
}
.search-inp::placeholder { color: rgba(255,255,255,.6); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 1000;
  min-width: 320px;
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-row:last-of-type { border-bottom: none; }
.search-result-row:hover { background: var(--bg-soft); }

.sr-icon { color: var(--primary); font-size: 18px !important; flex-shrink: 0; }
.sr-body  { flex: 1; min-width: 0; }
.sr-title { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-tag     { font-size: 11px; color: var(--text-muted); }
.sr-snippet {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 3px 0 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Search highlight marks (only when user's query words match) ── */
.search-hl,
.sr-snippet mark,
.ar-excerpt mark,
.sr-title mark {
  background: rgba(51, 177, 235, 0.2);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
  font-style: normal;
}

/* ── Best match badge (when no exact keyword matches) ── */
.sr-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.sr-best-match,
.best-match-badge {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
}

.search-dropdown-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-dropdown-footer {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--primary-text);
  font-weight: 500;
  border-top: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg-soft);
}
.search-dropdown-footer:hover { background: var(--primary-tint); }

/* Pilot Portal button */
.btn-portal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--primary);
  /* Dark text on brand-blue background ensures 6:1+ contrast in both themes */
  color: #0d1a33;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition);
}
.btn-portal:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}
.btn-portal .material-icons { font-size: 16px !important; }

/* Both hamburger buttons are desktop-hidden by default */
.mobile-menu-btn    { display: none; }
.sidebar-toggle-btn { display: none; } /* sidebar is always open on desktop — toggle only needed on mobile */

.mobile-nav {
  background: var(--primary-dark);
  padding: 8px 0;
}
.mobile-nav a {
  display: block;
  padding: 11px 20px;
  color: rgba(255,255,255,.9);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}
.mobile-nav a:hover { background: rgba(255,255,255,.1); }

.mobile-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 16px 4px;
  background: rgba(255,255,255,.15);
  border-radius: 24px;
  padding: 8px 14px;
}
.mobile-search .material-icons { color: rgba(255,255,255,.7); font-size: 18px; }
.mobile-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
}
.mobile-search input::placeholder { color: rgba(255,255,255,.6); }

/* ================================================================
   PAGE WRAPPER — sidebar + content
   ================================================================ */
.page-wrapper {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--nav-h));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 200;
  transition: transform var(--transition);
  transform: translateX(0);
}

.sidebar-scroller {
  padding: 12px 0 32px;
}

.sb-section {
  margin-bottom: 4px;
}

.sb-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sb-section-label .material-icons { font-size: 15px !important; }

/* Category header (expandable) — now a <button> for keyboard/screen reader access */
.sb-category-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  user-select: none;
  border-radius: 0;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
}
.sb-category-header:hover { background: var(--primary-tint); color: var(--primary-text); }
.sb-category-header.expanded { color: var(--primary-text); }

.cat-label { flex: 1; }

/* Sidebar links */
.sb-link {
  display: block;
  padding: 7px 14px 7px 36px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1.45;
}
.sb-link:hover { background: var(--primary-tint); color: var(--primary-text); }
.sb-link.active {
  background: var(--primary-tint2);
  color: var(--primary-text);
  border-left-color: var(--primary);
  font-weight: 500;
}

.sb-cat-links { padding-bottom: 4px; }

.sb-empty {
  display: block;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Sidebar TOC: inline "On this page" links ── */
.sb-toc-link {
  display: block;
  padding: 4px 14px 4px 48px;  /* deeper indent than .sb-link (36px) to sit nested under it */
  font-size: 11.5px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  border-left: 2px solid transparent;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.sb-toc-link:hover { color: var(--primary-text); background: var(--primary-tint); }
.sb-toc-link.active {
  color: var(--primary-text);
  border-left-color: var(--primary);
  background: var(--primary-tint);
  font-weight: 500;
}

.sb-loading {
  display: flex;
  justify-content: center;
  padding: 24px;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}

/* ================================================================
   CONTENT AREA
   ================================================================ */
.content-area {
  flex: 1;
  min-width: 0;        /* prevents flex child from overflowing its container */
  width: 0;            /* forces flex to compute width from flex-grow, not content */
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-h));
  transition: margin-left var(--transition);
}

.has-sidebar .content-area {
  margin-left: var(--sidebar-w);
}

.content-main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;  /* clip any content that exceeds the computed area width */
}

/* ================================================================
   SPINNERS / LOADING
   ================================================================ */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner-sm {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spin { animation: spin .9s linear infinite; }

/* desktop-only helper — visibility controlled by media query */
.desktop-only { display: flex; }

/* ================================================================
   HOME PAGE
   ================================================================ */

/* Hero */
/* ── Hero — full-bleed image with overlay text ── */
.hero {
  position: relative;
  min-height: 420px;
  background-image: url('/images/hero.png');
  background-size: cover;
  background-position: center center;
  display: flex;
  align-items: center;
  justify-content: flex-end;   /* text block sits on the right */
  overflow: hidden;
}

/* Gradient scrim — dark by default (dark mode), overridden for light mode below */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(5, 15, 40, 0.10) 0%,
    rgba(5, 15, 40, 0.50) 35%,
    rgba(5, 15, 40, 0.88) 62%,
    rgba(5, 15, 40, 0.97) 100%
  );
  pointer-events: none;
}

/* Light mode: use the daytime hero image */
[data-theme="light"] .hero {
  background-image: url('/images/hero-light.png');
}

/* Light mode: brighter, brand-blue tinted scrim so the photo breathes */
[data-theme="light"] .hero::before {
  background: linear-gradient(
    to right,
    rgba(51, 177, 235, 0.08) 0%,
    rgba(32, 56, 100, 0.30) 35%,
    rgba(32, 56, 100, 0.82) 62%,
    rgba(32, 56, 100, 0.94) 100%
  );
}

/* Text content — floated right, above the scrim */
.hero-content-col {
  position: relative;
  z-index: 1;
  width: min(44%, 520px);
  max-width: 100%;
  padding: clamp(28px, 5vw, 56px) clamp(24px, 5vw, 56px) clamp(28px, 5vw, 56px) clamp(20px, 3vw, 40px);
  color: #fff;
  box-sizing: border-box;
}

.hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}

.hero-title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.18;
  margin-bottom: 16px;
}
.hero-title-accent { color: #ffd54f; }

.hero-body {
  font-size: 15px;
  line-height: 1.72;
  color: rgba(255,255,255,.82);
  margin-bottom: 30px;
}

.hero-search-bar {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 32px;
  padding: 5px 5px 5px 16px;
  max-width: 400px;
  transition: background var(--transition), border-color var(--transition);
}
.hero-search-bar:focus-within {
  background: rgba(255,255,255,.2);
  border-color: rgba(255,255,255,.55);
}
.hero-search-bar .material-icons { color: rgba(255,255,255,.6); margin-right: 8px; flex-shrink: 0; }
.hero-search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: #fff;
  background: none;
}
.hero-search-bar input::placeholder { color: rgba(255,255,255,.5); }
.hero-search-bar button {
  background: #ffd54f;
  color: #0d2046;
  border: none;
  border-radius: 26px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--transition);
}
.hero-search-bar button:hover { background: #ffca28; }

/* Home body */
.home-body { padding: 36px 32px; max-width: 1200px; margin: 0 auto; width: 100%; box-sizing: border-box; }

/* Quick cards */
.home-quick-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 48px;
}
.quick-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 24px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.quick-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--primary-light);
}
.quick-card .material-icons { font-size: 40px; color: var(--primary); margin-bottom: 12px; display: block; }
.quick-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.quick-card p  { font-size: 13px; color: var(--text-secondary); }

/* Section title */
.home-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 48px;
}
.cat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.cat-card:hover {
  background: var(--primary-tint);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}
.cat-card-icon { color: var(--primary); font-size: 26px !important; flex-shrink: 0; }
.cat-card-body strong { display: block; font-size: 13px; font-weight: 600; }
.cat-card-body small  { display: block; font-size: 11px; color: var(--text-muted); }
.cat-views {
  display: flex !important;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
}
.cat-views .material-icons { font-size: 12px !important; }

.show-more-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 32px;
}
.btn-show-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 20px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-show-more:hover {
  background: var(--primary-tint);
  border-color: var(--primary-light);
  color: var(--primary);
}

/* ================================================================
   ARTICLE LIST (shared)
   ================================================================ */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 24px;
}
.article-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.article-row:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}
.ar-info { flex: 1; min-width: 0; }
.ar-info h3 { font-size: 15px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.ar-info p  { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.ar-excerpt {
  white-space: normal !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: unset !important;
  line-height: 1.5;
}
.ar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.ar-arrow { color: var(--text-muted); flex-shrink: 0; }

/* Meta details */
.meta-detail {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.meta-detail .material-icons { font-size: 14px !important; }

/* Tag chip — uses accessible primary text on light-blue tint */
.tag-chip {
  font-size: 11px;
  font-weight: 600;
  background: #e3f2fd;
  color: var(--primary-text);
  padding: 2px 9px;
  border-radius: 12px;
}

/* ================================================================
   PAGE LIST (Onboarding / KB)
   ================================================================ */
.page-list {
  padding: 32px;
  max-width: calc(var(--content-max) + 64px);
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}

.list-header { margin-bottom: 28px; }
.list-header h1 {
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.list-header h1 .material-icons { font-size: 30px !important; color: var(--primary); }
.list-header p { font-size: 15px; color: var(--text-secondary); }

.kb-category-section { margin-bottom: 36px; }
.kb-cat-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.kb-cat-heading .material-icons { color: var(--primary); font-size: 20px !important; }

/* ================================================================
   ARTICLE PAGE
   ================================================================ */
.page-article {
  padding: 28px 40px 48px;
  max-width: calc(var(--content-max) + 80px);
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 13px;
  margin-bottom: 20px;
  color: var(--text-muted);
}
.breadcrumbs a { color: var(--primary-text); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .material-icons { font-size: 16px !important; color: var(--border); }
.bc-current { color: var(--text-secondary); }

/* ── Article card — popout look ── */
.article-card {
  background-color: #1E1E1E;
  border: 1px solid #252525;
  border-radius: 0.75rem;
  max-width: 100%;
  box-sizing: border-box;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 10px 15px  -3px rgba(0, 0, 0, 0.10);
  overflow: hidden;
}

[data-theme="light"] .article-card {
  background-color: #ffffff;
  border-color: #dee2e6;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.08),
    0 10px 15px  -3px rgba(0, 0, 0, 0.04);
}

.article-card-header {
  padding: 1.5rem;
  border-bottom: 1px solid #252525;
}

[data-theme="light"] .article-card-header {
  border-bottom-color: #dee2e6;
}

.article-card-header h1 {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 1.875rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  margin-bottom: 14px;
}

[data-theme="light"] .article-card-header h1 {
  color: #000000;
}

.article-card-body {
  padding: 2rem;
}

.article-meta-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  /* Dark text on primary bg: 6:1+ contrast in both light (#33B1EB) and dark (#E0B651) themes */
  color: #0d1a33;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}
.tag-badge .material-icons { font-size: 13px !important; }

/* ── Prose (article body) ── */
.prose {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Explicit heading sizes — required because CSS resets strip them */
.prose h1 { font-size: 1.75em;  font-weight: 700; line-height: 1.3; margin: 0.67em 0; }
.prose h2 { font-size: 1.5em;  font-weight: 700; line-height: 1.3; margin: 0.83em 0; }
.prose h3 { font-size: 1.25em; font-weight: 600; line-height: 1.3; margin: 1em 0; }
.prose h4 { font-size: 1.1em;  font-weight: 600; line-height: 1.3; margin: 1em 0; }

.prose p  { margin-bottom: 14px; }
.prose br { display: block; }

.prose ul,
.prose ol { margin: 10px 0 14px 24px; }
.prose li { margin-bottom: 6px; }

.prose a       { color: var(--primary-text) !important; text-decoration: underline !important; background: none !important; }
.prose a:hover { opacity: 0.85; }
.prose strong  { font-weight: 600; }
.prose em      { font-style: italic; }

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 16px 0;
  display: block;
}

.prose table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
  overflow-x: auto;
  display: block;
  max-width: 100%;
}
.prose th {
  background: #252525;
  font-weight: 600;
  color: #e5e7eb;
  padding: 0.5em 0.75em;
  text-align: left;
  border: 1px solid #333333;
  white-space: nowrap;
}
.prose td {
  padding: 0.5em 0.75em;
  border: 1px solid #333333;
  vertical-align: top;
}
[data-theme="light"] .prose th {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #dee2e6;
}
[data-theme="light"] .prose td { border-color: #dee2e6; }
.prose tr:nth-child(even) td { background: var(--table-stripe); }

.prose code {
  background: #252525;
  color: #E0B651;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-family: 'Roboto Mono', 'Consolas', monospace;
  font-size: 0.9em;
}
[data-theme="light"] .prose code {
  background: #e9ecef;
  color: #203864;
}

.prose pre {
  background: #252525;
  color: var(--pre-color);
  border-radius: 0.5rem;
  padding: 1em;
  overflow-x: auto;
  margin: 18px 0;
  line-height: 1.55;
}
.prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 13px;
}
[data-theme="light"] .prose pre {
  background: #e9ecef;
  color: #1e293b;
}

.prose blockquote {
  border-left: 4px solid var(--primary);
  background: var(--blockquote-bg);
  padding: 12px 1em;
  margin: 18px 0;
  color: var(--text-secondary);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: 2px solid #333333;
  margin: 1.25em 0;
}
[data-theme="light"] .prose hr { border-top-color: #dee2e6; }

/* Article footer */
.article-footer {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid #333333;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
[data-theme="light"] .article-footer { border-top-color: #dee2e6; }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.btn-back:hover { background: var(--bg-soft); color: var(--primary); border-color: var(--primary); }
.btn-back .material-icons { font-size: 18px !important; }

.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.btn-next:hover { background: var(--bg-soft); color: var(--primary); border-color: var(--primary); }
.btn-next .material-icons { font-size: 18px !important; }

/* ── Dark-mode inline-color preservation ──
   Articles are often authored with dark text on light backgrounds.
   These rules override near-black inline styles to remain readable. */
[data-theme="dark"] .kb-content [style*="color: rgb(0, 0, 0)"],
[data-theme="dark"] .kb-content [style*="color: black"],
[data-theme="dark"] .kb-content [style*="color: #000000"],
[data-theme="dark"] .kb-content [style*="color: #000"],
[data-theme="dark"] .kb-content [style*="color: rgb(68, 68, 68)"],
[data-theme="dark"] .kb-content [style*="color: rgb(102, 102, 102)"] {
  color: #ffffff !important;
}
[data-theme="dark"] .kb-content [style*="color: rgb(136, 136, 136)"] {
  color: #d1d5db !important;
}

/* ================================================================
   SUPPORT PAGE
   ================================================================ */
.page-support { padding: 32px; max-width: calc(var(--content-max) + 64px); width: 100%; box-sizing: border-box; margin: 0 auto; }

.support-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.support-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 30px 24px;
  text-align: center;
  transition: box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.support-card:hover { box-shadow: var(--shadow-md); }
.support-card .material-icons { font-size: 42px !important; color: var(--primary); margin-bottom: 14px; display: block; }
.support-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.support-card p  { font-size: 14px; color: var(--text-secondary); margin-bottom: 18px; line-height: 1.55; }

/* Disabled / coming-soon state */
.support-card--disabled {
  opacity: 0.72;
  pointer-events: none;
}
.support-card--disabled a {
  pointer-events: auto;
}
.support-card--disabled:hover { box-shadow: none; }

.coming-soon-ribbon {
  position: absolute;
  top: 18px;
  right: -30px;
  width: 130px;
  padding: 5px 0;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
  transform: rotate(35deg);
  transform-origin: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  pointer-events: none;
}

.coming-soon-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px !important;
  background: var(--primary-tint);
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  padding: 10px 14px;
  text-align: left;
  margin-bottom: 0 !important;
}
.coming-soon-note .material-icons { font-size: 16px !important; color: var(--primary) !important; margin-bottom: 0 !important; flex-shrink: 0; margin-top: 2px; }
.coming-soon-note span:last-child { flex: 1; line-height: 1.5; }
.coming-soon-note a { color: var(--primary-text); font-weight: 600; pointer-events: auto; text-decoration: underline; }
.support-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid var(--primary-text);
  border-radius: 20px;
  padding: 9px 18px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
/* Dark text on primary background: 6:1+ contrast in both themes */
.support-link:hover { background: var(--primary); color: #0d1a33; border-color: var(--primary); }
.support-link .material-icons { font-size: 16px !important; }

.support-email-links {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: 100%;
}
.support-email-links .support-link {
  flex: 1;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  padding: 9px 12px;
}
.support-email-links .support-link .material-icons { font-size: 15px !important; }

/* ================================================================
   EMPTY / ERROR STATES
   ================================================================ */
.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 32px;
}
.empty-state .material-icons,
.error-state .material-icons { font-size: 52px !important; }
.error-state h2 { font-size: 20px; color: var(--text-secondary); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  /* Dark text on primary bg: 6:1+ contrast in both themes */
  color: #0d1a33;
  border: none;
  border-radius: var(--radius);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }

/* ================================================================
   FOOTER
   ================================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 20px 24px;
  width: 100%;
  box-sizing: border-box;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* Left: copyright + legal links */
.footer-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.footer-copyright {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.footer-legal {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-legal a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-legal a:hover { color: var(--primary-text); }
.footer-divider { color: var(--border); font-size: 12px; }

/* Right: social icons */
.footer-social {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition), transform var(--transition);
}
.social-icon:hover {
  color: var(--primary-text);
  transform: translateY(-2px);
}
.social-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ================================================================
   RESPONSIVE — TABLET / MOBILE
   ================================================================ */
@media (max-width: 1024px) {
  .brand-sub { display: none; }
}

@media (max-width: 900px) {
  /* On mobile, --nav-h collapses to just row-1 height */
  :root { --nav-h: var(--nav-row1-h); }

  .nav-row-2.desktop-only  { display: none; }
  .nav-search.desktop-only { display: none; }
  .mobile-menu-btn         { display: flex; }
  .sidebar-toggle-btn      { display: flex; }
  .btn-portal              { display: none; }

  /* Sidebar: off-canvas on mobile */
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    z-index: 500;
  }
  .sidebar.open { transform: translateX(0); }

  /* Content no longer needs margin */
  .has-sidebar .content-area { margin-left: 0; }

  /* Hero: keep content on the right, right-justified at tablet */
  .hero              { justify-content: flex-end; }
  .hero-content-col  { width: 100%; max-width: 100%; padding: 40px 28px; text-align: right; }
  .hero-content-col .hero-search-bar { margin-left: auto; }

  .home-quick-cards { grid-template-columns: 1fr 1fr; }
  .category-grid    { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .support-grid     { grid-template-columns: 1fr; }
  .home-body        { padding: 24px 16px; }
  .page-list,
  .page-support     { padding: 24px 16px; }
  .page-article     { padding: 20px 16px 40px; }
  .site-footer      { padding: 20px 16px; }
}

@media (max-width: 600px) {
  /* Hero: tighter overlay on small phones */
  .hero              { min-height: 300px; }
  .hero::before      { background: rgba(5,15,40,.78); }
  .hero-content-col  { padding: 32px 20px; }
  .hero-title        { font-size: 20px; }
  .hero-body         { display: none; }
  .category-grid    { grid-template-columns: 1fr 1fr; }
  .home-quick-cards { grid-template-columns: 1fr 1fr; }
  .home-body        { padding: 20px 12px; }
  .page-list,
  .page-support     { padding: 20px 12px; }
  .page-article     { padding: 16px 12px 40px; }
  .article-card-header h1 { font-size: 1.4rem; }
  .article-card-header { padding: 1.25rem; }
  .article-card-body   { padding: 1.25rem; }
}

/* ================================================================
   DARK THEME OVERRIDES
   (anything that uses a hard-coded colour not covered by variables)
   ================================================================ */
[data-theme="dark"] {
  /* ── Nav ── */
  .search-box { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
  .search-box.focused,
  .search-box:focus-within { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.38); }
  .search-dropdown { background: #1e1e1e; border: 1px solid var(--border); }
  .search-result-row:hover { background: #2a2a2a; }
  .sr-title { color: var(--text); }
  .search-dropdown-footer { background: #181818; }
  .search-hl { background: rgba(224, 182, 81, 0.28); }
  .mobile-nav { background: #111d30; }

  /* ── Sidebar ── */
  .sidebar {
    border-right-color: var(--border);
    scrollbar-color: var(--primary) var(--bg-sidebar);
    scrollbar-width: thin;
  }
  .sidebar::-webkit-scrollbar { width: 8px; }
  .sidebar::-webkit-scrollbar-track { background: var(--bg-sidebar); }
  .sidebar::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }
  .sidebar::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }
  .sb-category-header:hover { background: var(--primary-tint); color: var(--primary-text); }
  .sb-link:hover { background: var(--primary-tint); color: var(--primary-text); }
  .sb-link.active { background: var(--primary-tint2); color: var(--primary-text); }

  /* ── Cards & rows ── */
  .quick-card,
  .support-card { border-color: var(--border); }
  .quick-card:hover  { border-color: var(--primary-light); }
  /* Article rows get the card popout treatment in dark mode */
  .article-row {
    background: #1E1E1E;
    border-color: #252525;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  }
  .article-row:hover {
    border-color: var(--primary-light);
    box-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 4px 12px rgba(0,0,0,0.3);
  }
  .cat-card { background: var(--bg-soft); border-color: var(--border); }
  .cat-card:hover { background: var(--primary-tint); border-color: var(--primary-light); }

  /* ── Hero ── */
  /* hero uses image + ::before scrim — no bg override needed in dark mode */

  /* ── Buttons ── */
  .btn-back { border-color: var(--border); color: var(--text-secondary); }
  .btn-back:hover { background: var(--bg-soft); color: var(--primary-light); border-color: var(--primary); }

  /* ── Misc ── */
  .tag-chip { background: rgba(224, 182, 81, 0.15); color: var(--primary-text); }
  .site-footer { background: #181818; border-top-color: var(--border); }
  .page-loading p { color: var(--text-muted); }
  .kb-cat-heading { border-bottom-color: var(--border); }
  .list-header h1 { color: var(--text); }
}

/* ================================================================
   ASK ACE — Floating AI Chat Widget
   ================================================================ */

/* Container — anchors the whole widget to the bottom-right viewport */
.chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── Trigger Button ── */
.chat-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0 20px 0 6px;
  height: 52px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
}
.chat-trigger-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 24px rgba(0,0,0,.28);
  transform: translateY(-2px);
}
.chat-trigger-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-trigger-icon .material-icons { font-size: 22px; }
.chat-trigger-label {
  letter-spacing: 0.01em;
}

/* When panel is open, shrink trigger to a round close button */
.chat-widget--open .chat-trigger-btn {
  width: 52px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}
.chat-widget--open .chat-trigger-label { display: none; }
.chat-widget--open .chat-trigger-icon {
  background: transparent;
  width: auto;
  height: auto;
}

/* ── Chat Panel ── */
.chat-panel {
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatPanelIn 0.22s cubic-bezier(.22,1,.36,1);
}

@keyframes chatPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Panel Header ── */
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--nav-bg);
  color: #fff;
  flex-shrink: 0;
}
.chat-panel-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-panel-titles { display: flex; flex-direction: column; line-height: 1.3; }
.chat-panel-name   { font-weight: 600; font-size: 0.97rem; color: #fff; }
.chat-panel-status {
  font-size: 0.76rem;
  color: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}
.chat-close-btn {
  color: rgba(255,255,255,.8) !important;
}
.chat-close-btn:hover { color: #fff !important; }

/* ── Messages Area ── */
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;

  /* Subtle custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-messages-area::-webkit-scrollbar { width: 6px; }
.chat-messages-area::-webkit-scrollbar-track { background: transparent; }
.chat-messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Individual message ── */
.chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.chat-msg--user { align-self: flex-end; align-items: flex-end; }
.chat-msg--bot  { align-self: flex-start; align-items: flex-start; }

.chat-msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}

/* User bubble */
.chat-msg--user .chat-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Bot bubble */
.chat-msg--bot .chat-msg-bubble {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown content inside bot bubble */
.chat-msg-bubble p         { margin: 0 0 8px; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }
.chat-msg-bubble ol,
.chat-msg-bubble ul        { margin: 6px 0 8px; padding-left: 20px; }
.chat-msg-bubble li        { margin-bottom: 4px; }
.chat-msg-bubble strong    { font-weight: 600; }
.chat-msg-bubble code      { font-family: 'Roboto Mono', monospace; font-size: 0.82em; background: var(--code-bg); color: var(--code-color); padding: 1px 5px; border-radius: 3px; }
.chat-msg-bubble a         { color: var(--primary-text); text-decoration: underline; }
.chat-msg-bubble a:hover   { opacity: 0.8; }

/* Typing animation bubble */
.chat-msg-bubble--loading {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 16px;
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chatTyping 1.2s infinite ease-in-out;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Article References ── */
.chat-refs {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 100%;
}
.chat-refs-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-refs-heading .material-icons { font-size: 13px; }

.chat-ref-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--primary-text);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
  overflow: hidden;
}
.chat-ref-link:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
}
.chat-ref-link .material-icons { font-size: 15px; flex-shrink: 0; }
.chat-ref-link span:nth-child(2) {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-ref-arrow { color: var(--text-muted); font-size: 13px !important; }

/* Web page source links get a slightly different accent to distinguish from KB article refs */
.chat-ref-link--web {
}

/* ── Input Area ── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.5;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  max-height: 120px;
  overflow-y: auto;
}
.chat-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint2);
}
.chat-input:disabled { opacity: 0.6; cursor: not-allowed; }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.chat-send-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.06);
}
.chat-send-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
.chat-send-btn .material-icons { font-size: 18px; }

/* ── Panel Footer ── */
.chat-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  flex-shrink: 0;
}
.chat-clear-btn {
  background: none;
  border: none;
  color: var(--primary-text);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
}
.chat-clear-btn:hover { opacity: 0.75; }

/* ── Chat footer actions row ── */
.chat-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-withdraw-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition);
  border-radius: var(--radius);
}
.chat-withdraw-btn .material-icons { font-size: 13px; }
.chat-withdraw-btn:hover { opacity: 1; color: var(--primary-text); }

/* ── Locked trigger state (consent declined) ── */
.chat-trigger-btn--locked {
  background: var(--text-muted);
}
.chat-trigger-btn--locked:hover {
  background: var(--text-secondary);
}
.chat-trigger-icon { position: relative; }
.chat-trigger-lock {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.chat-trigger-lock .material-icons {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ================================================================
   GDPR CONSENT MODAL — Ask Ace
   ================================================================ */

/* Full-screen backdrop — sits above everything including the chat widget */
.consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: consent-backdrop-in 0.22s ease;
}
@keyframes consent-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Modal card */
.consent-modal {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.30);
  padding: 28px 28px 22px;
  width: 100%;
  max-width: 460px;
  animation: consent-modal-in 0.25s cubic-bezier(0.34, 1.36, 0.64, 1);
}
@keyframes consent-modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Header row — avatar + title */
.consent-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.consent-modal-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.consent-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.consent-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}
.consent-modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* Short intro paragraph */
.consent-modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 16px;
  line-height: 1.55;
}

/* Privacy notice box */
.consent-notice {
  display: flex;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 20px;
}
.consent-notice-icon {
  font-size: 20px;
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 1px;
}
.consent-notice-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.consent-notice-text strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 4px;
}
.consent-notice-text p { margin: 0 0 6px; }
.consent-notice-text p:last-child { margin-bottom: 0; }
.consent-notice-text ul {
  margin: 4px 0 8px 16px;
  padding: 0;
}
.consent-notice-text ul li { margin-bottom: 2px; }
.consent-notice-text a {
  color: var(--primary-text);
  text-decoration: underline;
}
.consent-notice-text a:hover { opacity: 0.8; }

/* Action buttons */
.consent-modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.consent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}
.consent-btn .material-icons { font-size: 18px; }
.consent-btn--accept {
  background: var(--primary);
  color: #fff;
  flex: 1;
  box-shadow: 0 2px 8px rgba(51, 177, 235, 0.30);
}
.consent-btn--accept:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(51, 177, 235, 0.40);
  transform: translateY(-1px);
}
.consent-btn--decline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 18px;
}
.consent-btn--decline:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* Legal small print */
.consent-modal-legal {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

/* ── Dark mode overrides ── */
[data-theme="dark"] .consent-modal {
  background: #1a1a1a;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
[data-theme="dark"] .consent-notice {
  background: #242424;
  border-color: #333;
  border-left-color: var(--primary);
}
[data-theme="dark"] .consent-btn--decline {
  border-color: #444;
  color: var(--text-muted);
}
[data-theme="dark"] .consent-btn--decline:hover {
  background: #2a2a2a;
  color: var(--text);
}

/* ── Mobile ── */
@media (max-width: 500px) {
  .consent-modal {
    padding: 22px 18px 18px;
    border-radius: 12px;
  }
  .consent-modal-actions {
    flex-direction: column;
  }
  .consent-btn--accept,
  .consent-btn--decline {
    width: 100%;
  }
}

/* ── Dark mode overrides ── */
[data-theme="dark"] .chat-panel {
  border-color: var(--border);
  box-shadow: 0 12px 48px rgba(0,0,0,.45);
}
[data-theme="dark"] .chat-msg--bot .chat-msg-bubble {
  background: #1e1e1e;
  border-color: var(--border);
}
[data-theme="dark"] .chat-ref-link {
  background: #1e1e1e;
  border-color: var(--border);
}
[data-theme="dark"] .chat-ref-link:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
}
[data-theme="dark"] .chat-input {
  background: #1e1e1e;
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .chat-panel-footer {
  background: #181818;
}

/* ── Mobile ── */
@media (max-width: 500px) {
  .chat-widget {
    bottom: 16px;
    right: 16px;
  }
  .chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    border-radius: 14px;
  }
}

/* ================================================================
   REDUCED MOTION (WCAG 2.3.3)
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
