/* Knowledge Base - Minimal Black & White Design */

/* ─── View Transitions opt-in ──────────────────────────────────
   Cross-document navigations between the Knowledge surface and the
   Support portal share the same SSR-emitted header, but each click is
   still a full document swap (Express renders a fresh HTML doc per
   route). Opting in to the View Transitions API gives the browser
   permission to crossfade between the two documents instead of
   instant-painting the new one, hiding the header flicker.

   The named transition on `.kb-header` tells the browser to treat the
   header as the same logical element across both pages — it morphs in
   place rather than fading out + in. The center nav appears to stay
   put while the page body underneath swaps.

   Supported in Chromium and Safari TP. Firefox no-ops the @rule and
   falls back to today's instant navigation — no regression. */
@view-transition { navigation: auto; }

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --kb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --kb-font-family: var(--kb-font);
  --kb-bg: #ffffff;
  --kb-text: #1a1a1a;
  --kb-text-muted: #666666;
  --kb-border: #e5e5e5;
  --kb-hover: #f5f5f5;
  --kb-active: #1a1a1a;
  --kb-active-text: #ffffff;
}

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

body {
  font-family: var(--kb-font-family);
  line-height: 1.6;
  color: var(--kb-text);
  background-color: var(--kb-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.kb-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* AI Assistant is an overlay panel — it sits on top of the page and
   does NOT reflow the layout regardless of viewport width or resize-
   handle drags. The page underneath stays at its natural width and
   remains scrollable behind the panel.
   `ask-assistant.js` still toggles `data-kb-assistant-open` on <body>
   (and keeps the `--kb-assistant-width` var in sync) so other rules
   can react to the open state — currently just hiding the Ask
   Assistant pill below. The var itself is unused by layout now. */
body[data-kb-assistant-open="true"] .kb-ask-pill {
  display: none;
}

.kb-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--kb-bg);
  border-bottom: 1px solid var(--kb-border);
  /* Stable identity across document navigations — the View Transitions
     API morphs the header between routes rather than fading old/new,
     so the center nav links appear to stay in place. Pair with
     @view-transition { navigation: auto } above. */
  view-transition-name: kb-header;
}

.kb-header-inner {
  /* Full-viewport header — logo flush-left, actions flush-right, nav
     absolutely centered against the viewport so it doesn't shift when
     the left cluster's width changes (e.g. hamburger present on KB
     article pages, absent on KB home / support portal). */
  position: relative;
  padding: 0 24px;
  height: 64px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}

.kb-header-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.kb-header-cluster--left {
  justify-self: start;
}

.kb-header-cluster--right {
  justify-self: end;
}

/* Center cluster — primary surface links (Knowledge / Tickets) +
   admin-defined nav links (kbNavLinks). Lives in the grid's center `1fr`
   column (the header is `grid: auto 1fr auto`), centered within the space
   BETWEEN the left/right clusters. This is overlap-proof by construction:
   the grid reserves the clusters' space first, so the nav can never paint
   under the search/actions — the previous absolute-centering (relative to
   the viewport, ignoring cluster widths) caused exactly that bug on
   mid-width screens. If the links don't fit they scroll within the column. */
.kb-header-nav {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.kb-header-nav::-webkit-scrollbar {
  display: none;
}

.kb-header-nav a {
  position: relative;
  color: var(--kb-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  /* Reserve the pill geometry on every link so swapping the active
     state in/out doesn't reflow the row. The active link gets a
     visible outline; inactive links keep the same padding with a
     transparent border. */
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.kb-header-nav a:hover {
  color: var(--kb-text);
}

.kb-header-nav a[aria-current="page"] {
  color: var(--kb-text);
  border-color: currentColor;
}

/* "Unseen ticket update" indicator — a red dot top-right of the
   nav link. Toggled by kb.js setting [data-has-update="true"] on
   the link after polling /api/ticket-portal/.../has-updates.
   Pulses by default; reduced-motion users get a static dot. */
.kb-header-nav a[data-has-update="true"]::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 2px var(--kb-bg, #ffffff);
  animation: kb-nav-dot-pulse 1.5s ease-in-out infinite;
}

@keyframes kb-nav-dot-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

@media (prefers-reduced-motion: reduce) {
  .kb-header-nav a[data-has-update="true"]::after {
    animation: none;
  }
}

.kb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--kb-text);
  font-weight: 600;
  font-size: 18px;
}

.kb-logo img {
  height: 32px;
  width: auto;
}

/* Shared pill base — search + Ask Assistant share this shape. */
.kb-toolbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9999px;
  border: 1px solid var(--kb-border);
  background: var(--kb-hover);
  color: var(--kb-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.kb-toolbar-pill:hover {
  background: var(--kb-bg);
  border-color: var(--kb-text-muted);
  color: var(--kb-text);
}

.kb-pill-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.kb-pill-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--kb-text-muted);
}

/* Mac default. The kb script sets data-platform="other" on non-Mac. */
.kb-pill-shortcut::before {
  content: "⌘";
}
[data-platform="other"] .kb-pill-shortcut::before {
  content: "Ctrl ";
}
.kb-pill-shortcut::after {
  content: attr(data-shortcut);
}

/* Language switcher — a JS-free native <details> dropdown. The closed pill
   shows the current locale's flag + a caret; opening reveals an anchored menu
   of every supported language. Mirrors the .kb-copy-page-menu popover so the
   visual language matches. */
.kb-lang-switcher {
  position: relative;
  flex-shrink: 0;
  /* The <details> base would otherwise stretch; keep it pill-shaped. */
  height: 36px;
  padding: 0;
  overflow: visible;
}
.kb-lang-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  list-style: none; /* strip the default disclosure triangle (Firefox) */
  cursor: pointer;
}
.kb-lang-summary::-webkit-details-marker {
  display: none; /* strip the default disclosure triangle (WebKit) */
}
.kb-lang-summary:focus-visible {
  outline: 2px solid var(--kb-active);
  outline-offset: 2px;
}
.kb-lang-flag {
  font-size: 16px;
  line-height: 1;
}
/* CSS-drawn caret — a small chevron that flips when the menu is open. */
.kb-lang-caret {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-top: -3px;
  transition: transform 0.15s ease;
}
.kb-lang-switcher[open] .kb-lang-caret {
  transform: rotate(-135deg);
  margin-top: 2px;
}
.kb-lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 50;
}
.kb-lang-switcher:not([open]) .kb-lang-menu {
  display: none;
}
.kb-lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--kb-text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.kb-lang-option:hover,
.kb-lang-option:focus-visible {
  background: var(--kb-hover);
  outline: none;
}
.kb-lang-option .kb-lang-name {
  flex: 1;
}
/* Green checkmark on the active language, echoing the design reference. */
.kb-lang-option[aria-current="true"]::after {
  content: "✓";
  color: #15803d;
  font-weight: 700;
}

/* Search pill — overrides for the input + results dropdown.
   Compact at rest (it doesn't need to be big until engaged); it grows on
   focus. The smaller resting width also keeps the absolutely-centered nav
   from colliding with the right cluster on mid-width viewports. */
.kb-search-pill {
  position: relative;
  width: 180px;
  padding: 0 8px 0 12px;
}
.kb-search-pill:focus-within {
  background: var(--kb-bg);
  border-color: var(--kb-text);
  width: 320px;
}

.kb-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--kb-text);
  height: 100%;
  min-width: 0;
}
.kb-search-input::placeholder {
  color: var(--kb-text-muted);
}

.kb-search-icon {
  color: var(--kb-text-muted);
}

/* Hide the shortcut chip when the search has focus — let the text breathe. */
.kb-search-pill:focus-within .kb-pill-shortcut {
  display: none;
}

/* Ask Assistant pill — same base, distinct accent. */
.kb-ask-pill {
  border-color: var(--kb-border);
}
.kb-ask-pill .kb-pill-icon {
  color: var(--kb-text);
}

/* Ask Assistant modal — built on demand by ask-assistant.js. */
.kb-ask-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 300;
}

.kb-ask-modal {
  width: 100%;
  max-width: 420px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 24px;
}

.kb-ask-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--kb-text);
  margin-bottom: 12px;
}

.kb-ask-modal-body {
  margin: 0 0 20px;
  color: var(--kb-text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.kb-ask-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.kb-ask-btn {
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.kb-ask-btn--ghost {
  background: transparent;
  border-color: var(--kb-border);
  color: var(--kb-text-muted);
}
.kb-ask-btn--ghost:hover {
  border-color: var(--kb-text-muted);
  color: var(--kb-text);
}

.kb-ask-btn--primary {
  background: var(--kb-text);
  color: var(--kb-bg);
}
.kb-ask-btn--primary:hover {
  opacity: 0.9;
}

.kb-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.kb-search-results.active {
  display: block;
}

.kb-search-result {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--kb-text);
  border-bottom: 1px solid var(--kb-border);
  transition: background 0.15s;
}

.kb-search-result:last-child {
  border-bottom: none;
}

.kb-search-result:hover {
  background: var(--kb-hover);
}

.kb-search-result-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
}

.kb-search-result-desc {
  font-size: 12px;
  color: var(--kb-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--kb-text);
}

/* Main Layout — spans the viewport. Sidebar sits at the left edge,
   content column is centered inside its (now wider) flex slot. */
.kb-main {
  flex: 1;
  display: flex;
  width: 100%;
}

/* Sidebar */
.kb-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--kb-border);
  padding: 24px;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  overflow-y: auto;
}

/* The portal nav drawer only exists as a mobile drawer — never on desktop,
   where the base .kb-sidebar styles above would otherwise show it inline. */
.kb-sidebar--nav {
  display: none;
}

.kb-sidebar-overlay {
  display: none;
}

/* Home/welcome pages don't render the sidebar at all (no <aside>, no
   hamburger), so .kb-main has nothing on the left. Ensure the content
   slot fills the remaining width without inheriting the sidebar gap. */
.kb-main--no-sidebar .kb-content {
  width: 100%;
}

.kb-category {
  margin-bottom: 8px;
}

.kb-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
}

.kb-category-header:hover {
  background: var(--kb-hover);
}

.kb-category-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--kb-text);
}

.kb-category-icon {
  width: 16px;
  height: 16px;
  color: var(--kb-text-muted);
  transition: transform 0.2s;
}

.kb-category.collapsed .kb-category-icon {
  transform: rotate(-90deg);
}

.kb-category-content {
  overflow: hidden;
  transition: max-height 0.25s ease;
  max-height: 2000px;
}

.kb-category.collapsed .kb-category-content {
  max-height: 0;
}

.kb-article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.kb-article-link {
  display: block;
  padding: 8px 12px 8px 24px;
  font-size: 14px;
  color: var(--kb-text-muted);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
}

.kb-article-link:hover {
  background: var(--kb-hover);
  color: var(--kb-text);
}

.kb-article-link.active {
  background: var(--kb-active);
  color: var(--kb-active-text);
  font-weight: 500;
}

/* Content */
.kb-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px;
  /* Centered reading column inside the wide layout slot. 1100px keeps
     prose at a comfortable ~85ch line length while giving content blocks
     (forms, scheduler, video, multi-column rows) room to breathe on wide
     displays. Below 1024px the cap drops entirely (see media query). */
  max-width: 1100px;
  margin: 0 auto;
}

.kb-breadcrumb {
  font-size: 12px;
  color: var(--kb-text-muted);
  margin-bottom: 24px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kb-title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  color: var(--kb-text);
}

/* Title row holds the article title and the Copy page control side by
   side. On narrow viewports the control wraps under the title. */
.kb-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.kb-title-row .kb-title {
  flex: 1 1 auto;
  min-width: 0;
}

/* Copy page split-button — main action + chevron + dropdown menu. */
.kb-copy-page {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  margin-top: 4px;
}
.kb-copy-page-main,
.kb-copy-page-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--kb-bg);
  color: var(--kb-text);
  border: 1px solid var(--kb-border);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.kb-copy-page-main {
  gap: 6px;
  padding: 7px 10px 7px 10px;
  border-radius: 8px 0 0 8px;
  border-right: 0;
}
.kb-copy-page-chevron {
  padding: 7px 8px;
  border-radius: 0 8px 8px 0;
}
.kb-copy-page-main:hover,
.kb-copy-page-chevron:hover {
  background: var(--kb-hover);
}
.kb-copy-page-main:focus-visible,
.kb-copy-page-chevron:focus-visible {
  outline: 2px solid var(--kb-active);
  outline-offset: 2px;
}
.kb-copy-page-icon-success {
  display: none;
}
.kb-copy-page.is-copied .kb-copy-page-icon-default {
  display: none;
}
.kb-copy-page.is-copied .kb-copy-page-icon-success {
  display: inline-block;
  color: #15803d;
}

/* Dropdown menu */
.kb-copy-page-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 50;
}
.kb-copy-page-menu[hidden] {
  display: none;
}
.kb-copy-page-item {
  display: flex;
  align-items: flex-start;
  width: 100%;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--kb-text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.kb-copy-page-item:hover,
.kb-copy-page-item:focus-visible {
  background: var(--kb-hover);
  outline: none;
}
.kb-copy-page-item > svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--kb-text-muted);
}
.kb-copy-page-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kb-copy-page-item-title {
  font-weight: 500;
  color: var(--kb-text);
}
.kb-copy-page-item-sub {
  font-size: 12px;
  color: var(--kb-text-muted);
}
.kb-copy-page-item-arrow {
  display: inline-block;
  margin-left: 2px;
  color: var(--kb-text-muted);
  font-size: 11px;
}

/* Signed-in user menu — three-dot trigger + popover that consolidates
   the visitor's email, the theme toggle, and Sign out. Mounted by
   auth-slot.js into #kb-auth-slot when /me returns a user. Mirrors
   the .kb-copy-page-menu pattern so the visual language matches. */
.kb-user-menu-wrap {
  position: relative;
}
.kb-user-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--kb-text);
  cursor: pointer;
}
.kb-user-menu-trigger:hover,
.kb-user-menu-trigger:focus-visible {
  background: var(--kb-hover);
  outline: none;
}
.kb-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 50;
}
.kb-user-menu[hidden] {
  display: none;
}
.kb-user-menu-email {
  padding: 8px 10px 6px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--kb-text-muted);
  word-break: break-all;
}
.kb-user-menu-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--kb-border);
}
.kb-user-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--kb-text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.kb-user-menu-item:hover,
.kb-user-menu-item:focus-visible {
  background: var(--kb-hover);
  outline: none;
}
.kb-user-menu-item > svg {
  flex-shrink: 0;
  color: var(--kb-text-muted);
}

@media (max-width: 640px) {
  .kb-copy-page-main .kb-copy-page-label {
    display: none;
  }
  .kb-copy-page-main {
    padding: 7px 9px;
  }
}

.kb-description {
  font-size: 18px;
  color: var(--kb-text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
}

/* Prose Content */
.kb-prose {
  font-size: 16px;
  line-height: 1.75;
}

.kb-prose h2 {
  font-size: 28px;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--kb-border);
  scroll-margin-top: 80px;
}

/* Section title injected by the SSR for Form/Scheduler embeds that have
   a wrapperTitle set. The embed sits flush beneath, so collapse the
   bottom margin to avoid double-air; the embed's own top margin still
   applies. */
.kb-prose .kb-block-section-title {
  margin-bottom: 8px;
}
.kb-prose .kb-block-section-title + .ec-form,
.kb-prose .kb-block-section-title + .ec-scheduler,
.kb-prose .kb-block-section-title + [data-ec-block] {
  margin-top: 16px;
}

/* Optional subtext line under the section title, rendered by the
   form/scheduler hydrators when wrapperBody is set. */
.ec-block-wrapper-body {
  font-size: 15px;
  line-height: 1.55;
  color: var(--kb-text-muted);
  margin: 0 0 16px;
}

/* "Was this page helpful?" feedback section — bottom of every article.
   Posts to /api/public/knowledge/feedback; behavior lives in /knowledge/feedback.js. */
.kb-feedback {
  margin-top: 56px;
  padding: 24px;
  border-top: 1px solid var(--kb-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.kb-feedback-prompt {
  font-size: 15px;
  font-weight: 500;
  color: var(--kb-text);
}
.kb-feedback-actions {
  display: inline-flex;
  gap: 8px;
}
.kb-feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--kb-bg);
  color: var(--kb-text);
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.kb-feedback-btn:hover {
  background: var(--kb-hover);
}
.kb-feedback-btn:focus-visible {
  outline: 2px solid var(--kb-link-color, var(--kb-active));
  outline-offset: 2px;
}
.kb-feedback-btn.is-selected {
  background: var(--kb-link-color, var(--kb-active));
  color: var(--kb-bg);
  border-color: var(--kb-link-color, var(--kb-active));
}
.kb-feedback-thanks {
  font-size: 13px;
  color: var(--kb-text-muted);
}

.kb-prose h3 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 12px;
  scroll-margin-top: 80px;
}

.kb-prose h4 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
  scroll-margin-top: 80px;
}

.kb-prose p {
  margin-bottom: 16px;
}

.kb-prose ul,
.kb-prose ol {
  margin-bottom: 16px;
  padding-left: 28px;
}

.kb-prose li {
  margin-bottom: 8px;
}

.kb-prose strong {
  font-weight: 600;
}

.kb-prose code {
  background: var(--kb-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Monaco', 'Menlo', monospace;
}

.kb-prose pre {
  background: #1a1a1a;
  color: #f5f5f5;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 24px 0;
}

.kb-prose pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  color: inherit;
}

.kb-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 24px 0;
}

.kb-prose a {
  color: var(--kb-text);
  text-decoration: underline;
}

.kb-prose a:hover {
  text-decoration: none;
}

.kb-prose blockquote {
  border-left: 3px solid var(--kb-text);
  padding-left: 16px;
  margin: 24px 0;
  color: var(--kb-text-muted);
  font-style: italic;
}

.kb-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
}

.kb-prose th,
.kb-prose td {
  border: 1px solid var(--kb-border);
  padding: 10px 14px;
  text-align: left;
}

.kb-prose th {
  background: var(--kb-hover);
  font-weight: 600;
}

/* TOC */
.kb-toc {
  width: 220px;
  flex-shrink: 0;
  padding: 40px 24px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.kb-toc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--kb-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.kb-toc-list {
  list-style: none;
  padding: 0 0 0 16px;
  margin: 0;
  position: relative;
}

/* Vertical track line that the indicator dot rides along. Sits inside
   the list's left padding (16px in). */
.kb-toc-list::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--kb-border);
}

/* Sliding indicator dot — the scrollspy in kb.js sets --kb-toc-dot-y to
   the active link's center offset within the list. Snug transition so
   it reads as a deliberate slide, not a teleport. */
.kb-toc-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--kb-link-color, var(--kb-active, #1a1a1a));
  transform: translateY(var(--kb-toc-dot-y, 0));
  transition: transform 200ms ease-out, opacity 200ms ease-out;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
.kb-toc-list.has-active .kb-toc-indicator {
  opacity: 1;
}

.kb-toc-link {
  display: block;
  padding: 6px 0;
  font-size: 13px;
  color: var(--kb-text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

/* H3-level entries sit one notch further in so the parent H2 reads as a
   section header. */
.kb-toc-link--sub {
  padding-left: 16px;
  font-size: 12.5px;
}

.kb-toc-link:hover {
  color: var(--kb-text);
}

.kb-toc-link.active {
  color: var(--kb-link-color, var(--kb-text));
  font-weight: 500;
}
.kb-toc-link--sub.active {
  font-weight: 500;
}

/* Empty State */
.kb-empty {
  text-align: center;
  padding: 80px 24px;
}

.kb-empty-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 12px;
}

.kb-empty-desc {
  color: var(--kb-text-muted);
}

/* ── Public-portal sign-in gate (centered modal over a background) ──
   Standalone layout for generateKBGatePage (server/kb-ssr.ts) — no KB
   chrome. Card uses --kb-* theme tokens so it flips in dark mode. */
.kb-gate-body {
  margin: 0;
}
.kb-gate {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  /* Default background when no image/color is configured: the KB theme bg. */
  background: var(--kb-bg);
}
/* Portal login reuses the gate card but renders as a React component
   inside the SSR portal shell (mounted in .portal-main, behind the
   header) — not as a standalone document like generateKBGatePage. The
   --portal modifier breaks it out of that flow to cover the viewport
   and the header, matching the standalone gate's full-screen feel. */
.kb-gate.kb-gate--portal {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
}
.kb-gate-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
.kb-gate-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 10px 10px -5px rgba(0, 0, 0, 0.06);
  padding: 40px 32px;
  text-align: center;
}
.kb-gate-logo {
  height: 40px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  margin: 0 auto 20px;
  display: block;
}
.kb-gate-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--kb-text);
  margin: 0 0 8px;
}
.kb-gate-desc {
  color: var(--kb-text-muted);
  margin: 0;
  line-height: 1.5;
}
/* The signin form / links sit below the desc. The form carries its own
   inline flex layout; this just gives it room and a sensible width. */
.kb-gate-card form {
  margin-top: 24px;
  text-align: left;
}
@media (max-width: 480px) {
  .kb-gate-card {
    padding: 32px 20px;
    border-radius: 14px;
  }
}

/* Mobile */
@media (max-width: 1024px) {
  .kb-toc {
    display: none;
  }
  
  .kb-content {
    max-width: none;
    padding: 32px 24px;
  }
}

/* Tablet — let the center nav pack to the start of its column and scroll
   horizontally if the links overflow the tighter space. (The nav is a grid
   child now, so it's already overlap-proof; this just trades centering for
   left-packing where the column gets narrow.) */
@media (max-width: 1023px) {
  .kb-header-nav {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .kb-menu-btn {
    display: block;
  }

  /* Center nav collapses into the sidebar drawer at mobile widths. */
  .kb-header-nav,
  .kb-ask-pill,
  .kb-theme-toggle {
    display: none;
  }

  /* Search collapses to an icon-only pill; tapping expands the input. */
  .kb-search-pill {
    width: 40px;
    padding: 0;
    justify-content: center;
  }
  .kb-search-pill .kb-search-input,
  .kb-search-pill .kb-pill-shortcut {
    display: none;
  }
  .kb-search-pill:focus-within {
    width: 100%;
    padding: 0 12px;
  }
  .kb-search-pill:focus-within .kb-search-input {
    display: block;
  }

  .kb-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    z-index: 200;
    background: var(--kb-bg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--kb-border);
    padding-top: 64px;
  }
  
  .kb-sidebar.open {
    transform: translateX(0);
  }
  
  .kb-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
  }
  
  .kb-sidebar-overlay.active {
    display: block;
  }

  /* Portal nav drawer: participates in the slide-in drawer at mobile only. */
  .kb-sidebar--nav {
    display: block;
  }

  .kb-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
  }
  .kb-sidebar-nav a {
    display: block;
    padding: 12px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--kb-text);
    font-size: 15px;
    font-weight: 500;
  }
  .kb-sidebar-nav a:hover {
    background: var(--kb-hover);
  }
  .kb-sidebar-nav a[aria-current="page"] {
    background: var(--kb-hover);
    color: var(--kb-text);
  }
  /* Theme toggle sits inline as a full-width row inside the drawer. The bare
     `.kb-theme-toggle { display: none }` above hides the header copy on mobile;
     this more-specific selector wins it back for the drawer copy. */
  .kb-sidebar-nav .kb-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 8px;
    padding: 8px;
  }

  .kb-title {
    font-size: 28px;
  }
  
  .kb-content {
    padding: 24px 16px;
  }
}

/* Print */
@media print {
  .kb-header,
  .kb-sidebar,
  .kb-toc,
  .kb-menu-btn {
    display: none !important;
  }
  
  .kb-content {
    max-width: none;
    padding: 0;
  }
}

/* Theme Toggle Button */
.kb-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.kb-theme-toggle:hover {
  background: var(--kb-hover);
}

.kb-theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--kb-text);
}

.kb-theme-toggle .kb-theme-icon-light {
  display: none;
}

.kb-theme-toggle .kb-theme-icon-dark {
  display: block;
}

/* Auth slot — sign-in link / signed-in email + sign out, populated
   client-side by /knowledge/auth-slot.js. Starts empty so the SSR HTML can be
   cached tenant-wide without leaking visitor identity. */
.kb-auth-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 32px;
}

.kb-auth-slot:empty {
  display: none;
}

.kb-auth-email {
  font-size: 13px;
  color: var(--kb-text);
  opacity: 0.75;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "Login" — a themed primary pill. Solid ink/themed background with the
   inverse text color, so it reads as the header's primary CTA and flips
   with the tenant's light/dark theme via the --kb-* tokens. */
.kb-auth-link {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--kb-bg);
  background: var(--kb-text);
  border: 1px solid var(--kb-text);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease, background 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.kb-auth-link:hover {
  opacity: 0.88;
}

.kb-auth-link:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 768px) {
  .kb-auth-email {
    display: none;
  }
}

/* Dark Mode */
.dark {
  --kb-bg: #0a0a0a;
  --kb-text: #fafafa;
  --kb-text-muted: #a1a1a1;
  --kb-border: #262626;
  --kb-hover: #1a1a1a;
  --kb-active: #fafafa;
  --kb-active-text: #0a0a0a;
}

.dark .kb-theme-toggle .kb-theme-icon-light {
  display: block;
}

.dark .kb-theme-toggle .kb-theme-icon-dark {
  display: none;
}

.dark .kb-search-results {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.dark .kb-lang-menu {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dark .kb-category-card {
  background: #141414;
  border-color: var(--kb-border);
}

.dark .kb-category-card:hover {
  background: #1a1a1a;
  border-color: #404040;
}

.dark .kb-toc {
  background: #141414;
  border-color: var(--kb-border);
}

.dark .kb-sidebar-overlay {
  background: rgba(0,0,0,0.6);
}

.dark pre,
.dark code {
  background: #1a1a1a;
}

.dark blockquote {
  border-left-color: #404040;
  background: #141414;
}

.dark table th {
  background: #1a1a1a;
}

.dark table td,
.dark table th {
  border-color: var(--kb-border);
}

/* ─────────────────────────────────────────────────────────────
   Content blocks
   Hydrated by /knowledge/blocks.js. Form/Scheduler render the embedded
   widget directly with no wrapper chrome — the widget owns its
   own border and background. Video and Checklist get themed
   chrome via these tokens.
   ───────────────────────────────────────────────────────────── */

/* Shared spacing — every block gets vertical breathing room. */
.ec-video,
.ec-embed,
.ec-form,
.ec-scheduler,
.ec-checklist,
.ec-rawhtml {
  margin: 24px auto;
}

/* Raw HTML — sandboxed iframe owns its own chrome, so the container is a
   bare full-width block with no background or border. The iframe auto-sizes
   via the raw-html-embed-resize postMessage handler in blocks.js. */
.ec-rawhtml {
  width: 100%;
}
.ec-rawhtml iframe {
  display: block;
  width: 100%;
  border: 0;
}

/* Columns — pure CSS grid. data-col-count drives template-columns.
   No hydrator needed; the children are real HTML, sanitized into the
   prose pipeline like any other block. Collapses to a single stack on
   narrow screens so phones get one column in author order. */
.kb-prose [data-ec-columns] {
  display: grid;
  gap: 24px;
  margin: 24px 0;
  align-items: start;
}
.kb-prose [data-ec-columns][data-col-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.kb-prose [data-ec-columns][data-col-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.kb-prose [data-ec-columns][data-col-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.kb-prose [data-ec-column] {
  min-width: 0;
}
.kb-prose [data-ec-column] > *:first-child {
  margin-top: 0;
}
.kb-prose [data-ec-column] > *:last-child {
  margin-bottom: 0;
}
@media (max-width: 767px) {
  .kb-prose [data-ec-columns],
  .kb-prose [data-ec-columns][data-col-count="2"],
  .kb-prose [data-ec-columns][data-col-count="3"],
  .kb-prose [data-ec-columns][data-col-count="4"] {
    grid-template-columns: 1fr;
  }
}

/* Video */
.ec-video {
  max-width: 100%;
}
.ec-video-aspect {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.ec-video-aspect iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.ec-video-caption {
  text-align: center;
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--kb-text-muted);
}

/* Embed — mirrors Video for iframe (URL) mode; ec-embed-html is a plain
   normal-flow container for sanitized author-pasted HTML (no aspect box). */
.ec-embed {
  max-width: 100%;
}
.ec-embed-aspect {
  position: relative;
  width: 100%;
  height: 0;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.ec-embed-aspect iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.ec-embed-caption {
  text-align: center;
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--kb-text-muted);
}
.ec-embed-html {
  max-width: 100%;
}
.ec-embed-html iframe {
  max-width: 100%;
}

/* Form / Scheduler — no wrapper chrome. The embedded widget IS the chrome. */
.ec-form,
.ec-scheduler {
  max-width: 640px;
}
.ec-scheduler { max-width: 760px; }
.ec-form iframe,
.ec-scheduler iframe {
  width: 100%;
  border: 0;
  display: block;
  background: transparent;
}
.ec-form-title,
.ec-scheduler-title {
  margin: 0 0 8px;
  font-weight: 600;
  text-align: center;
  color: var(--kb-text);
}
.ec-form-body,
.ec-scheduler-body {
  margin: 0 0 12px;
  text-align: center;
  color: var(--kb-text-muted);
}

/* Checklist */
.ec-checklist {
  max-width: 720px;
}
.ec-checklist-title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--kb-text);
}
.ec-checklist-body {
  margin: 0 0 16px;
  color: var(--kb-text-muted);
}
.ec-checklist-section {
  margin: 12px 0 8px;
  color: var(--kb-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}
.ec-checklist-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ec-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  background: var(--kb-bg);
  margin-bottom: 8px;
  transition: opacity 0.15s ease;
}
.ec-checklist-item[data-checked="true"] {
  opacity: 0.55;
}
.ec-checklist-item input[type="checkbox"] {
  margin-top: 4px;
  accent-color: var(--kb-text);
}
.ec-checklist-item-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--kb-text);
  font-weight: 600;
}
.ec-checklist-item[data-checked="true"] .ec-checklist-item-heading {
  text-decoration: line-through;
}
.ec-checklist-item-description {
  margin: 2px 0 0;
  color: var(--kb-text-muted);
  font-size: 14px;
}
.ec-checklist-required {
  color: #e23d3d;
  font-weight: 700;
}
.dark .ec-checklist-item {
  background: #141414;
  border-color: var(--kb-border);
}

/* FAQ — server-rendered <details><summary>. */
.ec-faq {
  max-width: 720px;
  margin: 24px auto;
}
.ec-faq-item {
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  background: var(--kb-bg);
  margin-bottom: 8px;
}
.ec-faq-item summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--kb-text);
  list-style: none;
}
.ec-faq-item summary::-webkit-details-marker { display: none; }
.ec-faq-item summary::before {
  content: "▸";
  display: inline-block;
  width: 20px;
  color: var(--kb-text-muted);
  transition: transform 0.15s ease;
}
.ec-faq-item[open] summary::before {
  transform: rotate(90deg);
}
.ec-faq-answer {
  padding: 0 16px 16px 36px;
  color: var(--kb-text);
}
.ec-faq-answer p { margin: 0 0 8px; }
.ec-faq-answer p:last-child { margin: 0; }
.dark .ec-faq-item {
  background: #141414;
}
