/* Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V5
 * macrostructure: Portfolio Grid · genre: atmospheric · tone: technical
 * hero: H1 Marquee · polish: HP3 Cursor-spotlight (extended into custom canvas grid+light engine)
 * enrichment: real screenshots (E8-style), tier: none custom-built (no invented imagery)
 * nav: N5 Floating pill · footer: Ft5 Statement
 * theme: custom (amber-anchor dark) · accent: warm amber ~63° · studied: no
 * contrast: pass (40–41) · nav: N5 · footer: Ft5 · slop: pass (42–45)
 * honest: pass (46) · chrome: pass (47) · tokens: pass (48) · responsive: pass (49)
 * mobile: pass (34, 49, 50–57)
 */

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Clears the fixed floating nav pill so every in-page anchor (nav
     links, hero CTA, wordmark) lands with the target section's heading
     visible below it, not hidden underneath. */
  scroll-padding-top: 6rem;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

/* ---------- page-wide reactive field — the connective layer ---------- */

.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
}

/* ---------- intro — fast, skippable brand sting ---------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  overflow: hidden;
}
.intro__half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(50% + 1px);
  display: flex;
  align-items: center;
  background: var(--color-paper);
  transition: transform 480ms var(--ease-in-out);
}
.intro__half--left { left: 0; justify-content: flex-end; }
.intro__half--right { right: 0; justify-content: flex-start; }

.intro__digit {
  font-family: var(--font-mono);
  font-size: clamp(6rem, 22vw, 18rem);
  font-weight: 600;
  line-height: 1;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

.intro.is-leaving .intro__half--left { transform: translateX(-100%); }
.intro.is-leaving .intro__half--right { transform: translateX(100%); }

.intro.is-done { display: none; }

.skip-link {
  position: absolute;
  left: var(--space-md);
  top: -100%;
  background: var(--color-paper-2);
  color: var(--color-ink);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  z-index: var(--z-tooltip);
  transition: top var(--dur-short) var(--ease-out);
}
.skip-link:focus-visible {
  top: var(--space-md);
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: inherit;
}

/* ---------- nav — N5 floating pill ---------- */

.nav {
  position: fixed;
  top: var(--space-md);
  left: 0;
  right: 0;
  z-index: var(--z-sticky-nav);
  max-width: min(44rem, calc(100% - var(--space-lg)));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-lg);
  border-radius: 999px;
  border: var(--rule-hair) solid var(--color-rule);
  background: color-mix(in oklch, var(--color-paper-2) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 1px 2px oklch(20% 0.01 63 / 0.2);
}

.nav__wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-base);
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--color-ink);
  white-space: nowrap;
}
.nav__wordmark:hover { color: var(--color-accent); }
.nav__wordmark .kchar {
  display: inline;
  will-change: font-variation-settings;
}

@media (prefers-reduced-motion: reduce) {
  .nav__wordmark .kchar { font-variation-settings: "wght" 600 !important; }
}

.nav__links {
  display: flex;
  flex: 1 1 auto;
  justify-content: space-evenly;
  gap: var(--space-md);
}
.nav__link {
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-short) var(--ease-out);
}
.nav__link:hover { color: var(--color-ink); }

@media (hover: hover) and (pointer: fine) {
  .nav__link[data-magnetic] { transition: transform 150ms var(--ease-out), color var(--dur-short) var(--ease-out); }
}

.nav__cta { white-space: nowrap; }

@media (max-width: 40rem) {
  .nav__links { display: none; }
  .nav { max-width: calc(100% - var(--space-lg)); }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  height: 44px;
  padding-inline: var(--space-lg);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: var(--rule-hair) solid transparent;
  transition: background-color var(--dur-short) var(--ease-out),
              border-color var(--dur-short) var(--ease-out),
              transform 100ms var(--ease-out);
}
.btn--sm { height: 36px; padding-inline: var(--space-md); }

.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}
.btn--primary:hover { background: color-mix(in oklch, var(--color-accent) 88%, white); }
.btn--primary:active { transform: translateY(1px); }

.btn--ghost, .btn--sm {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--color-rule-2);
}
.btn--ghost:hover, .btn--sm:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.btn--ghost:active, .btn--sm:active { transform: translateY(1px); }

.btn:focus-visible { outline-offset: 3px; }

@media (hover: hover) and (pointer: fine) {
  .btn[data-magnetic] { transition: transform 150ms var(--ease-out), background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out); }
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  overflow: hidden;
}

.hero__body {
  position: absolute;
  z-index: 2;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 40rem;
  padding: 0 var(--space-lg) clamp(var(--space-2xl), 12vh, var(--space-3xl));
  text-align: left;
}

.hero__title {
  margin: 0 0 var(--space-md);
  max-width: 20ch;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-display-s);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  text-wrap: balance;
}

.hero__tagline {
  margin: 0 0 var(--space-xl);
  max-width: 42ch;
  font-size: var(--text-md);
  color: var(--color-ink-2);
}

.hero__actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* ---------- hero stage — arcade scene, torch-reveal on hover ---------- */

.hero__stage {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  background: oklch(10% 0.006 63);
}

.hero__stage-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/*
 * Torch reveal, two independent mask layers:
 *  1) a soft turbulence-warped blob (the "hole"), repositioned/rescaled
 *     every frame via plain mask-position/mask-size — ordinary CSS
 *     painting properties that always resolve against the element's
 *     live box, so this tracks scroll correctly (unlike an SVG <mask>
 *     with maskContentUnits="userSpaceOnUse", which doesn't).
 *  2) a solid white fill sized 100% 100% — always covers the whole
 *     box regardless of scroll or of how big/small the hole is.
 * Layer 1 is subtracted from layer 2, punching the hole out of an
 * otherwise-always-complete cover.
 */
.hero__stage-img--off {
  --torch-tex: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MDAiIGhlaWdodD0iNTAwIj4KPGRlZnM+CjxmaWx0ZXIgaWQ9ImUiIHg9Ii02MCUiIHk9Ii02MCUiIHdpZHRoPSIyMjAlIiBoZWlnaHQ9IjIyMCUiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZVR1cmJ1bGVuY2UgdHlwZT0iZnJhY3RhbE5vaXNlIiBiYXNlRnJlcXVlbmN5PSIwLjAxMiAwLjAyIiBudW1PY3RhdmVzPSIyIiBzZWVkPSI3IiByZXN1bHQ9Im4iLz4KPGZlRGlzcGxhY2VtZW50TWFwIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9Im4iIHNjYWxlPSI3MCIgeENoYW5uZWxTZWxlY3Rvcj0iUiIgeUNoYW5uZWxTZWxlY3Rvcj0iRyIvPgo8ZmVHYXVzc2lhbkJsdXIgc3RkRGV2aWF0aW9uPSIyMCIvPgo8L2ZpbHRlcj4KPC9kZWZzPgo8Y2lyY2xlIGN4PSIyNTAiIGN5PSIyNTAiIHI9IjE1MCIgZmlsbD0iI2ZmZiIgZmlsdGVyPSJ1cmwoI2UpIi8+Cjwvc3ZnPg==");
  mask-image: var(--torch-tex), linear-gradient(#fff, #fff);
  mask-repeat: no-repeat, no-repeat;
  mask-position: 0 0, 0 0;
  mask-size: 0 0, 100% 100%;
  mask-composite: exclude, add;
  -webkit-mask-image: var(--torch-tex), linear-gradient(#fff, #fff);
  -webkit-mask-repeat: no-repeat, no-repeat;
  -webkit-mask-position: 0 0, 0 0;
  -webkit-mask-size: 0 0, 100% 100%;
}

.hero__scrim {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(0deg, oklch(6% 0.005 63 / 0.7) 0%, oklch(6% 0.005 63 / 0.3) 32%, transparent 58%);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .hero__stage-img--on { display: none; }
}

/* ---------- section head (no eyebrow, single column) ---------- */

.section__head {
  display: block;
  max-width: 46rem;
  margin: 0 auto var(--space-2xl);
  padding-inline: var(--space-lg);
}
.section__title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-2xl);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--color-ink);
}
.section__sub {
  margin: 0;
  max-width: 60ch;
  color: var(--color-muted);
  font-size: var(--text-base);
}

.work, .bots { padding: var(--space-3xl) var(--space-lg); }

/* ---------- work grid ---------- */

.work__grid {
  max-width: 72rem;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-xl) var(--space-lg);
}

.work-card {
  opacity: 0;
  transform: translateY(8px);
}
.work-card.is-visible {
  animation: reveal var(--dur-long) var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}
@keyframes reveal { to { opacity: 1; transform: none; } }

.work-card__figure {
  margin: 0 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1000 / 703;
}
.work-card__figure img { width: 100%; height: 100%; object-fit: cover; }

.work-card__title {
  margin: 0 0 var(--space-2xs);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--color-ink);
}
.work-card__desc {
  margin: 0 0 var(--space-md);
  color: var(--color-muted);
  font-size: var(--text-sm);
  max-width: 46ch;
}
.work-card__note {
  margin: calc(-1 * var(--space-sm)) 0 var(--space-md);
  color: var(--color-neutral);
  font-size: var(--text-xs);
  max-width: 46ch;
}

/* tech-stack marquee — a slow, looping strip so the full list never
   sits on screen at once; content is duplicated in markup and the
   track scrolls exactly one copy-length via translateX(-50%). */
.work-card__stack {
  margin: 0 0 var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
}
.work-card__stack-label {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-muted);
}
.work-card__stack-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.work-card__stack-track {
  display: flex;
  width: max-content;
  gap: var(--space-lg);
  animation: stack-scroll var(--stack-dur, 16s) linear infinite;
}
.work-card__stack-item {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-neutral);
  white-space: nowrap;
}
@keyframes stack-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.work-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.work-card__link {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  transition: border-color var(--dur-short) var(--ease-out);
}
.work-card__link:hover { border-color: var(--color-accent); }

.work-card__github {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-short) var(--ease-out);
}
.work-card__github:hover { color: var(--color-ink); }
.work-card__github svg { width: 16px; height: 16px; fill: currentColor; flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  .work-card { opacity: 1; transform: none; animation: none; }
  .work-card__stack-track { animation: none; }
}

/* ---------- chat demo — one glass sheet, no boxed sub-panels ----------
   Deliberately narrow (phone-proportioned, not a full desktop app pane)
   and centered — this is what makes it read as a floating glass surface
   over the page's own background rather than another opaque card. Every
   internal region (header/log/composer) shares this ONE background; none
   of them get their own fill, so nothing double-glasses or looks stacked.
   .bg-canvas (fixed, z-index:-1, cursor-reactive dot-grid) sits behind
   every section already — this is what the backdrop-filter blurs. */

.chatdemo__disclaimer {
  max-width: 30rem;
  margin: var(--space-sm) auto 0;
  color: var(--color-neutral);
  font-size: var(--text-xs);
  text-align: center;
}

.chatdemo {
  max-width: 30rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklch, var(--color-ink) 10%, transparent);
  background: color-mix(in oklch, var(--color-paper-2) 13%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 color-mix(in oklch, var(--color-ink) 8%, transparent);
  overflow: hidden;
  /* Fixed, not min-height — the whole point is that switching bots/modes
     must never resize this card. Sized to comfortably fit the longest
     scenario (cafe's 5-entry business digest) without scrolling; shorter
     ones just leave trailing space in the log. `.chatdemo__log` (flex:1,
     overflow-y:auto) is the safety net for anything that still doesn't
     fit, so it scrolls internally instead of resizing the card. */
  height: 34rem;
}

.chatdemo__chat-head {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3xs);
  padding: var(--space-lg) var(--space-md) var(--space-md);
  border-bottom: 1px solid color-mix(in oklch, var(--color-ink) 8%, transparent);
}

/* ---------- bot picker — exactly 3 avatars, always: 2 small up top,
   1 big below. Picking a small one FLIP-animates it into the big slot
   (see js/main.js swapToBig/flip) instead of duplicating the icon in a
   separate always-big element. `.chatdemo__bot-avatar` is the one tile
   style; size comes purely from which container currently holds it. */

.chatdemo__bot-switch {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.chatdemo__bot-big {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-2xs);
}

.chatdemo__bot-avatar {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1.5px solid transparent;
  background: color-mix(in oklch, var(--color-paper-3) 45%, transparent);
  color: color-mix(in oklch, var(--color-ink) 55%, transparent);
  cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out);
}
.chatdemo__bot-avatar svg { width: 18px; height: 18px; }
.chatdemo__bot-avatar:hover { color: var(--color-accent); }
.chatdemo__bot-avatar:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chatdemo__bot-avatar[aria-selected="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: color-mix(in oklch, var(--color-accent) 16%, transparent);
  cursor: default;
}

.chatdemo__bot-big .chatdemo__bot-avatar {
  width: 3.5rem;
  height: 3.5rem;
}
.chatdemo__bot-big .chatdemo__bot-avatar svg { width: 28px; height: 28px; }

.chatdemo__chat-name {
  margin-top: var(--space-2xs);
  max-width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--color-ink);
  overflow-wrap: anywhere;
}
.chatdemo__chat-status { font-size: var(--text-xs); color: var(--color-muted); }

/* ---------- client / business mode toggle ---------- */

.chatdemo__modes {
  position: relative;
  display: inline-flex;
  margin-top: var(--space-sm);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--color-ink) 10%, transparent);
  background: color-mix(in oklch, var(--color-paper) 35%, transparent);
}
.chatdemo__modes-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--color-accent);
  transition: transform var(--dur-long) var(--ease-out);
}
.chatdemo__modes[data-active="business"] .chatdemo__modes-indicator {
  transform: translateX(100%);
}

.chatdemo__mode-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-3xs) var(--space-sm);
  border: none;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  transition: color var(--dur-short) var(--ease-out);
}
.chatdemo__mode-btn svg { width: 13px; height: 13px; }
.chatdemo__mode-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chatdemo__modes[data-active="client"] .chatdemo__mode-btn[data-mode-btn="client"],
.chatdemo__modes[data-active="business"] .chatdemo__mode-btn[data-mode-btn="business"] {
  color: var(--color-accent-ink);
}

.chatdemo__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
  /* Thin accent-tinted scrollbar instead of the OS default. Firefox via
     scrollbar-width/-color, Chromium/WebKit via the pseudo-elements below;
     both degrade gracefully (default bar) on engines that support neither. */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklch, var(--color-accent) 50%, transparent) transparent;
}
.chatdemo__log.is-switching { opacity: 0; transform: translateY(4px); }

.chatdemo__log::-webkit-scrollbar { width: 6px; }
.chatdemo__log::-webkit-scrollbar-track { background: transparent; }
.chatdemo__log::-webkit-scrollbar-thumb {
  background: color-mix(in oklch, var(--color-accent) 50%, transparent);
  border-radius: 999px;
}
.chatdemo__log::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklch, var(--color-accent) 70%, transparent);
}

/* Same thin accent-tinted scrollbar, reused wherever else a panel can
   scroll internally (contact form's message textarea, and the modal
   itself as a fallback) — one scrollbar language across the site instead
   of the OS default anywhere. */
.field__input--area, .contact-modal {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklch, var(--color-accent) 50%, transparent) transparent;
}
.field__input--area::-webkit-scrollbar, .contact-modal::-webkit-scrollbar { width: 6px; }
.field__input--area::-webkit-scrollbar-track, .contact-modal::-webkit-scrollbar-track { background: transparent; }
.field__input--area::-webkit-scrollbar-thumb, .contact-modal::-webkit-scrollbar-thumb {
  background: color-mix(in oklch, var(--color-accent) 50%, transparent);
  border-radius: 999px;
}
.field__input--area::-webkit-scrollbar-thumb:hover, .contact-modal::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklch, var(--color-accent) 70%, transparent);
}

/* ---------- message bubbles — kept opaque on purpose: the brief asked
   for glass chrome, not glass content; opaque bubbles stay legible no
   matter what's blurring behind the panel. ---------- */

.chatdemo__msg, .chatdemo__chip, .chatdemo__file {
  opacity: 0;
  transform: translateY(6px);
  animation: chatdemo-reveal var(--dur-long) var(--ease-out) forwards;
}
.chatdemo__msg {
  max-width: 78%;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.45;
}
@keyframes chatdemo-reveal { to { opacity: 1; transform: none; } }
.chatdemo__msg.is-instant, .chatdemo__chip.is-instant, .chatdemo__file.is-instant {
  animation: none; opacity: 1; transform: none;
}

.chatdemo__msg--bot {
  align-self: flex-start;
  background: var(--color-paper-3);
  border: var(--rule-hair) solid var(--color-rule);
  color: var(--color-ink-2);
  border-end-start-radius: var(--radius-sm);
}
.chatdemo__msg--user {
  align-self: flex-end;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border-end-end-radius: var(--radius-sm);
  display: flex;
  align-items: flex-end;
  gap: var(--space-2xs);
}

.chatdemo__ticks { flex: 0 0 auto; display: inline-flex; }
.chatdemo__ticks svg { width: 14px; height: 14px; opacity: 0.7; }
.chatdemo__ticks[data-status="read"] svg { opacity: 1; }

/* ---------- system chip + file card (business-mode digest entries) ---------- */

.chatdemo__chip {
  align-self: center;
  padding: var(--space-3xs) var(--space-sm);
  border-radius: 999px;
  background: color-mix(in oklch, var(--color-paper-3) 65%, transparent);
  border: var(--rule-hair) solid var(--color-rule);
  color: var(--color-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.03em;
}

.chatdemo__file {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  max-width: 78%;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  border-end-start-radius: var(--radius-sm);
  background: var(--color-paper-3);
  border: var(--rule-hair) solid var(--color-rule);
}
.chatdemo__file-icon { flex: 0 0 auto; width: 26px; height: 26px; color: var(--color-accent); }
.chatdemo__file-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.chatdemo__file-name {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-2);
  overflow-wrap: anywhere;
}
.chatdemo__file-size { font-size: var(--text-xs); color: var(--color-muted); }

.chatdemo__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  border-end-start-radius: var(--radius-sm);
  background: var(--color-paper-3);
  border: var(--rule-hair) solid var(--color-rule);
}
.chatdemo__typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--color-muted);
  animation: chatdemo-bounce 1s var(--ease-in-out) infinite;
}
.chatdemo__typing span:nth-child(2) { animation-delay: 0.15s; }
.chatdemo__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatdemo-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ---------- inline keyboard ---------- */

.chatdemo__keyboard {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  padding: 0 var(--space-md) var(--space-sm);
}
.chatdemo__keyboard:empty { padding: 0; }

.chatdemo__kb-btn {
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: var(--rule-hair) solid color-mix(in oklch, var(--color-accent) 45%, transparent);
  background: color-mix(in oklch, var(--color-accent) 10%, transparent);
  color: var(--color-accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out);
}
.chatdemo__kb-btn:hover { background: color-mix(in oklch, var(--color-accent) 20%, transparent); }
.chatdemo__kb-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chatdemo__kb-btn:active { transform: translateY(1px); }
.chatdemo__kb-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- decorative composer (non-functional, disclosed) — no fill
   of its own, same reasoning as the header ---------- */

.chatdemo__composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0 var(--space-md) var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklch, var(--color-ink) 10%, transparent);
  color: var(--color-neutral);
}
.chatdemo__composer-input { flex: 1 1 auto; font-size: var(--text-sm); }
.chatdemo__composer-send { flex: 0 0 auto; width: 18px; height: 18px; color: var(--color-neutral); }
.chatdemo__composer-send svg { width: 100%; height: 100%; }

/* business mode is a passive digest feed — no reply keyboard, no composer */
.chatdemo[data-mode="business"] .chatdemo__keyboard,
.chatdemo[data-mode="business"] .chatdemo__composer {
  display: none;
}

@media (max-width: 26rem) {
  .chatdemo__bot-switch { gap: var(--space-xs); }
}

@media (prefers-reduced-motion: reduce) {
  .chatdemo__msg, .chatdemo__chip, .chatdemo__file { animation: none; opacity: 1; transform: none; }
  .chatdemo__typing span { animation: none; opacity: 0.7; }
  .chatdemo__kb-btn:active { transform: none; }
  .chatdemo__modes-indicator { transition: none; }
  .chatdemo__log { transition: none; }
  .chatdemo__log.is-switching { opacity: 1; transform: none; }
}

/* Section-break divider, not a caption — flanking hairline rules reuse
   the site's existing rule/hairline vocabulary (bot-log rows, chatdemo
   dividers) instead of inventing new decoration, per DESIGN.md's
   component-scope discipline. */
.bots__subhead {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 42rem;
  margin: var(--space-2xl) auto var(--space-lg);
  padding-inline: var(--space-lg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
.bots__subhead::before,
.bots__subhead::after {
  content: "";
  flex: 1 1 auto;
  height: var(--rule-hair);
  background: var(--color-rule);
}

.bots .work__grid { margin-top: 0; }

/* ---------- footer — Ft5 statement ---------- */

.footer {
  padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
  border-top: var(--rule-hair) solid var(--color-rule);
}
.footer__statement {
  max-width: 32ch;
  margin: 0 auto var(--space-xl);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--color-ink);
  overflow-wrap: anywhere;
}
.footer__meta {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.footer__wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-ink-2);
}
.footer__link {
  color: var(--color-accent);
  text-decoration: none;
  white-space: nowrap;
}
.footer__link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- responsive ---------- */

@media (max-width: 40rem) {
  .footer__meta { flex-direction: column; gap: var(--space-2xs); }
}

@media (min-width: 60rem) {
  .work { padding-inline: var(--space-3xl); }
}

/* ---------- floating CTA + contact modal ---------- */

.fab {
  position: fixed;
  right: var(--space-lg);
  bottom: var(--space-lg);
  z-index: var(--z-sticky);
  height: 48px;
  padding-inline: var(--space-lg);
  border-radius: 999px;
  border: none;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 16px oklch(10% 0.02 63 / 0.4);
  transition: background-color var(--dur-short) var(--ease-out), transform 100ms var(--ease-out);
}
.fab:hover { background: color-mix(in oklch, var(--color-accent) 88%, white); }
.fab:active { transform: translateY(1px); }
.fab:focus-visible { outline-offset: 3px; }

@media (max-width: 30rem) {
  .fab { right: var(--space-md); bottom: var(--space-md); padding-inline: var(--space-md); font-size: var(--text-xs); height: 44px; }
}

.contact-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-height: min(85dvh, 40rem);
  width: min(30rem, calc(100vw - var(--space-lg) * 2));
  padding: 0;
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-md);
  background: var(--color-paper-2);
  color: var(--color-ink);
  overflow-y: auto;
}
.contact-modal::backdrop {
  background: oklch(10% 0.01 63 / 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.contact-modal[open] { animation: modal-in var(--dur-long) var(--ease-out); }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .contact-modal[open] { animation: none; }
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-xl);
}
.contact-form__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.contact-form__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
}
.contact-form__close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: var(--rule-hair) solid var(--color-rule-2);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
}
.contact-form__close:hover { color: var(--color-ink); border-color: var(--color-accent); }
.contact-form__close:focus-visible { outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: var(--space-2xs); }
.field__label { font-size: var(--text-sm); color: var(--color-muted); }
.field__input {
  font: inherit;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--color-ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-rule-2);
  outline: 2px solid transparent;
  outline-offset: 2px;
  padding-block: var(--space-xs);
  transition: border-color var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out);
}
.field__input::placeholder { color: var(--color-muted); }
@media (hover: hover) and (pointer: fine) {
  .field__input:hover { background: color-mix(in oklch, var(--color-paper-3) 70%, transparent); }
}
.field__input:focus-visible { border-color: var(--color-accent); outline-color: var(--color-focus); }
.field__input--area {
  resize: vertical;
  min-height: 4rem;
  /* Capped so the native drag-resize handle can never grow the textarea
     past the modal's own max-height — past this it scrolls internally
     (own accent scrollbar below) instead of forcing .contact-modal into
     its default browser scrollbar. */
  max-height: 12rem;
  overflow-y: auto;
  font-size: var(--text-base);
}
.field__input:user-invalid { border-color: var(--color-error); }

.contact-form__status {
  margin: 0;
  min-height: 1lh;
  font-size: var(--text-sm);
}
.contact-form__status[data-state="error"] { color: var(--color-error); }

.contact-form__submit { align-self: flex-start; }
.contact-form__submit[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- success toast — replaces the old inline "Заявка отправлена"
   status text; fires once the modal is already closing, not inside it ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-xl);
  z-index: var(--z-tooltip);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: min(26rem, calc(100vw - var(--space-lg) * 2));
  padding: var(--space-sm) var(--space-lg) var(--space-sm) var(--space-sm);
  border-radius: 999px;
  border: var(--rule-hair) solid var(--color-rule);
  background: color-mix(in oklch, var(--color-paper-2) 92%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 8px 24px oklch(10% 0.01 63 / 0.35);
  color: var(--color-ink);
  font-size: var(--text-sm);
  transform: translate(-50%, calc(100% + var(--space-xl)));
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur-long) var(--ease-out), opacity var(--dur-long) var(--ease-out);
}
.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.toast__icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in oklch, var(--color-accent) 18%, transparent);
  color: var(--color-accent);
}
.toast__icon svg { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity var(--dur-short) linear; transform: translate(-50%, 0); }
}
