:root {
  /* Brand roles (dark default) to match brand guide */
  --bg: #0B1622;
  /* brand ink-900 */
  --surface: #0f1d2b;
  /* card/surface */
  --surface-2: #122335;
  /* elevated */
  --fg: #e8f0f7;
  /* text */
  --muted: #b3c0cc;
  /* text-muted */
  --border: #2b3b4f;
  /* borders */
  --focus: #89f3f8;
  /* focus ring */
  --link: #7de0e6;
  /* link color */

  /* Brand accent examples */
  --teal-600: #1ab1b9;
  --orange-600: #e0582b;
}

:root[data-theme="light"] {
  --bg: #f7fbfd;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --fg: #0b1622;
  --muted: #4a5a6a;
  --border: #d6e0ea;
  --focus: #067a82;
  --link: #0b8f97;
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--fg)
}

/* Text utilities */
.muted {
  color: var(--muted);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  filter: brightness(1.1);
}


.site-header {
  width: 100%;
  display: grid;
  /* order: hamburger, logo, title, actions */
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-weight: 600;
  color: var(--fg);
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--teal-600);
  box-shadow: 8px 0 0 var(--orange-600), 16px 0 0 var(--yellow-500);
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
}

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(88vw, 320px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  padding: 16px; /* space for header height */
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-100%);
  transition: transform 200ms ease;
  z-index: 60;
}

.site-nav a {
  color: var(--fg);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}
.site-nav a .nav-link-content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.site-nav a .nav-icon svg {
  display: block;
}

.site-nav a:hover {
  background: var(--surface-2);
}

.site-nav a.active,
.site-nav a[aria-current="page"] {
  background: color-mix(in hsl, var(--teal-600) 22%, transparent);
  outline: 1px solid color-mix(in hsl, var(--teal-600) 45%, var(--border));
}

/* Hamburger is always visible; nav is off-canvas (handled below). */
.menu-toggle { display: inline-flex; }
/* Ensure off-canvas container participates in layout; visibility via transform */
#primaryNav { display: flex; }

.site-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Hide header controls on mobile; show from 820px up */
@media (max-width: 819px) {
  .site-actions { display: none; }
}
@media (min-width: 820px) {
  .site-actions { display: inline-flex; }
}

/* Segmented theme toggle (header and nav) */
.segmented.theme-toggle {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.theme-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.theme-toggle label {
  margin: 0;
  text-align: center;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.theme-toggle .seg-slider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: calc(50% - 4px);
  left: 4px;
  background: color-mix(in hsl, var(--teal-600) 18%, transparent);
  border: 1px solid color-mix(in hsl, var(--teal-600) 40%, var(--border));
  border-radius: 8px;
  transition: transform 160ms ease;
}
.theme-toggle input[value="dark"]:checked ~ .seg-slider { transform: translateX(100%); }
.theme-toggle input:focus-visible + label { outline: 2px solid color-mix(in hsl, var(--teal-600) 60%, transparent); outline-offset: 2px; }

/* Off-canvas open state */
.nav-open #primaryNav { transform: translateX(0); }
.site-nav .nav-sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.site-nav .nav-controls {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

/* nav segmented inherits the generic theme-toggle rules */

.site-nav .nav-signout {
  text-align: left;
}

/* Backdrop for off-canvas */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 55;
}
.nav-open #navBackdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Header inline SVG logo sizing/color */
.site-header .site-logo {
  height: 38px;
  display: block;
  color: var(--fg);
}

.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;
}

.kb-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10
}

.kb-brand {
  font-weight: 700
}

.kb-nav a {
  color: var(--fg);
  text-decoration: none;
  margin: 0 8px;
  padding: 6px 10px;
  border-radius: 6px;
}

.kb-nav a:hover {
  background: var(--surface-2)
}

.kb-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px
}

.card h3 {
  margin: 0 0 6px 0
}

.card p {
  margin: 0;
  color: var(--muted)
}

.hero {
  padding: 32px 0
}

.hero h1 {
  margin: 0 0 8px 0;
  font-size: 32px
}

.kb-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  padding: 18px;
  text-align: center;
  margin-top: 40px
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted)
}

/* Search highlight */
mark {
  background: #e0582b;
  background: color-mix(in hsl, var(--orange-600) 100%, transparent);
  color: white;
  padding: 0 2px;
  border-radius: 3px;
}

/* Breadcrumbs */
.kb-breadcrumbs {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.kb-breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kb-breadcrumbs li {
  display: inline-flex;
  align-items: center;
}

.kb-breadcrumbs li+li::before {
  content: "›";
  margin: 0 6px;
  color: var(--muted);
}

.kb-breadcrumbs a {
  color: var(--fg);
  text-decoration: none;
}

.kb-breadcrumbs [aria-current="page"] span {
  color: var(--fg);
}

/* Buttons aligned with brand tokens */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary {
  background: var(--teal-600);
  color: #072a2c;
  border-color: rgba(0, 0, 0, .12);
}

.btn-secondary {
  background: var(--orange-600);
  color: #2b110a;
  border-color: rgba(0, 0, 0, .12);
}

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}

/* Auth user menu */
.auth-user {
  position: relative;
  margin-left: 8px;
}
.auth-user-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: default;
}
.auth-user-summary:hover {
  background: var(--surface-2);
}
.auth-user-summary img {
  display: block;
  border-radius: 50%;
}
.auth-name {
  color: var(--fg);
  font-size: 14px;
}
.auth-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
  padding: 6px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 60;
}
.auth-user:hover .auth-menu,
.auth-user:focus-within .auth-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.auth-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.auth-menu-item:hover {
  background: var(--surface-2);
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Modern homepage & effects (appended to avoid breaking existing styles) --- */
/* Extra tokens and effects */
:root {
  --yellow-500: #ffd464;
  --shadow-1: 0 4px 20px rgba(0, 0, 0, .25);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  --shadow-1: 0 4px 20px rgba(0, 0, 0, .12);
  --shadow-2: 0 12px 40px rgba(0, 0, 0, .18);
}

/* Hero upgrades without altering base selectors */
.hero.hero-modern {
  padding: 48px 0;
  text-align: center;
  position: relative;
}

.hero.hero-modern::before {
  content: "";
  position: absolute;
  inset: -20px 0 auto 0;
  height: 320px;
  background:
    radial-gradient(60% 60% at 50% 0%, color-mix(in hsl, var(--teal-600) 20%, transparent) 0%, transparent 60%),
    radial-gradient(30% 30% at 20% 30%, color-mix(in hsl, var(--yellow-500) 18%, transparent) 0%, transparent 60%);
  filter: blur(18px);
  pointer-events: none;
}

.hero.hero-modern h1 {
  font-size: clamp(28px, 4vw, 44px);
}

.hero .lead {
  color: var(--muted);
  max-width: 65ch;
  margin: 0 auto;
}

.gradient-text {
  background: linear-gradient(90deg, var(--teal-600), var(--yellow-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cta-row {
  margin-top: 18px;
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, .1);
  color: var(--fg);
  background: var(--orange-600);
  box-shadow: var(--shadow-1);
}

.cta-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  filter: brightness(1.02);
}

.cta-secondary {
  background: transparent;
  border-color: var(--border);
  box-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {

  .cta-button,
  .kb-main .card {
    transition: transform .12s ease, filter .2s ease, box-shadow .2s ease, border-color .2s ease;
  }
}

/* Card hover accents and subtle glow */
.kb-main .grid {
  gap: 18px;
}

.kb-main .card {
  position: relative;
  overflow: hidden;
}

.kb-main .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-1);
  border-color: color-mix(in hsl, var(--teal-600) 35%, var(--border));
}

.kb-main .card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in hsl, var(--teal-600) 22%, transparent), transparent);
  opacity: .25;
  mask: linear-gradient(#000, transparent 60%);
}
