
/* Colour and font tokens come from app/models/theme.rb (inlined by the layout).
   Roles: --kw keyword, --fn function, --num number, --str string, --type type. */

:root {
  --measure: 40rem;
  --wide: 70rem;
  --gutter: 1rem;
  color-scheme: dark;
}

@media (min-width: 40rem) {
  :root { --gutter: 2.5rem; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: var(--size);
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s, color 0.25s;
}

::selection { background: var(--rule); color: var(--bright); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in oklab, var(--fn) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s, text-decoration-color 0.15s;
}
a:hover { color: var(--fn); text-decoration-color: var(--fn); }
:focus-visible { outline: 1px solid var(--kw); outline-offset: 3px; }

h1, h2, h3 { color: var(--bright); font-weight: 500; line-height: 1.15; }
h1 { font-size: clamp(2.4rem, 6.5vw, 4rem); margin: 0 0 1rem; letter-spacing: -0.015em; font-weight: 400; }
h2 { font-size: 1.6rem; margin: 0 0 1rem; }
h3 { font-size: 1.2rem; margin: 0 0 0.35rem; }

p { margin: 0 0 1rem; }

.wrap { max-width: var(--wide); margin-inline: auto; padding-inline: var(--gutter); }
.measure { max-width: var(--measure); }

/* labels read like code comments */
.label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  color: var(--comment);
}

.muted { color: var(--muted); }

.lede { font-size: 1.15em; line-height: 1.5; color: var(--fg); font-weight: 300; }
@media (min-width: 40rem) { .lede { font-size: 1.3em; } }

/* ---------- header / footer ---------- */

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.5rem;
}
.brand {
  text-decoration: none;
  color: var(--bright);
  font-size: 1.05rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
}
.brand .brand:hover { color: var(--bright); }

.nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-family: var(--mono); font-size: 0.78rem; }
.nav a { text-decoration: none; color: var(--comment); padding-block: 0.25rem; }
.nav a:hover { color: var(--fn); }
.nav a[aria-current='page'] { color: var(--bright); box-shadow: inset 0 -1px 0 var(--kw); }

.site-footer {
  margin-top: 6rem;
  border-top: 1px solid var(--rule);
  padding-block: 2rem 3.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--comment);
}
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.site-footer a { text-decoration: none; }

main { padding-top: 3.5rem; }

section + section { margin-top: 5.5rem; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.6rem;
  margin-bottom: 2rem;
}
.section-head h2 { margin: 0; font-size: 1.45rem; }
.section-head a { font-family: var(--mono); font-size: 0.75rem; text-decoration: none; color: var(--comment); }
.section-head a:hover { color: var(--fn); }

/* ---------- grids ---------- */

/* four streams: 1 → 2 → 4 columns, never 3+1 */
.grid-4 { display: grid; gap: 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 36rem) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 62rem) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* ---------- streams ---------- */

.stream-mark { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.stream-mark .stream-mark .iast { font-style: italic; color: var(--str); font-size: 0.85em; }

.now-col h3 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.now-col h3 a { text-decoration: none; }
.now-col > .label { display: block; margin-bottom: 0.9rem; }

.entries { list-style: none; margin: 0; padding: 0; }
.entry { padding-block: 0.75rem; border-bottom: 1px solid var(--rule); }
.entry:first-child { padding-top: 0; }
.entry-title { color: var(--bright); line-height: 1.35; }
.entry-title a { text-decoration-color: var(--rule); }
.entry-title a:hover { text-decoration-color: var(--fn); }
.entry-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--comment);
  margin-top: 0.3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
}
.entry-meta time { color: var(--num); }
.entry-meta .next { color: var(--kw); }
.theme-field { margin: 1rem 0 0.4rem; font-family: var(--mono); font-size: 0.7rem; color: var(--comment); text-transform: lowercase; }
.theme-field::before { content: "// "; }
.theme-field:first-child { margin-top: 0; }
.entry-summary {
  margin: 0.35rem 0 0;
  font-size: 0.9em;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-meta .stream { color: var(--kw); }

.badge {
  font-family: var(--mono);
  font-size: 0.62rem;
  border: 1px solid currentColor;
  padding: 0 0.35rem;
  border-radius: 2px;
  color: var(--type);
  vertical-align: 0.2em;
  margin-left: 0.4rem;
}

.empty { color: var(--comment); font-style: italic; }

.month { margin-top: 2.75rem; }
.month:first-of-type { margin-top: 0; }
.month > .label { display: block; margin-bottom: 0.9rem; color: var(--num); }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2.5rem; font-family: var(--mono); font-size: 0.75rem; }
.filters a {
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  color: var(--comment);
}
.filters a:hover, .filters a[aria-current='page'] { border-color: var(--kw); color: var(--bright); }

/* ---------- path (timeline) ---------- */

.path { list-style: none; margin: 0; padding: 0; }
.path li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.2rem 2rem;
  padding-block: 1.3rem;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 40rem) {
  .path li { grid-template-columns: 8rem 1fr; }
}
.path .when { font-family: var(--mono); font-size: 0.75rem; color: var(--comment); padding-top: 0.3rem; }
.path .when b { display: block; color: var(--num); font-weight: 400; }
.path p { margin: 0; font-size: 0.95em; color: var(--muted); }

/* About: counts from the ontology (OntologyFacts) */
.facts-head { font-size: 1rem; margin: 1.6rem 0 0.5rem; }
.facts-head .verb { font-family: var(--mono); font-size: 0.68rem; color: var(--comment); font-weight: 400; margin-left: 0.4rem; }
.facts-head .verb::before { content: "// "; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem; font-family: var(--mono); font-size: 0.75rem; }
.facts li { display: grid; grid-template-columns: minmax(0, 12rem) minmax(0, 1fr) 2.5rem; gap: 0.6rem; align-items: center; }
.facts-label { color: var(--fg); overflow-wrap: anywhere; }
.facts-bar { height: 0.45rem; background: linear-gradient(to right, var(--kw) var(--share), transparent var(--share)); border-bottom: 1px solid var(--rule); }
.facts-n { color: var(--num); text-align: right; }
.facts-pair { display: grid; gap: 0 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 52rem) { .facts-pair { grid-template-columns: 1fr 1fr; } .facts-pair .facts li { grid-template-columns: minmax(0, 8rem) minmax(0, 1fr) 2.5rem; } }
@media (max-width: 30rem) { .facts li { grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 2rem; } }
.num { color: var(--num); font-weight: 400; }



/* ---------- prose (entry bodies) ---------- */

.prose { max-width: var(--measure); }
.prose h2 { font-size: 1.35rem; margin-top: 2.25rem; }
.prose blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--kw);
  color: var(--muted);
}
.prose img { max-width: 100%; height: auto; }
.prose code { font-family: var(--mono); font-size: 0.85em; background: var(--panel); color: var(--str); padding: 0.1em 0.35em; border-radius: 3px; }
.prose pre { font-family: var(--mono); background: var(--panel); padding: 1rem; overflow-x: auto; font-size: 0.85rem; }

/* ---------- hero & page heads ---------- */

.hero { padding-bottom: 0.5rem; }
.routes { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem; font-family: var(--mono); font-size: 0.85rem; }
.routes a { display: inline-block; padding-block: 0.3rem; }
.routes li::before { content: "↓ "; color: var(--kw); }

.stream-head { margin-bottom: 3rem; }
.stream-head h1 .stream-head .iast { font-style: italic; color: var(--str); }

.entry-page header { margin-bottom: 2.25rem; }
.entry-page .entry-meta { font-size: 0.78rem; }
.back { font-family: var(--mono); font-size: 0.8rem; text-decoration: none; color: var(--comment); }

/* ---------- home: hero ---------- */

.name {
  font-size: clamp(3rem, 10vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}
.roles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  font-family: var(--mono);
  font-size: clamp(0.8rem, 1.6vw, 0.95rem);
  margin-bottom: 1.75rem;
}
.role-0 { color: var(--kw); }
.role-1 { color: var(--fn); }
.role-2 { color: var(--str); }
.roles { flex-direction: column; }
@media (min-width: 40rem) {
  .roles { flex-direction: row; }
  .role + .role::before { content: '/'; color: var(--comment); margin-right: 1.4rem; }
}

.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  text-decoration: none;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--rule);
  color: var(--bright);
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--fn); color: var(--fn); }

/* ---------- home: studio ---------- */

.studio {
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--kw);
}
.studio p { color: var(--muted); margin: 0; }
.studio h2 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); max-width: 22ch; margin: 0.6rem 0 1.25rem; font-weight: 400; }
.studio .btn { margin-top: 1.5rem; }

.chips { list-style: none; padding: 0; margin: 1.25rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; font-family: var(--mono); font-size: 0.7rem; }
.chips li { border: 1px solid var(--rule); padding: 0.2rem 0.55rem; color: var(--fg); background: var(--bg); }

/* ---------- home: crafts ---------- */

.crafts { display: grid; gap: 3.5rem; grid-template-columns: 1fr; }
@media (min-width: 56rem) { .crafts { grid-template-columns: 1fr 1fr; gap: 4rem; } }
.craft h3 { font-size: clamp(1.7rem, 3vw, 2.2rem); font-weight: 400; margin: 0.3rem 0 1rem; }

.work { list-style: none; padding: 0; margin: 0 0 1.5rem; border-top: 1px solid var(--rule); }
.work li { padding-block: 0.6rem; border-bottom: 1px solid var(--rule); display: grid; gap: 0.1rem; }
.work-title { color: var(--bright); }
.work-role { font-family: var(--mono); font-size: 0.7rem; color: var(--comment); }

.arrows { list-style: none; padding: 0; margin: 0; font-family: var(--mono); font-size: 0.75rem; }
.arrows li + li { margin-top: 0.35rem; }
.arrows li::before { content: '→ '; color: var(--kw); }



.nav .nav-cta { color: var(--kw); border: 1px solid color-mix(in oklab, var(--kw) 60%, transparent); padding: 0.2rem 0.6rem; }
.nav .nav-cta:hover { color: var(--bg); background: var(--kw); }

/* ---------- home: research, commissions ---------- */

.grid-3 { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 52rem) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.series {
  display: block;
  text-decoration: none;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  transition: border-color 0.2s;
}
.series:hover { color: inherit; border-top-color: var(--kw); }
.series:hover h3 { color: var(--fn); }
.series .count { display: block; font-size: clamp(2.4rem, 5vw, 3.2rem); line-height: 1; color: var(--num); font-weight: 300; margin-bottom: 0.6rem; }
.series p { font-size: 0.92em; color: var(--muted); margin: 0.35rem 0 0; }


.commissions { margin: 0; display: grid; gap: 1rem 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 52rem) { .commissions { grid-template-columns: repeat(3, 1fr); } }
.commissions dt { color: var(--bright); }
.commissions dd { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.95em; }

.note-links { margin-top: 2rem; }
.entry-page .chips { margin-top: 1.5rem; }

.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--panel); color: var(--bright); padding: 0.4rem 0.8rem; z-index: 20; }
.skip:focus { left: 0.5rem; }

/* ---------- theme picker ---------- */

#theme-picker {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  display: grid;
  justify-items: end;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
}
.tp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.3);
}
.tp-toggle:hover, .tp-toggle[aria-expanded="true"] { border-color: var(--kw); color: var(--bright); }
.tp-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: conic-gradient(var(--kw) 0 25%, var(--fn) 0 50%, var(--str) 0 75%, var(--num) 0); }
.tp-panel {
  display: grid;
  gap: 0.45rem;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.35);
}
.tp-panel[hidden] { display: none; }
.tp-title { color: var(--bright); }
.tp-hint { color: var(--comment); font-size: 0.65rem; }
.tp-row { display: flex; gap: 0.35rem; }
#theme-picker select, .tp-panel button { font: inherit; color: var(--bright); background: var(--bg); border: 1px solid var(--rule); padding: 0.3rem 0.4rem; }
#theme-picker select { flex: 1; min-width: 0; }
.tp-panel button { cursor: pointer; width: 1.9rem; }
.tp-panel button:hover { border-color: var(--kw); }
.tp-swatches { display: flex; gap: 0.25rem; }
.tp-swatches i { flex: 1; height: 0.35rem; }
.sw-kw { background: var(--kw); } .sw-fn { background: var(--fn); } .sw-num { background: var(--num); } .sw-str { background: var(--str); } .sw-type { background: var(--type); }

/* ---------- contact form (public) ---------- */

.contact-form { display: grid; gap: 0.9rem; margin-top: 1.5rem; }
.contact-form .row { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: flex-end; }
.contact-form label { display: grid; gap: 0.3rem; font-family: var(--mono); font-size: 0.72rem; color: var(--comment); min-width: 0; }
.contact-form label.grow { flex: 1 1 13rem; }
.contact-form input, .contact-form select, .contact-form textarea {
  font: inherit; font-family: var(--serif); font-size: 1rem; color: var(--bright);
  background: var(--panel); border: 1px solid var(--rule); padding: 0.55rem 0.65rem; width: 100%; min-width: 0;
}
.contact-form select { font-family: var(--mono); font-size: 0.8rem; }
.contact-form textarea { resize: vertical; line-height: 1.5; }
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus { outline: 1px solid var(--kw); border-color: var(--kw); }
.contact-form .btn { cursor: pointer; background: transparent; }
.contact-form .optional { color: var(--comment); }
.form-note { font-family: var(--mono); font-size: 0.72rem; color: var(--comment); }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.flash { margin: 0 0 1.5rem; padding: 0.6rem 0.9rem; border-left: 3px solid var(--kw); background: var(--panel); font-family: var(--mono); font-size: 0.8rem; }

.commissions-grid { display: grid; gap: 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 56rem) { .commissions-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; } }
.commissions-grid .commissions { grid-template-columns: 1fr; }
.commissions-grid .contact-form { margin-top: 0; }
.flash.notice { border-left-color: var(--str); }

/* ---------- error pages ---------- */

.error-page { padding-top: 5rem; min-height: 70vh; }
.error-page .label { font-size: 0.85rem; color: var(--num); }
.error-page h1 { margin-top: 0.4rem; }
.code {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--kw);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  max-width: var(--measure);
  overflow-x: auto;
  color: var(--fg);
}
.code .kw { color: var(--kw); }
.code .fn { color: var(--fn); }
.code .str { color: var(--str); }
.code .num { color: var(--num); }
.code .type { color: var(--type); }
.code .cm { color: var(--comment); font-style: italic; }
.arrows .quiet { opacity: 0.6; }

.reads { margin-top: 5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-family: var(--mono); font-size: 0.78rem; color: var(--comment); }
.commission-links { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; margin-top: 0.35rem; font-family: var(--mono); font-size: 0.72rem; }
.commission-links a::before { content: "→ "; color: var(--kw); }
.commission-links a { display: inline-block; padding-block: 0.25rem; }
.commission-links .ask { color: var(--fn); }

/* ---------- link previews (link_preview_controller.js) ---------- */

.link-preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  width: 400px;
  padding: 0.7rem 1rem 0.85rem;
  pointer-events: none;            /* never catches a click or a scroll */
  background: var(--panel);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--kw);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 140ms ease, visibility 0s linear 140ms;
}
.link-preview.is-open { opacity: 1; visibility: visible; transition: opacity 140ms ease; }
.lp-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.66rem; color: var(--comment); }
.lp-label::before { content: "// "; }
.link-preview .lp-out { width: 0.75rem; height: 0.75rem; align-self: center; }
.link-preview .lp-out.is-here { -webkit-mask-image: var(--arrow-right); mask-image: var(--arrow-right); }
.lp-title { font-family: var(--serif); font-size: 1.02rem; line-height: 1.3; color: var(--bright); margin: 0.2rem 0 0.6rem; }
.lp-art svg { display: block; overflow: visible; }
.lp-art text { font-family: var(--mono); }
.lp-art .lp-tick { font-size: 9px; }
.lp-art .lp-row { font-size: 9.5px; }
.lp-facts { list-style: none; padding: 0; margin: 0.65rem 0 0; display: flex; flex-wrap: wrap; gap: 0.15rem 0.9rem; font-family: var(--mono); font-size: 0.66rem; }
.lp-facts .k { color: var(--comment); }
.lp-facts .v { color: var(--str); }
.lp-facts .v.n { color: var(--num); }
.lp-caption { margin: 0.45rem 0 0; font-family: var(--serif); font-size: 0.82rem; line-height: 1.45; color: var(--muted); }
.lp-caption:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .link-preview { transition: none; } }

/* External links to Rafał's own sites wear a small arrow that leans in on
   hover. It is drawn (a mask over the accent colour), never the ↗ character:
   iOS renders that as an emoji. */
:root {
  --arrow-out: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 8 8 2M3.5 2H8v4.5' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5h7M5.5 2 8.5 5 5.5 8' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
a.ext::after, .lp-out {
  content: "";
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin-left: 0.22em;
  background: var(--kw);
  -webkit-mask: var(--arrow-out) center / contain no-repeat;
  mask: var(--arrow-out) center / contain no-repeat;
  transition: transform 160ms ease;
}
a.ext:hover::after, a.ext:focus-visible::after { transform: translate(2px, -2px); }

/* ---------- analytics consent (bottom-left, clear of the theme picker) ---------- */

.consent {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: min(26rem, calc(100vw - 2rem - 9rem));
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--kw);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.35);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--fg);
}
.consent[hidden] { display: none; }
.consent p { margin: 0; line-height: 1.5; }
.consent-actions { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; }
.consent .btn { cursor: pointer; background: transparent; padding: 0.4rem 0.9rem; }
.consent .linkish { background: none; border: 0; font: inherit; color: var(--comment); cursor: pointer; text-decoration: underline; }
@media (max-width: 40rem) { .consent { max-width: calc(100vw - 2rem); bottom: 4rem; } }

.keynav-hints {
  position: fixed;
  inset: 0;
  z-index: 10020;
  pointer-events: none;
  isolation: isolate;
}
.keynav-hint {
  position: fixed;
  transform: translate(-20%, -70%);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  padding: 3px 5px 3px 6px;
  border: 1px solid color-mix(in srgb, var(--panel) 72%, transparent);
  border-radius: 4px 4px 4px 1px;
  background: var(--kw);
  color: var(--panel);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--kw) 35%, transparent), 0 2px 8px rgb(0 0 0 / 0.28);
  white-space: nowrap;
  animation: keynav-pointer-in 110ms ease-out both;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out, box-shadow 140ms ease-out;
}
.keynav-hint::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 6px;
  height: 6px;
  background: var(--kw);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.keynav-hint b {
  font-weight: 700;
  color: var(--bright);
  opacity: 1;
}
.keynav-hint span {
  opacity: 0.78;
}
.keynav-hint--dim {
  display: none;
}
.keynav-hint--charged {
  z-index: 2;
  transform: translate(-20%, -70%) scale(1.14) !important;
  border-color: color-mix(in srgb, var(--bright) 70%, var(--str));
  background: var(--str);
  color: var(--panel);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--str) 70%, transparent),
              0 0 13px color-mix(in srgb, var(--str) 48%, transparent),
              0 2px 8px rgb(0 0 0 / 0.28);
}
.keynav-hint--charged::after {
  background: var(--str);
}
.keynav-hint--ready {
  z-index: 3;
  transform: translate(-20%, -70%) scale(1.24) !important;
  border-color: var(--bright);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bright) 75%, transparent),
              0 0 19px color-mix(in srgb, var(--str) 60%, transparent),
              0 2px 8px rgb(0 0 0 / 0.28);
}
.keynav-hint-target {
  outline: 1px solid color-mix(in srgb, var(--kw) 40%, transparent) !important;
  outline-offset: 3px;
}
.keynav-hint-target--ready {
  outline: 2px solid var(--kw) !important;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--kw) 12%, transparent) !important;
}

@keyframes keynav-pointer-in {
  from { opacity: 0; transform: translate(-20%, -42%) scale(0.82); }
  to { opacity: 1; transform: translate(-20%, -70%) scale(1); }
}

/* A selected pointer discharges at the exact place it marked. It is a fast
   lock-on confirmation, not a navigation delay disguised as decoration. */
.keynav-echo {
  position: fixed;
  z-index: 10040;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  isolation: isolate;
  padding: 3px 5px;
  border: 1px solid var(--kw);
  border-radius: 4px 4px 4px 1px;
  background: var(--kw);
  color: var(--panel);
  font: 800 10px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: lowercase;
  transform-origin: 20% 80%;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--kw) 45%, transparent),
              0 0 12px color-mix(in srgb, var(--kw) 36%, transparent);
  animation: keynav-mark-fire 520ms cubic-bezier(0.16, 0.72, 0.18, 1) both;
}
.keynav-echo::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-block: 1px solid var(--str);
  opacity: 0;
  animation: keynav-mark-brackets 520ms ease-out both;
}
@keyframes keynav-mark-fire {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  18% {
    opacity: 1;
    background: var(--str);
    border-color: var(--bright);
    color: var(--bright);
    transform: scale(1.18);
  }
  52% {
    opacity: 0.88;
    background: transparent;
    border-color: var(--str);
    color: var(--str);
    letter-spacing: 0.2em;
    transform: scale(1.78);
  }
  100% {
    opacity: 0;
    background: transparent;
    border-color: transparent;
    color: var(--str);
    letter-spacing: 0.52em;
    transform: scale(3.1);
    box-shadow: 0 0 0 12px transparent;
  }
}
@keyframes keynav-mark-brackets {
  0%, 12% { opacity: 0; transform: scaleX(0.65); }
  34% { opacity: 0.9; transform: scaleX(1.15); }
  100% { opacity: 0; transform: scaleX(2.7); }
}

/* The keystroke ribbon is deliberately more instrument panel than toast. */
.keynav-command {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 10030;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0.7rem;
  min-width: 11rem;
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 0.55rem 0.75rem 0.55rem 0.6rem;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--panel);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.69rem;
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.14);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.8rem) scale(0.97);
  transition: opacity 100ms ease-out, transform 130ms ease-out, border-color 120ms ease-out;
}
.keynav-command--visible {
  opacity: 0.96;
  transform: translate(-50%, 0) scale(1);
}
.keynav-command__beam {
  position: absolute;
  top: -1px;
  left: 0;
  width: 2.5rem;
  height: 2px;
  background: var(--kw);
  box-shadow: 0 0 8px color-mix(in srgb, var(--kw) 75%, transparent);
  opacity: 0;
}
.keynav-command--visible .keynav-command__beam {
  opacity: 0.72;
  animation: keynav-single-light 300ms ease-out both;
}
.keynav-command--combo {
  border-color: color-mix(in srgb, var(--kw) 58%, var(--rule));
  animation: keynav-combo-flare 420ms ease-out both;
}
.keynav-command--combo .keynav-command__beam {
  animation: keynav-combo-light 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.keynav-command--pending {
  border-color: var(--str);
  background: color-mix(in srgb, var(--str) 8%, var(--panel));
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.14),
              0 0 0 3px color-mix(in srgb, var(--str) 10%, transparent),
              0 0 17px color-mix(in srgb, var(--str) 18%, transparent);
  transform: translate(-50%, 0) scale(1.035);
}
.keynav-command--pending .keynav-command__beam {
  width: 36%;
  background: var(--str);
  box-shadow: 0 0 11px color-mix(in srgb, var(--str) 78%, transparent);
  opacity: 0.82;
  animation: keynav-power-wait 720ms ease-in-out infinite alternate;
}
.keynav-command--pending .keynav-command__keys kbd {
  border-color: color-mix(in srgb, var(--str) 68%, var(--bright));
  background: var(--str);
  color: var(--panel);
  box-shadow: 0 0 9px color-mix(in srgb, var(--str) 28%, transparent);
  transform: scale(1.08);
}
.keynav-command--pending .keynav-command__keys i {
  color: var(--str);
  opacity: 0.9;
}
.keynav-command__slot {
  min-width: 1.35rem !important;
  border-style: dashed !important;
  color: var(--bright) !important;
  animation: keynav-slot-wait 620ms steps(2, jump-none) infinite;
}
.keynav-command--miss {
  border-color: var(--comment);
  opacity: 0.78;
}
.keynav-command--miss .keynav-command__beam {
  background: var(--comment);
  box-shadow: none;
}
.keynav-command__keys {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  white-space: nowrap;
}
.keynav-command__keys kbd,
.keynav-help kbd,
.keynav-nudge kbd {
  display: inline-flex;
  min-width: 1.65rem;
  height: 1.65rem;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
  border: 1px solid color-mix(in srgb, var(--kw) 52%, var(--rule));
  border-radius: 4px;
  background: var(--bg);
  color: var(--kw);
  font: 700 0.69rem/1 var(--mono);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--rule) 80%, transparent);
}
.keynav-command__keys i {
  color: var(--comment);
  font-style: normal;
  opacity: 0.55;
}
.keynav-command__verb {
  min-width: 0;
  overflow: hidden;
  color: var(--comment);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.keynav-command--up .keynav-command__verb::before { content: "↑ "; color: var(--kw); }
.keynav-command--down .keynav-command__verb::before { content: "↓ "; color: var(--kw); }

@keyframes keynav-single-light {
  from { transform: translateX(-120%); opacity: 0; }
  35% { opacity: 0.8; }
  to { transform: translateX(14rem); opacity: 0; }
}
@keyframes keynav-combo-light {
  from { width: 1rem; transform: translateX(-130%); opacity: 0; }
  28% { opacity: 1; }
  to { width: 52%; transform: translateX(205%); opacity: 0; }
}
@keyframes keynav-combo-flare {
  0% { box-shadow: 0 4px 18px rgb(0 0 0 / 0.14), 0 0 0 0 color-mix(in srgb, var(--kw) 30%, transparent); }
  42% { box-shadow: 0 4px 18px rgb(0 0 0 / 0.14), 0 0 0 7px color-mix(in srgb, var(--kw) 9%, transparent); }
  100% { box-shadow: 0 4px 18px rgb(0 0 0 / 0.14), 0 0 0 12px transparent; }
}
@keyframes keynav-power-wait {
  from { transform: translateX(-8%); opacity: 0.38; }
  to { transform: translateX(180%); opacity: 0.95; }
}
@keyframes keynav-slot-wait {
  from { opacity: 0.42; }
  to { opacity: 1; }
}

.keynav-flash-target {
  outline: 2px solid var(--kw) !important;
  outline-offset: 4px;
  animation: keynav-target-flash 600ms ease-out both;
}
@keyframes keynav-target-flash {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--kw) 38%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}

.keynav-help {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 10025;
  width: min(47rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.1rem 1.2rem 0.9rem;
  border: 1px solid var(--rule);
  border-top: 2px solid var(--kw);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgb(0 0 0 / 0.2);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.75rem;
  animation: keynav-help-in 150ms ease-out both;
}
/* humanitloop runs on a reset stylesheet; this site's base styles (section
   spacing, dd indent, heading margins) must not reach the panel. */
.keynav-help section { margin: 0; }
.keynav-help dl, .keynav-help dd, .keynav-help h2, .keynav-help h3, .keynav-help p { margin: 0; }
.keynav-help:focus, .keynav-help:focus-visible { outline: none; }
.keynav-help__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--rule);
}
.keynav-help__header h2 {
  margin-top: 0.12rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 400;
}
.keynav-help__eyebrow,
.keynav-help h3 {
  color: var(--comment);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.64rem;
}
.keynav-help__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  padding: 1rem 0 0.85rem;
}
.keynav-help h3 {
  margin-bottom: 0.48rem;
}
.keynav-help dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.38rem 0.65rem;
  align-items: center;
}
.keynav-help dt {
  display: flex;
  gap: 0.16rem;
  color: var(--kw);
}
.keynav-help dd {
  color: var(--comment);
  line-height: 1.25;
}
.keynav-help kbd {
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.25rem;
  font-size: 0.61rem;
}
.keynav-help__foot {
  padding-top: 0.72rem;
  border-top: 1px solid var(--rule);
  color: var(--comment);
  font-size: 0.64rem;
}
.keynav-help__foot kbd {
  display: inline;
  min-width: 0;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--kw);
}
@keyframes keynav-help-in {
  from { opacity: 0; transform: translateY(0.6rem); }
  to { opacity: 1; transform: translateY(0); }
}

.keynav-nudge {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 10010;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.52rem 0.7rem;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--panel);
  color: var(--comment);
  font-family: var(--mono);
  font-size: 0.66rem;
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.12);
  animation: keynav-nudge-in 180ms ease-out both;
}
.keynav-nudge__line {
  position: absolute;
  top: 0;
  left: 0;
  width: 2.4rem;
  height: 2px;
  background: var(--kw);
}
.keynav-nudge__quiet {
  padding-left: 0.55rem;
  border-left: 1px solid var(--rule);
}
.keynav-nudge kbd {
  display: inline-flex;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.24rem;
  font-size: 0.6rem;
}
@keyframes keynav-nudge-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  .keynav-command {
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    width: calc(100vw - 1.3rem);
  }
  .keynav-help {
    right: 0.65rem;
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    width: calc(100vw - 1.3rem);
  }
  .keynav-help__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .keynav-nudge {
    right: 0.65rem;
    bottom: max(0.65rem, env(safe-area-inset-bottom));
  }
  .keynav-nudge__quiet { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .keynav-hint,
  .keynav-command,
  .keynav-command__beam,
  .keynav-command--combo,
  .keynav-command__slot,
  .keynav-echo,
  .keynav-echo::before,
  .keynav-flash-target,
  .keynav-help,
  .keynav-nudge {
    animation: none !important;
    transition: none !important;
  }
}
