/* visavi — tokens, themes, messenger layout */

/* ============ vendored webfont: Architects Daughter (SIL OFL, public/fonts) ============ */

@font-face {
  font-family: 'Architects Daughter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/architects-daughter-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: 'Architects Daughter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/architects-daughter-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;
}

/* ============ theme tokens ============ */

:root, [data-theme="pink"] {
  color-scheme: light;
  --bg: #ffdcec;
  --bg-2: #ffc9e0;
  --surface: #ffffffe6;
  --surface-2: #ffd0e4b3;
  --text: #4a1027;
  --text-muted: #6f4159;
  --accent: #d1157a;
  --accent-2: #f0479b;
  --on-accent: #ffffff;
  --bubble-in: #ffffff;
  --bubble-out: #f8bcd8;
  --text-out: #40091f;
  --border: #eba6c9;
  --focus: #7a1140;
  --danger: #b3123f;
  --success: #1c7a4b;
  --sheen: linear-gradient(110deg, transparent 30%, #ffffff8c 48%, transparent 66%);
  --glow: 0 8px 32px #e0218a4d;
  --radius: 18px;
  --shadow: 0 2px 10px #4a10271f;
  --font-display: "Avenir Next", "Segoe UI Variable", ui-rounded, system-ui, sans-serif;
}

[data-theme="steel"] {
  color-scheme: dark;
  --bg: #0f1723;
  --bg-2: #141e2e;
  --surface: #1a2638;
  --surface-2: #213048;
  --text: #e6edf6;
  --text-muted: #93a5bc;
  --accent: #5b9dd9;
  --accent-2: #7fb4e8;
  --on-accent: #0b1220;
  --bubble-in: #1a2638;
  --bubble-out: #2c4a6e;
  --text-out: #eaf3fb;
  --border: #2b3c55;
  --focus: #9ecbf0;
  --danger: #f87171;
  --success: #4ade80;
  --sheen: linear-gradient(110deg, transparent 40%, #ffffff14 50%, transparent 60%);
  --glow: 0 8px 24px #00000059;
  --radius: 8px;
  --shadow: 0 2px 8px #00000040;
  --font-display: "Segoe UI", system-ui, sans-serif;
}

[data-theme="rainbow"] {
  color-scheme: dark;
  --bg: #1e1e2e;
  --bg-2: #26263a;
  --surface: #2e2e42;
  --surface-2: #38384f;
  --text: #f6f4ff;
  --text-muted: #b9b6d6;
  --accent: #f0abfc;
  --accent-2: #fbcfe8;
  --on-accent: #25143f;
  --bubble-in: #2e2e42;
  --bubble-out: #4a3b73;
  --text-out: #f7f0ff;
  --border: #44445e;
  --focus: #fef08a;
  --danger: #fb7185;
  --success: #86efac;
  --sheen: linear-gradient(110deg, #ff595e33, #ffde3433, #32cd3233, #00b9fb33, #5865f233, #b663ff33);
  --glow: 0 8px 30px #b663ff40;
  --radius: 16px;
  --shadow: 0 2px 10px #0000004d;
  --font-display: system-ui, sans-serif;
}

[data-theme="smoky"] {
  color-scheme: dark;
  --bg: #1a1a1f;
  --bg-2: #202027;
  --surface: #26262e;
  --surface-2: #2e2e38;
  --text: #d8d5cf;
  --text-muted: #9b978f;
  --accent: #8296ae;
  --accent-2: #64788f;
  --on-accent: #14181d;
  --bubble-in: #26262e;
  --bubble-out: #343b46;
  --text-out: #dfe4ea;
  --border: #3a3a44;
  --focus: #b7c6d9;
  --danger: #cd7c7c;
  --success: #7fae8e;
  --sheen: none;
  --glow: none;
  --radius: 10px;
  --shadow: 0 1px 4px #00000033;
  --font-display: "Architects Daughter", "Segoe Print", "Bradley Hand", cursive;
}

[data-theme="fun"] {
  color-scheme: light;
  --bg: #fff1f7;
  --bg-2: #ffe3ef;
  --surface: #ffffffe6;
  --surface-2: #fff3b0;
  --text: #4a1d63;
  --text-muted: #7a5c9e;
  --accent: #ff2d87;
  --accent-2: #b78cff;
  --on-accent: #3c0a26;
  --bubble-in: #ffffff;
  --bubble-out: #c1f0d0;
  --text-out: #14432a;
  --border: #e0aaff;
  --focus: #5b21b6;
  --danger: #d81e5b;
  --success: #16a34a;
  --sheen: linear-gradient(110deg, transparent 35%, #ffffff99 50%, transparent 65%);
  --glow: 0 10px 26px #ff2d8740;
  --radius: 24px;
  --shadow: 0 4px 14px #4a1d631a;
  --font-display: ui-rounded, "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
}

[data-theme="gold"] {
  color-scheme: light;
  --bg: #faf3e3;
  --bg-2: #f3e6c9;
  --surface: #fffdf7;
  --surface-2: #f7ecd4;
  --text: #4a3417;
  --text-muted: #85662f;
  --accent: #d9a520;
  --accent-2: #b8860b;
  --on-accent: #3d2a08;
  --bubble-in: #fffdf7;
  --bubble-out: #f0dcae;
  --text-out: #3d2a08;
  --border: #e3cfa0;
  --focus: #7a4f12;
  --danger: #a33a1f;
  --success: #4a7a2e;
  --sheen: linear-gradient(110deg, transparent 30%, #fff8e7a6 48%, transparent 66%);
  --glow: 0 8px 26px #d9a52040;
  --radius: 12px;
  --shadow: 0 2px 10px #4a341714;
  --font-display: Georgia, "Palatino Linotype", "Book Antiqua", serif;
}

[data-theme="forest"] {
  color-scheme: dark;
  --bg: #0f1a12;
  --bg-2: #15231a;
  --surface: #1c2d21;
  --surface-2: #24382a;
  --text: #e8f0e4;
  --text-muted: #9fb89f;
  --accent: #86c98a;
  --accent-2: #5aa862;
  --on-accent: #10260f;
  --bubble-in: #1c2d21;
  --bubble-out: #2e4a33;
  --text-out: #eef7e6;
  --border: #3a5440;
  --focus: #b7e3a5;
  --danger: #e07856;
  --success: #7fc97f;
  --sheen: linear-gradient(110deg, transparent 35%, #ffffff1a 50%, transparent 65%);
  --glow: 0 8px 26px #2e6b3f59;
  --radius: 14px;
  --shadow: 0 2px 10px #00000059;
  --font-display: system-ui, sans-serif;
}

/* rainbow accent rings (decorative only — text never sits on gradient) */
[data-theme="rainbow"] .ring-progress,
[data-theme="rainbow"] .avatar.user { border-color: transparent; }
[data-theme="rainbow"] .mic-btn { background:
  linear-gradient(var(--bg), var(--bg)) padding-box,
  linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e) border-box;
  border: 3px solid transparent; color: var(--text); }

/* ============ unified login mask ============ */

.mask-card { position: relative; display: flex; flex-direction: column; gap: .9rem; }
.mask-card .invite-form { margin-top: .5rem; }

/* ============ big-record hero (empty conversation) ============ */

.hero {
  margin: auto; display: flex; flex-direction: column; align-items: center;
  gap: .6rem; padding: 2rem 1rem; text-align: center;
}
.mic-wrap.hero-wrap { width: 104px; height: 104px; }
.mic-btn.hero-btn { width: 104px; height: 104px; }
.mic-btn.hero-btn .icon { width: 44px; height: 44px; }

/* ============ QR scanner ============ */

.scan-wrap { position: relative; width: min(80vw, 60vh, 360px); aspect-ratio: 1; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 12%; border: 3px solid #ffffffcc; border-radius: 16px;
  box-shadow: 0 0 0 9999px #00000066; pointer-events: none;
}

/* ============ message tags & notes (admin) ============ */

/* gap >=12px so the 44px ::after rings of the 32px tag-btns never overlap */
.tag-row { display: flex; gap: .75rem; padding: .1rem .35rem 0; align-items: center; }
.msg.out .tag-row { justify-content: flex-end; }
.tag-btn {
  background: transparent; border: none; color: var(--text-muted);
  padding: .2rem; border-radius: 8px; display: grid; place-items: center;
  position: relative;
}
.tag-btn .icon { width: 17px; height: 17px; }
@media (hover: hover) { .tag-btn:hover { background: var(--surface-2); } }
.tag-btn.on { color: var(--accent); }
.tag-btn.on.solid .icon { fill: currentColor; }
.tag-btn.on:not(.solid) { color: var(--accent); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--accent); }
.msg-note { font-size: .78rem; color: var(--text-muted); font-style: italic; padding: .1rem .4rem; white-space: pre-wrap; }

textarea { resize: vertical; min-height: 5rem; width: 100%; }

/* ============ base ============ */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-display);
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-2), var(--bg));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, a, select, [role="button"] { touch-action: manipulation; }
input, textarea, select { font-size: max(1rem, 16px); } /* prevent iOS focus-zoom */
button, .icon-btn, .swatch, .tag-btn, .play-btn { min-width: 44px; min-height: 44px; }
.icon-btn { min-width: 40px; min-height: 40px; }
/* small visuals keep their designed size; the pseudo-element restores the
   44px touch target without changing layout */
.icon-btn, .id-trigger { position: relative; }
.icon-btn::after, .tag-btn::after, .small-btn::after, .id-trigger::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
}
button:active:not(:disabled) { transform: scale(.97); filter: brightness(.96); }
h1, h2, h3 { font-weight: 600; letter-spacing: .01em; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
  padding: .6rem .8rem;
}
label { color: var(--text-muted); font-size: .85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.muted { color: var(--text-muted); }
.small { font-size: .8rem; }
.error-text { color: var(--danger); }
.flex1 { flex: 1; }
.w100 { width: 100%; }
.mt1 { margin-top: 1rem; }
.dur-label { min-width: 4rem; text-align: right; }
.chat-full { height: 100vh; height: 100dvh; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--accent); color: var(--on-accent);
  border: none; border-radius: calc(var(--radius) / 2);
  padding: .65rem 1.2rem; font-weight: 600;
  box-shadow: var(--glow);
  position: relative; overflow: hidden;
}
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .sheen { position: absolute; inset: 0; background: var(--sheen); transform: translateX(-100%); animation: sheen 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes sheen { 50%, 100% { transform: translateX(100%); } }

.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }

/* ============ landing ============ */

.landing {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem;
  padding: calc(1rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
}
.landing .card { max-width: 30rem; width: 100%; text-align: center; }
/* the "or" between the QR buttons and the paste field. It is a plain block in a
   plain section — no flex gap reaches it — so its own margin is the only
   clearance there is, and it has to be generous to read as a divider. */
.or-sep { font-size: 1.05rem; margin: .85rem 0; }
.landing-hero {
  display: block; width: 100%; height: auto; margin: 0 auto; max-width: 24rem;
  aspect-ratio: 511 / 440.8; object-fit: cover; object-position: top;
}

/* invite landing: generated identity preview + rich description */
.landing-id { display: grid; justify-items: center; gap: .45rem; }
.landing-avatar-wrap { position: relative; display: inline-block; }
.avatar.landing-avatar { width: 84px; height: 84px; }
#shuffle-avatar-btn { position: absolute; right: -10px; bottom: -4px; }
.landing-name-row { display: flex; align-items: center; justify-content: center; gap: .35rem; min-width: 0; max-width: 100%; }
.landing-hello { margin: 0; font-size: 1.35rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.landing-id .landing-shuffle {
  width: 34px; height: 34px; min-width: 0; min-height: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-muted); box-shadow: var(--shadow);
}
.landing-id .landing-shuffle .icon { width: 18px; height: 18px; }
#shuffle-btn .icon { width: 18px; height: 18px; }
#invite-box .help-btn {
  position: absolute; top: .4rem; right: .4rem; margin: 0; padding: 0;
  width: 52px; height: 52px; min-width: 0; min-height: 0;
  display: grid; place-items: center; color: var(--text-muted);
}
#invite-box .help-btn .icon { width: 40px; height: 40px; }
.rich-desc { text-align: left; white-space: normal; }
.rich-desc ul { margin: .35rem 0 .35rem 1.15rem; padding: 0; list-style: disc; }
.rich-desc li { margin: .15rem 0; }
.rich-desc strong { font-weight: 700; }
.btn.cta { padding: .85rem 1.2rem; font-size: 1.08rem; }

/* ============ chat (messenger) ============ */

.chat-app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; margin: 0 auto; }
.chat-header {
  display: flex; align-items: center; gap: .75rem;
  padding: calc(.6rem + env(safe-area-inset-top)) max(.9rem, env(safe-area-inset-right)) .6rem max(.9rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-header .who { flex: 1; min-width: 0; }
.chat-header .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .tools { display: flex; gap: .35rem; }
/* clear visual break so the conversation play control never reads as part of
   the identity trigger pill */
.tools .tool-sep { flex: none; width: 1px; height: 26px; align-self: center; margin: 0 .3rem; background: var(--border); }
.icon-btn {
  background: transparent; border: 1px solid transparent; border-radius: 50%;
  color: var(--text); padding: .45rem; display: grid; place-items: center;
}
/* the glyph is a grid item already, but block display rules out any
   inline-box/vertical-align quirk so it sits dead-center in the hover circle */
.icon-btn .icon { display: block; }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); border-color: var(--border); } }
.icon-btn:disabled { opacity: .5; cursor: default; }
@media (hover: hover) { .icon-btn:disabled:hover { background: transparent; border-color: transparent; } }

/* conversation transport bar, pinned under the chat header */
.conv-bar {
  display: flex; align-items: center; gap: .2rem; flex: none;
  padding: .1rem max(.9rem, env(safe-area-inset-right)) .25rem max(.9rem, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.conv-bar .icon-btn { min-width: 44px; min-height: 44px; padding: .3rem; }
.conv-bar .icon-btn .icon { width: 18px; height: 18px; }
.conv-bar .conv-pos { margin-left: .5rem; font-size: .78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.msg-list {
  flex: 1; overflow-y: auto; padding: 1rem .9rem 0;
  display: flex; flex-direction: column; gap: .9rem;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: .55rem; align-items: flex-start; max-width: 88%; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--surface-2); border: 2px solid var(--border);
  display: grid; place-items: center; color: var(--text-muted);
}
.avatar .icon { width: 20px; height: 20px; }
.avatar.user { background: linear-gradient(135deg, var(--bg-2), var(--surface-2)); }
.msg .avatar { width: 44px; height: 44px; }
.msg .avatar .icon { width: 26px; height: 26px; }
.bubble-wrap { min-width: 0; }
.meta-row { display: flex; gap: .45rem; align-items: baseline; padding: 0 .4rem .15rem; font-size: .72rem; color: var(--text-muted); }
.msg.out .meta-row { justify-content: flex-end; }
.meta-row .name { font-weight: 700; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble {
  background: var(--bubble-in);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .7rem;
  box-shadow: var(--shadow);
  position: relative;
}
.msg.out .bubble { background: var(--bubble-out); color: var(--text-out); }
.msg.out .meta-row .name { color: var(--text); }
.read-ticks { color: var(--text-muted); }
.read-ticks.read { color: var(--success); }

/* voice bubble */
.voice { display: flex; align-items: center; gap: .6rem; min-width: min(13rem, 100%); }
.play-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--on-accent); border: none;
  display: grid; place-items: center;
}
.play-btn .icon { width: 20px; height: 20px; }
.wave { flex: 1; height: 34px; display: block; min-width: 0; }
.wave.wave-open { cursor: pointer; }
.dur { font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--text-muted); min-width: 3.2rem; text-align: right; white-space: nowrap; }

/* composer */
.composer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: .8rem max(.8rem, env(safe-area-inset-left)) calc(.8rem + env(safe-area-inset-bottom)) max(.8rem, env(safe-area-inset-right));
  display: flex; align-items: center; gap: .8rem; min-height: 88px;
}
.mic-wrap { position: relative; width: 64px; height: 64px; flex: none; }
.mic-btn {
  width: 64px; height: 64px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent); display: grid; place-items: center;
  box-shadow: var(--glow);
}
.mic-btn .icon { width: 28px; height: 28px; }
.ring-progress { position: absolute; inset: -4px; pointer-events: none; }
.ring-progress circle { fill: none; stroke-width: 4; }
.ring-track { stroke: var(--surface-2); }
.ring-bar { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke .3s; }
.ring-bar.warn { stroke: var(--danger); }
.composer .hint { color: var(--text-muted); font-size: .85rem; flex: 1; }
.preview { display: flex; align-items: center; gap: .6rem; row-gap: .5rem; flex-wrap: wrap; flex: 1; min-width: 0; }
/* icon-only mask toggle in the preview action row; pressed = accent (rides the
   .icon-btn base, the id selector outranks the plain :hover rule) */
#fx-mask[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: var(--on-accent); }
/* icon-only discard/send in both panes (same .icon-btn base as #fx-mask);
   send is a filled primary circle — the id selector outranks .icon-btn:hover
   so the accent fill survives hover, and the accent/on-accent pair is
   token-tested for contrast; :disabled keeps the base opacity handling */
#send-btn, #send-btn-a { background: var(--accent); border-color: transparent; color: var(--on-accent); }

/* ============ modals / panels ============ */

dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 1.4rem; padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  max-width: 34rem; width: calc(100vw - 2rem);
  width: calc(100vw - 2rem - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem);
  /* --kb is the keyboard-covered height while a modal input is focused (chrome.js); 0 otherwise */
  max-height: calc(100vh - 2rem - var(--kb, 0px)); max-height: calc(100dvh - 2rem - var(--kb, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  box-shadow: 0 20px 60px #00000040;
}
dialog::backdrop { background: #00000066; backdrop-filter: blur(3px); }
.qr-box { display: grid; place-items: center; gap: .8rem; }
.qr-box svg:not(.icon), .qr-box canvas { background: #fff; padding: 10px; border-radius: 12px; }
.qr-box svg:not(.icon) { width: min(72vw, 260px); height: auto; }
code.join {
  display: block; word-break: break-all; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .6rem;
  font-size: .72rem; max-height: 7rem; overflow: auto;
}
.reveal-row { display: flex; gap: .5rem; align-items: center; justify-content: center; flex-wrap: wrap; }

/* dialog form rhythm: one consistent vertical cadence, scoped to dialogs so
   the pages cannot drift. Labels become block-level with clearance below — at
   least the 5px the 3px :focus-visible outline at 2px offset reaches past the
   control — so a focused input can never brush its label. */
dialog h2 { margin: 0 0 1rem; }
dialog label:not(.switch) { display: block; margin: 0 0 .5rem; }
dialog .invite-form { gap: 1rem; }
dialog .invite-form .row { gap: 1rem; }
dialog > .reveal-row { margin-top: 1.1rem; }
dialog .reveal-row + .reveal-row { margin-top: .3rem; }
dialog fieldset { gap: .8rem; }
dialog fieldset legend { padding: 0 .45rem; }

/* banner */
.banner {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: calc(var(--radius) / 2); padding: .6rem .8rem;
  display: flex; gap: .6rem; align-items: center; margin: .6rem .9rem 0;
  font-size: .85rem; flex-wrap: wrap; row-gap: .4rem;
}
.banner.warn { border-color: var(--danger); }
/* toast: a fixed banner (see chrome.js) with a safe-area aware bottom offset */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); margin: 0;
  z-index: 50; max-width: 92vw;
  bottom: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* checkbox switch (settings rows) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.switch { position: relative; display: inline-block; flex: none; width: 2.7rem; height: 1.5rem; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch-track {
  display: block; width: 100%; height: 100%; box-sizing: border-box; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.switch-track::after {
  content: ''; position: absolute; top: 50%; left: .18rem; width: 1.02rem; height: 1.02rem;
  transform: translateY(-50%); border-radius: 50%; background: var(--text-muted);
  transition: left .15s ease, background .15s ease;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { left: calc(100% - 1.2rem); background: var(--on-accent); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ============ admin ============ */

.admin-grid { display: grid; grid-template-columns: 20rem 1fr; height: 100vh; height: 100dvh; }
.inbox {
  border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface);
  padding-bottom: 0; padding-bottom: env(safe-area-inset-bottom);
}
.inbox-head { padding: .8rem; display: flex; gap: .5rem; align-items: center; border-bottom: 1px solid var(--border); }
.inbox-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item {
  width: 100%; text-align: left; background: transparent; border: none;
  border-bottom: 1px solid var(--border); padding: .8rem; color: var(--text);
  display: flex; gap: .6rem; align-items: center;
}
@media (hover: hover) { .conv-item:hover { background: var(--surface-2); } }
.conv-item.active { background: var(--surface-2); border-left: 3px solid var(--accent); }
.grow { flex: 1; min-width: 0; }
.conv-item .label { font-weight: 600; display: flex; align-items: baseline; min-width: 0; }
.conv-item .label .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-title {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.unread-dot {
  background: var(--accent); color: var(--on-accent); border-radius: 99px;
  min-width: 1.4rem; height: 1.4rem; display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; padding: 0 .35rem;
}
.empty-pane { display: grid; place-items: center; height: 100%; min-width: 0; padding: 1rem; text-align: center; color: var(--text-muted); }

.invite-form { display: grid; gap: .8rem; }
.invite-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.theme-swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch {
  width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 2px solid var(--border);
  position: relative; overflow: hidden; padding: 0;
}
.swatch i { position: absolute; inset: 0; display: block; }
.swatch.sel { outline: 3px solid var(--focus); }
.swatch.pink i { background: linear-gradient(135deg, #ffdcec, #d1157a); }
.swatch.steel i { background: linear-gradient(135deg, #141e2e, #5b9dd9); }
.swatch.rainbow i { background: conic-gradient(#ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e); }
.swatch.smoky i { background: linear-gradient(135deg, #202027, #8296ae); }
.swatch.fun i { background: conic-gradient(#ff2d87, #b78cff, #fff3b0, #c1f0d0, #ff2d87); }
.swatch.gold i { background: linear-gradient(135deg, #faf3e3, #d9a520); }
.swatch.forest i { background: linear-gradient(135deg, #15231a, #86c98a); }

/* ============ styled invite-QR design editor ============ */
.qrd-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
/* the design trigger is a select-styled button: same box as native selects,
   a downward chevron as the affordance, current design name as the value */
.qrd-design-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
  padding: .6rem .8rem; cursor: pointer; min-width: 11rem;
}
.qrd-design-btn:hover { border-color: var(--accent); }
.qrd-design-btn > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.qrd-design-btn .icon { width: 18px; height: 18px; flex: none; }
.qrd-chev { color: var(--text-muted); transform: rotate(90deg); }
.qrd-pop {
  display: grid; gap: .5rem; padding: .5rem; z-index: 60;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.qrd-pop[hidden] { display: none; }
.qrd-emoji-grid { display: grid; grid-template-columns: repeat(5, auto); gap: .25rem; }
.qrd-emoji-grid button {
  font-size: 1.15rem; line-height: 1; padding: .25rem .35rem; color: var(--text);
  border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
  background: var(--surface-2); cursor: pointer;
}
@media (hover: hover) { .qrd-emoji-grid button:hover { border-color: var(--accent); } }
.qrd-canvas-wrap { touch-action: none; display: grid; place-items: center; }
.qrd-canvas-wrap canvas {
  width: 100%; max-width: 340px; height: auto; aspect-ratio: 1080 / 1350;
  border-radius: 12px; box-shadow: var(--shadow); display: block;
  cursor: grab; touch-action: none;
}
.qrd-canvas-wrap canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.qrd-canvas-wrap:empty { display: none; }
.qrd-panel {
  display: grid; gap: .6rem; padding: .8rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.qrd-panel label { margin: 0; }
.qrd-field { display: grid; gap: .3rem; }
.qrd-swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.qrd-swatches button {
  width: 2rem; height: 2rem; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid var(--border);
}
.qrd-swatches button[aria-pressed="true"] { outline: 3px solid var(--focus); outline-offset: 2px; }
.qrd-panel .btn.danger { justify-self: start; }

/* ============ motion / a11y ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .msg { opacity: 1 !important; transform: none !important; }
  .msg-list { scroll-behavior: auto; }
}
@media (prefers-contrast: more) {
  :root { --border: currentColor; }
  .bubble { border-width: 2px; }
}

.msg { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

.fx-piece { position: fixed; width: 10px; height: 10px; top: -12px; z-index: 99; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
.fx-heart { border-radius: 0; clip-path: path('M5 9 C5 5 0 3 0 6 C0 8 5 12 5 12 C5 12 10 8 10 6 C10 3 5 5 5 9 Z'); width: 14px; height: 14px; }
.fx-smoke { width: 26px; height: 26px; border-radius: 50%; filter: blur(7px); opacity: .5; animation-name: smoke; animation-timing-function: ease-out; }
@keyframes smoke { to { transform: translateY(-40vh) translateX(6vw) scale(2.4); opacity: 0; } }
.fx-leaf {
  width: 14px; height: 14px; border-radius: 50% 0 50% 0;
  animation-name: leaf, leaf-sway;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: 1, infinite;
  animation-direction: normal, alternate;
}
@keyframes leaf {
  15% { transform: perspective(500px) translateY(45vh) rotate(140deg) rotateY(210deg); }
  35% { transform: perspective(500px) translateY(72vh) rotate(260deg) rotateY(430deg); }
  60% { transform: perspective(500px) translateY(90vh) rotate(380deg) rotateY(560deg); }
  80% { transform: perspective(500px) translateY(99vh) rotate(460deg) rotateY(700deg); }
  to { transform: perspective(500px) translateY(105vh) rotate(540deg) rotateY(760deg); }
}
@keyframes leaf-sway { from { margin-left: -8vw; } to { margin-left: 8vw; } }

.play-state { font-size: .68rem; color: var(--success); }

/* ============ identity trigger + anchored menu ============ */

.id-trigger {
  display: inline-flex; gap: .5rem; align-items: center; justify-content: flex-end;
  background: transparent; border: 1px solid transparent; color: var(--text);
  border-radius: 99px; padding: .2rem .6rem .2rem .2rem; font-size: .9rem;
  min-width: 0; max-width: 100%;
}
.id-trigger .avatar { width: 34px; height: 34px; flex: none; }
.id-trigger .id-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .id-trigger:hover { background: var(--surface-2); border-color: var(--border); } }
.anchor-menu {
  position: fixed; z-index: 60; display: flex; flex-direction: column; gap: .1rem;
  min-width: 13rem; max-width: min(20rem, calc(100vw - 16px)); padding: .35rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.anchor-menu[hidden] { display: none; }
.menu-item {
  display: flex; gap: .65rem; align-items: center; width: 100%;
  min-height: 44px; padding: .45rem .7rem; text-align: left;
  background: transparent; border: none; color: var(--text);
  border-radius: calc(var(--radius) / 2);
}
@media (hover: hover) { .menu-item:hover { background: var(--surface-2); } }
.menu-item .icon { width: 20px; height: 20px; }
.menu-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item.danger { color: var(--danger); }
.profile-av { width: 84px; height: 84px; margin: 0 auto .25rem; }
.profile-av .icon { width: 40px; height: 40px; }
/* profile sheet: the avatar carries its own compact controls — edit always,
   remove only while an uploaded avatar is set (toggled in admin.js) */
.avatar-row { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: 0 0 .6rem; }
.avatar-row .profile-av { margin: 0; }
.avatar-actions { display: flex; flex-direction: column; gap: .35rem; }
.avatar-actions .icon-btn { color: var(--text-muted); }
.inbox-filter { padding: .5rem .8rem; border-bottom: 1px solid var(--border); }
.invite-desc:not([hidden]) { margin-top: 1rem; margin-bottom: 1.25rem; }
.invite-desc {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
  padding: .6rem .8rem; font-weight: 600;
}
.tag-btn { min-width: 32px; min-height: 32px; }
.react-pop .tag-btn { min-width: 36px; min-height: 36px; }
.consent-globe { display: inline-flex; flex: none; color: var(--accent); }
.consent-globe .icon { width: 1.05rem; height: 1.05rem; }
#peer-name-a { display: flex; align-items: baseline; min-width: 0; }
#peer-name-a .peer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-row {
  display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: center;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.invite-row .label { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-row .badge { white-space: nowrap; flex: none; }
.invite-row .small { white-space: normal; overflow-wrap: anywhere; }
.invite-details {
  margin: 0 0 .5rem; padding: .55rem .7rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
  color: var(--text-muted); font-size: .8rem;
  display: grid; gap: .15rem;
}
.invite-details .rich-desc { color: var(--text); margin-top: .1rem; }
.iv-title { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.invite-details .fact {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .22rem 0; border-bottom: 1px dashed var(--border);
}
.invite-details .fact .k { color: var(--text-muted); }
.invite-details .fact .v { color: var(--text); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.iv-desc-cap { margin-top: .5rem; color: var(--text-muted); }
.iv-desc-card {
  border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
  background: var(--bg-2); padding: .55rem .7rem; margin-top: .25rem;
}
/* small-btn keeps its compact look; overflow:visible lets the ::after hit
   expander reach past the rounded clip that exists for the .sheen span */
.btn.small-btn { padding: .3rem .7rem; font-size: .8rem; min-height: 32px; overflow: visible; }

/* ============ avatars ============ */

.avatar img.avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar svg:not(.icon) { width: 100%; height: 100%; border-radius: 50%; display: block; }

/* ============ failed bubble retry ============ */

.voice .retry-btn { margin-left: auto; }

/* ============ reactions (single-select picker) ============ */

.react-pop {
  position: fixed; z-index: 60; display: flex; gap: .25rem; padding: .35rem .5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.react-pop[hidden] { display: none; }
.react-opts { display: flex; gap: .5rem; align-items: center; }
/* popover options are .tag-btns, so they ride the 44px ::after hit expander
   (see the expander block in base); the .35rem/.5rem popover padding contains
   the outer 4px ring bleed of 36px and the .5rem gap keeps neighbouring rings
   tangent instead of overlapping */

/* ============ settings dialog ============ */

fieldset { border: 1px solid var(--border); border-radius: calc(var(--radius) / 2); padding: .8rem; margin: 0; display: grid; gap: .7rem; }
legend { font-size: .85rem; color: var(--text-muted); padding: 0 .4rem; }
.crop-wrap { display: grid; gap: .7rem; justify-items: center; }
.crop-zoom { width: 100%; }
.crop-wrap .reveal-row { width: 100%; margin-top: .3rem; }
.crop-stage { width: 192px; height: 192px; border-radius: 50%; overflow: hidden; border: 2px solid var(--border); background: var(--surface-2); }
.crop-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.crop-stage canvas.dragging { cursor: grabbing; }

/* ============ big player dialog (admin) ============ */

#player-dlg { max-width: min(720px, 92vw); width: min(720px, 92vw); }
.pd-head { display: flex; align-items: center; gap: .5rem; margin: 0 0 .9rem; }
.pd-head h2 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-wave-wrap { position: relative; }
.pd-wave {
  display: block; width: 100%; height: 140px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: calc(var(--radius) / 2);
}
.pd-marker {
  position: absolute; top: 0; left: 0; transform: translate(-50%, -7px);
  width: 30px; height: 30px; min-width: 0; min-height: 0; padding: 0;
  border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--surface); border: 1.5px solid var(--accent); color: var(--accent);
  box-shadow: var(--shadow);
}
.pd-marker .icon { width: 15px; height: 15px; }
.pd-marker:active:not(:disabled) { transform: translate(-50%, -6px) scale(.97); }
.pd-marker[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.pd-marker::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
}
.pd-transport { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .9rem; }
.pd-time { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--text-muted); min-width: 3rem; }
.pd-sep { color: var(--text-muted); }

/* ============ marker dialog ============ */

.mk-icons { display: flex; flex-wrap: wrap; gap: .5rem; }
.mk-icon { border-radius: 50%; }
.mk-icon .icon { width: 20px; height: 20px; }
.mk-icon[aria-pressed="true"] { color: var(--accent); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* rainbow: full-spectrum buttons (decorative gradient; text tokens stay AA on solid --accent) */
[data-theme="rainbow"] .btn:not(.ghost):not(.danger) {
  background: linear-gradient(120deg, #c01f4f, #c25a00, #a08c00, #1d7a44, #0072a8, #4636c9, #8c2fb0, #c01f4f) border-box;
  background-size: 200% 100%;
  animation: rainbow-flow 8s linear infinite;
  color: #fff; text-shadow: 0 1px 2px #00000073;
}
[data-theme="rainbow"] .play-btn {
  background: linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e);
  background-size: 200% 100%;
  animation: rainbow-flow 8s linear infinite;
  color: #1a1a2e;
}
[data-theme="smoky"] .btn:not(.ghost):not(.danger) { filter: saturate(.55); }
[data-theme="smoky"] .play-btn { filter: saturate(.55); }

/* ============ rainbow: extra spectrum ============
   Flowing spectrum on structural lines and rounded frames (decorative only —
   text never sits on a gradient). Everything is [data-theme="rainbow"]-scoped,
   so the other themes keep their plain borders; the global
   prefers-reduced-motion kill-switch in "motion / a11y" (it covers
   *, *::before, *::after) stops every animation here — no per-rule guard.
   Skipped on purpose: the .ring-bar SVG stroke (needs markup defs) and the
   scrollbar (no gradient support). */

@keyframes rainbow-flow { to { background-position: 200% 0; } }
@keyframes rainbow-flow-inbox { to { background-position: 100% 200%; } }
@keyframes rainbow-flow-mic { to { background-position: 0 0, 200% 0; } }

/* fixed 3px spectrum strip across the very top of the viewport */
[data-theme="rainbow"] body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 60; pointer-events: none;
  background: linear-gradient(90deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e);
  background-size: 200% 100%;
  animation: rainbow-flow 6s linear infinite;
}

/* hosts of the animated divider strips; the abspos pseudos stay out of the
   flex flow and are click-through, so layout is untouched */
[data-theme="rainbow"] .chat-header,
[data-theme="rainbow"] .conv-bar,
[data-theme="rainbow"] .composer { position: relative; }

/* 2px flowing spectrum on the bottom edge (bottom:-1px covers the plain
   --border line visually while the border keeps reserving the layout) */
[data-theme="rainbow"] .chat-header::after,
[data-theme="rainbow"] .conv-bar::after,
[data-theme="rainbow"] .composer::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e);
  background-size: 200% 100%;
  animation: rainbow-flow 6s linear infinite;
}
/* the composer's divider is its border-top */
[data-theme="rainbow"] .composer::after { top: -1px; bottom: auto; }

/* .inbox is a scroll container — an abspos strip would scroll away with the
   rows — so its right-edge spectrum rides the element's own (non-scrolling)
   background layer: a 2px vertical band pinned to the right padding edge */
[data-theme="rainbow"] .inbox {
  background-image: linear-gradient(180deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e);
  background-repeat: no-repeat;
  background-size: 2px 200%;
  background-position: 100% 0;
  border-right-color: transparent;
  animation: rainbow-flow-inbox 6s linear infinite;
}

/* active conversation: flowing spectrum ring on all four sides — the row's own
   opaque --surface-2 fill on the padding-box keeps content readable, the
   border-box spectrum only shows in the 2px transparent border */
[data-theme="rainbow"] .conv-item.active {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff, #ff595e) border-box;
  background-size: 200% 100%;
  animation: rainbow-flow 6s linear infinite;
}

/* tool separator: static vertical spectrum instead of the plain border bar */
[data-theme="rainbow"] .tool-sep { background: linear-gradient(180deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff); }

/* rounded spectrum frames via the mic-btn trick: solid fill on padding-box +
   spectrum ring on border-box (2px transparent border carries the ring) */
[data-theme="rainbow"] .bubble {
  background:
    linear-gradient(var(--bubble-in), var(--bubble-in)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}
[data-theme="rainbow"] .msg.out .bubble {
  background:
    linear-gradient(var(--bubble-out), var(--bubble-out)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}
[data-theme="rainbow"] dialog {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}
[data-theme="rainbow"] .banner {
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}
/* warn banners keep unmistakable danger: re-declared after the spectrum
   frame so their solid border always wins */
[data-theme="rainbow"] .banner.warn { background: var(--surface-2); border: 2px solid var(--danger); }
[data-theme="rainbow"] code.join {
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}
[data-theme="rainbow"] .crop-stage {
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}
/* QR scannability: the white padding-box fill MUST stay (#fff), the spectrum
   only rings the outside */
[data-theme="rainbow"] .qr-box svg:not(.icon),
[data-theme="rainbow"] .qr-box canvas {
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(120deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff) border-box;
  border: 2px solid transparent;
}

/* checked switch: static spectrum track (the knob ::after keeps --on-accent) */
[data-theme="rainbow"] .switch input:checked + .switch-track {
  background: linear-gradient(90deg, #ff595e, #ffde34, #32cd32, #00b9fb, #5865f2, #b663ff);
  border-color: transparent;
}

/* mic ring flows too: only the border-box spectrum layer pans — the
   padding-box fill is a solid color, so moving it is invisible */
[data-theme="rainbow"] .mic-btn {
  background-size: auto, 200% 100%;
  background-position: 0 0, 0 0;
  animation: rainbow-flow-mic 8s linear infinite;
}

@media (orientation: landscape) and (max-height: 560px) {
  .chat-header { padding-top: .35rem; padding-top: max(.35rem, env(safe-area-inset-top)); padding-bottom: .35rem; }
  .composer { padding-top: .45rem; padding-bottom: max(.45rem, env(safe-area-inset-bottom)); }
  .inbox-head { padding: .45rem .8rem; }
  dialog { max-height: calc(100vh - 1rem - var(--kb, 0px)); max-height: calc(100dvh - 1rem - var(--kb, 0px)); }
}
@media (max-width: 560px) {
  #secure-note span { display: none; }
  .chat-header .who { font-size: .9rem; }
  .btn { padding: .55rem .9rem; }
  .inbox-head { flex-wrap: wrap; row-gap: .35rem; }
  .pd-wave { height: 104px; }
}
@media (max-width: 760px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-grid.chat-open .inbox { display: none; }
  .admin-grid:not(.chat-open) .chat-pane { display: none; }
}
