/* ===========================================================================
   GhostChat design system
   ---------------------------------------------------------------------------
   Three rules this file follows:

   1. Every value comes from a scale. Spacing is a 4px grid, type is a fixed
      ramp, radii and shadows are enumerated. Nothing is eyeballed.
   2. The gradient is a highlight, not a texture. It appears on the primary
      action and on outgoing messages. Everywhere else is restrained neutral,
      which is what stops a dark UI from looking like a screensaver.
   3. Contrast is checked against the surface it sits on, not against black.
   =========================================================================== */

/* --------------------------------------------------------------- typeface */
/* Self-hosted: a privacy tool should not announce every page view to a font
   CDN. Variable weight axis, so one file covers the whole ramp.             */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                 U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                 U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF,
                 U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                 U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ----------------------------------------------------------------- tokens */

:root {
  /* Surfaces. A dark UI needs more steps than a light one, because every
     elevation change has to read at low luminance.                          */
  --bg:          #02040a;
  --canvas:      #02040a;
  --surface-1:   #0f1220;
  --surface-2:   #161a2b;
  --surface-3:   #1d2237;
  --surface-4:   #252b43;

  /* Hairlines. Two weights: one that separates, one that merely suggests.   */
  --line:        #232943;
  --line-soft:   #181d30;

  /* Text ramp. Three steps is enough; a fourth always gets misused.         */
  --text-1:      #eef1fb;
  --text-2:      #9aa3c2;
  --text-3:      #666e91;

  /* Brand. The gradient endpoints, plus a cyan used only for accents that
     must not read as interactive.                                           */
  --brand:       #4b6bff;
  --brand-2:     #7c5cff;
  --brand-ink:   #ffffff;
  --cyan:        #4cc6f5;

  --ok:          #3ddc97;
  --warn:        #f5c451;
  --danger:      #ff6b6b;   /* text and status, on dark surfaces */
  /* A filled destructive button needs a deeper red than the text colour:
     #ff6b6b as a fill reads as a warning sticker, and white on it fails
     contrast. These two carry white at 4.6:1. */
  --danger-fill: #e0393f;
  --danger-fill-2: #c0272d;

  /* Spacing: 4px grid. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;
  --s9: 48px; --s10: 64px;

  /* Radii. */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 999px;
  --r-bubble: 18px;
  --r-tail: 4px;

  /* Elevation. Dark UIs need shadow plus a light top edge, or cards float
     with no sense of material.                                              */
  --sh-1: 0 1px 2px rgba(0, 0, 0, .45);
  --sh-2: 0 4px 14px -3px rgba(0, 0, 0, .55);
  --sh-3: 0 20px 48px -12px rgba(0, 0, 0, .7);
  --glow: 0 6px 22px -6px rgba(75, 107, 255, .55);

  --grad: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);

  --ease: cubic-bezier(.32, .72, 0, 1);
  --fast: 140ms;
  --med:  220ms;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shell-max: 480px;
}

/* ------------------------------------------------------------------ reset */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "cv05" 1, "cv11" 1, "ss03" 1;  /* single-storey g, straight l */
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* One focus treatment, applied consistently. Keyboard users get a ring;
   pointer users never see it. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

[hidden] { display: none !important; }

/* One flat background for the whole app. The ambient radial wash that used to
   live here tinted the page a few points off the specified value, so it is
   gone: what is measured on screen is exactly --bg. */

/* ============================================================== LANDING == */

.hero {
  min-height: 100dvh;
  max-width: 26rem;
  margin-inline: auto;
  padding: var(--s8) var(--s5) calc(var(--s8) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.mark {
  width: 104px;
  height: 104px;
  border-radius: 26px;
  margin-bottom: var(--s6);
  filter: drop-shadow(0 12px 32px rgba(75, 107, 255, .32));
}

.wordmark {
  font-size: 38px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin-bottom: var(--s3);
}
.wordmark .accent {
  background: linear-gradient(105deg, var(--brand) 10%, var(--brand-2) 62%, var(--cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--text-2);
  font-size: 16px;
  margin-bottom: var(--s8);
  text-wrap: balance;
}

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

.btn {
  --btn-h: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: var(--btn-h);
  padding-inline: var(--s6);
  border-radius: var(--r-full);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.011em;
  white-space: nowrap;
  text-decoration: none;            /* .btn is worn by <a> as well as <button> */
  transition: transform var(--fast) var(--ease),
              box-shadow var(--med) var(--ease),
              background-color var(--fast) var(--ease),
              opacity var(--fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--grad);
  color: var(--brand-ink);
  box-shadow: var(--glow);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 30px -6px rgba(75, 107, 255, .68); }

.btn-quiet {
  background: var(--surface-2);
  color: var(--text-1);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
}
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); }

.btn-danger {
  background: rgba(255, 107, 107, .12);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, .26);
}
.btn-danger:hover:not(:disabled) { background: rgba(255, 107, 107, .2); }

.btn-sm { --btn-h: 40px; padding-inline: var(--s4); font-size: 14px; }
.btn-full { width: 100%; }

.hero .btn-primary { width: 100%; max-width: 20rem; }

/* Option 2 previews the game room it leads to: the same red, held back to
   an outline so it never competes with the primary action above it. */
.mode-or {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  max-width: 20rem;
  margin: var(--s5) 0 var(--s4);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.mode-or::before, .mode-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.btn-game {
  width: 100%;
  max-width: 20rem;
  background: linear-gradient(180deg, rgba(227, 23, 43, .14), rgba(227, 23, 43, .06));
  color: #ffd9dd;
  border: 1px solid rgba(255, 58, 77, .45);
  box-shadow: 0 10px 28px -16px rgba(227, 23, 43, .8), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.btn-game svg { color: #ff3a4d; }
.btn-game:hover {
  background: linear-gradient(180deg, rgba(227, 23, 43, .24), rgba(227, 23, 43, .1));
  border-color: #ff3a4d;
  color: #fff;
}

.mode-hint {
  margin-top: var(--s2);
  color: var(--text-3);
  font-size: 12px;
}

.home-note {
  margin-top: var(--s6);
  max-width: 21rem;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.6;
  text-wrap: pretty;
}
.home-note.bad { color: var(--danger); }
.home-note kbd {
  font-family: inherit;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ================================================================= ROOM == */

body.room { height: 100dvh; overflow: hidden; }

.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: var(--shell-max);
  margin-inline: auto;
  background: var(--canvas);
  border-inline: 1px solid var(--line-soft);
}
@media (min-width: 520px) {
  .shell { box-shadow: var(--sh-3); }
}

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

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  padding-top: calc(var(--s3) + env(safe-area-inset-top));
  /* Sits directly on the conversation, like the composer. */
  background: transparent;
}

.avatar {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
}
.avatar img {
  width: 100%; height: 100%;
  border-radius: var(--r-md);
  display: block;
}
/* Presence dot, notched out of the avatar so it reads as attached to it
   rather than laid on top. */
.avatar::after {
  content: "";
  position: absolute;
  right: -2px; bottom: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-3);
  border: 2.5px solid var(--canvas);
  transition: background-color var(--med) var(--ease);
}
body[data-phase="chat"] .avatar::after { background: var(--ok); }
body[data-phase="gone"] .avatar::after,
body[data-phase="blocked"] .avatar::after { background: var(--danger); }

.identity { flex: 1; min-width: 0; }
.identity h1 {
  font-size: 16px;
  font-weight: 620;
  letter-spacing: -0.017em;
  line-height: 1.25;
}

.status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-3);
}
.status::before {
  content: "";
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status.good { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad  { color: var(--danger); }
/* Only the transitional state pulses. A steady state that blinks reads as an
   error even when it is not. */
.status.warn::before { animation: pulse 1.8s var(--ease) infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .45; transform: scale(.82); }
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  color: var(--text-2);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text-1); }
.icon-btn.danger:hover { background: rgba(255, 107, 107, .14); color: var(--danger); }

/* ---------------------------------------------------- verification strip */
/* A slim always-visible bar rather than a card. The six symbols are the
   security surface, so they stay on screen; the explanation is one tap away
   and does not permanently eat a third of the viewport. */

.verify {
  flex: none;
  background: transparent;
}
/* The code sits dead centre. The caption goes above it rather than beside it,
   because anything sharing the row pushes the code off centre -- and this is
   the one element on screen whose whole job is to be compared, glyph for
   glyph, against another device. */
.verify > summary {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: var(--s3) var(--s8);     /* room for the chevron at the edge */
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color var(--fast) var(--ease);
}
.verify > summary::-webkit-details-marker { display: none; }
.verify > summary:hover { background: var(--surface-2); }

.sas-row {
  display: flex;
  gap: 3px;
  flex: none;
  /* The code is read character by character, so the glyphs must not shift
     width between sessions. */
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.sas-row span {
  display: grid;
  place-items: center;
  width: 22px; height: 26px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
}
/* Split into two blocks of four. Eight unbroken characters are noticeably
   harder to compare across two screens than 4 + 4. */
.sas-row span:nth-child(5) { margin-left: 9px; }

.verify-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  white-space: nowrap;
}
.verify .chev {
  position: absolute;
  right: var(--s4);
  top: 50%;
  margin-top: -8px;
  pointer-events: none;
  color: var(--text-3);
  transition: transform var(--med) var(--ease);
}
.verify[open] .chev { transform: rotate(180deg); }

.verify-body {
  padding: 0 var(--s5) var(--s4);
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  text-wrap: pretty;
}
.verify-body strong { color: var(--text-1); font-weight: 600; }

/* ------------------------------------------------------------------- log */

/* A transcript hangs from the bottom, the way every chat client behaves:
   new messages appear just above the composer rather than stranded at the
   top of an empty pane. `justify-content: flex-end` would be the obvious way
   and is also the wrong one -- in a scrolling flex container it clips the
   overflowing top. Pushing the first child down does not. */
.log > :first-child { margin-top: auto; }

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s4) var(--s4) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* --------------------------------------------------------------- bubbles */

.msg {
  display: flex;
  max-width: 100%;
  animation: msg-in var(--med) var(--ease) both;
}
.msg.out { justify-content: flex-end; }

/* Consecutive messages from one side pull together and drop the tail, so a
   burst reads as one turn instead of five separate events. */
.msg + .msg.same { margin-top: -2px; }
.msg:not(.same) { margin-top: var(--s3); }
.log > .msg:first-child { margin-top: 0; }

.bubble {
  position: relative;
  max-width: 78%;
  padding: 9px 13px 7px;
  border-radius: var(--r-bubble);
  font-size: 15px;
  line-height: 1.45;
  box-shadow: var(--sh-1);
}

/* The tail belongs to the final bubble of a run and to nothing else. Every
   other bubble keeps four equal corners, which is what makes a run read as
   one block of speech rather than a stack of separate ones. */
.msg.in .bubble {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--text-1);
}
.msg.in.last .bubble { border-bottom-left-radius: var(--r-tail); }

.msg.out .bubble {
  background: var(--grad);
  color: var(--brand-ink);
  box-shadow: 0 2px 14px -4px rgba(75, 107, 255, .5);
}
.msg.out.last .bubble { border-bottom-right-radius: var(--r-tail); }

.bubble .text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A time on every bubble is noise. Only the last message of a run carries
   one, which is the only place it tells you anything, and the reserved
   gutter is applied only there so short messages keep their natural width. */
.bubble .meta { display: none; }
.msg.last .bubble .meta {
  display: block;
  position: absolute;
  right: 12px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;   /* times must not jitter */
  letter-spacing: 0.02em;
  opacity: .5;
}
.msg.last .bubble .text { padding-inline-end: 34px; }
.msg.out.last .bubble .meta { opacity: .72; }

/* Image messages: the picture is the content, so the padding collapses. */
/* Specificity has to beat `.msg.in .bubble`, which carries the hairline. */
.msg .bubble:has(.attach),
.msg.in .bubble:has(.attach),
.msg.out .bubble:has(.attach) {
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--sh-2);
}
.bubble:has(.attach) .text { padding-inline-end: 0; }
.bubble .attach {
  display: block;
  width: 100%;
  max-height: 22rem;
  object-fit: cover;
  background: var(--surface-3);
}
.msg.last .bubble:has(.attach) .meta {
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: rgba(6, 7, 15, .6);
  color: #fff;
  opacity: 1;
  backdrop-filter: blur(6px);
}

/* In flight: the bubble is on screen but not yet acknowledged by the wire. */
.msg.sending .bubble { opacity: .55; }
.msg.sending .bubble .meta { opacity: 0; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- notices */

/* A neutral notice is a quiet line of system text, not a component. Only the
   ones that need action get a container. */
.notice {
  align-self: center;
  max-width: 19rem;
  margin-block: var(--s4);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}
/* No container on any of them -- system notices are a line of text in the
   conversation, and colour alone carries the severity. */
.notice.good { color: var(--ok); }
.notice.warn { color: var(--warn); }
.notice.bad  { color: var(--danger); }

/* ------------------------------------------------------- typing indicator */

.typing {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  margin: 0 var(--s4) var(--s3);
  padding: 10px 13px;
  border-radius: var(--r-bubble);
  border-bottom-left-radius: var(--r-tail);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  animation: msg-in var(--med) var(--ease) both;
}
.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing 1.25s var(--ease) infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

@keyframes typing {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1;  transform: translateY(-3px); }
}

/* -------------------------------------------------------------- composer */

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom));
  background: transparent;
}

.attach-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: var(--r-full);
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.attach-btn:hover { color: var(--text-1); background: var(--surface-3); }

/* The field is the wrapper, not the textarea: that way the focus ring hugs
   the visible pill and the textarea can grow without moving its own border. */
.field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.field:focus-within { border-color: var(--brand); background: var(--surface-3); }

.field textarea {
  flex: 1;
  min-width: 0;
  max-height: 128px;
  padding: 10px 0;
  border: 0;
  background: none;
  resize: none;
  font-size: 15px;
  line-height: 1.45;
  scrollbar-width: none;
}
.field textarea:focus { outline: none; }
.field textarea::-webkit-scrollbar { display: none; }
.field textarea::placeholder { color: var(--text-3); }

.send {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--grad);
  color: var(--brand-ink);
  box-shadow: var(--glow);
  transition: transform var(--fast) var(--ease), opacity var(--med) var(--ease),
              box-shadow var(--med) var(--ease);
}
.send:hover:not(:disabled) { filter: brightness(1.12); }
.send:active:not(:disabled) { transform: scale(.9); }
/* Empty field: the button stays put but stops advertising itself. Hiding it
   would make the composer jump on every first keystroke. */
.send:disabled {
  opacity: .32;
  box-shadow: none;
  cursor: default;
}

/* ------------------------------------------------------------ invite card */

.stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s5);
  padding: var(--s6) var(--s5) calc(var(--s7) + env(safe-area-inset-bottom));
  text-align: center;
}

.ghost-idle {
  width: 84px; height: 84px;
  border-radius: 21px;
  opacity: .9;
  filter: drop-shadow(0 12px 28px rgba(75, 107, 255, .3));
  animation: drift 4.2s var(--ease) infinite;
}
@keyframes drift {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.stage h2 {
  font-size: 19px;
  font-weight: 620;
  letter-spacing: -0.021em;
  text-wrap: balance;
}
.stage p {
  max-width: 23rem;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
  text-wrap: pretty;
}
.stage .fine { color: var(--text-3); font-size: 12.5px; }

.copyfield {
  width: 100%;
  max-width: 22rem;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.copyfield input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--cyan);
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
}
.copyfield input:focus { outline: none; }

.btn-copy { flex: none; min-width: 84px; }
.btn-copy.done { background: rgba(61, 220, 151, .14); border-color: rgba(61, 220, 151, .3); color: var(--ok); }

/* Which stage is on screen is a pure function of the session phase. Each
   panel names the phases it belongs to, rather than a list of phases naming
   the panels -- adding a phase then cannot silently leave a panel stranded. */
#invitePanel, #endPanel { display: none; }

body[data-phase="waiting"] #invitePanel,
body[data-phase="joining"] #invitePanel { display: flex; }

body[data-phase="gone"]    #endPanel,
body[data-phase="blocked"] #endPanel { display: flex; }

body:not([data-phase="chat"]) .log,
body:not([data-phase="chat"]) .composer,
body:not([data-phase="chat"]) .verify { display: none; }

/* The idle ghost drifts while you wait; the one on the end screen does not.
   Motion there would read as "still going" at the exact moment the point is
   that nothing is. */
.ghost-still {
  width: 72px; height: 72px;
  border-radius: 18px;
  opacity: .4;
  filter: grayscale(.35);
}

#endPanel .btn-primary { width: 100%; max-width: 17rem; margin-top: var(--s2); }

/* Nothing left to delete once the room is gone, so the action goes with it. */
body[data-phase="gone"] #destroy,
body[data-phase="blocked"] #destroy { display: none; }

/* ----------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: var(--s4);
  padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom));
  background: rgba(1, 2, 6, .72);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  animation: fade var(--med) var(--ease);
}
@media (min-width: 520px) { .modal { place-items: center; } }

.sheet {
  width: min(23rem, 100%);
  padding: var(--s7) var(--s6) var(--s6);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1) 46%);
  border: 1px solid var(--line);
  border-radius: 22px;
  text-align: center;
  /* The inset hairline is what gives a dark panel a lit top edge, and it is
     the difference between a card that sits on the page and one that floats
     above it. */
  box-shadow: var(--sh-3), inset 0 1px 0 rgba(255, 255, 255, .055);
  animation: sheet-up var(--med) var(--ease);
}

/* Concentric rings rather than a filled tile: the halo carries the severity
   without the icon itself having to shout. */
.sheet-icon {
  display: grid;
  place-items: center;
  width: 54px; height: 54px;
  margin: 0 auto var(--s5);
  border-radius: 50%;
  color: #ff8a8e;
  background: radial-gradient(circle at 50% 42%,
              rgba(224, 57, 63, .26), rgba(224, 57, 63, .08) 70%);
  box-shadow: 0 0 0 1px rgba(255, 107, 107, .24),
              0 0 0 9px rgba(255, 107, 107, .055),
              0 10px 28px -10px rgba(224, 57, 63, .55);
}

.sheet h3 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.024em;
  margin-bottom: var(--s3);
  text-wrap: balance;
}
.sheet p {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.62;
  margin: 0 auto;
  max-width: 19rem;
  text-wrap: pretty;
}
.sheet-warn {
  margin-top: var(--s3) !important;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 550;
}

/* Stacked, full width. Side-by-side buttons of equal weight make the reader
   decide which one is the default; stacking puts the action they asked for
   first and leaves the way out plainly beneath it. */
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-top: var(--s6);
}

.btn-destructive {
  background: linear-gradient(180deg, var(--danger-fill), var(--danger-fill-2));
  color: #fff;
  box-shadow: 0 6px 20px -8px rgba(224, 57, 63, .75),
              inset 0 1px 0 rgba(255, 255, 255, .16);
}
.btn-destructive:hover:not(:disabled) { filter: brightness(1.07); }

.btn-plain {
  background: transparent;
  color: var(--text-2);
}
.btn-plain:hover:not(:disabled) { background: var(--surface-3); color: var(--text-1); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up {
  from { opacity: 0; transform: translateY(18px) scale(.965); }
  to   { opacity: 1; transform: none; }
}

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

@media (max-width: 380px) {
  .bubble { max-width: 84%; }
  .sas-row span { width: 26px; height: 26px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* The sidebar wrapper is inert on the phone: its children stay direct flex
   children of .shell, so the mobile layout behaves exactly as if it were not
   in the markup at all. */
.side { display: contents; }
.side-fill, .side-facts { display: none; }

/* ---------------------------------------------------- keeping it on screen */

/* The transcript can be read but not selected, long-pressed or dragged out.
   The composer is deliberately left alone -- it is the user's own text. */
.log, .log *, .verify, .verify * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;          /* iOS copy / save-image menu */
}
.bubble .attach {
  -webkit-user-drag: none;
  user-drag: none;
}

/* The veil. Showing is instant -- the OS snapshots the app the moment it is
   backgrounded, and a fade-in would be caught half-transparent. Hiding
   fades, because nothing is at stake on the way back. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--med) var(--ease), visibility 0s linear var(--med);
  cursor: pointer;
}
body.veiled .veil {
  opacity: 1;
  visibility: visible;
  transition: none;
}
.veil img {
  width: 64px; height: 64px;
  border-radius: 16px;
  margin-bottom: var(--s3);
  opacity: .5;
}
.veil p { font-size: 16px; font-weight: 600; color: var(--text-1); }
.veil span { font-size: 12.5px; color: var(--text-3); }

/* Printing produces a notice, not a transcript. */
@media print {
  body.room * { display: none !important; }
  body.room::after {
    content: "GhostChat conversations cannot be printed.";
    display: block;
    padding: 2rem;
    font: 600 14px/1.5 system-ui, sans-serif;
    color: #000;
  }
}

/* ===========================================================================
   DESKTOP
   ---------------------------------------------------------------------------
   Everything above is the phone layout, which is the one that was designed
   first and signed off. None of it is overridden lightly: the breakpoints
   below re-arrange, they do not restyle.
   =========================================================================== */

/* --------------------------------------------------- landing: two columns */

.showcase { display: none; }

@media (min-width: 980px) {
  body.home { display: grid; place-items: center; min-height: 100dvh; }

  .home-wrap {
    display: grid;
    grid-template-columns: minmax(0, 24rem) minmax(0, 30rem);
    align-items: center;
    gap: var(--s10);
    padding: var(--s8) var(--s7);
  }

  /* The hero stops being the page and becomes a column in it. */
  .hero {
    min-height: 0;
    max-width: none;
    padding: 0;
    align-items: flex-start;
    text-align: left;
  }
  .mark { width: 76px; height: 76px; border-radius: 19px; margin-bottom: var(--s5); }
  .wordmark { font-size: 46px; }
  .tagline { margin-bottom: var(--s7); font-size: 17px; }
  .hero .btn-primary { width: 100%; max-width: 20rem; }
  .mode-or { max-width: 20rem; }
  .home-note { margin-top: var(--s5); max-width: 22rem; }

  .showcase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s6);
  }
}

.slides {
  position: relative;
  width: 100%;
  /* Fixed height: the slides are absolutely stacked, so the box cannot be
     sized by its content, and a box that resizes per slide makes the dots
     jump every five seconds. */
  height: 23rem;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s7) var(--s6);
  text-align: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface-1), rgba(15, 18, 32, .35));
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.985);
  transition: opacity var(--med) var(--ease),
              transform var(--med) var(--ease),
              visibility 0s linear var(--med);
}
.slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity var(--med) var(--ease),
              transform var(--med) var(--ease),
              visibility 0s;
}

.art {
  width: 120px;
  height: 120px;
  color: var(--cyan);
  filter: drop-shadow(0 6px 26px rgba(76, 198, 245, .22));
}
.art svg { width: 100%; height: 100%; }

.slide h2 {
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.slide p {
  max-width: 24rem;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.65;
  text-wrap: pretty;
}

.dots { display: flex; gap: var(--s2); }
.dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border-radius: var(--r-full);
  background: var(--surface-4);
  transition: width var(--med) var(--ease), background-color var(--med) var(--ease);
}
.dot:hover { background: var(--text-3); }
.dot.is-active { width: 22px; background: var(--brand); }

/* ------------------------------------------------------ room: two panes */

@media (min-width: 900px) {
  body.room { display: grid; place-items: center; padding: var(--s6); }

  .shell {
    /* place-items: center on the body sizes this to its content, so the
       width has to be asked for explicitly. */
    width: 100%;
    height: min(100dvh - 2 * var(--s6), 46rem);
    max-width: 68rem;
    display: grid;
    grid-template-columns: 19rem minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "side main"
      "side typing"
      "side composer";
    border: 1px solid var(--line-soft);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--sh-3);
  }

  /* `display: contents` on the phone, a real column here -- so the sidebar
     needs no separate markup and the mobile layout is untouched. */
  .side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    gap: var(--s5);
    padding: var(--s5);
    border-right: 1px solid var(--line-soft);
    background: rgba(15, 18, 32, .34);
    overflow-y: auto;
  }

  .topbar { padding: 0; padding-top: 0; }
  .identity h1 { font-size: 17px; }

  /* In a column the code has room to breathe, and the explanation is worth
     showing without a click. */
  .verify { border: 1px solid var(--line-soft); border-radius: var(--r-lg); }
  .verify > summary { padding: var(--s4) var(--s3); }
  .verify .chev { right: var(--s2); }
  .verify-body { padding: 0 var(--s4) var(--s4); font-size: 12.5px; }
  .sas-row span { width: 24px; height: 28px; font-size: 13.5px; }

  .side-fill { flex: 1; }

  .side-facts {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line-soft);
    padding-top: var(--s4);
  }
  .side-facts li {
    position: relative;
    padding-left: var(--s4);
    color: var(--text-3);
    font-size: 11.5px;
    line-height: 1.55;
    text-wrap: pretty;
  }
  .side-facts li + li { margin-top: var(--s3); }
  .side-facts li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 7px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--brand);
    opacity: .7;
  }

  .log     { grid-area: main; padding: var(--s6) var(--s7) var(--s5); }
  .typing  { grid-area: typing; margin-inline: var(--s7); }
  .composer{ grid-area: composer; padding: var(--s3) var(--s7) var(--s6); }

  #invitePanel, #endPanel { grid-area: main; }
  body[data-phase="waiting"] #invitePanel,
  body[data-phase="joining"] #invitePanel,
  body[data-phase="gone"]    #endPanel,
  body[data-phase="blocked"] #endPanel { display: flex; }

  /* Long lines are hard to read; a bubble that spans a 900px pane is a wall
     of text. Cap the measure rather than the percentage. */
  .bubble { max-width: min(68%, 34rem); }

  .modal { place-items: center; }
}

@media (min-width: 1240px) {
  .shell { grid-template-columns: 21rem minmax(0, 1fr); }
  .log { padding-inline: var(--s8); }
  .composer { padding-inline: var(--s8); }
  .typing { margin-inline: var(--s8); }
}
