:root {
  --bg: #efe8dc;
  --panel: #fffaf2;
  --ink: #1c1917;
  --muted: #57534e;
  --line: #e7ddd0;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --ok: #047857;
  --warn: #b45309;
  --shot: #44403c;
  --radius: 18px;
  --sidebar: 280px;
  --top: 72px;
  --navy: #0b1224;
  --ai-grad: linear-gradient(120deg, #38bdf8 0%, #6366f1 40%, #f472b6 75%, #f59e0b 100%);
  --word-grad: linear-gradient(90deg, #38bdf8, #6366f1, #f472b6, #f59e0b, #38bdf8);
  --display: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --ui: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ui);
  background:
    radial-gradient(1200px 480px at 10% -10%, rgb(56 189 248 / 14%), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgb(244 114 182 / 10%), transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.65;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  z-index: 20;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: linear-gradient(180deg, #0b1224 0%, #111827 100%);
  color: #fff;
  border-bottom: 1px solid rgb(148 163 184 / 18%);
}

.menu-btn {
  display: none;
  background: transparent;
  color: #fff;
  border: 1px solid #334155;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 20px;
}

.academy-back {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgb(199 210 254 / 32%);
  color: #c7d2fe;
  text-decoration: none;
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.academy-back:hover,
.academy-back:focus-visible {
  color: #fff;
  background: rgb(255 255 255 / 8%);
  border-color: rgb(255 255 255 / 28%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  flex-shrink: 0;
}
.brand-logo,
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 12%), 0 8px 18px rgb(99 102 241 / 28%);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong {
  font-family: var(--ui);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #e2e8f0;
}
.brand-elinom,
.elinom-gradient {
  background: var(--word-grad);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: academyWordmark 4s ease-in-out infinite;
}
@keyframes academyWordmark {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.brand-text small { color: #94a3b8; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }

.search {
  flex: 1;
  /* Without this the form keeps its min-content width — the search input's
     intrinsic size — so on a phone it grows past the topbar and the AI badge
     lands off-screen. */
  min-width: 0;
  max-width: 560px;
}
.search--ai {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  background:
    linear-gradient(#0b1224, #0f172a) padding-box,
    var(--ai-grad) border-box;
  border: 1.5px solid transparent;
  box-shadow:
    0 0 0 1px rgb(99 102 241 / 22%),
    0 0 18px rgb(56 189 248 / 28%);
}
.search-ai-icon {
  display: grid;
  place-items: center;
  color: #38bdf8;
  background: var(--ai-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.search--ai input {
  flex: 1;
  min-width: 0;
  width: auto;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  padding: 10px 4px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.search--ai input::placeholder { color: #94a3b8; }
.search-ai-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #0b1224;
  background: var(--ai-grad);
}

.top-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 11px;
  color: #cbd5e1;
  white-space: nowrap;
}

.search-panel {
  position: sticky;
  top: var(--top);
  z-index: 7;
  background: #fffaf2;
  border-bottom: 1px solid var(--line);
  max-height: 50vh;
  overflow: auto;
  padding: 8px 16px 16px;
  box-shadow: 0 16px 40px rgb(28 25 23 / 8%);
}
.search-panel[hidden] { display: none; }
.search-hint { color: var(--muted); margin: 8px 0; }
.search-panel ul { list-style: none; margin: 0; padding: 0; }
.search-panel a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}
.search-panel a:hover, .search-panel a:focus { background: var(--brand-soft); }
.search-panel small { display: block; color: var(--muted); }

.layout { display: flex; min-height: calc(100vh - var(--top)); }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: rgb(255 250 242 / 82%);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  padding: 20px 12px 40px;
  overflow: auto;
  position: sticky;
  top: var(--top);
  height: calc(100vh - var(--top));
}
.sidebar h2 {
  margin: 18px 8px 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #78716c;
}
.sidebar a {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: #44403c;
  text-decoration: none;
  font-size: 14px;
}
.sidebar a.active, .sidebar a:hover { background: var(--brand-soft); color: var(--brand); }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 72px;
  max-width: 1040px;
}
.crumbs {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.crumbs a { color: var(--brand); text-decoration: none; }

.article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 48px 48px;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 70%) inset,
    0 24px 60px rgb(28 25 23 / 8%);
}
.article--magazine {
  background:
    linear-gradient(180deg, rgb(255 255 255 / 55%), transparent 90px),
    var(--panel);
}
.article--cover::before {
  content: "Master User Manual  ·  Field issue";
  display: block;
  margin-bottom: 18px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #78716c;
}
.article h1 {
  margin: 0 0 0.45em;
  font-family: var(--display);
  font-size: clamp(2.1rem, 4vw, 3.15rem);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.03em;
}
.article--cover > p:first-of-type {
  font-size: 1.15rem;
  color: #44403c;
  max-width: 40rem;
}
.article--cover > p:first-of-type::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 3.4rem;
  line-height: 0.82;
  padding: 8px 10px 0 0;
  font-weight: 750;
  background: var(--word-grad);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.article h2 {
  margin-top: 2.4rem;
  border-top: 1px solid var(--line);
  padding-top: 1.4rem;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 650;
}
.article h3 {
  margin-top: 1.6rem;
  font-family: var(--display);
  font-size: 1.2rem;
}
.article a { color: var(--brand); }
.article table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 14px; }
/* A wide reference table must scroll on its own rather than pushing the whole
   page sideways on a narrow phone. */
.article table { display: block; overflow-x: auto; max-width: 100%; }
.article th, .article td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.article th { background: #f4efe6; }
.article code { background: #f4efe6; padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.article pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 10px;
  overflow: auto;
}
.article pre code { background: transparent; color: inherit; padding: 0; }
.article blockquote,
.article .note {
  margin: 1.2rem 0;
  padding: 14px 18px;
  border-left: 4px solid transparent;
  border-image: var(--ai-grad) 1;
  background: #f7f1e8;
  font-family: var(--display);
  font-size: 1.15rem;
}
.article ul.checklist { list-style: none; padding-left: 0; }
.article .shot {
  margin: 18px 0;
  padding: 36px 16px;
  border: 1px dashed #c4b5a5;
  border-radius: 14px;
  background:
    linear-gradient(180deg, #faf6ef, #f3ece2);
  color: var(--shot);
  text-align: center;
  font-weight: 600;
}
.magazine-figure {
  margin: 28px 0;
  padding: 10px;
  background: #1c1917;
  border-radius: 16px;
  box-shadow: 0 22px 48px rgb(28 25 23 / 18%);
}
.magazine-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #0b1224;
}
.magazine-figure figcaption {
  margin: 10px 6px 4px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e7e5e4;
}
.article .note {
  border-radius: 10px;
  font-family: var(--ui);
  font-size: 0.98rem;
}
.article .note.warn { background: #fff7ed; border: 1px solid #fdba74; border-image: none; }
.article .note.ok { background: #ecfdf5; border: 1px solid #6ee7b7; border-image: none; }
.article .flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0;
}
.article .flow .node {
  background: var(--brand-soft);
  color: #312e81;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.article .flow .arrow { color: #64748b; }

.mermaid-fallback {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.mermaid-fallback .step {
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
}

.related, .pager { margin-top: 24px; }
.related ul { padding-left: 18px; }
.pager { display: flex; justify-content: space-between; gap: 12px; }
.pager-link {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fffaf2;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}
.pager-link.next { margin-left: auto; }
.pager-link[hidden] { display: none; }

.backdrop { display: none; }

@media (max-width: 900px) {
  :root { --top: 64px; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .top-meta { display: none; }
  .brand-text { display: none; }
  .academy-back { padding: 6px 9px; font-size: 0.78rem; }
  .brand-logo { width: 34px; height: 34px; }
  .search--ai { min-height: 40px; padding: 0 6px 0 10px; }
  .search--ai input { font-size: 13px; padding: 8px 2px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--top);
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    z-index: 9;
    box-shadow: 20px 0 40px rgba(15, 23, 42, 0.2);
    background: #fffaf2;
  }
  .sidebar.open { transform: none; }
  .backdrop {
    display: block;
    position: fixed;
    inset: var(--top) 0 0 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 8;
  }
  .backdrop[hidden] { display: none; }
  .main { padding: 16px 14px 48px; }
  .article { padding: 22px 18px 28px; }
  .article--cover > p:first-of-type::first-letter { font-size: 2.6rem; }
}

/* Narrow phones: the wordmark squeezed the search field down to a couple of
   visible characters, so keep the logo and give the row back to search. */
@media (max-width: 430px) {
  .brand-text { display: none; }
}
