/* Architecture page in the Himalai design system (DESIGN.md, section 2): tokens, fonts, radii,
   elevation. Self-contained: fonts are self-hosted, nothing loads from another origin. */

@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url(fonts/onest-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 700; font-display: swap; src: url(fonts/onest-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215; }
@font-face { font-family: "Onest"; font-weight: 800; font-display: swap; src: url(fonts/onest-cyrillic-800-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-weight: 800; font-display: swap; src: url(fonts/onest-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215; }
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url(fonts/golos-text-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url(fonts/golos-text-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215; }
@font-face { font-family: "Golos Text"; font-weight: 600; font-display: swap; src: url(fonts/golos-text-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 600; font-display: swap; src: url(fonts/golos-text-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215; }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+2212, U+2215; }

:root {
  color-scheme: light;
  --background: #F5F8FF;
  --surface: #FFFFFF;
  --surface-muted: #F2F8FF;
  --ink: #1A1F3B;
  --text: #334155;
  --text-muted: #56627A;
  --line: #D3E1F2;
  --line-strong: #7A8BA8;
  --accent: #3B82F6;
  --accent-strong: #2563EB;
  --accent-soft: #E3EDFF;
  --success: #7C5CFF;
  --success-strong: #7C3AED;
  --secondary-soft: #EEEAFF;
  --correct-text: #157A3F;
  --wrong: #F4455E;
  --wrong-text: #C01D38;
  --shadow-md: 0 6px 20px rgba(59,130,246,.10), 0 1px 3px rgba(26,31,59,.06);
  --font-heading: "Onest", system-ui, sans-serif;
  --font-sans: "Golos Text", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #10142A;
    --surface: #1A1F3B;
    --surface-muted: #151A33;
    --ink: #F1F5FF;
    --text: #CBD5E1;
    --text-muted: #98A5C3;
    --line: #2C3358;
    --line-strong: #6D7AA3;
    --accent: #5B9BFA;
    --accent-strong: #7CB2FB;
    --accent-soft: #1F2F5E;
    --success: #9F8BFF;
    --success-strong: #BBA5FC;
    --secondary-soft: #29245A;
    --correct-text: #5ED894;
    --wrong: #FF6B81;
    --wrong-text: #FF97A6;
    --shadow-md: 0 6px 20px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 400 16px/26px var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus, var(--accent-strong)); outline-offset: 2px; border-radius: 4px; }
code { font: 500 0.86em/1.4 var(--font-mono); font-variant-ligatures: none; color: var(--ink); background: var(--surface-muted); padding: 1px 5px; border-radius: 6px; white-space: nowrap; }
h1, h2, h3 { font-family: var(--font-heading); color: var(--ink); margin: 0; text-wrap: balance; }
h1 { font-size: 48px; line-height: 52px; font-weight: 800; letter-spacing: -0.025em; }
h2 { font-size: 30px; line-height: 36px; font-weight: 800; letter-spacing: -0.015em; margin-bottom: 16px; }
h3 { font-size: 18px; line-height: 26px; font-weight: 700; margin: 40px 0 12px; }
p { margin: 0 0 12px; }
b { color: var(--ink); font-weight: 600; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--background) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-row { max-width: 1200px; margin: 0 auto; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font: 800 18px/1 var(--font-heading); color: var(--ink); }
.brand img { border-radius: 7px; }
.brand:hover { text-decoration: none; }
.top-link { font-size: 14px; font-weight: 600; }

/* Layout: contents column and the article */
.layout { max-width: 1200px; margin: 0 auto; padding: 0 32px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; }
.toc { position: sticky; top: 56px; align-self: start; padding-top: 64px; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { display: flex; gap: 10px; padding: 5px 0; font-size: 14px; line-height: 20px; color: var(--text-muted); }
.toc a::before { content: counter(toc); font-family: var(--font-mono); font-size: 12px; color: var(--line-strong); min-width: 14px; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--ink); font-weight: 600; }
.toc a.active::before { color: var(--success-strong); }
main { min-width: 0; padding-bottom: 32px; }

/* Hero */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding: 64px 0 48px; border-bottom: 1px solid var(--line); }
.lead { font-size: 19px; line-height: 30px; color: var(--text); max-width: 34em; margin-top: 20px; }
.meta { font-size: 14px; color: var(--text-muted); margin: 16px 0 0; }
.hero-himo { width: 168px; height: 168px; flex: none; margin-bottom: -8px; }

/* Sections */
main > section:not(.hero) { padding: 64px 0; border-bottom: 1px solid var(--line); }
main > section:last-child { border-bottom: none; }
.prose { max-width: 38em; }
.note { font-size: 14px; line-height: 21px; color: var(--text-muted); max-width: 40em; margin-top: 12px; }

/* Panels: only diagrams and charts get a surface */
.panel { margin: 24px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.panel figcaption { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.panel .chart-title { font: 700 16px/24px var(--font-heading); color: var(--ink); margin: 0 0 8px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.svg-wide { display: block; width: 100%; min-width: 760px; height: auto; }
.svg-chart { display: block; width: 100%; height: auto; }

/* SVG */
svg text { font-family: var(--font-sans); font-size: 14px; fill: var(--text); }
svg .small { font-size: 12px; fill: var(--text-muted); }
svg .t-center { text-anchor: middle; }
svg .t-end { text-anchor: end; }
svg .t-strong { font-weight: 600; fill: var(--ink); }
.frame { fill: var(--surface-muted); stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 6 5; }
svg .frame-label { font-family: var(--font-heading); font-weight: 700; fill: var(--ink); font-size: 15px; }
.node rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.node-accent rect { fill: var(--accent-soft); stroke: var(--accent-strong); }
.node-violet rect { fill: var(--secondary-soft); stroke: var(--success); }
.node-ext rect { stroke-dasharray: 4 3; }
.node-muted rect { fill: var(--surface-muted); stroke: var(--line); }
.actor rect { fill: var(--accent-soft); }
svg .actor text { font-weight: 600; fill: var(--ink); }
.edge { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.edge-violet { stroke: var(--success); stroke-width: 2; }
.edge-dashed { stroke-dasharray: 4 3; }
.arrowhead { fill: var(--line-strong); }
svg .edge-label { font-size: 12px; fill: var(--text-muted); }

/* Numbered decisions */
.decisions { margin: 0; padding: 0; list-style: none; counter-reset: d; display: grid; grid-template-columns: 1fr 1fr; gap: 24px 40px; }
.decisions li { counter-increment: d; position: relative; padding-left: 36px; font-size: 15px; line-height: 23px; max-width: 30em; }
.decisions li::before { content: counter(d); position: absolute; left: 0; top: 0; font: 700 15px/23px var(--font-mono); color: var(--success-strong); }
.decisions b { display: block; font-size: 16px; margin-bottom: 2px; }

/* Packages */
h3.group { margin-top: 32px; font-size: 13px; line-height: 18px; font-family: var(--font-sans); font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; }
.pkgs { margin: 0; border-top: 1px solid var(--line); }
.pkgs > div { display: grid; grid-template-columns: 140px 1fr; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pkgs dt code { font-size: 15px; background: none; padding: 0; color: var(--ink); }
.pkgs dd { margin: 0; font-size: 15px; line-height: 23px; max-width: 40em; }
.pkgs .stack { display: block; font-size: 13px; color: var(--text-muted); }

/* Definition rows */
.rows { margin: 0; border-top: 1px solid var(--line); }
.rows > div { display: grid; grid-template-columns: 132px 1fr; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 22px; }
.rows dt { color: var(--text-muted); }
.rows dd { margin: 0; color: var(--ink); }
.rows.tables dd { display: flex; flex-wrap: wrap; gap: 6px; }
.rows.tables code { font-size: 13px; }

/* Two columns */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.cols h3 { margin-top: 8px; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.split > .panel { margin-top: 0; }
.split h3 { margin-top: 0; }
#feed .split, #load .split { margin-top: 24px; }

/* Steps */
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.steps li { counter-increment: s; position: relative; padding: 9px 0 9px 32px; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 22px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 9px; font: 500 13px/16px var(--font-mono); color: var(--line-strong); }
.steps .who { display: block; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-muted); }
.steps .api-llm { color: var(--success-strong); }

/* Selection */
.select { margin: 0; padding: 0; list-style: none; counter-reset: q; }
.select li { counter-increment: q; position: relative; padding: 8px 0 8px 28px; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 22px; }
.select li::before { content: counter(q); position: absolute; left: 0; top: 8px; font: 500 13px/22px var(--font-mono); color: var(--line-strong); }
.select li:last-child { border-bottom: none; }
.select li:last-child::before { color: var(--success-strong); }

/* Charts */
.grid path { stroke: var(--line); stroke-width: 1; fill: none; }
.band { fill: var(--secondary-soft); }
svg .band-label { fill: var(--success-strong); }
.curve { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.target-line { stroke: var(--success); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.target-dot { fill: var(--success); stroke: var(--surface); stroke-width: 2; cursor: pointer; }
svg .target-label { font-weight: 600; font-size: 13px; fill: var(--success-strong); }
.formula { font-size: 13px; line-height: 26px; color: var(--text-muted); margin: 12px 0 0; }
.formula code { white-space: normal; }
.bar { fill: var(--accent); cursor: pointer; }
.bar:hover, .bar:focus-visible { fill: var(--accent-strong); }
.bar-fail { fill: var(--wrong); }
.bar-fail:hover, .bar-fail:focus-visible { fill: var(--wrong-text); }
.threshold { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 6 4; }
svg .threshold-label { fill: var(--ink); font-weight: 600; }
svg .value-labels text { fill: var(--ink); font-weight: 600; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 22px; }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--text-muted); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line-strong); }
td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: top; }
table.load th:not(:first-child), table.load td:not(:first-child) { text-align: right; }
table.load th:last-child, table.load td:last-child { padding-right: 0; }
table.ctx td:not(:first-child), table.ctx th:not(:first-child) { text-align: center; width: 28%; }
table.ctx td:first-child { color: var(--text); }
td.no { color: var(--wrong-text); font-weight: 600; }
td.ok { color: var(--correct-text); font-weight: 600; }
td.fail { color: var(--wrong-text); font-weight: 600; }
table.cost { max-width: 54em; }
table.cost td:first-child { white-space: nowrap; }
table.cost td.num { font-weight: 600; white-space: nowrap; }
table.cost td:last-child { color: var(--text); }

/* Release flow */
.flow { list-style: none; margin: 8px 0 24px; padding: 0; counter-reset: f; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 2px solid var(--ink); }
.flow li { counter-increment: f; padding: 14px 20px 0 0; font-size: 14px; line-height: 21px; color: var(--text); }
.flow li::before { content: counter(f); display: block; font: 500 12px/18px var(--font-mono); color: var(--text-muted); margin-bottom: 4px; }
.flow b { display: block; font-size: 15px; }

/* Footer */
.foot { max-width: 1200px; margin: 0 auto; padding: 24px 32px 40px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--text-muted); }

/* Tooltip */
.tip { position: fixed; z-index: 30; pointer-events: none; max-width: 280px; background: var(--ink); color: var(--background); font-size: 13px; line-height: 18px; padding: 8px 12px; border-radius: 10px; }

/* Narrower desktop and tablet */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { display: none; }
  .split { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
/* Phone */
@media (max-width: 720px) {
  .top-row, .layout { padding: 0 16px; }
  .foot { padding: 20px 16px 32px; flex-direction: column; }
  h1 { font-size: 34px; line-height: 40px; }
  h2 { font-size: 24px; line-height: 30px; }
  .lead { font-size: 17px; line-height: 27px; }
  .hero { padding: 40px 0 32px; }
  .hero-himo { display: none; }
  main > section:not(.hero) { padding: 48px 0; }
  .cols, .decisions { grid-template-columns: 1fr; gap: 28px; }
  .flow { grid-template-columns: 1fr 1fr; row-gap: 16px; }
  .pkgs > div { grid-template-columns: 1fr; gap: 2px; }
  .rows > div { grid-template-columns: 104px 1fr; gap: 12px; }
  .svg-chart { min-width: 520px; }
  .panel { padding: 14px; }
  code { white-space: normal; }
  table.cost td:first-child { white-space: normal; }
}
