/* ─────────────────────────────────────────────────────────────────────────
   Luhono signup — visual layer
   Brand: Mycroft Blue #22A7F0 / Navy #2C3E50 / Noto Sans / FOSS restraint.
   Dark, calm, premium. The orb's glow is the only color accent.

   Layout (spec §3): ONE coherent composition — orb + chat as the primary
   column. On desktop the active-widget panel docks BESIDE that column; on
   mobile it collapses to a bottom sheet. The password beat pops over the
   dimmed chat as a modal. No vertical stack of widgets between orb and chat.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --blue:      #22A7F0;
  --light-blue:#4DE0FF;
  --navy:      #2C3E50;
  --green:     #40DBB0;
  --grey1:     #F1F3F4;  /* text on dark */
  --grey2:     #BDC3C7;  /* muted */
  --grey3:     #6C7A89;  /* secondary */
  --red:       #D81159;

  /* Deep, calm background — darker than navy for the premium feel, navy as
     the mid-tone the orb glow sits against. */
  --bg-0: #0B141C;
  --bg-1: #11202C;
  --panel: rgba(20, 34, 46, 0.66);
  --panel-line: rgba(77, 224, 255, 0.14);

  --font: "Noto Sans", "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;

  /* ── ONE type scale (product owner, 2026-06-10: one font family + ONE deliberate size
     scale across the WHOLE page — orb area, greeting, bubbles, input, password,
     payment, everything). Four steps only; nothing off-scale. ── */
  --fs-xs: 13px;   /* hints, counters, secondary labels, fine print          */
  --fs-sm: 15px;   /* chat bubbles, secondary body                           */
  --fs-md: 17px;   /* PRIMARY body: greeting/oya line, inputs, buttons, beat */
                   /* labels, gate title — the dominant single size           */
  --fs-lg: 20px;   /* the one larger accent: redirect "waking" headline       */
  --lh: 1.55;      /* one body line-height                                    */

  /* The orb's natural design size; its container caps it at 25vw (brand rule:
     the orb NEVER exceeds 25% of the viewport width). */
  --orb-design: 300px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--grey1);
  background:
    radial-gradient(1200px 800px at 50% 38%, var(--bg-1) 0%, var(--bg-0) 60%, #060c11 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ── stage: holds the convo column + the docked side panel ─────────────────── */
.stage {
  position: relative;
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px;
}

/* ── conversation column: orb above, chat below ────────────────────────────── */
.convo {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 600px);
  max-height: 100%;
  min-height: 0;
}

/* ── orb ───────────────────────────────────────────────────────────────────
   BRAND RULE (product owner, 2026-06-10): the orb NEVER exceeds 25% of the viewport
   width, on desktop OR mobile. The cap is a max-width on the orb's container;
   the orb canvas fills it and the renderer's resize handler honors it. */
.orb-frame {
  /* 25vw is the brand width cap; 36vh keeps a long turn from being crushed
     under the orb on short landscape windows. */
  width: min(var(--orb-design), 25vw, 36vh);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  margin-bottom: 18px;
  pointer-events: none;
  transition: transform 600ms cubic-bezier(.2,.7,.2,1);
}
.orb {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* (No top bar / language switcher — the page is nothing but the orb and the
   chat box, product owner, 2026-06-10. Locale is auto-detected silently.) */

/* ── chat: history (scrolls) + current line + input, one panel ─────────────── */
.chat {
  position: relative;
  z-index: 4;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--panel-line);
  border-radius: 22px;
  box-shadow:
    0 24px 60px -24px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 22px 22px 18px;
  transition: opacity 400ms, transform 400ms, filter 300ms;
}
/* When the password modal is up, the chat dims behind it (spec §3 #5). */
.stage.modal-open .chat { filter: brightness(0.55) saturate(0.85); pointer-events: none; }

/* history scrollback — INVISIBLE scrollbar until the user actually scrolls
   (thin overlay style). Grows to fill, scrolls internally; latest at bottom. */
.history {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 38vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  /* Firefox: thin, auto-coloured (hidden when idle on overlay-capable UAs). */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 200ms;
}
.history:hover, .history:focus-within { scrollbar-color: rgba(108,122,137,0.5) transparent; }
/* WebKit/Blink: overlay-style thin bar, invisible until hover/scroll. */
.history::-webkit-scrollbar { width: 7px; }
.history::-webkit-scrollbar-track { background: transparent; }
.history::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.history:hover::-webkit-scrollbar-thumb,
.history.scrolling::-webkit-scrollbar-thumb { background: rgba(108,122,137,0.45); }
.history.empty { display: none; }
.history-turns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.turn { display: flex; }
.turn-user { justify-content: flex-end; }
.turn-oya { justify-content: flex-start; }
.bubble {
  max-width: 82%;
  font-size: var(--fs-sm);
  line-height: 1.5;
  padding: 11px 15px;
  border-radius: 18px;
  white-space: pre-wrap;
}
.turn-oya .bubble {
  background: rgba(0,0,0,0.20);
  border: 1px solid var(--panel-line);
  color: var(--grey1);
  border-bottom-left-radius: 6px;
}
.turn-user .bubble {
  background: var(--blue);
  color: #06121b;
  font-weight: 500;
  border-bottom-right-radius: 6px;
}

/* ── B3: echo chips (committed-field confirmations + correction surface) ─────
   Quiet, brand-consistent chips that confirm a field Oya gathered in
   conversation (Name, Email) landed server-side. Persistent but unobtrusive;
   one chip per field, latest value replaces the same-field chip. Mycroft-blue
   accent, Noto Sans, small. Sits just above Oya's current line. */
.echo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
  flex: 0 0 auto;
}
.echo-chips:empty { display: none; }
.echo-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  font-family: var(--font);
  font-size: var(--fs-xs);
  line-height: 1.3;
  color: var(--grey1);
  background: rgba(34, 167, 240, 0.12);     /* Mycroft-blue, low alpha */
  border: 1px solid rgba(34, 167, 240, 0.34);
  border-radius: 999px;
  padding: 4px 11px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 320ms ease, transform 320ms ease, background 200ms;
}
.echo-chip.landed { opacity: 1; transform: translateY(0); }
.echo-chip-label { color: var(--grey3); }
.echo-chip-value {
  font-weight: 600;
  color: var(--grey1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 24ch;
}
.echo-chip-tick { color: var(--blue); font-weight: 700; }

/* the current speaking line — the live, prominent turn.
   Hug short turns; cap long ones so the card does not become a full-viewport
   well. Input stays pinned. Typing lives outside this scroller. */
.speaking {
  margin-top: 14px;
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(40vh, 24rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 200ms;
}
.speaking:hover, .speaking:focus-within {
  scrollbar-color: rgba(108,122,137,0.5) transparent;
}
.speaking::-webkit-scrollbar { width: 7px; }
.speaking::-webkit-scrollbar-track { background: transparent; }
.speaking::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.speaking:hover::-webkit-scrollbar-thumb,
.speaking.scrolling::-webkit-scrollbar-thumb { background: rgba(108,122,137,0.45); }
.typing {
  display: none;
  gap: 6px;
  align-items: center;
  height: 14px;
  margin-top: 12px;
  margin-bottom: 0;
  flex: 0 0 auto;
}
.typing.on { display: flex; }
.typing.on + .speaking { margin-top: 8px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--light-blue);
  opacity: 0.5;
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%,80%,100%{opacity:.25;transform:translateY(0)} 40%{opacity:.9;transform:translateY(-2px)} }

.oya-line {
  /* V2 (product owner, 2026-06-10): Oya's current line is the dominant text. Stepped
     up one size from the body --fs-md to --fs-lg (20px, brand-compliant Noto
     Sans, well above the 16px desktop-body floor). `white-space: pre-line`
     renders paragraph breaks in her text as real paragraphs (the daemon sends
     "\n\n" between paragraphs) instead of a run-on block. */
  font-family: var(--font);
  font-size: var(--fs-lg);
  line-height: 1.6;
  font-weight: 400;
  color: var(--grey1);
  min-height: 30px;
  white-space: pre-line;
  overflow-wrap: break-word;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 480ms ease, transform 480ms ease;
}
.oya-line.show { opacity: 1; transform: translateY(0); }
.waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 180px;
  text-align: center;
}
.waiting[hidden] { display: none; }
.waiting-mark {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  color: #fff;
}
.waiting-text {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

/* ── input row (auto-grows; never shows a chrome scrollbar) ────────────────── */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex: 0 0 auto;
}
.input-row.hidden { display: none; }
.text-input {
  flex: 1;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--grey1);
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 12px 14px;
  resize: none;
  outline: none;
  max-height: 132px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: border-color 180ms, background 180ms;
}
.text-input::-webkit-scrollbar { width: 6px; }
.text-input::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
.text-input:hover::-webkit-scrollbar-thumb { background: rgba(108,122,137,0.4); }
.text-input::placeholder { color: var(--grey3); }
.text-input:focus { border-color: rgba(34,167,240,0.6); background: rgba(0,0,0,0.30); }
.send-btn {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 14px;
  border: none;
  background: var(--blue);
  color: #06121b;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: filter 160ms, transform 120ms;
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:active { transform: scale(0.95); }

/* Quiet character counter — hidden under ~85% of the limit, fades in near it,
   turns warning-red when at the cap. No nagging UI when the customer is well
   under the limit. */
.char-counter {
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: var(--grey3);
  text-align: right;
  margin: 6px 2px 0;
  min-height: 16px;
  flex: 0 0 auto;
  transition: color 200ms;
}
.char-counter[hidden] { display: none; }
.char-counter.at-limit { color: var(--red); }

/* ── invite gate ────────────────────────────────────────────────────────────
   Same calm dark panel language as the chat; shown until a valid code binds.
   Sits inside the convo column, in place of the chat. */
/* ZERO-text gate: ONLY the 8 boxes + the orb + a wordless icon button. No
   card, no panel, no title/hint/labels — the boxes float beneath the orb. */
.gate {
  position: relative;
  z-index: 5;
  width: 100%;
  display: flex;
  justify-content: center;
  background: none;
  border: none;
  box-shadow: none;
  padding: 8px 0 0;
  animation: beatIn 460ms cubic-bezier(.2,.7,.2,1);
}
.gate[hidden] { display: none; }
.gate-form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
/* The 8 single-char boxes. */
.gate-boxes {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.gate-box {
  width: 42px;
  height: 52px;
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: 600;
  text-transform: uppercase;
  text-align: center;
  color: var(--grey1);
  caret-color: var(--blue);
  /* The resting box must read clearly as a distinct input field on the dark
     background — the previous 14%-opacity panel-line border was invisible to a
     human eye (the boxes existed in the DOM but couldn't be seen). A solid
     2px Mycroft-blue-tinted border + lifted fill + soft glow makes all 8 boxes
     legible at rest; focus deepens the same accent.
     S2 fix (2026-06-10): the 7 UNFOCUSED boxes read dimmer than the focused
     one. Raise the resting contrast — full-opacity bright-blue border + a soft
     outer glow ring + a lighter fill — so all 8 boxes are clearly visible to a
     human eye at rest. Focus still deepens the accent (solid Mycroft-blue +
     wider glow) so the active box stays distinguished. */
  background: rgba(18, 40, 56, 0.92);
  border: 2px solid rgba(77, 224, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(77, 224, 255, 0.30),
              0 2px 12px -4px rgba(0,0,0,0.65),
              inset 0 1px 0 rgba(255,255,255,0.06);
  outline: none;
  transition: border-color 160ms, background 160ms, box-shadow 160ms;
}
.gate-box:focus {
  border-color: var(--blue);
  background: rgba(18, 40, 56, 0.98);
  box-shadow: 0 0 0 3px rgba(34,167,240,0.45),
              0 2px 14px -4px rgba(0,0,0,0.72);
}
/* Wordless send button — icon glyph only, appears when all 8 are filled. */
.gate-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  color: #06121b;
  background: var(--blue);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 0;
  transition: filter 160ms, opacity 200ms, transform 120ms;
  animation: beatIn 240ms cubic-bezier(.2,.7,.2,1);
}
.gate-submit[hidden] { display: none; }
.gate-submit-glyph { display: block; }
.gate-submit:hover:not(:disabled) { filter: brightness(1.08); }
.gate-submit:active:not(:disabled) { transform: scale(0.97); }
.gate-submit:disabled { opacity: 0.5; cursor: not-allowed; }
/* Wordless invalid feedback: shake + red tint on the boxes. */
.gate-boxes.invalid .gate-box {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(231,76,60,0.22);
}
.gate-boxes.invalid { animation: gateShake 380ms cubic-bezier(.36,.07,.19,.97); }
@keyframes gateShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
/* While the gate is up, the chat (conversation) stays hidden. */
.stage.gated .chat { display: none; }

/* ── active-widget side panel (desktop) / bottom sheet (mobile) ────────────── */
.side-panel {
  position: relative;
  z-index: 5;
  /* V4 (product owner, 2026-06-10): the active-widget panel (e.g. the color box) is the
     SAME SIZE as the convo/chat column it sits beside on desktop, so the text
     area and the color box read as an even, balanced pair — not a wide card and
     a narrow one. (On mobile it becomes a bottom sheet — see the media query.) */
  width: min(44vw, 480px);
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(108,122,137,0.4) transparent;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--panel-line);
  border-radius: 22px;
  box-shadow:
    0 24px 60px -24px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 24px 22px 20px;
  animation: panelIn 460ms cubic-bezier(.2,.7,.2,1);
}
.side-panel[hidden] { display: none; }
@keyframes panelIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }
.panel-host > .beat { border-top: none; padding-top: 0; }

/* ── password pop-over modal (spec §3 #5) ──────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 9, 13, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 240ms ease;
}
.modal-backdrop[hidden] { display: none; }
.password-modal {
  position: fixed;
  z-index: 21;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  max-height: 88dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(108,122,137,0.4) transparent;
  background: var(--bg-1);
  border: 1px solid var(--panel-line);
  border-radius: 22px;
  box-shadow:
    0 40px 90px -28px rgba(0,0,0,0.85),
    inset 0 1px 0 rgba(255,255,255,0.05);
  padding: 28px 26px 22px;
  animation: modalIn 360ms cubic-bezier(.2,.7,.2,1);
}
.password-modal[hidden] { display: none; }
.password-username {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.modal-host > .beat { border-top: none; padding-top: 0; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ── beat widgets (shared chrome — one font family + sizing across all) ─────── */
.beat {
  animation: beatIn 420ms cubic-bezier(.2,.7,.2,1);
}
@keyframes beatIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
/* P3 LATE-FLOW FONT NORMALIZATION (2026-06-10): the product owner — the late stages
   (payment / finalize / redirect) rendered text at TWO sizes and "really small."
   The beat label is the step's heading; the beat hint is its body. Normalize them
   to the established CONVERSATION scale (Noto Sans via --font everywhere; heading
   at --fs-lg 20px to match the oya-line, body at --fs-md 17px — well above the
   old --fs-xs 13px) so every late-flow surface reads at one coherent hierarchy. */
.beat-label {
  font-family: var(--font);
  font-size: var(--fs-lg);
  line-height: 1.5;
  font-weight: 600;
  color: var(--grey1);
  margin-bottom: 6px;
}
.beat-hint {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--grey2);
  margin-bottom: 16px;
}
.beat-error {
  color: var(--red);
  font-size: var(--fs-xs);
  font-weight: 500;
  min-height: 18px;
  margin: 4px 0 2px;
}
.beat-submit {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: 600;
  color: #06121b;
  background: var(--blue);
  border: none;
  border-radius: 14px;
  padding: 13px;
  margin-top: 14px;
  cursor: pointer;
  transition: filter 160ms, opacity 160ms, transform 120ms, background 280ms;
}
.beat-submit:hover:not(:disabled) { filter: brightness(1.08); }
.beat-submit:active:not(:disabled) { transform: scale(0.99); }
.beat-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* password */
.field { position: relative; margin-bottom: 10px; }
.field input {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--grey1);
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 12px 56px 12px 14px;
  outline: none;
  transition: border-color 160ms;
}
.field input:focus { border-color: rgba(34,167,240,0.6); }
.reveal {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font); font-size: var(--fs-xs); font-weight: 600;
  color: var(--grey3); background: transparent; border: none; cursor: pointer;
  padding: 6px 8px;
}
.reveal:hover { color: var(--light-blue); }
.strength { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.07); overflow: hidden; margin: 4px 2px 4px; }
.strength-bar { height: 100%; width: 0%; border-radius: 3px; transition: width 280ms, background 280ms; }
.strength-bar.s0 { width: 8%;  background: var(--red); }
.strength-bar.s1 { width: 30%; background: var(--red); }
.strength-bar.s2 { width: 55%; background: #FD9E66; }
.strength-bar.s3 { width: 78%; background: var(--green); }
.strength-bar.s4 { width: 100%; background: var(--green); }
.strength-label { font-size: var(--fs-xs); color: var(--grey3); margin: 0 2px 6px; min-height: 14px; }

/* P2 PASSWORD GRAVITY (2026-06-10) — the no-recovery acknowledgment checkbox.
   Brand-quiet: Noto Sans, Mycroft-blue accent on the box, calm body text. The
   customer must tick this before the password can be committed. */
.password-ack {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 6px 2px 4px;
  cursor: pointer;
  user-select: none;
}
.password-ack input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  margin-top: 2px;
  accent-color: var(--blue);   /* Mycroft Blue tick */
  cursor: pointer;
}
.password-ack-text {
  font-family: var(--font);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--grey2);
}

/* P2 KEEPSAKE — the "Continue" affordance shown beside/after the print button. */
.keepsake-continue {
  width: 100%;
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--grey2);
  background: transparent;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 10px;
  margin-top: 10px;
  cursor: pointer;
  transition: border-color 160ms, color 160ms;
}
.keepsake-continue:hover { color: var(--grey1); border-color: rgba(34,167,240,0.5); }

/* P2 KEEPSAKE CARD — a clean brand-styled printable card. Off-screen in normal
   flow (it only matters in the print dialog); the @media print block below makes
   it the sole printed surface. NOTE: rendered client-side only; the password
   plaintext lives here only between print-build and afterprint cleanup. */
.keepsake-host {
  position: fixed;
  left: -10000px; top: 0;          /* off-screen on the live page */
  width: 0; height: 0; overflow: hidden;
}
.keepsake-card {
  width: 520px;
  box-sizing: border-box;
  padding: 36px 40px;
  background: #ffffff;
  color: #2C3E50;                  /* brand Navy ink on white for print */
  border: 1px solid #d7dde3;
  border-radius: 16px;
  font-family: var(--font);
  text-align: center;
  border-top: 8px solid #22A7F0;
}
.keepsake-brand {
  margin: 0 auto 22px;
}
.keepsake-logo {
  display: block;
  width: 172px;
  height: auto;
  margin: 0 auto;
}
.keepsake-title {
  font-size: 22px; font-weight: 700; color: #2C3E50; margin-bottom: 22px;
}
.keepsake-pw-block {
  background: #f4f8fb;
  border: 1px solid #cfe6f7;
  border-radius: 12px;
  padding: 16px 14px;
  margin-bottom: 20px;
}
.keepsake-field-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: #6b7b8a; margin-bottom: 8px;
}
.keepsake-pw {
  font-family: "Courier New", "DejaVu Sans Mono", monospace;
  font-size: 26px; font-weight: 700;
  color: #16222c;
  word-break: break-all;
  line-height: 1.3;
}
.keepsake-meta { text-align: left; margin-bottom: 20px; }
.keepsake-meta-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 0; border-bottom: 1px solid #eef2f5;
  font-size: 14px;
}
.keepsake-meta-label { color: #6b7b8a; font-weight: 600; }
.keepsake-meta-value { color: #2C3E50; text-align: right; word-break: break-word; }
.keepsake-warning {
  font-size: 14px; font-weight: 700; color: #b00020;
  background: #fff3f4; border: 1px solid #f3c6cc;
  border-radius: 10px; padding: 12px; line-height: 1.45;
}
.keepsake-footer {
  margin-top: 20px;
  color: #6b7b8a;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* When printing, the keepsake card is the ONLY thing on the page. */
@media print {
  @page { margin: 14mm; }
  body * { visibility: hidden !important; }
  .keepsake-host, .keepsake-host * { visibility: visible !important; }
  .keepsake-host {
    position: absolute !important; left: 0 !important; top: 0 !important;
    width: auto !important; height: auto !important; overflow: visible !important;
    display: flex; justify-content: center; padding: 24px;
  }
  .keepsake-card { box-shadow: none; }
}

/* color */
.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.swatch {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--sw);
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 6px 18px -8px var(--sw);
  transition: transform 160ms, box-shadow 200ms, border-color 200ms;
}
.swatch:hover { transform: translateY(-2px) scale(1.04); }
.swatch.sel {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.18), 0 8px 22px -6px var(--sw);
}
.custom-pick { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.custom-pick input[type="color"] {
  width: 42px; height: 42px; border: none; border-radius: 12px; background: transparent; cursor: pointer; padding: 0;
}
.custom-pick input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.custom-pick input[type="color"]::-webkit-color-swatch { border: 1px solid var(--panel-line); border-radius: 10px; }
.custom-label { font-size: var(--fs-xs); color: var(--grey3); }
/* V4: the color-name label was rendering with its top clipped (tight line box +
   no padding). Give it a full line box + a little vertical room so the word is
   never half-cut. */
.color-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--grey1);
  line-height: 1.5;
  padding: 2px 0;
  margin: 8px 2px 0;
  overflow: visible;
}

/* V4 LOCKED state: after the customer commits a color, the picker is visibly
   committed — dimmed/disabled controls, a calm "locked" affordance — and is no
   longer re-editable. */
.beat-color.locked .swatches,
.beat-color.locked .custom-pick { opacity: 0.55; pointer-events: none; }
.beat-color.locked .swatch:not(.sel) { filter: grayscale(0.35); }
.beat-color.locked .beat-submit { opacity: 0.9; cursor: default; }
.beat-color.locked .color-name::after {
  content: " ✓";
  color: var(--green);
  font-weight: 700;
}

/* payment */
.stripe-mount { margin-bottom: 8px; }

/* V5: clear "Loading payment page…" message while the Stripe element loads. A
   small spinner + readable text — shown until the element (or mock card) mounts,
   then removed (.done collapses it). */
.payment-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 4px;
  color: var(--grey2);
}
.payment-loading.done { display: none; }
.payment-loading-spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(77,224,255,0.25);
  border-top-color: var(--light-blue);
  border-radius: 50%;
  animation: paymentSpin 0.9s linear infinite;
  flex: 0 0 auto;
}
@keyframes paymentSpin { to { transform: rotate(360deg); } }
/* P3: payment loading + status text at the body scale (was --fs-sm 15px). */
.payment-loading-text { font-family: var(--font); font-size: var(--fs-md); color: var(--grey2); }

/* V6: guarded chat input (while the payment widget is active). Dimmed + a
   not-allowed cursor so it's clearly inert; the hint text in the placeholder
   tells the customer to finish/close payment first. */
.input-row.guarded .text-input {
  opacity: 0.55;
  cursor: not-allowed;
}
.input-row.guarded .send-btn {
  opacity: 0.45;
  pointer-events: none;
}
.mock-card {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 16px;
}
.mock-card-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.mc-brand { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grey3); }
.mc-amt { font-size: var(--fs-md); font-weight: 700; color: var(--grey1); }
.mc-input {
  width: 100%;
  font-family: var(--font); font-size: var(--fs-sm);
  color: var(--grey1);
  background: rgba(0,0,0,0.20);
  border: 1px solid var(--panel-line);
  border-radius: 10px; padding: 11px 12px; margin-bottom: 10px; outline: none;
}
.mc-input:focus { border-color: rgba(34,167,240,0.6); }
.mc-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mc-2col .mc-input { margin-bottom: 0; }
/* P3: the test-mode note reads at the secondary body scale (was --fs-xs 13px). */
.mock-note { font-family: var(--font); font-size: var(--fs-sm); color: var(--grey3); margin-top: 10px; }

/* redirect */
.beat-redirect { position: relative; text-align: center; overflow: hidden; }
.beat-redirect .beat-label { font-size: var(--fs-lg); margin-top: 6px; }
.redirect-glow {
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(64,219,176,0.35), transparent 70%);
  filter: blur(20px);
  animation: bloom 2.6s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes bloom { from { opacity: 0.4; transform: translateX(-50%) scale(0.9); } to { opacity: 0.9; transform: translateX(-50%) scale(1.15); } }
.redirect-link {
  display: inline-block;
  font-family: var(--font);
  font-size: var(--fs-md); font-weight: 600;
  color: var(--light-blue);
  text-decoration: none;
  margin-top: 16px;
  border-bottom: 1px solid rgba(77,224,255,0.3);
  padding-bottom: 2px;
}
.redirect-link:hover { color: #fff; }
/* P3: the redirect sub-line reads at the secondary body scale (was --fs-xs 13px). */
.redirect-sub { font-family: var(--font); font-size: var(--fs-sm); color: var(--grey3); margin-top: 12px; }

/* queue (graceful "you're in line" screen) */
.beat-queue { position: relative; text-align: center; }
.queue-position {
  font-size: var(--fs-md); font-weight: 600; color: var(--light-blue);
  margin-top: 18px;
}
.queue-eta { font-size: var(--fs-xs); color: var(--grey3); margin-top: 8px; }

/* ── responsive ─────────────────────────────────────────────────────────────
   Desktop (≥900px): convo column + side panel sit side by side (default flex
   row). Below 900px: stack — the side panel becomes a bottom sheet overlay. */
@media (max-width: 900px) {
  .stage {
    flex-direction: column;
    gap: 0;
    justify-content: center;
  }
  .convo { width: min(94vw, 560px); }

  /* Side panel → bottom sheet overlay anchored to the screen bottom. */
  .side-panel {
    position: fixed;
    z-index: 18;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 82dvh;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -24px 60px -24px rgba(0,0,0,0.7);
    animation: sheetIn 420ms cubic-bezier(.2,.7,.2,1);
    padding: 22px 18px calc(20px + env(safe-area-inset-bottom));
  }
  @keyframes sheetIn { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }
}

@media (max-width: 520px) {
  .stage { padding: 16px; }
  .chat { padding: 18px 16px 14px; border-radius: 18px; }
  .history { max-height: 32vh; }
}

@media (max-height: 680px) {
  .orb-frame { margin-bottom: 10px; }
  .history { max-height: 28vh; }
}
