@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --fm-brand: #ea580c;
  --fm-brand-light: #f97316;
  --fm-brand-dark: #c2410c;
  --fm-bg: #ffffff;
  --fm-bg-soft: #f8f8f7;
  --fm-text: #1f1f1f;
  --fm-text-soft: #6b7280;
  --fm-border: #e5e7eb;
  --fm-mark-bg: #fef3c7;
  --fm-mark-fg: #713f12;
  --fm-risk-bg: #fee2e2;
  --fm-risk-fg: #7f1d1d;
  --fm-ok-bg: #dcfce7;
  --fm-ok-fg: #14532d;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --fm-bg: #16181d;
    --fm-bg-soft: #1e2127;
    --fm-text: #e5e7eb;
    --fm-text-soft: #9ca3af;
    --fm-border: #2a2e37;
    --fm-mark-bg: rgba(234, 179, 8, 0.22);
    --fm-mark-fg: #fde68a;
    --fm-risk-bg: rgba(239, 68, 68, 0.22);
    --fm-risk-fg: #fecaca;
    --fm-ok-bg: rgba(34, 197, 94, 0.22);
    --fm-ok-fg: #bbf7d0;
  }
}

.dark {
  --fm-bg: #16181d;
  --fm-bg-soft: #1e2127;
  --fm-text: #e5e7eb;
  --fm-text-soft: #9ca3af;
  --fm-border: #2a2e37;
  --fm-mark-bg: rgba(234, 179, 8, 0.22);
  --fm-mark-fg: #fde68a;
  --fm-risk-bg: rgba(239, 68, 68, 0.22);
  --fm-risk-fg: #fecaca;
  --fm-ok-bg: rgba(34, 197, 94, 0.22);
  --fm-ok-fg: #bbf7d0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--fm-bg);
  color: var(--fm-text);
  line-height: 1.6;
}

a { color: var(--fm-brand); }

.fm-header {
  border-bottom: 1px solid var(--fm-border);
  background: var(--fm-bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.fm-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 24px;
}
.fm-header-title { font-weight: 700; font-size: 1.25em; text-decoration: none; color: var(--fm-text); flex-shrink: 0; }
.fm-header-title, .fm-footer-brand { display: inline-flex; align-items: center; line-height: 0; }
.fm-logo { height: 32px; width: auto; display: block; }
.fm-logo-footer { height: 36px; }
.fm-header-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.fm-header-cta { background: var(--fm-brand); color: white !important; padding: 8px 16px; border-radius: 8px; text-decoration: none; font-size: 0.9em; font-weight: 600; }
.fm-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--fm-text-soft);
  cursor: pointer;
}
.fm-theme-toggle:hover { background: var(--fm-bg-soft); color: var(--fm-text); }
.fm-theme-toggle svg { width: 18px; height: 18px; }

.fm-header-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 9px 14px;
  border: none;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--fm-text) 5%, transparent);
  color: var(--fm-text-soft);
  font-family: inherit;
  font-size: 0.9em;
  cursor: pointer;
}
.fm-header-search:hover { background: color-mix(in srgb, var(--fm-text) 8%, transparent); }
.fm-header-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.fm-header-search span { flex: 1; text-align: left; }
.fm-header-search kbd {
  font-family: inherit;
  font-size: 0.75em;
  padding: 2px 6px;
  border: 1px solid var(--fm-border);
  border-radius: 4px;
  background: var(--fm-bg);
}
.fm-header-search-mobile {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--fm-text-soft);
  cursor: pointer;
}
.fm-header-search-mobile svg { width: 20px; height: 20px; }

.fm-tabstrip {
  border-bottom: 1px solid var(--fm-border);
  background: var(--fm-bg);
  position: sticky;
  top: 64px;
  z-index: 30;
}
.fm-tabstrip-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}
.fm-tabstrip-link {
  padding: 12px 2px;
  text-decoration: none;
  color: var(--fm-text-soft);
  font-size: 0.9em;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.fm-tabstrip-link.active { color: var(--fm-brand); border-bottom-color: var(--fm-brand); }

.fm-layout { display: flex; max-width: 1440px; margin: 0 auto; align-items: flex-start; }

.fm-sidebar {
  width: 280px;
  flex-shrink: 0;
  padding: 24px 16px;
  height: calc(100vh - 114px);
  overflow-y: auto;
  position: sticky;
  top: 114px;
  scrollbar-width: none;
}
.fm-sidebar::-webkit-scrollbar { width: 4px; }
.fm-sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.fm-sidebar:hover { scrollbar-width: thin; scrollbar-color: var(--fm-border) transparent; }
.fm-sidebar:hover::-webkit-scrollbar-thumb { background: var(--fm-border); }
.fm-nav-group { margin-bottom: 20px; }
.fm-nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875em;
  font-weight: 600;
  color: var(--fm-text);
  margin-bottom: 10px;
  padding: 0 12px 0 16px;
}
.fm-nav-group-icon { display: flex; flex-shrink: 0; color: var(--fm-text-soft); }
.fm-nav-group-icon svg, .fm-nav-link-icon svg { width: 16px; height: 16px; }
.fm-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 16px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--fm-brand);
  font-size: 0.875em;
  line-height: 24px;
}
.fm-nav-link-icon { display: flex; flex-shrink: 0; opacity: 0.7; }
.fm-nav-link:hover { background: color-mix(in srgb, var(--fm-text) 5%, transparent); }
.fm-nav-link.active { background: color-mix(in srgb, var(--fm-brand) 10%, transparent); font-weight: 600; }
.fm-nav-link.active .fm-nav-link-icon { opacity: 1; }

.fm-content { flex: 1; min-width: 0; padding: 40px 40px 60px; }
.fm-content article { max-width: 680px; margin: 0 auto; }
.fm-eyebrow { color: var(--fm-brand-light); font-size: 0.875em; font-weight: 600; margin-bottom: 10px; }
.fm-content h1 { font-size: 2.25em; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 12px; }
/* Clears the sticky header+tabstrip (114px) so a #anchor jump — from the
   TOC or an in-body cross-reference link — doesn't land with its target
   heading hidden underneath them. */
.fm-content h2, .fm-content h3, .fm-content h4 { scroll-margin-top: 130px; }
html { scroll-behavior: smooth; }
.fm-subtitle { color: var(--fm-text-soft); font-size: 1.125em; margin: 0 0 24px; }
.fm-content img { max-width: 100%; }
.fm-content pre { background: var(--fm-bg-soft); padding: 14px; border-radius: 8px; overflow-x: auto; }
.fm-content code { background: var(--fm-bg-soft); padding: 0.1em 0.4em; border-radius: 4px; }
.fm-content pre code { background: none; padding: 0; }

/* mermaid-init.js replaces each <pre><code class="language-mermaid"> with one of
   these once the diagram has rendered client-side; sized/bordered like the other
   embedded-content blocks (pre, table) above rather than mermaid's own defaults.
   .fm-mermaid itself never scrolls — only .fm-mermaid-scroll inside it does — so
   the expand button (absolutely positioned against .fm-mermaid) stays pinned to
   the corner instead of scrolling away with the diagram. */
.fm-content .fm-mermaid {
  position: relative;
  margin: 20px 0;
  padding: 16px;
  border: 1px solid var(--fm-border);
  border-radius: 8px;
  text-align: center;
}
.fm-content .fm-mermaid-scroll {
  overflow: auto;
  max-height: 420px;
}
/* No max-width here on purpose — mermaid-init.js renders at natural size
   (useMaxWidth:false) precisely so node text stays legible regardless of node
   count. A max-width:100% here would silently shrink it right back down; a
   diagram wider than the column scrolls horizontally via .fm-mermaid-scroll
   instead, the same way a wide table or code block already does. */
.fm-content .fm-mermaid svg { display: inline-block; height: auto; }

.fm-mermaid-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--fm-border);
  border-radius: 6px;
  background: var(--fm-bg);
  color: var(--fm-text-soft);
  cursor: pointer;
}
.fm-mermaid-expand:hover { color: var(--fm-text); background: var(--fm-bg-soft); }
.fm-mermaid-expand svg { width: 15px; height: 15px; }

#fm-mermaid-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
}
#fm-mermaid-lightbox.fm-open { display: flex; }

#fm-mermaid-lightbox-panel {
  position: relative;
  max-width: 96vw;
  max-height: 92vh;
  overflow: auto;
  padding: 32px;
  border-radius: 12px;
  background: var(--fm-bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#fm-mermaid-lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--fm-border);
  border-radius: 6px;
  background: var(--fm-bg);
  color: var(--fm-text-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
#fm-mermaid-lightbox-close:hover { color: var(--fm-text); background: var(--fm-bg-soft); }

#fm-mermaid-lightbox-body svg {
  /* SVG text scales with the element's own rendered size (it's all one coordinate
     system via viewBox), so forcing a much wider box here is what actually enlarges
     the diagram's labels, not a font-size override — an outer CSS font-size has no
     effect on text drawn inside an <svg>. mermaid-init.js strips the original width/
     height/style attributes before cloning so this width isn't fighting an inline one. */
  display: block;
  width: min(90vw, 1400px);
  height: auto;
  max-width: 100%;
}

.fm-content table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
  font-size: 0.9em;
  overflow-x: auto;
  display: block;
}
.fm-content table thead, .fm-content table tbody { display: table; width: 100%; table-layout: fixed; }
.fm-content th, .fm-content td {
  border: 1px solid var(--fm-border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.fm-content thead th {
  background: var(--fm-bg-soft);
  font-weight: 600;
  color: var(--fm-text);
}
.fm-content tbody tr:nth-child(even) { background: var(--fm-bg-soft); }

.fm-toc {
  width: 240px;
  flex-shrink: 0;
  padding: 24px 24px 24px 0;
  height: calc(100vh - 114px);
  overflow-y: auto;
  position: sticky;
  top: 114px;
  scrollbar-width: none;
}
.fm-toc::-webkit-scrollbar { width: 4px; }
.fm-toc::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.fm-toc:hover { scrollbar-width: thin; scrollbar-color: var(--fm-border) transparent; }
.fm-toc:hover::-webkit-scrollbar-thumb { background: var(--fm-border); }
.fm-toc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fm-text-soft);
  font-size: 0.875em;
  font-weight: 500;
  margin-bottom: 10px;
}
.fm-toc-header svg { width: 14px; height: 14px; }
.fm-toc-nav { display: flex; flex-direction: column; }
.fm-toc-link {
  color: var(--fm-text-soft);
  text-decoration: none;
  font-size: 0.875em;
  font-weight: 500;
  padding: 4px 0;
  line-height: 24px;
  border-left: 2px solid transparent;
  padding-left: 12px;
}
.fm-toc-link.fm-toc-level-3 { padding-left: 24px; }
.fm-toc-link:hover { color: var(--fm-brand); }
.fm-toc-link.fm-active { color: var(--fm-brand); border-left-color: var(--fm-brand); }

@media (max-width: 1100px) {
  .fm-toc { display: none; }
}

@media (max-width: 900px) {
  .fm-layout { flex-direction: column; }
  .fm-sidebar { width: 100%; height: auto; position: static; border-bottom: 1px solid var(--fm-border); }
  .fm-header-search { display: none; }
  .fm-header-search-mobile { display: flex; }
}

.fm-card-group { display: grid; grid-template-columns: repeat(var(--fm-card-cols, 1), minmax(0, 1fr)); gap: 16px; margin: 20px 0; }
@media (max-width: 640px) { .fm-card-group { grid-template-columns: 1fr; } }
.fm-card { display: block; border: 1px solid var(--fm-border); border-radius: 12px; padding: 16px; text-decoration: none; color: inherit; transition: border-color 0.2s; }
a.fm-card:hover { border-color: var(--fm-brand); }
.fm-card-icon { display: inline-flex; color: var(--fm-brand); margin-bottom: 8px; }
.fm-card-icon svg { width: 20px; height: 20px; }
.fm-card-title { font-weight: 600; margin-bottom: 4px; }
.fm-card-body { font-size: 0.9em; color: var(--fm-text-soft); }
.fm-card-body p:first-child { margin-top: 0; }
.fm-card-body p:last-child { margin-bottom: 0; }

.fm-frame { margin: 20px 0; }
.fm-frame-inner { border: 1px solid var(--fm-border); border-radius: 12px; overflow: hidden; }
.fm-frame-inner img { display: block; width: 100%; }
.fm-frame figcaption { margin-top: 8px; text-align: center; font-size: 0.85em; color: var(--fm-text-soft); }

/* image-lightbox.js adds this class to every screenshot on the page and wires up
   the click; the cursor is the only thing CSS needs to do here. */
.fm-frame-img-zoomable { cursor: zoom-in; }

#fm-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.75);
}
#fm-image-lightbox.fm-open { display: flex; }
#fm-image-lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  cursor: zoom-out;
}
#fm-image-lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
#fm-image-lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

.fm-steps { counter-reset: fm-step; margin: 20px 0 20px 14px; padding-left: 22px; border-left: 2px solid var(--fm-border); }
.fm-step { counter-increment: fm-step; position: relative; padding-bottom: 24px; }
.fm-step:last-child { padding-bottom: 0; }
.fm-step::before {
  content: counter(fm-step);
  position: absolute; left: -35px; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--fm-brand); color: white;
  font-size: 0.75em; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.fm-step-title { font-weight: 600; margin-bottom: 4px; }

.fm-tabs { margin: 20px 0; border: 1px solid var(--fm-border); border-radius: 12px; overflow: hidden; }
.fm-tabs-nav { display: flex; border-bottom: 1px solid var(--fm-border); background: var(--fm-bg-soft); }
.fm-tabs-btn { padding: 10px 16px; border: none; background: transparent; cursor: pointer; font-size: 0.9em; color: var(--fm-text-soft); border-bottom: 2px solid transparent; }
.fm-tabs-btn.active { color: var(--fm-brand); border-bottom-color: var(--fm-brand); font-weight: 600; }
.fm-tab-panel { padding: 16px; }

.fm-callout { margin: 16px 0; padding: 12px 16px; border-radius: 8px; border-left: 4px solid; }
.fm-callout p:first-child { margin-top: 0; }
.fm-callout p:last-child { margin-bottom: 0; }
.fm-callout-info { background: rgba(59, 130, 246, 0.08); border-color: #3b82f6; }
.fm-callout-tip { background: rgba(34, 197, 94, 0.08); border-color: #22c55e; }
.fm-callout-warning { background: rgba(234, 88, 12, 0.08); border-color: var(--fm-brand); }

.fm-details { margin: 12px 0; border: 1px solid var(--fm-border); border-radius: 8px; padding: 10px 16px; }
.fm-details summary { cursor: pointer; font-weight: 600; }
.fm-details[open] summary { margin-bottom: 8px; }

.fm-footer { border-top: 1px solid var(--fm-border); padding: 48px 24px; }
.fm-footer-top { display: flex; flex-wrap: wrap; gap: 48px; max-width: 1440px; margin: 0 auto; }
.fm-footer-brand { font-weight: 700; font-size: 1.375em; text-decoration: none; color: var(--fm-text); margin-right: auto; }
.fm-footer-header { font-weight: 600; margin-bottom: 8px; }
.fm-footer-link { display: block; color: var(--fm-brand); text-decoration: none; padding: 4px 0; font-size: 0.9em; }
.fm-footer-link:hover { text-decoration: underline; }

mark {
  background-color: var(--fm-mark-bg);
  color: var(--fm-mark-fg);
  padding: 0.1em 0.35em;
  border-radius: 0.3em;
  font-weight: 600;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
mark.risk { background-color: var(--fm-risk-bg); color: var(--fm-risk-fg); }
mark.ok { background-color: var(--fm-ok-bg); color: var(--fm-ok-fg); }
mark code { background-color: rgba(0, 0, 0, 0.06); color: inherit; }
.dark mark code { background-color: rgba(255, 255, 255, 0.12); }
