@font-face {
  font-family: 'MonaspaceKrypton';
  src: url('/assets/fonts/MonaspaceKryptonVar.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'SpaceGrotesk';
  src: url('/assets/fonts/SpaceGrotesk-VariableFont_wght.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'AnonymousPro';
  src: url('/assets/fonts/AnonymousPro-Regular.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Material Icons';
  src: url('/assets/fonts/MaterialIcons-Regular.otf') format('opentype');
  font-display: block;
}

:root {
  --app-bg: #101014;
  --card: #18191F;
  --alt: #23242B;
  --text: #D1D3D8;
  --muted: #9a9fa9;
  --border: #343640;
  --card-border: #454853;
  --accent: #D8344A;
  --mono: 'MonaspaceKrypton', ui-monospace, monospace;
  --sans: 'SpaceGrotesk', system-ui, -apple-system, sans-serif;
  --code: 'AnonymousPro', ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Scrollbar matching _KeepAliveScrollBehavior + ScrollbarThemeData in the app:
   5px thumb, 2px radius, muted text at 35% brightening to 72% on hover, no
   track. Width cannot change on hover the way the app's does (a scrollbar
   pseudo-element resize mid-gesture is not honoured), so only the colour
   responds. The app hides it below 900px, where the native bar is returned. */
* { scrollbar-width: thin; scrollbar-color: rgba(154, 159, 169, 0.35) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(154, 159, 169, 0.35);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(154, 159, 169, 0.72); }
::-webkit-scrollbar-corner { background: transparent; }
/* No stepper arrows: the app's scrollbar is a bare thumb. */
::-webkit-scrollbar-button,
::-webkit-scrollbar-button:single-button,
::-webkit-scrollbar-button:vertical:increment,
::-webkit-scrollbar-button:vertical:decrement {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
@media (max-width: 899px) {
  * { scrollbar-width: auto; scrollbar-color: auto; }
  ::-webkit-scrollbar { width: auto; height: auto; }
}

/* Topbar and footer are pinned; only the article column scrolls, matching the
   in-app help center where the sidebar stays put while topics scroll. */
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--app-bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
a { color: var(--accent); }

.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  /* Fixed height: as a flex item of the column body it defaults to
     flex-shrink: 1, so a tall shell squeezed the header instead of leaving
     the scrolling to main. */
  flex: 0 0 auto;
  height: 55px;
  min-height: 55px;
  padding: 0 clamp(16px, 5vw, 25px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.topbar .back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 30px;
  font-weight: 900;
  text-decoration: none;
  color: var(--text);
  font-family: var(--mono);
}
.topbar .back:hover { background: var(--alt); }
.topbar .crumb {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  /* One line, cut with an ellipsis: "Terms of Service" wrapped and pushed the
     bar into two rows on a phone. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Never break "Open app" across lines - it is a 55px bar. */
.topbar .open-app { margin-left: auto; flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 560px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .topbar .crumb { font-size: 15px; }
  .topbar .open-app { padding: 7px 10px; font-size: 12px; }
}

.shell {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  padding: 16px 0;
  background: var(--card);
  overflow-y: auto;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0 12px 6px; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 42px;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.sidebar a:hover { background: var(--alt); color: var(--text); }
.brand-it { font-style: normal; color: var(--accent); }

/* Curated cross-links, grouped so they read as asides rather than as the way
   forward - that is the pager's job. */
.related-h { margin-top: 32px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* Generated from the page order, so every topic has a way on without going
   back to the sidebar (a horizontal strip on a phone). */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  padding: 16px 18px;
  border: 1px solid var(--card-border);
  background: var(--alt);
  color: var(--text);
  text-decoration: none;
}
.pager:hover { border-color: var(--accent); }
.pager-kicker {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.pager-title { flex: 1 1 auto; font-weight: 700; font-size: 15px; }
.pager-arrow { flex: 0 0 auto; color: var(--accent); font-weight: 700; }
.sidebar .ico { flex: 0 0 auto; width: 20px; height: 20px; font-size: 20px; }
.sidebar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ico {
  display: block;
  width: 15px;
  height: 15px;
  font-family: 'Material Icons';
  font-size: 15px;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  text-rendering: optimizeLegibility;
}
.card.type h3, .embed-panel h3 { display: flex; align-items: center; gap: 8px; }
.card.type h3 .ico { color: var(--accent); width: 15px; height: 15px; }
.sidebar a[aria-current="page"] {
  background: rgba(216, 52, 74, 0.16);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 800;
}

/* Grid canvas behind the article, same 64px step as the landing hero. */
main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 24px;
  overflow-y: auto;
  background-image:
    repeating-linear-gradient(to right, #1a1a1f 0 1px, transparent 1px 64px),
    repeating-linear-gradient(to bottom, #1a1a1f 0 1px, transparent 1px 64px);
}
/* Left-aligned against the sidebar rather than centred in the viewport. */
.panel { max-width: 980px; margin: 0; background: var(--card); padding: 24px; }

h1 {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.3px;
  margin: 0 0 12px;
}
h2 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 16px 0 10px;
}
h3 { font-family: var(--mono); font-size: 15px; font-weight: 800; margin: 0 0 4px; }
p { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
p.lead { font-size: 15px; margin-bottom: 18px; }

.cur-toggle {
  display: flex;
  width: max-content;
  margin: 0 0 22px;
  border: 1px solid var(--card-border);
}
.cur-toggle[hidden] { display: none; }
.cur {
  padding: 8px 15px;
  border: 0;
  border-left: 1px solid var(--card-border);
  background: var(--card);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}
.cur:first-child { border-left: 0; }
.cur:hover { color: var(--text); }
.cur[aria-pressed="true"] { background: var(--text); color: var(--app-bg); }
ul { color: var(--muted); font-size: 14px; margin: 0 0 12px; padding-left: 20px; }
li { margin-bottom: 5px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 14px;
  margin-bottom: 10px;
}
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.card .example {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(209, 211, 216, 0.06);
  font-family: var(--code);
  font-size: 12.5px;
  color: var(--muted);
}
.card.status { display: flex; align-items: center; gap: 16px; }
.card.status p { margin: 0; }
/* Mirrors StatusBadge: solid status fill, hard 2px black border and a 3px
   offset shadow (palette.brutalShadow), with black label text - every status
   fill is light enough that StatusBadge's own contrast rule picks black. */
.badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #060608;
  color: #000;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
/* KeepAlivePalette.spans: statusUp/Down/Warn/Off fall back to
   success/danger/warning/info. MISS and DEG share their status colours. */
.s-OK { background: #C8CCD4; }
.s-KO, .s-MISS { background: var(--accent); }
.s-DEG, .s-WAF { background: #C6934C; }
.s-OFF { background: #7B8190; }

figure.code { margin: 0 0 12px; border: 1px solid var(--card-border); }
figure.code figcaption {
  padding: 8px 12px;
  background: var(--alt);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
figure.code pre {
  margin: 0;
  padding: 14px;
  background: var(--alt);
  overflow-x: auto;
}
figure.code code {
  font-family: var(--code);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
figure.guide-image {
  margin: 0 0 20px;
  border: 1px solid var(--card-border);
  background: var(--app-bg);
}
figure.guide-image img {
  display: block;
  max-width: 100%;
  height: auto;
}
figure.guide-image figcaption {
  padding: 8px 12px;
  border-top: 1px solid var(--card-border);
  color: var(--muted);
  font: 12px/1.45 var(--mono);
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  margin: 0 8px 0 0;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }

article a.btn { margin: 0 8px 8px 0; }

/* Plan tables, filled by /help/help.js from GET /plans. */
.help-slot { margin-bottom: 16px; }
.help-slot .pre { white-space: pre-line; }
.table-wrap { overflow-x: auto; border: 1px solid var(--card-border); }
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
table.cmp th, table.cmp td {
  padding: 10px 12px;
  border-top: 1px solid var(--card-border);
  text-align: left;
  vertical-align: top;
  white-space: pre-line;
  color: var(--muted);
  font-weight: 400;
}
table.cmp thead th {
  border-top: 0;
  background: var(--alt);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text);
  white-space: nowrap;
}
table.cmp tbody th { font-family: var(--mono); font-weight: 700; color: var(--text); }

.legal-date { font-family: var(--mono); font-size: 12px; margin-bottom: 20px; }
.legal-notice {
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: rgba(209, 211, 216, 0.04);
  font-family: var(--mono);
  font-size: 12px;
}
.legal-h2 {
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  margin: 28px 0 10px;
  color: var(--text);
}

.footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 7px 20px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  background: var(--card);
}

.footer .footer-brand { margin-left: auto; }
.footer .logo .word { color: var(--text); font-size: 15px; user-select: none; }

@media (max-width: 760px) {
  /* Too little height to pin three regions; let the whole page scroll. */
  body { overflow: auto; display: block; }
  .shell { flex-direction: column; }
  main { overflow: visible; }
  .sidebar {
    width: 100%;
    flex: none;
    padding: 8px;
    overflow-x: auto;
  }
  /* The thumb is too small to grab on a phone, and dragging the strip itself
     already works. The part-visible chip at the edge is the affordance. */
  .sidebar { scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; height: 0; }
  .sidebar ul { display: flex; gap: 6px; }
  .sidebar li { margin: 0; }
  .sidebar a { white-space: nowrap; font-size: 12px; padding: 6px 10px; min-height: 0; }
  main { padding: 8px; }
  .panel { padding: 16px; }
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  --bar-h: 4px;
}
.logo-bars { display: flex; flex-direction: column; gap: 3px; }
.logo-bars i { display: block; height: var(--bar-h); }
.logo-bars .b1 { width: calc(var(--bar-h) * 5.5); background: var(--ok, #62D49A); }
.logo-bars .b2 {
  width: calc(var(--bar-h) * 3.5);
  margin-left: calc(var(--bar-h) * 2);
  background: var(--accent);
}
.logo-bars .b3 {
  width: calc(var(--bar-h) * 4.5);
  margin-left: var(--bar-h);
  background: var(--warn, #E0B25A);
}
/* Footer mark: same ratios laid out in a row, scaled up 1.5x. */
.footer-logo { --bar-h: 8px; }
.logo-bars.row { flex-direction: row; align-items: center; gap: 4px; margin-right: 3px; }
.logo-bars.row i { margin-left: 0; }
.logo .word {
  line-height: 1;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text);
  user-select: none;
}
.logo .word em { font-style: normal; color: var(--accent); }
