:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --soft: #475569;
  --dim: #cbd5e1;
  --accent: #1d4ed8;
  --wire: #3b82f6;
  --good: #16a34a;
  --bad: #dc2626;
  --panel: #f4f6fa;
  --cached: #16a34a;
  --input: #d97706;
  --output: #1d4ed8;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bar-height: 64px;
  --display: "Manrope", system-ui, sans-serif;
  --mark: "Inter", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Sans 3", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12;
    --fg: #f5f7fb;
    --soft: #a3adbd;
    --dim: #3a4250;
    --accent: #60a5fa;
    --wire: #60a5fa;
    --good: #4ade80;
    --bad: #f87171;
    --panel: #151920;
    --cached: #4ade80;
    --input: #fbbf24;
    --output: #60a5fa;
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--fg);
  font: 400 1.125rem/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Top bar: the brand, the way to the live agent, the main site's pages, sign
   in and download, always in reach. It sits over the stage and is no part of
   any state, so nothing in it is morphed. Only its links take the pointer: a
   swipe that starts on the empty part of the bar still moves the stage. */
.bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  height: var(--bar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1rem, 3vw, 2rem);
  pointer-events: none;
}

.bar > * { pointer-events: auto; }

/* The plain page scrolls under the bar, so there the bar is a strip of its own. */
:root:not(.immersive) .bar {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* Outlines fly under the bar during a morph. A fade of the page colour keeps
   the links readable over them. */
.immersive .bar::before {
  content: "";
  position: absolute;
  inset: 0 0 -0.75rem 0;
  z-index: -1;
  background: linear-gradient(color-mix(in srgb, var(--bg) 88%, transparent) 55%, transparent);
  pointer-events: none;
}

/* Keyboard focus, in the bar and the footer. */
:is(.bar, .foot, .footline) :is(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.bar .button:focus-visible { outline-color: var(--fg); border-radius: 10px; }

.brand {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.5rem;
  font-size: 1.12rem;
  text-decoration: none;
}

/* The robot arm, drawn in the text colour so the logo is one colour in both
   themes. icon.svg is only its outline here; the favicon keeps its own blue. */
.brand-mark {
  flex: none;
  width: 24px;
  height: 26px;
  background: currentcolor;
  mask: url("icon.svg") center / contain no-repeat;
}

/* The wordmark, after the Local Hoist logo: capitals, a heavy first word and
   a thin second word set tight against it. The words are written in mixed
   case in the HTML so they read properly without styles. */
.wordmark {
  margin: 0;
  font-family: var(--mark);
  line-height: 0.74;
  text-transform: uppercase;
  white-space: nowrap;
}

.wordmark .heavy { font-weight: 800; letter-spacing: -0.012em; }
.wordmark .thin { font-weight: 250; letter-spacing: 0.012em; margin-left: 0.07em; }

.nav,
.nav-panel {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

.nav { font: 600 0.95rem/1 var(--body); }
/* On a wide screen the panel is a row in the bar and is never hidden. On a
   small one it is the menu the toggle opens (see the media rule below). */
.nav-panel[hidden] { display: flex; }
.nav a { white-space: nowrap; }
.quiet { color: var(--soft); text-decoration: none; }
.quiet:hover { color: var(--fg); }

.button {
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}

/* The link to the live agent, with a dot that says it is there to talk to. */
.nav-live { display: inline-flex; align-items: center; gap: 0.45rem; }

.nav-live i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--good);
}

@media (prefers-reduced-motion: no-preference) {
  .immersive .nav-live i { animation: live-dot 2.4s ease-in-out infinite; }
}

@keyframes live-dot {
  50% { box-shadow: 0 0 0 0.3rem color-mix(in srgb, var(--good) 22%, transparent); }
}

/* Download: a button for the visitor's platform, and beside it a smaller one
   that opens the other choices (src/nav.ts). */
.dl { position: relative; display: inline-flex; }

.dl svg,
.nav-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dl .dl-main {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.8rem 0.6rem 0.9rem;
  border-radius: 10px 0 0 10px;
}

.dl .dl-more {
  display: inline-flex;
  align-items: center;
  margin-left: 1px;
  padding: 0 0.5rem;
  border: 0;
  border-radius: 0 10px 10px 0;
  font: inherit;
  cursor: pointer;
}

.dl-more[aria-expanded="true"] svg { transform: rotate(180deg); }

.dl-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  display: grid;
  gap: 2px;
  min-width: 15rem;
  padding: 0.4rem;
  border: 1.5px solid var(--dim);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.14);
}

.dl-menu[hidden] { display: none; }

.dl-menu a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.75rem;
  border-radius: 9px;
  color: var(--fg);
  text-decoration: none;
}

.dl-menu a[href]:hover { background: var(--panel); }
.dl-menu a[aria-disabled="true"] { color: var(--soft); cursor: default; }
.dl-menu small { color: var(--soft); font-size: 0.85rem; font-weight: 400; }

.dl-note {
  margin: 0;
  max-width: 18rem;
  padding: 0.45rem 0.75rem 0.5rem;
  color: var(--soft);
  font: 400 0.88rem/1.4 var(--body);
  white-space: normal;
}

.dl-note:empty { display: none; }

.nav-toggle {
  display: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-right: -0.5rem;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  cursor: pointer;
}

.nav-toggle svg { width: 1.4rem; height: 1.4rem; stroke-width: 2; }
.nav-toggle .when-open,
.nav-toggle[aria-expanded="true"] .when-closed { display: none; }
.nav-toggle[aria-expanded="true"] .when-open { display: inline; }

/* A small screen: the brand, Sign in and a menu. The menu holds the rest,
   with the download choices laid out in it. */
@media (max-width: 820px) {
  .nav-toggle { display: inline-grid; }

  .nav-panel {
    position: fixed;
    top: calc(var(--bar-height) - 0.25rem);
    left: 0.75rem;
    right: 0.75rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    max-height: calc(100svh - var(--bar-height) - 0.75rem);
    padding: 0.6rem;
    overflow: auto;
    border: 1.5px solid var(--dim);
    border-radius: 18px;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 12px 32px rgb(0 0 0 / 0.14);
    font-size: 1.05rem;
  }

  .nav-panel[hidden] { display: none; }
  .nav-panel > a { padding: 0.85rem 0.75rem; border-radius: 10px; color: var(--fg); }

  .dl {
    display: flex;
    flex-direction: column;
    margin-top: 0.35rem;
    padding-top: 0.6rem;
    border-top: 1.5px solid var(--dim);
  }

  .dl .dl-main { justify-content: center; padding: 0.9rem; border-radius: 10px; }
  .dl .dl-more { display: none; }

  .dl-menu,
  .dl-menu[hidden] {
    position: static;
    display: grid;
    min-width: 0;
    padding: 0.35rem 0 0;
    border: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }

  .dl-note { max-width: none; }

  /* With no installer to go straight to (a phone, say), the button would only
     lead away. The choices and the note under them say what there is. */
  .dl[data-direct="false"] .dl-main { display: none; }

  .dl[data-direct="false"]::before {
    content: "Download";
    padding: 0.35rem 0.75rem 0;
    color: var(--soft);
    font: 800 0.78rem/1.2 var(--display);
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }
}

.only-immersive { display: none; }
.immersive .only-immersive { display: inline; }
.immersive .only-plain { display: none; }

/* Type. */
.phrase {
  margin: 0;
  max-width: min(92vw, 1080px);
  font: 800 clamp(2.5rem, 7.4vw, 6rem)/1 var(--display);
  letter-spacing: -0.045em;
  text-align: center;
  text-wrap: balance;
}

.phrase.small { font-size: clamp(1.5rem, 3.6vw, 2.75rem); }
.accent { color: var(--accent); }

.sub {
  margin: 1.75rem 0 0;
  max-width: min(88vw, 40rem);
  color: var(--soft);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  text-align: center;
  text-wrap: balance;
}

/* Drawings. Every shape is closed and filled, or a stroked outline. */
svg .ink { fill: var(--fg); }
svg .dim { fill: var(--dim); }
svg .hot { fill: var(--accent); }
svg .good { fill: var(--good); }
svg .bad { fill: var(--bad); }
svg .line { fill: none; stroke: var(--dim); stroke-width: 3; }
svg .line.hot { fill: none; stroke: var(--accent); stroke-width: 2; }

.crane { fill: var(--fg); overflow: visible; }
.crane.hero { height: min(34svh, 60vw, 260px); width: auto; }
.void { display: none; }

svg text {
  fill: var(--fg);
  font: 600 17px var(--body);
}

.reveal {
  width: min(88vw, 440px, calc((100svh - 290px) * 1.2));
  height: auto;
  margin-bottom: clamp(1.25rem, 3vh, 2.25rem);
}

/* The cost chart, and over it the parts that are not morphed. */
.chart-wrap {
  position: relative;
  margin-bottom: clamp(1.5rem, 4vh, 3rem);
}

.chart-wrap .chart { display: block; margin: 0; }

.chart-over {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

svg .cached { fill: var(--cached); }
svg .input { fill: var(--input); }
svg .output { fill: var(--output); }

/* While the tip is out, the bar under it stands out from the rest. */
.chart rect { transition: opacity 0.12s; }
.chart.brushing rect:is(.cached, .input, .output):not(.lit, [rx="3"]) { opacity: 0.38; }

.unit-label {
  fill: var(--soft);
  font-size: 10.5px;
  text-anchor: middle;
}

.unit-label.on { fill: var(--bg); }

.key {
  fill: var(--soft);
  font-size: 10.5px;
}

.tip { opacity: 0; }
.tip.on { opacity: 1; }
.tip rect { fill: var(--panel); stroke: var(--dim); stroke-width: 1; }

.tip text {
  font-size: 10.5px;
  text-anchor: middle;
}

.tip .tip-detail { font-size: 9px; }

/* The voice scene: a chat box. Messages arrive whole at the foot of it, and
   the sound bars under them move beside whoever is speaking (src/voice.ts).
   The box is a fixed size, so the caption below does not move as it fills. */
.chat {
  display: flex;
  flex-direction: column;
  width: min(92vw, 560px);
  height: clamp(250px, 44svh, 330px);
  margin-bottom: clamp(1rem, 2.5vh, 1.75rem);
  padding: 12px 12px 10px;
  border: 1.5px solid var(--dim);
  border-radius: 16px;
}

:root:not(.immersive) .chat { height: auto; }

/* The newest messages sit at the foot, and older ones leave by the top. */
.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

/* A message on its way out of the top fades, so it is not cut off sharp. */
.immersive .chat-view { mask-image: linear-gradient(transparent, #000 22px); }

.chat-flow {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.msg { display: flex; align-items: flex-end; gap: 8px; }
.msg.me { justify-content: flex-end; }
.msg.card { padding-left: 44px; }
.immersive .msg { animation: msg-in 0.3s ease-out both; }

@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } }

.bubble {
  margin: 0;
  max-width: 82%;
  padding: 0.5em 0.8em;
  border: 1.5px solid var(--dim);
  border-radius: 18px;
  font: 600 clamp(0.95rem, 2vw, 1.1rem)/1.3 var(--body);
  text-align: left;
}

.msg.me .bubble { border-color: var(--accent); }

/* Under the chat: the agent's speaker and its bars on the left, the
   visitor's bars and microphone on the right. */
.talk {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1.5px solid var(--dim);
}

.talk-icon {
  flex: none;
  width: 32px;
  height: 32px;
}

.talk-icon .badge {
  fill: var(--dim);
  transition: fill 0.2s;
}

.talk-icon :not(.badge) { fill: var(--bg); }
.speaking .talk-icon.speaker .badge { fill: var(--good); }
.listening .talk-icon.mic .badge { fill: var(--bad); }

.talk-in { margin-left: auto; }

.avatar { flex: none; width: 36px; height: 36px; }
.avatar .face { fill: var(--bg); }

.avatar.bot {
  display: grid;
  place-items: center;
  border: 1.5px solid var(--dim);
  border-radius: 50%;
}

.avatar.bot .crane { height: 20px; width: auto; }

/* What was asked for: a little website, as a card. Its three pictures (the
   logo, the name, a row of cells) are laid out on top of each other and not
   shown. The canvas over them morphs from one to the next. */
.built {
  width: min(62vw, 250px);
  padding: 10px 12px;
  border: 1.5px solid var(--dim);
  border-radius: 12px;
}

.built-stage {
  position: relative;
  height: 78px;
}

.built-frame {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  visibility: hidden;
}

/* Without the morph (the plain page, or a failure) the card shows its name. */
:root:not(.immersive) .built-frame.name,
.built.still .built-frame.name { visibility: visible; }

.built-crane {
  height: 64px;
  width: auto;
}

.built-name { font-size: 1.4rem; }

.built-cells {
  display: block;
  width: min(100%, 200px);
  height: auto;
}

.built-cells .line { stroke-width: 1.5; }

/* The script. src/voice.ts makes it into the chat's messages and marks the
   state as voiced. If the script never runs it is simply printed. */
.immersive .say-words,
.voiced .say-words { display: none; }

.say-words { display: grid; justify-items: center; gap: 0.3rem; margin: 0.75rem 0; }
.say-words p { margin: 0; text-align: center; font-weight: 600; }
.say-words p[data-says="agent"] { color: var(--accent); }

/* The concise and verbose scenes: one turn of work in a chat, as the app
   shows it. The panel is the same size in both so the chat does not move. */
.cz {
  display: flex;
  flex-direction: column;
  width: min(90vw, 560px);
  height: 300px;
  padding: 14px;
  margin-bottom: clamp(1.25rem, 3vh, 2.25rem);
  border: 1.5px solid var(--dim);
  border-radius: 16px;
  font: 400 15px/22px var(--body);
  text-align: left;
}

.cz p { margin: 0; }
.cz-view { flex: 1; min-height: 0; overflow: hidden; }
.cz-flow { display: flex; flex-direction: column; gap: 10px; }
.cz-user { display: flex; justify-content: flex-end; }

.cz-user > span {
  padding: 7px 12px;
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  font-weight: 600;
}

.cz-work {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--soft);
  font-weight: 600;
  font-size: 14px;
}

.cz-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.working .cz-dot { background: var(--accent); animation: cz-pulse 0.9s ease-in-out infinite; }
.working .cz-work .chev { opacity: 0; }
@keyframes cz-pulse { 50% { opacity: 0.25; } }

.cz-reply { font-size: 16px; }
.cz-reply span { opacity: 0; }
.cz-reply span.on { opacity: 1; transition: opacity 0.18s; }

.cz-box {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-top: 10px;
  padding: 0 8px 0 14px;
  border: 1.5px solid var(--dim);
  border-radius: 14px;
  color: var(--soft);
  font-size: 14px;
}

.cz-box i { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); }

.chev { color: var(--soft); font: 400 18px/1 var(--body); }
.plus { color: var(--good); }
.minus { color: var(--bad); }

.cz-row,
.cz-file {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding-left: 15px;
  color: var(--soft);
  font-size: 14px;
  white-space: nowrap;
}

.cz-file { padding-left: 34px; }
.cz code { color: var(--fg); font: 500 12.5px/1 var(--mono); overflow: hidden; text-overflow: ellipsis; }

/* A part that opens. Its row in the grid grows from nothing to its content. */
.cz-fold {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
}

.cz-fold > div { min-height: 0; overflow: hidden; }

.cz-fold pre {
  margin: 2px 0 6px 53px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel);
  font: 400 12px/17px var(--mono);
  overflow: hidden;
}

.cz-fold .hunk { color: var(--soft); }
.cz-fold .add { color: var(--good); }
.cz-fold .del { color: var(--bad); }

.playing .cz-fold { transition: grid-template-rows 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s; }
.playing .cz-flow { transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.playing .cz-row, .playing .cz-file, .playing .chev { transition: opacity 0.3s, transform 0.3s; }

.show-rows .cz-fold.rows,
.show-files .cz-fold.files,
.show-patch .cz-fold.patch {
  grid-template-rows: 1fr;
  opacity: 1;
}

.show-rows .cz-work .chev,
.show-files .cz-row.changed .chev,
.show-patch .cz-file.first .chev { transform: rotate(90deg); }

.show-files .cz-row:not(.changed),
.show-patch .cz-file:not(.first) { opacity: 0.45; }

/* As more opens, the chat scrolls up to keep the newest part in view. */
.show-files .cz-flow { transform: translateY(-40px); }
.show-patch .cz-flow { transform: translateY(-128px); }

/* On the plain page everything simply stands open. */
:root:not(.immersive) .cz { height: auto; }

:root:not(.immersive) .cz-fold {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* The six-bar sound meter, after the phone app's (src/bars.ts). Each bar's
   height runs from a round dot (--h: 0) to the full height (--h: 1). */
.soundbars {
  --bar: 3px;

  display: inline-flex;
  align-items: center;
  gap: var(--bar);
  height: 1.75rem;
}

.soundbars i {
  flex: none;
  width: var(--bar);
  height: calc(var(--bar) + (100% - var(--bar)) * var(--h, 0));
  border-radius: 99px;
  background: currentcolor;
}

/* The voice scene's bars: grey dots at rest, green while the agent speaks
   and red while the visitor does. */
.talk .soundbars {
  --bar: 4px;

  height: 26px;
  color: var(--dim);
}

.speaking .talk .talk-out { color: var(--good); }
.listening .talk .talk-in { color: var(--bad); }

/* The pointer that runs over the cost chart. */
.chart-pointer {
  fill: var(--fg);
  stroke: var(--bg);
  stroke-width: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.chart-pointer.on { opacity: 1; }

/* The flexible workspace scene: a list of chats, the open chat, and a message
   box with a recording in it. */
.ws {
  position: relative;
  display: grid;
  grid-template-columns: clamp(104px, 28%, 150px) minmax(0, 1fr);
  width: min(90vw, 560px);
  height: 280px;
  margin-bottom: clamp(1rem, 2.5vh, 1.75rem);
  border: 1.5px solid var(--dim);
  border-radius: 16px;
  font: 600 13px/1 var(--body);
  text-align: left;
}

.ws p { margin: 0; }
.ws-side { display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; border-right: 1.5px solid var(--dim); }

.ws-chat,
.ws-new {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--soft);
  white-space: nowrap;
  overflow: hidden;
}

.ws-new { margin-bottom: 6px; border: 1.5px solid var(--dim); }
.ws-new b { color: var(--accent); font-size: 15px; }
.ws .on:is(.ws-chat, .ws-new) { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.ws-main { display: flex; flex-direction: column; min-width: 0; padding: 12px; }
.ws-panes { position: relative; flex: 1; min-height: 0; }

.ws-pane {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  opacity: 0;
}

.ws-pane.on { opacity: 1; }
.ws-pane > i { height: 10px; border-radius: 5px; background: var(--dim); }
.ws-pane > i.me { align-self: flex-end; height: 22px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 45%, transparent); }

/* The screenshot, small in the chat, as a thumbnail, and opened large. */
.ws-defs { position: absolute; }

.ws-thumb,
.ws-shot,
.ws-attached,
.ws-big {
  display: block;
  flex: none;
  border-radius: 6px;
  outline: 1px solid var(--dim);
}

.ws-shot { width: 104px; height: 65px; }
.ws-thumb { width: 36px; height: 24px; border-radius: 4px; }

/* The picture as it is sent: large enough to show what was marked on it. */
.ws-attached {
  width: 144px;
  height: 90px;
}

/* The marks are on the message box's copy once the picture has been closed. */
.ws-chip .ws-marks { display: none; }
.annotated .ws-chip .ws-marks { display: inline; }

/* Opened: the screenshot large, with a line drawn on it and a spoken note. */
.ws-edit {
  position: absolute;
  inset: -3px -3px 3px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg);
  opacity: 0;
  transform: scale(0.5);
}


/* Closed after marking it up, it shrinks away toward the message box, where
   the marked-up copy is. */
.annotated .ws-edit {
  transform: scale(0.15);
  transform-origin: 88% 118%;
}

.editing .ws-edit { opacity: 1; transform: none; }
.playing .ws-edit { transition: opacity 0.2s, transform 0.3s cubic-bezier(0.2, 1.2, 0.4, 1); }

/* The opened screenshot, and the note that sits in it. */
.ws-opened {
  position: relative;
  width: min(100%, 216px);
}

.ws-big {
  width: 100%;
  height: auto;
}

.ws-ink {
  fill: none;
  stroke: #facc15;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

/* The spoken note sits inside the screenshot, at its foot, so it reads as a
   note on the picture. The screenshot is dark whatever the page's colours
   are, so the note has colours of its own. */
.ws-note {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 12px);
  height: 24px;
  padding: 0 8px 0 2px;
  border-radius: 12px;
  background: rgb(13 17 23 / 90%);
  font-size: 11px;
  white-space: nowrap;
  visibility: hidden;
}

.note-mic .ws-note { visibility: visible; }

.ws-note-mic {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid #3a4250;
  border-radius: 50%;
}

.ws-note-mic .ws-mic {
  width: 9px;
  height: 11px;
  fill: #c9d1dc;
  stroke: #c9d1dc;
}

.ws .dictating .ws-note-mic, .dictating .ws-note-mic { border-color: var(--bad); background: var(--bad); }
.dictating .ws-note-mic .ws-mic { fill: var(--bg); stroke: var(--bg); }
.ws-note-text { display: none; padding-left: 6px; border-left: 2px solid #facc15; color: #f5f7fb; }
.noted .ws-note-text { display: inline; }

.ws-compose {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 8px 0 12px;
  border: 1.5px solid var(--dim);
  border-radius: 14px;
  color: var(--soft);
}

.ws-mic { flex: none; width: 15px; height: 18px; fill: var(--soft); stroke: var(--soft); stroke-width: 1.8; stroke-linecap: round; }
.ws-mic path { fill: none; }
.ws-time { display: none; color: var(--bad); font-variant-numeric: tabular-nums; }
.ws-hint { flex: 1; min-width: 0; overflow: hidden; }
.ws-send { flex: none; width: 26px; height: 26px; margin-left: auto; border-radius: 50%; background: var(--accent); }

/* The sound bars, moved by src/workspace.ts (see .soundbars). */
.ws-bars {
  display: none;
  height: 20px;
  color: var(--bad);
}

.ws-note .ws-bars { height: 14px; }
.dictating .ws-note .ws-bars { display: flex; }

.recording .ws-compose .ws-mic { fill: var(--bad); stroke: var(--bad); }
.recording .ws-time { display: inline; }
.recording .ws-compose .ws-bars { display: flex; }
.recording .ws-hint { visibility: hidden; }

/* The picture in the message box. */
.ws-chip {
  display: none;
  width: 48px;
  height: 30px;
}

.has-image .ws-chip { display: block; }

/* While a picture is being dragged, the chip's room is kept so the pointer
   knows where to take it. */
.dragging .ws-chip { display: block; visibility: hidden; }

/* The message once it is sent: the picture and the recording. */
.ws-sent {
  align-self: flex-end;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 8px;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  color: var(--soft);
}

.sent .ws-sent { display: flex; animation: ws-land 0.35s cubic-bezier(0.2, 1.3, 0.4, 1); }

.ws-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

.ws-sent .ws-bars {
  display: flex;
  color: var(--soft);
}

@keyframes ws-land { from { opacity: 0; transform: translateY(14px); } }

/* The new chat's answer to the message. */
.ws-reply {
  display: none;
  align-items: center;
  gap: 7px;
  color: var(--soft);
}

.replied .ws-reply {
  display: flex;
  animation: ws-land 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.ws-reply i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  animation: ag-wait 0.7s ease-in-out infinite alternate;
}

/* The pointer is over everything in the scene, the opened screenshot
   included, so it is seen drawing the yellow line. */
.ws-cursor {
  position: absolute;
  left: 62%;
  top: 38%;
  z-index: 2;
  width: 0;
  height: 0;
  opacity: 0;
}

.playing .ws-cursor { opacity: 1; transition: left 0.6s cubic-bezier(0.3, 0, 0.2, 1), top 0.6s cubic-bezier(0.3, 0, 0.2, 1), opacity 0.2s; }

/* While the pointer draws the yellow line it is placed on every frame, so it
   must not glide: a glide started again each frame never gets going, and the
   pointer stays behind at the start of the line. This comes after the rule
   above so that it wins. */
.playing.drawing .ws-cursor { transition: opacity 0.2s; }
.playing .ws-pane { transition: opacity 0.2s; }
.ws-cursor svg { position: absolute; left: -2px; top: -2px; width: 16px; height: 20px; fill: var(--fg); stroke: var(--bg); stroke-width: 1.2; }
.ws-cursor .ws-thumb { position: absolute; left: 8px; top: 12px; display: none; opacity: 0.85; }
.dragging .ws-cursor .ws-thumb { display: block; }
.ws + .phrase + .sub { margin-top: 0.8rem; }

/* The line under the heading is a caption while the scene plays. It dips
   out while src/workspace.ts changes what it says. */
.playing > .ws + .phrase + .sub { transition: opacity 0.14s; }
.playing.recaption > .ws + .phrase + .sub { opacity: 0; }

/* The four ways to power it, one at a time: the newest is large. */
.power-hero {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: min(88vw, 30rem);
  margin-top: clamp(1.25rem, 3.5vh, 2.5rem);
  padding: 1.4rem 1.6rem;
  border: 1.5px solid var(--accent);
  border-radius: 18px;
  text-align: left;
}

.power-hero strong { font: 800 clamp(1.5rem, 3.4vw, 2.1rem)/1.15 var(--display); letter-spacing: -0.03em; }
.power-hero span { color: var(--soft); font-size: clamp(1.05rem, 1.6vw, 1.25rem); line-height: 1.35; }

/* The files a chat has changed, and a button to commit them. */
.commit {
  position: relative;
  width: min(88vw, 420px);
  padding: 14px 16px;
  margin-bottom: clamp(1.25rem, 3vh, 2.25rem);
  border: 1.5px solid var(--dim);
  border-radius: 16px;
  font: 400 14px/1.3 var(--body);
  text-align: left;
}

.commit p { margin: 0; }
.commit-head { color: var(--soft); font-weight: 600; }
.commit ul { list-style: none; margin: 8px 0 12px; padding: 0; }
.commit li { display: flex; align-items: center; gap: 8px; height: 28px; }
.commit code { flex: 1; min-width: 0; font: 500 12.5px/1 var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit-go { display: flex; justify-content: flex-end; }

.commit-btn {
  padding: 7px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* The code review button comes in from nothing and pushes its neighbour over. */
.commit-btn.review {
  max-width: 0;
  margin-left: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
}

.show-review .commit-btn.review {
  max-width: 130px;
  margin-left: 8px;
  padding: 7px 14px;
  border-width: 1.5px;
  opacity: 1;
}

.playing .commit-btn.review { transition: all 0.35s cubic-bezier(0.2, 1.3, 0.4, 1); }
.reviewing .commit-btn.review { background: var(--accent); color: var(--bg); }

/* How the review is going. Its room is kept so the panel does not jump. */
.commit-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  margin-bottom: 10px;
  color: var(--soft);
  font-weight: 600;
  visibility: hidden;
}

.commit .commit-status { margin-bottom: 10px; }
.commit-status.on { visibility: visible; }

.commit-status i {
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid var(--dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: commit-spin 0.7s linear infinite;
}

.commit-status.review { color: var(--accent); }
.commit-status.review i { border: 0; background: var(--accent); animation: cz-pulse 0.9s ease-in-out infinite; }
.commit-status.ok { color: var(--good); }
.commit-status.ok i { border: 0; background: var(--good); animation: none; }

@keyframes commit-spin { to { transform: rotate(360deg); } }

.commit + .phrase + .sub { margin-top: 0.9rem; }

.chart {
  width: min(88vw, 520px, calc((100svh - 400px) * 2.27));
  height: auto;
  margin-bottom: clamp(1.5rem, 4vh, 3rem);
}

/* The crane stands about 2.2 capitals tall with its foot just below the
   baseline, as in the Local Hoist logo. */
.lockup {
  display: flex;
  align-items: flex-end;
  gap: 0.2em;
  font-size: clamp(1.7rem, 7.6vw, 6rem);
}

.lockup .crane { height: 1.62em; width: auto; margin-bottom: -0.09em; }
.lockup .wordmark { font-size: 1em; }

.paths {
  list-style: none;
  margin: clamp(1.5rem, 4vh, 3rem) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  width: min(92vw, 56rem);
}

.paths button {
  width: 100%;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.paths a,
.paths button,
.paths div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  height: 100%;
  padding: 1rem 1.15rem;
  border: 1.5px solid var(--dim);
  border-radius: 14px;
  text-decoration: none;
  line-height: 1.35;
}

.paths a:hover,
.paths button:hover { border-color: var(--accent); }
.paths strong { font: 800 1.1rem/1.2 var(--display); letter-spacing: -0.02em; }
.paths span { color: var(--soft); font-size: 0.98rem; }
/* Muted with colour, not opacity, so the traced outlines match exactly. */
.paths div strong { color: var(--soft); }

/* The four ways to power it: cards that are all on offer, so nothing is muted. */
.paths.four { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(94vw, 62rem); }
.paths.four div strong { color: var(--fg); }
.providers { margin-top: clamp(1.25rem, 3.5vh, 2.25rem); font-weight: 600; }

@media (max-width: 900px) {
  .paths.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .paths:not(.four) { grid-template-columns: 1fr; }
  .paths { gap: 0.5rem; }
  .providers { font-size: 0.95rem; }
  .paths a, .paths button, .paths div { padding: 0.7rem 0.95rem; }
  .brand { font-size: 0.95rem; }
}

/* The plain page: the same states as an ordinary column. */
.track { display: block; }
canvas { display: none; }

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 78svh;
  padding: calc(var(--bar-height) + 2rem) 1rem 3rem;
}

/* The site footer. It is the last state, after the end (data-coda): on the
   plain page the ordinary footer at the bottom, on the stage a state of its
   own. Its content is the main site's footer. */
.state.coda {
  min-height: 0;
  padding: 3rem 1.5rem 4rem;
  border-top: 1px solid var(--dim);
}

.coda:focus { outline: 0; }

.foot {
  width: min(92vw, 54rem);
  color: var(--soft);
  font-size: 0.98rem;
}

.foot .lockup {
  justify-content: center;
  color: var(--fg);
  font-size: clamp(1.5rem, 3.4vw, 2.5rem);
}

.foot-cols {
  display: grid;
  /* The last column holds an email address, and is as wide as that needs. */
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(max-content, 1fr);
  gap: 1.5rem 2rem;
  margin-top: clamp(1.25rem, 4vh, 2.5rem);
  padding-top: clamp(1.25rem, 4vh, 2.5rem);
  border-top: 1.5px solid var(--dim);
}

.foot h2 {
  margin: 0 0 0.7rem;
  color: var(--fg);
  font: 800 0.78rem/1.2 var(--display);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.foot ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.foot a { color: var(--soft); text-decoration: none; overflow-wrap: anywhere; }
.foot a:hover { color: var(--fg); }
.foot-social { display: inline-block; margin: -0.3rem; padding: 0.3rem; }
.foot-social svg { display: block; width: 1.15rem; height: 1.15rem; fill: currentColor; }

.foot-end,
.foot-mode {
  margin: clamp(1.25rem, 4vh, 2.5rem) 0 0;
  font-size: 0.9rem;
  text-align: center;
}

.foot-mode { margin-top: 0.4rem; }
.foot .foot-mode a { display: inline-block; padding: 0.25rem 0.4rem; text-decoration: underline; text-underline-offset: 0.2em; }
.immersive .foot-mode .only-plain,
:root:not(.immersive) .foot-mode .only-immersive { display: none; }

@media (max-width: 640px) {
  .foot-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1rem; }
  .foot { font-size: 0.94rem; }
  /* Room for a thumb. */
  .foot li a:not(.foot-social) { display: inline-block; padding: 0.1rem 0; }
}

/* The foot line: the legal links and the way to the footer, at the foot of
   the stage in every state. It goes when the footer itself is showing. */
.footline { display: none; }

.immersive .footline {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 1.1rem;
  padding: 0 1rem max(0.3rem, env(safe-area-inset-bottom));
  color: var(--soft);
  font: 600 0.78rem/1.2 var(--body);
  pointer-events: none;
  transition: opacity 0.25s, visibility 0.25s;
}

.footline > * { pointer-events: auto; }
.footline a { padding: 0.45rem 0.2rem; color: inherit; text-decoration: none; }
.footline a:hover { color: var(--fg); }
.at-coda .footline { opacity: 0; visibility: hidden; }

@media (max-width: 640px) {
  .footline-copy,
  .footline-plain { display: none; }
  .immersive .footline { gap: 0.35rem 1.4rem; }
}

/* Immersive mode: one stage that fills the window and does not scroll. The
   script moves between states; the browser's own scrolling is out of it. */
.immersive,
.immersive body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}


.immersive .stage {
  position: relative;
  height: 100svh;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--wire) 12%, transparent), transparent 70%),
    var(--bg);
}

.immersive .state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  /* The foot gives the foot line its room. */
  padding: var(--bar-height) 1rem 2.5rem;
  border: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.immersive .state[data-live] { pointer-events: auto; }

/* The agent: "Talk to it" and "Chat with it". A layer over the page, built by
   src/agent.ts. Its state is in data attributes on the layer: data-mode is
   voice or chat, data-call is idle, connecting or live, data-rec is off, on
   or busy (dictating a chat message), data-speaking is set while the agent's
   voice is sounding, data-muted while the visitor's microphone is off. */
.ag {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  /* One column that cannot grow past the screen, however wide a line in it is. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto auto;
  justify-items: center;
  padding: 0.9rem clamp(0.9rem, 3vw, 2rem) max(0.9rem, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: ag-in 0.26s ease-out;
}

.ag[hidden] { display: none; }
.ag-open { overflow: hidden; }

@keyframes ag-in {
  from { opacity: 0; }
}

.ag button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.ag svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ag svg .fill { fill: currentColor; }

.ag-top {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ag-tabs {
  display: inline-flex;
  padding: 3px;
  border: 1.5px solid var(--dim);
  border-radius: 999px;
}

.ag-tabs button {
  padding: 0.3rem 1rem;
  border-radius: 999px;
  color: var(--soft);
  font: 800 0.95rem/1.4 var(--display);
}

.ag-tabs button[aria-selected="true"] {
  background: var(--fg);
  color: var(--bg);
}

/* New chat, beside the tabs. It is there only when there is something to
   start over from. The gap after it pushes the rest of the bar to the right. */
.ag .ag-new {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.8rem 0.3rem 0.55rem;
  border: 1.5px solid var(--dim);
  border-radius: 999px;
  color: var(--soft);
  font: 800 0.95rem/1.4 var(--display);
  white-space: nowrap;
}

.ag .ag-new[hidden] { display: none; }
.ag .ag-new:hover { color: var(--fg); }

.ag-new svg {
  width: 1rem;
  height: 1rem;
}

.ag-gap { flex: 1; }

/* The owner's model selector. Nobody else sees it. */
.ag-model {
  min-width: 0;
  max-width: 12rem;
  padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--dim);
  border-radius: 999px;
  background: var(--bg);
  color: var(--soft);
  font: inherit;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  cursor: pointer;
}

.ag-model:hover { color: var(--fg); }
.ag-model:disabled { opacity: 0.4; }

/* The agent's voice, top right, as in the app: six green bars that rest as
   dots, and a speaker that opens the volume control. Shown for the whole
   call. */
.ag-out {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--good);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
  transition: opacity 0.25s, transform 0.25s;
}

.ag:is([data-call="live"], [data-call="connecting"]) .ag-out {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.ag .ag-vol-btn {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--good);
  color: var(--bg);
}

.ag-vol {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 2;
  display: flex;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--dim);
  border-radius: 14px;
  background: var(--bg);
}

.ag-vol[hidden] { display: none; }

.ag-vol input {
  width: 10rem;
  margin: 0;
  accent-color: var(--good);
}

.ag-close {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  color: var(--soft);
}

.ag-close:hover { color: var(--fg); }


.ag-main {
  position: relative;
  width: min(100%, 62rem);
  min-height: 0;
  display: grid;
  place-items: center;
}

/* What the agent is saying, a short phrase at a time. Each word is simply
   there as it is spoken, the newest in the accent colour; a finished phrase
   drifts up and out as the next one starts. */
.ag-words {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.ag-phrase {
  grid-area: 1 / 1;
  margin: 0;
  max-width: 100%;
  font: 800 clamp(2.3rem, 8.4vw, 6rem)/1.04 var(--display);
  letter-spacing: -0.035em;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  transition: opacity 0.22s, transform 0.22s;
}

/* A finished phrase gets out of the way fast: the next one starts where it was. */
.ag-phrase.out {
  opacity: 0;
  transform: translateY(-0.3em);
}

/* The default. A phrase starts at a fixed point, a line above the middle, and
   grows to the right and then down. Text set from the left with ordinary
   wrapping never moves a word that is already there: no centring to redo and
   no line breaks to rebalance. */
.ag[data-words="anchor"] .ag-phrase {
  position: absolute;
  top: calc(50% - 1.04em);
  left: 0;
  right: 0;
  text-align: left;
  text-wrap: wrap;
}

/* A word takes its full room at once, so nothing after it has to move. */
.ag-word {
  display: inline-block;
  margin: 0 0.11em;
}

.ag-phrase:not(.out) .ag-word:last-child { color: var(--accent); }

.ag-thread {
  align-self: stretch;
  width: min(100%, 44rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 0 0.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ag-thread:empty::before {
  content: "Ask anything about ContextGrip.";
  margin: auto;
  color: var(--soft);
  font: 800 clamp(1.5rem, 4.4vw, 2.5rem)/1.15 var(--display);
  letter-spacing: -0.03em;
  text-align: center;
}

.ag-msg {
  margin: 0;
  max-width: 88%;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ag-msg.user {
  align-self: flex-end;
  padding: 0.55rem 1rem;
  border-radius: 16px;
  background: var(--panel);
}

.ag-msg.failed { color: var(--bad); }

.ag-msg.drew {
  color: var(--soft);
  font-size: 0.82rem;
}
.ag-msg.pending::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--soft);
  animation: ag-pulse 1s ease-in-out infinite;
}

@keyframes ag-pulse {
  50% { opacity: 0.25; }
}

.ag-start {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.6rem;
  border-radius: 18px;
  font: 800 1.2rem/1.2 var(--display);
}

.ag .ag-start {
  background: var(--fg);
  color: var(--bg);
}

/* With pictures up the board is in front (see the board, below). The Start
   button stays on top of it. */
.ag[data-sketch] .ag-start {
  position: relative;
  z-index: 2;
}

.ag-status {
  min-height: 1.6em;
  margin: 0.4rem 0 0;
  color: var(--soft);
  font-size: 0.95rem;
  text-align: center;
}

/* One line. When it is too long for the screen its start is cut off, not its
   end, so the newest words stay in view. */
.ag-heard {
  width: min(100%, 44rem);
  min-height: 1.5em;
  margin: 0 0 0.5rem;
  display: flex;
  justify-content: center;
  color: var(--bad);
  font-size: 1rem;
}

.ag-heard span {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
  white-space: nowrap;
}

.ag[data-ended] :is(.ag-compose, .ag-start, .ag-tabs, .ag-model) {
  opacity: 0.4;
  pointer-events: none;
}

/* The message box, after the app's: a microphone with a running time and a
   red waveform while it listens, a circled check to finish, a cross to stop,
   and a blue arrow to send. */
.ag-compose {
  width: min(100%, 44rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.45rem 0.4rem 0.5rem;
  border: 1.5px solid var(--dim);
  border-radius: 16px;
  background: var(--bg);
}

.ag-compose:focus-within { border-color: var(--accent); }

.ag-compose button {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
}

.ag .ag-mic { color: var(--soft); }
.ag-mic svg { height: 1.4rem; }

.ag-time {
  color: var(--bad);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ag-in {
  margin-right: auto;
  color: var(--bad);
}

.ag-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--fg);
  font: inherit;
}

.ag-input::placeholder { color: var(--soft); }

.ag .ag-done {
  border: 2px solid currentColor;
  color: var(--bad);
  width: 2.1rem;
  height: 2.1rem;
}

.ag .ag-kill { color: var(--bad); }

.ag .ag-send {
  background: var(--accent);
  color: var(--bg);
}

.ag[data-busy] .ag-send { opacity: 0.4; }

.ag-fine {
  margin: 0.55rem 0 0;
  color: var(--soft);
  font-size: 0.8rem;
  text-align: center;
}

.ag-link {
  color: inherit;
  text-decoration: underline;
}

/* Which parts show in which state. */
.ag-time,
.ag-in,
.ag .ag-done,
.ag .ag-kill { display: none; }

.ag[data-call="live"] :is(.ag-time, .ag-in),
.ag[data-rec="on"] :is(.ag-time, .ag-in) { display: inline-flex; }

.ag[data-call="live"] .ag-kill,
.ag[data-call="connecting"] .ag-kill,
.ag[data-rec="on"] :is(.ag-done, .ag-kill) { display: grid; }

/* A call and a dictation are spoken only: no text box. The bars sit after
   the timer, as in the app, and the buttons keep to the right. */
.ag[data-call="live"] :is(.ag-input, .ag-send),
.ag[data-call="connecting"] :is(.ag-input, .ag-send),
.ag[data-rec="on"] :is(.ag-input, .ag-send) { display: none; }

.ag[data-call="connecting"] .ag-kill { margin-left: auto; }
.ag[data-rec="busy"] .ag-compose { opacity: 0.6; }

.ag[data-call="live"] .ag-mic,
.ag[data-rec="on"] .ag-mic { color: var(--bad); }

.ag[data-muted] .ag-mic { color: var(--soft); }
.ag[data-muted] :is(.ag-in, .ag-time) { opacity: 0.3; }

.ag[data-mode="chat"] :is(.ag-words, .ag-heard, .ag-out),
.ag[data-mode="voice"] .ag-thread { display: none; }

.ag[data-mode="voice"][data-call="idle"] .ag-start { display: inline-flex; }

/* The notice a visitor agrees to before anything starts. It covers the whole
   layer until they do. */
.ag-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 1.1rem;
  padding: 1.5rem;
  background: var(--bg);
  text-align: center;
}

.ag[data-gate] .ag-gate { display: grid; }

.ag-gate h2 {
  margin: 0;
  font: 800 clamp(1.6rem, 4.4vw, 2.4rem)/1.1 var(--display);
  letter-spacing: -0.03em;
}

.ag-gate p {
  max-width: 34rem;
  margin: 0;
  color: var(--soft);
  line-height: 1.55;
}

.ag .ag-gate a { color: var(--accent); }

.ag-gate-go {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.ag .ag-agree,
.ag .ag-code-yes {
  padding: 0.85rem 1.5rem;
  border-radius: 16px;
  background: var(--fg);
  color: var(--bg);
  font: 800 1.05rem/1.2 var(--display);
}

.ag .ag-decline,
.ag .ag-code-no {
  padding: 0.85rem 1.2rem;
  color: var(--soft);
}

/* What the agent has drawn. In a call it fills the middle behind the words
   and dims while the agent speaks, so the words stay readable. In a chat it is
   a box above the thread. The caption marks it as the model's own drawing.
   The negative z-index keeps it behind the Start button, which is not
   positioned. */

/* The board: one cell for each picture on the screen, side by side. */
.ag-sketch {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.4rem 0.8rem;
  pointer-events: none;
}

.ag-sketch[hidden] { display: none; }

.ag-pic {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 0;
}

/* display is set here because the plain page hides every canvas by default.
   The animated page sizes every canvas to its holder, and the layer's name in
   front keeps a cell's canvas above its caption there too. */
.ag .ag-pic canvas {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: calc(100% - 1.7rem);
}

/* The line under a picture or widget: what it is, and a button for its code.
   It has the 1.7rem the canvas leaves, so it never lies over the picture. */
.ag-pic figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  color: var(--soft);
  font-size: 0.78rem;
  line-height: 1;
}

.ag-cap {
  min-width: 0;
  padding: 0.15rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-pic[data-own] .ag-cap::before {
  content: "Sketch: ";
  opacity: 0.7;
}

.ag-pic[data-state="working"] .ag-cap { animation: ag-wait 1.2s ease-in-out infinite alternate; }
.ag-pic[data-state="failed"] figcaption { color: var(--bad); }

/* The Code button. The board lets the mouse through, and this takes it back. */
.ag .ag-code {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.18rem 0.45rem 0.18rem 0.35rem;
  border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent);
  border-radius: 999px;
  color: var(--soft);
  font-size: 0.72rem;
  line-height: 1;
  pointer-events: auto;
}

.ag .ag-code[hidden] { display: none; }

.ag .ag-code:hover {
  border-color: var(--fg);
  color: var(--fg);
}

.ag-code svg {
  width: 0.8rem;
  height: 0.8rem;
}

/* A widget: code the model wrote, running in a sandboxed frame from another
   site. It takes the mouse, which the rest of the board does not, and has a
   border so it is plainly a box of its own and not part of this page. */
.ag-pic[data-kind="widget"] {
  pointer-events: auto;
}

.ag-pic iframe {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  width: 100%;
  height: calc(100% - 1.7rem);
  border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);

  /* The frame's own page declares no colour scheme, which means light. A
     browser paints a frame white when its scheme differs from the element
     holding it, so this matches it and the frame stays see-through on a dark
     page. The widget gets the page's real colours as variables. */
  color-scheme: light;
}

.ag-pic[data-kind="widget"] .ag-cap::before {
  content: none;
}

/* With anything on it the board comes in front, so clicks reach a widget's
   frame and the Code buttons. The board still lets the mouse through
   everywhere else. In a call the words and the Start button stay on top of
   the pictures, as they were. */
.ag[data-sketch] .ag-sketch {
  z-index: 1;
}

.ag[data-sketch] .ag-words {
  z-index: 2;
}

@keyframes ag-wait {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.ag[data-mode="chat"][data-sketch] .ag-main { grid-template-rows: auto minmax(0, 1fr); }

.ag[data-mode="chat"] .ag-sketch {
  position: relative;
  inset: auto;
  width: min(100%, 44rem);
  height: clamp(10rem, 34vh, 20rem);
  margin-top: 0.75rem;
  padding: 0.3rem 0.5rem 0;
  border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.ag[data-mode="chat"] .ag-sketch[data-many] {
  width: 100%;
  height: clamp(14rem, 54vh, 36rem);
}

/* A widget is something to use, so it gets more room than a picture. Its own
   border is the box, and the board's is not drawn around it a second time. */
.ag[data-mode="chat"][data-widget] .ag-sketch {
  height: clamp(16rem, 52vh, 34rem);
  padding: 0;
  border-color: transparent;
  background: none;
}

/* In a call with pictures up, the pictures have the middle. The words become
   a small line above them instead of filling the screen. */
.ag[data-mode="voice"][data-sketch] .ag-sketch { top: 4.4rem; }

.ag[data-mode="voice"]:is([data-sketch], [data-scene]) .ag-words {
  bottom: auto;
  height: 4rem;
}

.ag[data-mode="voice"]:is([data-sketch], [data-scene]) .ag-phrase {
  top: 0;
  font-size: clamp(1.05rem, 2.1vw, 1.55rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

/* In a call with a widget up, nothing may lie over it. The words keep their
   line above the board, and the Start button moves up to that line. A scene
   is treated the same way. */
.ag[data-mode="voice"]:is([data-widget], [data-scene]) .ag-start {
  position: relative;
  z-index: 3;
  align-self: start;
  margin-top: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
}

/* The scene stage (src/sceneStage.ts): a prefabricated, animated scene of an
   app feature, in the layer itself with no frame. data-scene is on the layer
   while one is up or on its way. The stage holds a canvas, which carries the
   morph in and out, and the fit box, in which the scene's host is centred.
   A scene is 75em by 45em and the stage sets the host's font-size to fit.

   In a call the stage spans the screen, wider than the column the words and
   pictures keep to, and its box never changes size, so words can be traced
   on its canvas before the scene arrives. The words become the small line
   above, as with pictures. */
.ag-scene {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 50vw + clamp(0.9rem, 3vw, 2rem));
  width: calc(100vw - 2 * clamp(0.9rem, 3vw, 2rem));
  z-index: 1;
  pointer-events: none;
}

.ag .ag-scene canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 0.26s;
}

.ag-scene-fit {
  position: absolute;
  inset: 4.4rem 0 0;
  display: grid;
  place-items: center;
}

.ag-scene-host { transition: opacity 0.26s; }
.ag-scene-host[data-hidden] { opacity: 0; transition: none; }

.ag[data-scene] .ag-words { z-index: 2; }

/* In a chat the scene has the room above the thread, as wide as the screen
   allows and at most a little over half its height. */
.ag[data-mode="chat"]:not([data-scene]) .ag-scene { display: none; }
.ag[data-mode="chat"][data-scene] .ag-main { grid-template-rows: auto minmax(0, 1fr); }

.ag[data-mode="chat"] .ag-scene {
  position: relative;
  inset: auto;
  justify-self: center;
  width: min(calc(100vw - 2 * clamp(0.9rem, 3vw, 2rem)), 72rem);
  height: min(60vh, calc(min(calc(100vw - 2 * clamp(0.9rem, 3vw, 2rem)), 72rem) * 0.6));
  margin-top: 0.6rem;
}

.ag[data-mode="chat"] .ag-scene-fit { inset: 0; }

/* ?scene=<id>: one scene alone, for building and checking scenes. */
.ag-preview { grid-template-rows: minmax(0, 1fr) auto; }
.ag-preview .ag-main { width: 100%; height: 100%; }
.ag-preview .ag-scene-fit { inset: 0; }

/* The code viewer: what the model wrote, as a file to read, copy or download
   (src/codeView.ts). A dialog over the layer. The first time, it shows a
   short notice in the style of the one above, and the code after that. */
.ag-code-box {
  box-sizing: border-box;
  width: min(100vw - 1.5rem, 56rem);
  max-width: none;
  height: min(100dvh - 1.5rem, 46rem);
  max-height: none;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent);
  border-radius: 16px;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

.ag-code-box::backdrop { background: rgb(0 0 0 / 45%); }

.ag-code-box[data-pane="ask"] {
  width: min(100vw - 1.5rem, 38rem);
  height: fit-content;
}

.ag-code-ask,
.ag-code-view { display: none; }

.ag-code-box[data-pane="ask"] .ag-code-ask {
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  padding: 2rem 1.5rem 1.6rem;
  text-align: center;
}

.ag-code-box[data-pane="view"] .ag-code-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0.7rem;
  padding: 1rem;
}

.ag-code-box h2 {
  margin: 0;
  font: 800 1.25rem/1.2 var(--display);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.ag-code-ask h2 {
  font-size: clamp(1.5rem, 4.4vw, 2rem);
  letter-spacing: -0.03em;
}

.ag-code-box p {
  margin: 0;
  color: var(--soft);
}

.ag-code-ask p {
  max-width: 32rem;
  line-height: 1.55;
}

.ag-code-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.ag-code-by {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* The code itself. Text only: it cannot be edited and nothing in it runs. */
.ag-code-text {
  min-height: 0;
  margin: 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  color: var(--fg);
  font: 0.8rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  tab-size: 2;
  user-select: text;
}

.ag-code-text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* The sound report, shown with ?audiodebug (src/audioProbe.ts). */
.ag-audiodebug {
  position: absolute;
  left: 0.75rem;
  bottom: 3.25rem;
  z-index: 6;
  max-width: min(46rem, calc(100% - 1.5rem));
  max-height: 45%;
  overflow: auto;
  padding: 0.5rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 92%, var(--fg));
  color: var(--fg);
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ag-audiodebug pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.ag .ag-audiodebug button {
  float: right;
  margin: 0 0 0.3rem 0.6rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--fg) 25%, transparent);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.ag-code-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
}

.ag .ag-code-foot button,
.ag .ag-code-close {
  flex: none;
  padding: 0.4rem 0.95rem;
  border: 1.5px solid var(--dim);
  border-radius: 999px;
  font: 800 0.9rem/1.4 var(--display);
}

.ag .ag-code-foot button:hover,
.ag .ag-code-close:hover { border-color: var(--fg); }

.ag .ag-code-copy {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.ag-code-said {
  color: var(--soft);
  font-size: 0.85rem;
}

.ag-code-view .ag-code-terms {
  font-size: 0.72rem;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .ag-fine { font-size: 0.72rem; }

  /* The top bar has to hold the tabs, New chat, the owner's selector, the
     speaker and Close on one line. */
  .ag-top { gap: 0.4rem; }
  .ag-tabs button { padding: 0.3rem 0.7rem; }
  .ag .ag-new { padding: 0.45rem; }
  .ag-new span { display: none; }
  .ag-model { max-width: 6.5rem; }

  /* With many cells there is room for the icon only. */
  .ag-sketch[data-many] .ag-code { padding: 0.18rem 0.3rem; }
  .ag-sketch[data-many] .ag-code span { display: none; }
  .ag-code-box[data-pane="view"] .ag-code-view { padding: 0.75rem; }
  .ag-code-text { font-size: 0.74rem; }
}

/* Squircle corners, as in the desktop app, a little stronger. A squircle bends
   later along each edge, so its extents are larger than the circular radii
   they replace. Browsers without corner-shape keep the round corners above.
   The morph reads the computed shape, so the canvas matches either way. */
@supports (corner-shape: squircle) {
  .button,
  .commit-btn { border-radius: 18px; corner-shape: squircle; }
  .dl .dl-main { border-radius: 18px 0 0 18px; }
  .dl .dl-more { border-radius: 0 18px 18px 0; }
  @media (max-width: 820px) { .dl .dl-main { border-radius: 18px; } }

  .bubble,
  .cz-user > span,
  .cz-box,
  .ws-compose,
  .paths a,
  .paths button,
  .paths div,
  .ag-compose,
  .ag-audiodebug,
  .ag-msg.user,
  .ag[data-mode="chat"] .ag-sketch,
  .ag-pic iframe,
  .ag-code-box { border-radius: 26px; corner-shape: squircle; }

  .ag-start,
  .ag .ag-agree,
  .ag .ag-code-yes { border-radius: 30px; corner-shape: squircle; }

  .cz,
  .ws,
  .chat,
  .commit { border-radius: 30px; corner-shape: squircle; }

  .power-hero { border-radius: 34px; corner-shape: squircle; }

  .built,
  .ag-vol,
  .ws-sent { border-radius: 22px; corner-shape: squircle; }

  .cz-fold pre,
  .ws-new,
  .ws-note,
  .ag-code-text { border-radius: 14px; corner-shape: squircle; }

  .ws-attached,
  .ws-big { border-radius: 11px; corner-shape: squircle; }
  .ws-thumb { border-radius: 8px; corner-shape: squircle; }
}


.immersive canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}


