/*
 * TownSquare design foundations.
 *
 * Warm, calm, scene-native palette and type, shared by the host page and the
 * embedded widget. Everything downstream consumes these tokens — never raw
 * hex — so the look stays consistent and a host can later re-theme in one place.
 */
@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:ital,wght@0,400;0,460;0,500;0,600;0,650;1,460&display=swap");

:root {
  color-scheme: light;

  /* Surfaces — warm gray scene, cream chrome */
  --scene: #e4e2dd;
  --scene-edge: #dad8d1;
  --page: #efede9;
  --surface: #fdf8f4;
  --surface-2: #f4eee6;

  /* Ink — near-black down to faint labels */
  --ink: #2a2926;
  --ink-soft: #7c766c;
  --ink-faint: #aba59b;

  /* Hairlines */
  --hair: rgba(42, 41, 38, 0.1);
  --hair-2: rgba(42, 41, 38, 0.16);

  /* Accent — terracotta marks "you", used sparingly */
  --you: #c8641f;
  --you-deep: #a8521a;
  --you-tint: rgba(200, 100, 31, 0.13);

  /* Cast + ground */
  --other: #26241f;
  --ground: rgba(42, 41, 38, 0.16);

  /* Radii */
  --r: 20px;
  --r-sm: 13px;

  /* Elevation */
  --bshadow: 0 9px 16px -10px rgba(60, 40, 20, 0.3), 0 2px 5px -2px rgba(60, 40, 20, 0.16);
  --tray-shadow: 0 14px 30px -16px rgba(60, 40, 20, 0.42), 0 3px 8px -4px rgba(60, 40, 20, 0.2);

  /* Type */
  --font: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --fs-speech: 12px;
  --fw-speech: 480;
  --fs-history: 12px;
  --fw-history: 460;
  --fs-name: 13.5px;
  --fw-name: 600;
  --fs-time: 12px;
  --fw-time: 500;

  /* Legacy aliases — keep the host page chrome on the same palette */
  --bg: var(--page);
  --text: var(--ink);
  --muted: var(--ink-soft);
  --line: var(--hair-2);
  --accent: var(--you);
  --shadow: var(--bshadow);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg), color-mix(in oklab, var(--bg) 92%, black 8%));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page-shell {
  padding: 24px 16px 0;
}

.page-card {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.page-card h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 0.98;
}

.page-card p,
.page-card li {
  font-size: 1rem;
  line-height: 1.6;
  color: color-mix(in oklab, var(--text) 88%, var(--muted) 12%);
}

.page-card ul {
  margin: 16px 0 0;
  padding-left: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.townsquare-host {
  width: min(1100px, 100%);
  margin: 48px auto 0;
  padding: 0 12px 18px;
}

.townsquare {
  position: relative;
  min-height: 224px;
  border-top: 1px solid var(--line);
  overflow: hidden;
}

.townsquare__status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.townsquare__stage {
  position: relative;
  height: 180px;
  border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(
    180deg,
    var(--scene) 0%,
    var(--scene) 71%,
    var(--scene-edge) 71%,
    var(--page) 71.4%,
    var(--page) 100%
  );
}

.townsquare__ground {
  position: absolute;
  inset: auto 0 52px;
  height: 1px;
  background: var(--ground);
}

.prop {
  position: absolute;
  bottom: 53px;
  transform: translateX(-50%);
  color: color-mix(in oklab, var(--text) 58%, var(--muted) 42%);
  opacity: 0.5;
  pointer-events: none;
}

.prop svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.prop svg * {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.townsquare__hint {
  padding: 10px 4px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.dev-page {
  min-height: 100vh;
}

.dev-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 14px 24px;
}

.dev-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 0 4px 18px;
}

.dev-toolbar h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  line-height: 1;
}

.dev-controls {
  display: flex;
  align-items: end;
  gap: 10px;
}

.dev-field {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.83rem;
  font-weight: 600;
}

.dev-field input {
  width: 116px;
  height: 38px;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  font: 600 1rem var(--font);
}

.dev-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
  user-select: none;
}

.dev-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--you);
}

.dev-button {
  height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--ink);
  color: var(--surface);
  font: 650 0.92rem var(--font);
  cursor: pointer;
}

.dev-host {
  margin-top: 0;
  padding-inline: 0;
}

.dev-host .townsquare {
  min-height: 420px;
}

.dev-host .townsquare__stage {
  height: 360px;
}

.walk-page {
  min-height: 100vh;
}

.walk-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 14px 28px;
}

.walk-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 0 4px 18px;
}

.walk-toolbar h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  line-height: 1;
}

.walk-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.walk-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 650 1.4rem/1 var(--font);
  cursor: pointer;
}

.walk-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(68vh, 680px);
  border-top: 1px solid var(--line);
  border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(
    180deg,
    var(--scene) 0%,
    var(--scene) 72%,
    var(--scene-edge) 72%,
    var(--page) 72.4%,
    var(--page) 100%
  );
  overflow: hidden;
}

.walk-preview {
  position: relative;
  z-index: 1;
  width: min(300px, 54vw);
  aspect-ratio: 20 / 44;
  color: var(--you);
  filter: drop-shadow(0 16px 18px rgba(0,0,0,0.12));
}

.walk-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 27.6%;
  height: 1px;
  background: var(--ground);
}

.walk-timeline {
  display: grid;
  gap: 12px;
  padding: 16px 4px 0;
}

.walk-slider {
  display: grid;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.walk-slider input {
  width: 100%;
  accent-color: var(--you);
}

.walk-readout {
  min-height: 40px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.avatar {
  --walk-cycle: 0.8s;
  position: absolute;
  bottom: 53px;
  width: 18px;
  height: 46px;
  transform: translateX(-50%);
  transition: left 80ms linear;
  /* --speak-order: most recent speaker stacks on top when columns must overlap */
  z-index: var(--speak-order, 0);
}

.avatar.flip svg {
  transform: scaleX(-1);
  transform-origin: 50% 50%;
}

.avatar svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.avatar svg * {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.avatar svg circle.head {
  fill: currentColor;
}

.avatar--self { color: var(--you); }
.avatar--peer { color: var(--other); }

/* reading a character's tray outranks any neighbour's speak-order stacking */
.avatar--has-history:hover,
.avatar--has-history:focus-within { z-index: 2147483000; }
.avatar.walking { filter: drop-shadow(0 2px 5px rgba(0,0,0,0.12)); }
.avatar--sitting { bottom: 44px; }

/* Walk-sandbox preview: fills the preview box instead of standing on a stage. */
.avatar--preview {
  position: static;
  width: 100%;
  height: 100%;
  transform: none;
  transition: none;
}

.avatar--preview.walking { filter: none; }
.avatar--preview svg * { stroke-width: 1.4; }

.avatar svg :is(g.figure-core, g.joint) {
  transform-box: view-box;
}

.avatar svg g.figure-core { transform-origin: 10px 24px; }
.avatar svg g.arm-l { transform-origin: 9.4px 14px; }
.avatar svg g.arm-r { transform-origin: 10.6px 14px; }
.avatar svg g.elbow-l { transform-origin: 6.1px 20px; }
.avatar svg g.elbow-r { transform-origin: 13.9px 20px; }
.avatar svg g.leg-l { transform-origin: 9.2px 26px; }
.avatar svg g.leg-r { transform-origin: 10.8px 26px; }
.avatar svg g.knee-l { transform-origin: 7.1px 34px; }
.avatar svg g.knee-r { transform-origin: 12.9px 34px; }

.avatar.walking svg :is(g.figure-core, g.joint) {
  animation-duration: var(--walk-cycle);
  /* linear between frames: the easing lives in the keyframe spacing itself,
     so motion doesn't decelerate/re-accelerate at every keyframe. */
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.avatar.walking svg g.figure-core { animation-name: presence-body-bob; }
.avatar.walking svg g.leg-l { animation-name: presence-leg-a; }
.avatar.walking svg g.leg-r { animation-name: presence-leg-b; }
.avatar.walking svg g.knee-l { animation-name: presence-knee-a; }
.avatar.walking svg g.knee-r { animation-name: presence-knee-b; }
.avatar.walking svg g.arm-l { animation-name: presence-arm-a; }
.avatar.walking svg g.arm-r { animation-name: presence-arm-b; }
.avatar.walking svg g.elbow-l { animation-name: presence-forearm-a; }
.avatar.walking svg g.elbow-r { animation-name: presence-forearm-b; }

/*
  Walk cycle, figure facing right (the .flip scaleX(-1) mirrors it for left —
  the pose data itself never changes with direction).

  Sign conventions in the un-mirrored pose:
    legs/arms  positive deg = limb swung backward, negative = forward
    knees      positive deg = flexion (heel toward butt); never negative
    elbows     negative deg = flexion (hand swings forward); never positive

  Phase layout: left-leg heel strike at 0%, right-leg heel strike at 50%.
  Each leg spends ~60% of the cycle in stance and ~40% in swing, with peak
  knee flexion mid-swing for ground clearance.
*/
@keyframes presence-body-bob {
  0%, 50%, 100% { transform: translateY(0.4px) rotate(0.6deg); }
  6%, 56% { transform: translateY(0.7px) rotate(0.9deg); }
  28%, 78% { transform: translateY(-0.6px) rotate(1.2deg); }
}

@keyframes presence-leg-a {
  0%, 100% { transform: rotate(-20deg); }
  8% { transform: rotate(-18deg); }
  30% { transform: rotate(-2deg); }
  45% { transform: rotate(10deg); }
  55% { transform: rotate(14deg); }
  62% { transform: rotate(15deg); }
  75% { transform: rotate(-4deg); }
  88% { transform: rotate(-17deg); }
  94% { transform: rotate(-21deg); }
}

@keyframes presence-leg-b {
  0%, 100% { transform: rotate(12deg); }
  5% { transform: rotate(14deg); }
  12% { transform: rotate(15deg); }
  25% { transform: rotate(-4deg); }
  38% { transform: rotate(-17deg); }
  44% { transform: rotate(-21deg); }
  50% { transform: rotate(-20deg); }
  58% { transform: rotate(-18deg); }
  80% { transform: rotate(-2deg); }
  95% { transform: rotate(10deg); }
}

@keyframes presence-knee-a {
  0%, 100% { transform: rotate(4deg); }
  8% { transform: rotate(12deg); }
  20% { transform: rotate(6deg); }
  40% { transform: rotate(5deg); }
  55% { transform: rotate(18deg); }
  65% { transform: rotate(32deg); }
  72% { transform: rotate(38deg); }
  80% { transform: rotate(28deg); }
  90% { transform: rotate(8deg); }
  96% { transform: rotate(3deg); }
}

@keyframes presence-knee-b {
  0%, 100% { transform: rotate(14deg); }
  5% { transform: rotate(18deg); }
  15% { transform: rotate(32deg); }
  22% { transform: rotate(38deg); }
  30% { transform: rotate(28deg); }
  40% { transform: rotate(8deg); }
  46% { transform: rotate(3deg); }
  50% { transform: rotate(4deg); }
  58% { transform: rotate(12deg); }
  70% { transform: rotate(6deg); }
  90% { transform: rotate(5deg); }
}

@keyframes presence-arm-a {
  0%, 100% { transform: rotate(12deg); }
  12% { transform: rotate(10deg); }
  30% { transform: rotate(1deg); }
  50% { transform: rotate(-10deg); }
  60% { transform: rotate(-11deg); }
  75% { transform: rotate(-5deg); }
  90% { transform: rotate(7deg); }
}

@keyframes presence-arm-b {
  0%, 100% { transform: rotate(-10deg); }
  10% { transform: rotate(-11deg); }
  25% { transform: rotate(-5deg); }
  40% { transform: rotate(7deg); }
  50% { transform: rotate(12deg); }
  62% { transform: rotate(10deg); }
  80% { transform: rotate(1deg); }
}

@keyframes presence-forearm-a {
  0%, 100% { transform: rotate(-6deg); }
  15% { transform: rotate(-7deg); }
  35% { transform: rotate(-10deg); }
  55% { transform: rotate(-14deg); }
  68% { transform: rotate(-15deg); }
  85% { transform: rotate(-9deg); }
}

@keyframes presence-forearm-b {
  0%, 100% { transform: rotate(-13deg); }
  5% { transform: rotate(-14deg); }
  18% { transform: rotate(-15deg); }
  35% { transform: rotate(-9deg); }
  50% { transform: rotate(-6deg); }
  65% { transform: rotate(-7deg); }
  85% { transform: rotate(-10deg); }
}

.avatar--sitting svg :is(g.figure-core, g.joint) {
  animation: none !important;
  transition: transform 220ms ease;
}

.avatar--sitting svg g.figure-core { transform: translateY(0) rotate(0); }
.avatar--sitting svg g.leg-l { transform: rotate(74deg); }
.avatar--sitting svg g.leg-r { transform: rotate(70deg); }
.avatar--sitting svg g.knee-l { transform: rotate(-84deg); }
.avatar--sitting svg g.knee-r { transform: rotate(-80deg); }
.avatar--sitting svg g.arm-l,
.avatar--sitting svg g.arm-r { transform: rotate(16deg); }
.avatar--sitting svg g.elbow-l { transform: rotate(24deg); }
.avatar--sitting svg g.elbow-r { transform: rotate(-24deg); }

/* ── Ghost stack: history lives in the scene as fading bubbles above the figure ── */
.avatar__above {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  /* --bubble-shift: collision-avoidance nudge; --bubble-scale / --bubble-fade:
     proximity prominence — all set per frame by bubble-layout */
  transform: translateX(calc(-50% + var(--bubble-shift, 0px))) scale(var(--bubble-scale, 1));
  transform-origin: bottom center;
  opacity: var(--bubble-fade, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(240px, 72vw);
  pointer-events: none;
  transition: opacity 140ms ease, transform 160ms ease;
}

.avatar__above:empty { display: none; }

/* hovering to read history yields the live stack to the tray */
.avatar--has-history:hover .avatar__above,
.avatar--has-history:focus-within .avatar__above { opacity: 0; }

.avatar__bubble {
  position: relative;
  max-width: 100%;
  padding: 11px 16px 12px;
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-speech);
  line-height: 1.28;
  font-weight: var(--fw-speech);
  letter-spacing: -0.005em;
  box-shadow: var(--bshadow);
  transform-origin: bottom center;
  transition: opacity 280ms ease, transform 280ms ease, box-shadow 280ms ease;
}

.avatar__bubble-text {
  display: block;
  overflow-wrap: anywhere;
}

.avatar__tail {
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 160px;
  height: 12px;
  background: var(--surface);
  /* The base slides along the bubble's flat bottom (--tail-shift) and the tip
     leans the rest of the way to the speaker (--tail-tip), so the pointer
     always lands on whoever spoke even when the column was nudged aside. */
  transform: translateX(calc(-50% + var(--tail-shift, 0px)));
  clip-path: polygon(
    calc(50% - 8px) 0,
    calc(50% + 8px) 0,
    calc(50% + var(--tail-tip, 0px) + 1.5px) 100%,
    calc(50% + var(--tail-tip, 0px) - 1.5px) 100%
  );
  filter: drop-shadow(2px 3px 2px rgba(60, 40, 20, 0.14));
  transition: transform 160ms ease, clip-path 160ms ease;
}

/* only the live (bottom) bubble keeps its tail */
.avatar__bubble--ghost .avatar__tail { display: none; }

.avatar__bubble--ghost {
  opacity: 0.5;
  transform: scale(0.9);
  box-shadow: none;
}

.avatar__bubble--ghost.avatar__bubble--far {
  opacity: 0.26;
  transform: scale(0.84);
}

/* each line fades out on its own timer, oldest first */
.avatar__bubble--expiring {
  opacity: 0;
  transform: scale(0.8);
}

/* ── History tray: hover a character to recover their recent lines ── */
.avatar__tray {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  z-index: 3;
  width: max-content;
  min-width: 200px;
  max-width: min(260px, 76vw);
  padding: 5px 4px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--tray-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.avatar--has-history:hover .avatar__tray,
.avatar--has-history:focus-within .avatar__tray {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* transparent bridge across the gap so hover survives figure → tray travel */
.avatar__tray::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 16px;
}

.avatar__tray-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 8px 13px;
}

.avatar__tray-row + .avatar__tray-row {
  box-shadow: 0 -1px 0 var(--hair);
}

.avatar__tray-msg {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-history);
  font-weight: var(--fw-history);
  color: var(--ink);
}

.avatar__tray-time {
  flex: 0 0 auto;
  font-size: var(--fs-time);
  font-weight: var(--fw-time);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ── Nameplate / composer: the persistent way in, below your figure ── */
.avatar__below {
  position: absolute;
  left: 50%;
  top: calc(100% + 9px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
}

.avatar__plate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px 6px 11px;
  border: 0;
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--bshadow);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.avatar__plate:hover { transform: translateY(-1px); }
.avatar__plate:focus-visible {
  outline: 2px solid var(--you);
  outline-offset: 2px;
}

.avatar__plate[hidden] { display: none; }

.avatar__plate-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--you);
}

.avatar__plate-name {
  font-size: var(--fs-name);
  font-weight: var(--fw-name);
  letter-spacing: 0.01em;
  color: var(--you);
  text-transform: lowercase;
}

.avatar__plate-hint {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-faint);
}

.avatar__composer {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 7px 7px 19px;
  min-width: 300px;
  max-width: min(340px, 80vw);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--tray-shadow);
}

.avatar__composer[hidden] { display: none; }

.avatar__input {
  flex: 1;
  min-width: 0;
  min-height: 30px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  font-weight: 460;
}

.avatar__input::placeholder { color: var(--ink-faint); }

.avatar__send {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--hair);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.avatar__send svg { width: 17px; height: 17px; display: block; }

.avatar__send--ready {
  background: var(--you);
  color: #fff;
  box-shadow: none;
}

.hosted-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 36px 16px;
}

.hosted-panel {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hosted-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.hosted-panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.hosted-copy,
.hosted-note,
.hosted-status {
  color: var(--muted);
  line-height: 1.5;
}

.hosted-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.hosted-form label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.hosted-form input,
.hosted-token input,
.hosted-dialog input,
.hosted-section textarea,
.hosted-result textarea {
  width: 100%;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 500 1rem var(--font);
}

.hosted-form input,
.hosted-token input,
.hosted-dialog input {
  height: 44px;
  padding: 0 12px;
}

.hosted-token {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.hosted-token input,
.hosted-dialog input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.hosted-section textarea,
.hosted-result textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}

.hosted-form button,
.hosted-actions button,
.hosted-actions a,
.visitor-row button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--ink);
  color: var(--surface);
  font: 700 0.92rem var(--font);
  text-decoration: none;
  cursor: pointer;
}

.hosted-actions a,
.hosted-actions button:nth-child(n + 2),
.visitor-row button {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--hair-2);
}

.hosted-result,
.hosted-section,
.hosted-meta {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--hair-2);
}

.hosted-dialog {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.hosted-dialog::backdrop {
  background: rgb(33 31 28 / 0.45);
}

.hosted-dialog form {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.hosted-dialog h2,
.hosted-dialog p {
  margin: 0;
}

.hosted-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hosted-meta dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.hosted-meta div {
  min-width: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.hosted-meta dt {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.hosted-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.hosted-section-head,
.hosted-toggle,
.visitor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hosted-toggle {
  justify-content: flex-start;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
}

.hosted-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--you);
}

.visitor-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.visitor-row {
  padding: 12px;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
}

.visitor-row div {
  display: grid;
  gap: 3px;
}

.visitor-row span {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

@media (max-width: 640px) {
  .page-card { padding: 20px; border-radius: 20px; }
  .hosted-panel { padding: 20px; }
  .hosted-meta dl { grid-template-columns: 1fr; }
  .hosted-section-head,
  .visitor-row {
    align-items: stretch;
    flex-direction: column;
  }
  .townsquare-host { margin-top: 32px; }
  .townsquare__status { flex-direction: column; gap: 4px; }
  .avatar__composer { min-width: min(260px, 80vw); }
  .dev-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .dev-controls {
    align-items: end;
  }
  .dev-host .townsquare__stage {
    height: 300px;
  }
  .walk-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .walk-controls {
    flex-wrap: wrap;
  }
  .walk-stage {
    min-height: 58vh;
  }
}
