/* bridgeai kit v1: the shared look of the bridgeai site and of every module page.
   Pages on this site link it relatively (kit/v1/kit.css, ../kit/v1/kit.css); an app on its own subdomain may link
   https://bridgeai.loadsavedelete.com/kit/v1/kit.css. A breaking change goes to kit/v2/, so a page never changes under
   a link it did not ask for. Fonts: the page loads Literata, Golos Text and IBM Plex Mono from Google Fonts (see
   module-template.html for the exact <link>). Script: kit.js (languages, the clip sound button, the "Top" button).
   Look: ice paper, graphite ink, oxide green for links and the model route, a "wake" yellow kept for the bot's
   asleep/awake state only. Literata for headings and numerals, Golos Text for reading, Plex Mono only for real commands. */
:root {
  --bg: #eceff3;
  --paper: #f8f9fb;
  --ink: #1c2230;
  --muted: #5a6273;
  --rule: #d3d8e0;
  --oxide: #1e6b73;
  --oxide-ink: #ffffff;
  --wake: #c9951a;
  --me: #dfeceb;
  /* where it runs: four states, each also told by an icon and words (never colour alone) */
  --w-local: #1e6b73; --w-first: #2b5c9e; --w-cloud: #6b49a1; --w-ext: #a2432b;
  --serif: "Literata", "PT Serif", Georgia, serif;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  /* scale on a 1.25 ratio from 17px */
  --s-1: 0.85rem; --s0: 1.0625rem; --s1: 1.33rem; --s2: 1.66rem; --s3: 2.07rem; --s4: clamp(2.1rem, 5.4vw, 3.6rem);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #11151c; --paper: #181e28; --ink: #e3e7ee; --muted: #8f98a8; --rule: #2a3240;
  --oxide: #63b9bf; --oxide-ink: #0b1416; --wake: #f0c14b; --me: #1c3134; color-scheme: dark;
  --w-local: #63b9bf; --w-first: #8db6ef; --w-cloud: #bda2ef; --w-ext: #f19a82; } }
:root[data-theme="dark"] {
  --bg: #11151c; --paper: #181e28; --ink: #e3e7ee; --muted: #8f98a8; --rule: #2a3240;
  --oxide: #63b9bf; --oxide-ink: #0b1416; --wake: #f0c14b; --me: #1c3134; color-scheme: dark;
  --w-local: #63b9bf; --w-first: #8db6ef; --w-cloud: #bda2ef; --w-ext: #f19a82; }

/* Languages: every text is in the page three times (data-l="es|en|ru"); only the chosen one shows. Diagrams (.dg) move
   off-screen instead of display:none so Mermaid can measure their text. */
html[data-lang="es"] [data-l]:not([data-l="es"]):not(.dg),
html[data-lang="en"] [data-l]:not([data-l="en"]):not(.dg),
html[data-lang="ru"] [data-l]:not([data-l="ru"]):not(.dg) { display: none !important; }
html[data-lang="es"] .dg:not([data-l="es"]), html[data-lang="en"] .dg:not([data-l="en"]), html[data-lang="ru"] .dg:not([data-l="ru"]) {
  position: absolute !important; left: -10000px; top: 0; width: 960px; visibility: hidden; }

* { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--s0)/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
img, svg, video { max-width: 100%; }
a { color: var(--oxide); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--oxide); outline-offset: 3px; border-radius: 4px; }
code { font: 400 0.9em var(--mono); background: color-mix(in srgb, var(--oxide) 9%, transparent); padding: 0.06em 0.34em; border-radius: 4px; }
.wrap { max-width: 1040px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.col { max-width: 40em; }
h2 { font: 500 var(--s3)/1.18 var(--serif); font-optical-sizing: auto; letter-spacing: -0.012em; margin: 0 0 18px; text-wrap: balance; }
h3 { font: 600 var(--s0)/1.4 var(--sans); margin: 0 0 4px; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }

/* Header: the mark (home), where you are, the languages, GitHub */
/* It stays on top while reading (the shared toolkit's sticky nav), so home, languages and modules are one tap away
   anywhere on a long page; anchors land below it. kit.js adds the "Top" button after one screen of scrolling. */
header.top { border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 40; background: var(--bg); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header.top { background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: saturate(1.3) blur(12px); backdrop-filter: saturate(1.3) blur(12px); } }
html { scroll-padding-top: 76px; }
.totop { position: fixed; z-index: 41; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: 500 var(--s-1)/1 var(--sans); cursor: pointer;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--ink) 16%, transparent);
  opacity: 0; transform: translateY(10px); visibility: hidden; transition: opacity .2s, transform .2s, visibility 0s .2s; }
.totop.on { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.totop:hover { border-color: var(--oxide); }
.totop svg { width: 16px; height: 16px; }
@media (prefers-reduced-motion: reduce) { .totop { transition: none; } }
@media print { header.top { position: static; } .totop { display: none; } }
.top .wrap { display: flex; align-items: center; gap: 20px; padding-block: 14px; }
.mark { display: flex; align-items: center; gap: 9px; font: 600 1.1rem/1 var(--serif); color: var(--ink); text-decoration: none; }
.mark svg { width: 26px; height: 26px; }
.mark .arch { stroke: currentColor; }
.mark .piers { stroke: var(--oxide); }
.crumb { font: 500 var(--s-1)/1 var(--sans); color: var(--muted); text-decoration: none; white-space: nowrap; }
.crumb::before { content: "/"; margin-right: 12px; color: var(--rule); }
a.crumb:hover { color: var(--ink); }
.grow { flex: 1; }
.langs { display: flex; gap: 14px; }
.langs button { font: 500 var(--s-1)/1 var(--sans); color: var(--muted); background: none; border: 0; padding: 6px 0; cursor: pointer; border-bottom: 2px solid transparent; }
.langs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--oxide); }
.langs .short { display: none; }
@media (max-width: 680px) { .langs .long { display: none; } .langs .short { display: inline; } }
.gh { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); text-decoration: none; font: 500 var(--s-1)/1 var(--sans); }
.gh svg { width: 18px; height: 18px; fill: currentColor; }
@media (max-width: 480px) { .gh span { display: none; } .top .wrap { gap: 14px; } }

.btn { display: inline-flex; align-items: center; gap: 9px; background: var(--oxide); color: var(--oxide-ink); text-decoration: none; font-weight: 600; padding: 13px 20px; border-radius: 8px; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }

section.band { border-top: 1px solid var(--rule); padding-block: clamp(44px, 7vw, 84px); }
.tag { font: 500 var(--s-1)/1 var(--sans); color: var(--oxide); border: 1px solid currentColor; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.tag.soon { color: var(--muted); border-style: dashed; }

/* The chat, as it looks in Telegram: the one picture every module is told with */
.look { display: grid; grid-template-columns: minmax(0, 23rem) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
@media (max-width: 820px) { .look { grid-template-columns: minmax(0, 1fr); } }
.chat { background: var(--paper); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--oxide); color: var(--oxide-ink); display: grid; place-items: center; font: 600 0.95rem var(--serif); }
.who { font-weight: 600; line-height: 1.2; }
.state { display: flex; align-items: center; gap: 6px; font-size: var(--s-1); color: var(--muted); }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--wake); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wake) 25%, transparent); }
.thread { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.msg { max-width: 86%; padding: 8px 12px 6px; border-radius: 14px; font-size: 0.95rem; line-height: 1.45; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.msg time { display: block; text-align: right; font-size: 0.7rem; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg a { overflow-wrap: anywhere; }
.woke { align-self: center; font-size: 0.75rem; color: var(--muted); }
/* media inside a bubble: a clip plays muted in a loop like Telegram shows it, sound on request (kit.js) */
.msg.media { padding: 4px 4px 6px; max-width: 80%; }
.msg.media video, .msg.media img { display: block; width: 100%; height: auto; border-radius: 11px; background: var(--rule); }
.msg.media .cap { padding: 6px 8px 0; }
.clip { position: relative; }
.sound { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 6px 10px; font: 500 0.75rem/1 var(--sans); color: #fff; background: rgb(0 0 0 / 0.55); cursor: pointer; }
.sound svg { width: 14px; height: 14px; fill: currentColor; }
/* a file the bot changed or a link preview inside a bubble */
.attach { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: center; margin: 4px 0 2px; padding: 8px 10px;
  border-left: 3px solid var(--oxide); background: color-mix(in srgb, var(--oxide) 7%, transparent); border-radius: 0 8px 8px 0; font-size: 0.85rem; }
.attach b { font-weight: 600; }
.attach span { color: var(--muted); grid-column: 1 / -1; }

/* Which part lives where: rows with rules, never cards */
.parts { margin: 0; }
.parts div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 16px; padding-block: 14px; border-top: 1px solid var(--rule); align-items: baseline; }
.parts div:last-child { border-bottom: 1px solid var(--rule); }
@media (max-width: 640px) { .parts div { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.parts dt { font-weight: 600; }
.parts dd { margin: 0; color: var(--muted); }
/* What works today and what does not yet */
.mod-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 40px; margin-top: 30px; max-width: 52em; }
.mod-status ul { margin: 6px 0 0; padding-left: 1.1em; }
.mod-status li { margin-bottom: 6px; }

h3.sub { font: 500 var(--s2)/1.25 var(--serif); margin: 34px 0 12px; }
.note { font-size: var(--s-1); margin: 14px 0 0; max-width: 44em; }
.parts.times { max-width: 52em; }
.parts.times div { grid-template-columns: 17rem minmax(0, 1fr); }
@media (max-width: 640px) { .parts.times div { grid-template-columns: minmax(0, 1fr); } }

/* Steps: only for a real sequence */
.steps { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 26px 32px; }
.steps li { counter-increment: s; min-width: 0; }
.steps li::before { content: counter(s); display: block; font: 500 var(--s3)/1 var(--serif); color: var(--oxide); margin-bottom: 10px; }
.steps p { margin: 0; color: var(--muted); }
.cmds { margin: 36px 0 0; display: grid; gap: 8px; max-width: 40em; }
.cmds div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 14px; align-items: baseline; }
.cmds dd { margin: 0; color: var(--muted); }

/* The modules index (home): one row per module, name and status on the left, what it does on the right */
.modlist { margin: 30px 0 0; max-width: 58em; padding: 0; list-style: none; }
.modlist li { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 8px 28px; padding-block: 20px; border-top: 1px solid var(--rule); align-items: baseline; }
.modlist li:last-child { border-bottom: 1px solid var(--rule); }
@media (max-width: 640px) { .modlist li { grid-template-columns: minmax(0, 1fr); } }
.modlist .name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
.modlist .name a, .modlist .name b { font: 500 var(--s1)/1.25 var(--serif); }
.modlist .name a { color: var(--ink); text-decoration-color: var(--oxide); }
.modlist p { margin: 0; color: var(--muted); }

/* Module page: the name and one sentence on the left, the chat on the right; the rest of the page under it */
.mhero .wrap { padding-block: clamp(36px, 6vw, 72px) clamp(40px, 6vw, 80px); }
.mhero .look { grid-template-columns: minmax(0, 1fr) minmax(0, 23rem); }
@media (max-width: 820px) { .mhero .look { grid-template-columns: minmax(0, 1fr); } }
.mhero h1 { font: 500 var(--s4)/1.06 var(--serif); font-optical-sizing: auto; letter-spacing: -0.02em; margin: 14px 0 22px; text-wrap: balance; }
.mhero .lede { font-size: var(--s1); line-height: 1.5; color: var(--muted); max-width: 30em; margin: 0 0 26px; }
.asks { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 30em; }
.asks li { font-family: var(--serif); font-size: var(--s0); padding-left: 1.1em; text-indent: -1.1em; }
.asks li::before { content: "«"; color: var(--oxide); margin-right: 0.15em; }
html[data-lang="en"] .asks li::before { content: "“"; }
.asks li::after { content: "»"; color: var(--oxide); margin-left: 0.1em; }
html[data-lang="en"] .asks li::after { content: "”"; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); }
@media (max-width: 820px) { .two { grid-template-columns: minmax(0, 1fr); } }
.needs { margin: 0; }
.needs div { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 14px; padding-block: 10px; border-top: 1px solid var(--rule); align-items: baseline; }
@media (max-width: 480px) { .needs div { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.needs dt { font-weight: 600; }
.needs dd { margin: 0; color: var(--muted); }
.others { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; padding: 0; list-style: none; }
.others a { font: 500 var(--s1)/1.3 var(--serif); }

/* Where it runs: <span class="where" data-where="local|local-first|cloud|external"></span>. kit.js fills it in with an icon and the
   words in the three languages. Optional: data-via="Groq" (a provider shown after the words), data-as="device|admin" (a local
   state worded for your own device or the administrator's machines), data-note-es/-en/-ru (what travels, as title and as
   screen-reader text). <span class="where-flag" data-flag="off"></span> says a home service is switched off on purpose for now.
   <div class="where-legend" data-legend></div> (add data-flag to list the flag too) explains them once per page. */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.where, .where-flag { --wc: var(--w-local); display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-left: 0.55em; padding: 1px 8px 1px 6px;
  border: 1px solid color-mix(in srgb, var(--wc) 42%, var(--rule)); border-radius: 6px; background: color-mix(in srgb, var(--wc) 6%, transparent);
  color: var(--ink); font: 500 0.74rem/1.45 var(--sans); font-style: normal; letter-spacing: 0; text-transform: none; text-align: left; vertical-align: 0.08em; }
.where svg, .where-flag svg { width: 13px; height: 13px; flex: none; color: var(--wc); fill: none; stroke: currentColor; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.where[data-where="local-first"] { --wc: var(--w-first); }
.where[data-where="cloud"] { --wc: var(--w-cloud); border-style: dashed; }
.where[data-where="external"] { --wc: var(--w-ext); border-style: dotted; }
.where-flag { --wc: var(--muted); background: transparent; border-style: dashed; font-weight: 400; color: var(--muted); }
.where .via { font-weight: 400; color: var(--muted); }
.where.blk, .where-flag.blk { display: flex; width: fit-content; margin: 6px 0 0; }
.where.blk + .where.blk, .where.blk + .where-flag.blk { margin-top: 4px; }
h2 .where, h3 .where, h4 .where { font-size: 0.74rem; font-weight: 500; font-family: var(--sans); }
.where-legend { margin: 0 0 28px; max-width: 60em; }
.where-legend > p { margin: 0 0 4px; font-weight: 500; }
.where-legend ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr)); gap: 12px 28px; }
.where-legend li { display: grid; gap: 4px; justify-items: start; color: var(--muted); font-size: var(--s-1); line-height: 1.45; }
.where-legend .where, .where-legend .where-flag { margin: 0; }
.where-legend .lg-note { margin: 12px 0 0; max-width: 60em; color: var(--muted); font-size: var(--s-1); font-weight: 400; }
.where[data-where="local"] { background: color-mix(in srgb, var(--wc) 13%, transparent); }
.where[data-where="home"] { background: transparent; }
@media print { .where, .where-flag { border-color: currentColor; } }

footer { border-top: 1px solid var(--rule); padding-block: 26px 44px; color: var(--muted); font-size: var(--s-1); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 26px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
