:root {
  --bg: #07080c;
  --panel: #0d0f17;
  --panel2: #151826;
  --panel3: #1d2133;
  --line: rgba(255, 255, 255, .07);
  --line2: rgba(255, 255, 255, .13);
  --text: #e8eaf4;
  --muted: #7c839b;
  --a1: #3b82f6;
  --a2: #22d3ee;
  --accent: #38bdf8;
  --grad: linear-gradient(135deg, #2563eb, #0ea5e9);
  --gold: #f5b301;
  --ok: #34d399;
  --err: #fb7185;
  --hl: rgba(245, 179, 1, .09);
  --nick-l: 72%;
  --av-a: .16;
  --glow: 0 0 0 1px rgba(56, 189, 248, .55), 0 0 22px rgba(56, 189, 248, .22);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel2: #eef0f7;
  --panel3: #e3e6f1;
  --line: rgba(15, 20, 50, .09);
  --line2: rgba(15, 20, 50, .16);
  --text: #0e1122;
  --muted: #646c86;
  --a2: #0891b2;
  --accent: #0369a1;
  --err: #e11d48;
  --ok: #059669;
  --hl: rgba(245, 179, 1, .16);
  --nick-l: 38%;
  --av-a: .13;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(70% 45% at 100% 0%, rgba(34, 211, 238, .07), transparent 70%),
    radial-gradient(70% 45% at 0% 100%, rgba(56, 189, 248, .10), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--a2); outline-offset: 2px; }

.primary { background: var(--grad); color: #fff; border-radius: 14px; font-weight: 600; letter-spacing: .01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 6px 24px rgba(14, 165, 233, .32), inset 0 1px 0 rgba(255, 255, 255, .22); transition: transform .12s, filter .12s; }
.primary:active { transform: scale(.97); filter: brightness(.92); }
.primary:disabled { opacity: .5; }
.ghost { color: var(--muted); border: 1px solid var(--line2); border-radius: 14px; min-height: 44px; padding: 0 14px; font-size: 14px; }
.ghost:active { background: var(--panel2); }
.icon { position: relative; min-width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: 12px; color: var(--muted); transition: background .12s, color .12s; }
.icon:active { background: var(--panel2); color: var(--text); }
.icon.on { color: var(--a2); background: rgba(34, 211, 238, .10); }

input, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 14px; padding: 11px 14px; outline: none; transition: box-shadow .15s, border-color .15s; }
input:focus, textarea:focus { border-color: transparent; box-shadow: var(--glow); }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ---------- login ---------- */
#login { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; }
.bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(72px); opacity: .5; animation: drift 17s ease-in-out infinite alternate; }
.o1 { width: 74vmin; height: 74vmin; left: -24vmin; top: -20vmin; background: #2563eb; }
.o2 { width: 62vmin; height: 62vmin; right: -26vmin; top: 36%; background: #06b6d4; opacity: .34; animation-duration: 23s; animation-direction: alternate-reverse; }
.o3 { width: 40vmin; height: 40vmin; left: 10%; bottom: -18vmin; background: #f5b301; opacity: .10; animation-duration: 29s; }
@keyframes drift { to { transform: translate(9vmin, 7vmin) scale(1.18); } }
:root[data-theme="light"] .orb { opacity: .22; }
:root[data-theme="light"] .o3 { opacity: .12; }
.grid { position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(90% 60% at 50% 35%, #000, transparent);
  mask-image: radial-gradient(90% 60% at 50% 35%, #000, transparent); }

.lp { position: relative; min-height: 100%; display: flex; flex-direction: column; gap: 18px; max-width: 470px; margin: 0 auto;
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 22px) calc(var(--sab) + 18px) calc(var(--sal) + 22px); }
.lp-top { display: flex; align-items: center; gap: 10px; }
.lp-top img { filter: drop-shadow(0 6px 16px rgba(56, 189, 248, .45)); }
.lp-top b { flex: 1; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.lp-top b span, .lp h1 em { background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line2); border-radius: 999px;
  font: 11.5px var(--mono); color: var(--muted); background: color-mix(in srgb, var(--panel) 55%, transparent); }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 1.4s infinite alternate; }
.lp h1 { margin: 14px 0 10px; font-size: clamp(34px, 10.6vw, 48px); line-height: 1.03; font-weight: 800; letter-spacing: -.045em; }
.lp h1 em { font-style: normal; }
.tagline { margin: 0; max-width: 36ch; color: var(--muted); font-size: 15.5px; line-height: 1.5; }

/* animated product preview */
.demo { flex: 1; min-height: 0; display: flex; align-items: center; perspective: 900px; }
.demo-win { width: 100%; overflow: hidden; border: 1px solid var(--line2); border-radius: 20px;
  background: color-mix(in srgb, var(--panel) 74%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 34px 70px rgba(0, 0, 0, .45), 0 0 50px rgba(56, 189, 248, .10), inset 0 1px 0 rgba(255, 255, 255, .07);
  transform: rotateX(9deg) rotateY(-8deg) rotateZ(1.500deg); animation: float 7s ease-in-out infinite alternate; }
@keyframes float { to { transform: rotateX(4deg) rotateY(-3deg) rotateZ(.5deg) translateY(-8px); } }
:root[data-theme="light"] .demo-win { box-shadow: 0 30px 60px rgba(20, 50, 110, .18), inset 0 1px 0 #fff; }
.demo-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); font: 11.5px var(--mono); color: var(--muted); }
.demo-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--line2); }
.demo-bar span { margin-left: 6px; }
.demo-bar .demo-tag { margin-left: auto; font-size: 10px; letter-spacing: .12em; color: var(--a2); }
#demoLog { padding: 2px 0 14px; pointer-events: none; }
#demoLog .msg, #demoLog .tr { animation: demoIn 11s both infinite; animation-delay: var(--d, 0s); }
@keyframes demoIn { 0% { opacity: 0; transform: translateY(10px); } 5%, 88% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; transform: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 14px; }
.chips li { padding: 6px 11px; border: 1px solid var(--line2); border-radius: 999px; font: 11.5px var(--mono); color: var(--muted);
  background: color-mix(in srgb, var(--panel) 55%, transparent); }
.chips li::before { content: "✓ "; color: var(--a2); font-weight: 700; }
.big { position: relative; overflow: hidden; width: 100%; min-height: 58px; font-size: 17px; border-radius: 18px; }
.big::after { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 34%; transform: skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .34), transparent); animation: sheen 3.600s ease-in-out infinite; }
@keyframes sheen { 0%, 55% { left: -40%; } 100% { left: 120%; } }
.big svg { transition: transform .15s; }
.big:active svg { transform: translateX(4px); }
#loginMsg { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 13.5px; }
#loginMsg:empty { display: none; }
#loginMsg.err { color: var(--err); }
.fine { margin: 12px 0 0; text-align: center; font: 11px/1.5 var(--mono); color: var(--muted); }

@media (max-height: 720px) {
  #demoLog .msg:nth-child(3) { display: none; }
  .lp { gap: 12px; }
  .lp h1 { font-size: 32px; margin-top: 10px; }
}
@media (max-height: 590px) { .demo { display: none; } }
@media (min-width: 900px) {
  .lp { max-width: 1080px; display: grid; grid-template: "top top" auto "hero demo" 1fr "cta demo" 1fr / 1fr 1fr; column-gap: 64px; padding-left: 40px; padding-right: 40px; }
  .lp-top { grid-area: top; }
  .lp-hero { grid-area: hero; align-self: end; }
  .lp-cta { grid-area: cta; max-width: 420px; }
  .demo { grid-area: demo; }
  .lp h1 { font-size: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  .orb, .demo-win, .big::after, .pill i { animation: none; }
  #demoLog .msg, #demoLog .tr { animation: none; }
}

/* ---------- app shell ---------- */
#app { position: absolute; left: 0; right: 0; top: 0; height: var(--app-h, 100dvh); display: grid;
  grid-template: "head" auto "banner" auto "msgs" 1fr "emoji" auto "foot" auto / 1fr; }
header { grid-area: head; position: relative; display: flex; align-items: center; gap: 2px;
  padding: calc(var(--sat) + 6px) calc(var(--sar) + 8px) 6px calc(var(--sal) + 8px);
  background: color-mix(in srgb, var(--panel) 88%, transparent); border-bottom: 1px solid var(--line); }
header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--a1), var(--a2), transparent); opacity: .55; }
#title { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; min-height: 42px; padding: 0 6px; cursor: pointer; }
#title b { display: flex; align-items: center; gap: 8px; min-width: 0; font: 600 15.5px/1.3 var(--mono); letter-spacing: -.01em; }
#bufName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#connDot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent), 0 0 10px var(--ok); }
#app[data-conn="off"] #connDot { background: var(--gold); box-shadow: 0 0 0 3px rgba(245, 179, 1, .22); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
#bufTopic { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 16px; }
#bufTopic:empty { display: none; }
#userCount { font: 12px var(--mono); }
#usersBtn { padding: 0 9px; }
#menuDot { position: absolute; top: 7px; right: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--a2); border: 2px solid var(--panel); }
#menuDot.hl { background: var(--gold); }

#banner { grid-area: banner; padding: 7px 12px; text-align: center; font: 12px var(--mono); color: var(--gold);
  background: rgba(245, 179, 1, .10); border-bottom: 1px solid rgba(245, 179, 1, .25); }

#msgs { grid-area: msgs; position: relative; min-height: 0; }
.log { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 0 12px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--panel3) transparent; }
.msg { padding: 1px calc(var(--sar) + 14px) 1px calc(var(--sal) + 14px); overflow-wrap: anywhere; }
.msg time { font: 11px var(--mono); color: var(--muted); opacity: .8; }
.nick { cursor: pointer; }

/* chat messages: avatar + header, grouped when the same person keeps talking */
.msg.chat { display: grid; grid-template-columns: 36px 1fr; column-gap: 10px; margin-top: 10px; }
.msg.cont { margin-top: 0; }
.msg.cont .av, .msg.cont .mh { display: none; }
.msg.cont .mb { grid-column: 2; }
.av { width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-top: 2px;
  font: 700 15px var(--mono); color: hsl(var(--h, 200) 80% var(--nick-l));
  background: hsl(var(--h, 200) 70% 55% / var(--av-a)); box-shadow: inset 0 0 0 1px hsl(var(--h, 200) 70% 60% / .28); }
.mb { min-width: 0; }
.mh { display: flex; align-items: baseline; gap: 8px; line-height: 1.3; }
.mh .nick { font-weight: 650; font-size: 14.5px; color: hsl(var(--h, 200) 75% var(--nick-l)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.self .mh .nick { color: var(--accent); }
.mt { white-space: pre-wrap; }
.msg.chat .mt { cursor: pointer; }
.msg.hl { background: var(--hl); box-shadow: inset 3px 0 0 var(--gold); padding-top: 4px; padding-bottom: 4px; }
.tr { position: relative; margin: 3px 0 2px; padding: 3px 8px 3px 10px; border-left: 2px solid var(--a2); border-radius: 0 8px 8px 0;
  background: rgba(34, 211, 238, .07); color: color-mix(in srgb, var(--text) 86%, var(--a2)); font-size: 14.5px; white-space: pre-wrap; }
.tr::before { content: attr(data-lang); margin-right: 7px; font: 700 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--a2); vertical-align: 1px; }
.tr.err { border-color: var(--err); background: rgba(251, 113, 133, .08); color: var(--err); }

/* everything else is a compact mono line aligned with the message column */
.msg.sys, .msg.notice, .msg.err, .msg.action { padding-left: calc(var(--sal) + 60px); font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.msg.sys, .msg.err { font-family: var(--mono); font-size: 11.5px; }
.msg.sys time, .msg.notice time, .msg.err time, .msg.action time { margin-right: 8px; }
.msg.err { color: var(--err); }
.msg.action { font-style: italic; font-size: 14.5px; color: var(--text); }
.msg.action .nick { font-weight: 650; font-style: normal; color: hsl(var(--h, 200) 75% var(--nick-l)); }
.msg.action .nick::before { content: "✦ "; color: var(--muted); }
.msg a { color: var(--a2); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--a2) 45%, transparent); }
.msg .chan { color: var(--accent); font-family: var(--mono); font-size: .93em; cursor: pointer; }
.day { display: flex; align-items: center; gap: 12px; margin: 14px 14px 8px; font: 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fb { font-weight: 700; } .fi { font-style: italic; } .fu { text-decoration: underline; } .fs { text-decoration: line-through; }
.fm { font-family: var(--mono); font-size: .9em; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; }

#newPill { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--foot-h, 64px) + 12px); z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: var(--grad); color: #fff; font: 600 12px var(--mono); box-shadow: 0 8px 26px rgba(59, 130, 246, .4); }

footer { grid-area: foot; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px calc(var(--sar) + 10px) calc(var(--sab) + 10px) calc(var(--sal) + 10px);
  background: color-mix(in srgb, var(--panel) 88%, transparent); border-top: 1px solid var(--line); }
#input { flex: 1; min-width: 0; resize: none; max-height: 132px; min-height: 46px; line-height: 1.4; border-radius: 16px; padding: 11px 15px; display: block; }
#sendBtn { width: 46px; height: 46px; border-radius: 15px; flex: none; }

/* ---------- drawers ---------- */
.drawer { position: absolute; top: 0; bottom: 0; z-index: 20; width: min(84vw, 320px); display: flex; flex-direction: column;
  background: var(--panel); transition: transform .24s cubic-bezier(.2, .8, .2, 1); will-change: transform; padding-top: var(--sat); }
#left { left: 0; transform: translateX(-102%); border-right: 1px solid var(--line2); padding-left: var(--sal); }
#right { right: 0; transform: translateX(102%); border-left: 1px solid var(--line2); padding-right: var(--sar); }
#left.open, #right.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
#backdrop { position: absolute; inset: 0; z-index: 15; background: rgba(3, 4, 8, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.me { display: flex; align-items: center; gap: 12px; padding: 16px 14px; border-bottom: 1px solid var(--line); }
.me img { filter: drop-shadow(0 4px 12px rgba(56, 189, 248, .45)); }
.me div { min-width: 0; display: flex; flex-direction: column; }
.me b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15.5px; }
.me span { color: var(--muted); font: 11.5px var(--mono); }
.me span::before { content: "● "; color: var(--ok); }
.drawer-head, .group { padding: 16px 12px 6px; color: var(--muted); font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .12em; }
.drawer nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 8px; scrollbar-width: thin; scrollbar-color: var(--panel3) transparent; }
.drawer-foot { display: flex; flex-direction: column; gap: 8px; padding: 12px 12px calc(var(--sab) + 12px); border-top: 1px solid var(--line); }
.drawer-foot .primary { min-height: 48px; }
.row { position: relative; display: flex; align-items: center; width: 100%; min-height: 46px; padding: 0 6px 0 12px; border-radius: 12px; text-align: left; gap: 10px; cursor: pointer; }
.row:active { background: var(--panel2); }
.row.active { background: var(--panel2); }
.row.active::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: linear-gradient(var(--a1), var(--a2)); }
.row .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bufList .row .name { font-family: var(--mono); font-size: 14px; }
.row.off .name { color: var(--muted); text-decoration: line-through; }
.row .badge { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 7px; background: var(--grad); color: #fff; font: 700 11px var(--mono); display: inline-flex; align-items: center; justify-content: center; }
.row .badge.hl { background: var(--gold); color: #1c1400; }
.row .x { width: 38px; height: 38px; flex: none; color: var(--muted); font-size: 19px; line-height: 1; border-radius: 10px; }
.row .x:active { background: var(--panel3); color: var(--err); }
.row .pfx { width: 1em; flex: none; text-align: center; color: var(--gold); font: 700 13px var(--mono); }
.row .sub { color: var(--muted); font: 12px var(--mono); flex: none; padding-right: 8px; }
#userList .row { min-height: 42px; }
#userList .row .name { color: hsl(var(--h, 200) 75% var(--nick-l)); font-weight: 600; font-size: 14.5px; }
.switch { flex: none; width: 44px; height: 26px; margin-right: 6px; border-radius: 13px; background: var(--panel3); position: relative; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--grad); }
.switch.on::after { transform: translateX(18px); }

/* ---------- bottom sheet ---------- */
#sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 80%; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line2); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 8px calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5); animation: up .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes up { from { transform: translateY(100%); } }
.grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line2); margin: 0 auto 12px; flex: none; }
#sheetBody { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
#sheetBody h2 { font-size: 17px; margin: 2px 8px 10px; overflow-wrap: anywhere; letter-spacing: -.01em; }
#sheetBody p { margin: 4px 8px 12px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; font-size: 14px; }
#sheetBody p.hint { margin-top: 12px; font: 11px/1.5 var(--mono); }
#sheetBody form { display: flex; gap: 8px; margin: 0 2px 10px; }
#sheetBody form input { flex: 1; min-width: 0; font-family: var(--mono); }
#sheetBody form button { min-width: 78px; min-height: 46px; }
.row.danger .name { color: var(--err); }

@media (prefers-reduced-motion: reduce) { .drawer, #sheet, #connDot { transition: none; animation: none !important; } }

/* ---------- wide screens: drawers become sidebars ---------- */
@media (min-width: 900px) {
  #app { grid-template: "left head right" auto "left banner right" auto "left msgs right" 1fr "left emoji right" auto "left foot right" auto / 264px 1fr 220px; }
  #app.no-users { grid-template-columns: 264px 1fr 0; }
  #app.no-users #right { display: none; }
  .drawer { position: static; transform: none !important; width: auto; z-index: auto; box-shadow: none !important; }
  #left { grid-area: left; } #right { grid-area: right; }
  #menuBtn, #usersBtn { display: none !important; }
  header { padding-left: 14px; }
  .msg { padding-right: 22px; padding-left: 22px; }
  .msg.sys, .msg.notice, .msg.err, .msg.action { padding-left: 68px; }
  footer { padding-left: 18px; padding-right: 18px; }
  #sheet { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: 420px; border: 1px solid var(--line2); border-radius: 22px; animation: none; }
  #sheet .grip { display: none; }
  #newPill { left: calc(264px + (100% - 484px) / 2); }
}

/* ---------- theme switch ---------- */
.theme-btn { color: var(--muted); }
.theme-btn .sun, :root[data-theme="light"] .theme-btn .moon { display: none; }
:root[data-theme="light"] .theme-btn .sun { display: block; }
.foot-row { display: flex; gap: 8px; }
.foot-row .ghost { flex: 1; }
.foot-row .icon { border: 1px solid var(--line2); border-radius: 14px; min-width: 46px; height: 44px; }
:root[data-theme="light"] #backdrop { background: rgba(20, 28, 50, .38); }
:root[data-theme="light"] #sheet { box-shadow: 0 -20px 60px rgba(20, 40, 90, .18); }

/* ---------- app MOTD in the server tab ---------- */
.msg.motd { padding-top: 1px; padding-bottom: 1px; font-size: 14.5px; white-space: pre-wrap; }
.msg.motd time { display: none; }
.day + .msg.motd { margin-top: 6px; font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.msg.motd .mt:empty { display: block; height: .7em; }

/* ---------- connection loader ---------- */
#loader { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background:
    radial-gradient(60% 40% at 50% 42%, rgba(56, 189, 248, .16), transparent 70%),
    var(--bg);
  transition: opacity .42s ease, transform .42s ease; }
#loader.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.ld-orb { position: relative; width: 168px; height: 168px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.ld-orb img { position: relative; filter: drop-shadow(0 10px 26px rgba(56, 189, 248, .55)); animation: ldBob 2.400s ease-in-out infinite alternate; }
.ld-ring { position: absolute; inset: 18px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 55%, var(--a1), var(--a2) 96%, transparent);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: ldSpin 1.300s linear infinite; }
.ld-ring.r2 { inset: 0; opacity: .45; animation-duration: 2.900s; animation-direction: reverse; }
.ld-wave { position: absolute; inset: 34px; border-radius: 50%; border: 1px solid var(--a2); opacity: 0; animation: ldWave 2.400s ease-out infinite; }
.ld-wave + .ld-wave { animation-delay: 1.200s; }
.ld-ok { position: absolute; right: 44px; bottom: 44px; color: var(--ok); transform: scale(0); transition: transform .35s cubic-bezier(.2, 1.6, .4, 1); filter: drop-shadow(0 0 10px var(--ok)); }
#ldText { font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.ld-sub { font: 11.5px var(--mono); color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.ld-bar { width: 148px; height: 3px; margin-top: 14px; border-radius: 3px; background: var(--line2); overflow: hidden; }
.ld-bar i { display: block; width: 40%; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--a1), var(--a2)); animation: ldSlide 1.300s ease-in-out infinite; }
#loader.done .ld-ring { animation-play-state: paused; background: var(--ok); opacity: .9; }
#loader.done .ld-ring.r2 { opacity: .25; }
#loader.done .ld-wave { border-color: var(--ok); }
#loader.done .ld-ok { transform: scale(1); }
#loader.done #ldText { color: var(--ok); }
#loader.done .ld-bar i { width: 100%; animation: none; background: var(--ok); transition: width .3s; }
@keyframes ldSpin { to { transform: rotate(1turn); } }
@keyframes ldBob { to { transform: translateY(-5px); } }
@keyframes ldWave { 0% { transform: scale(.8); opacity: .55; } 100% { transform: scale(2.100); opacity: 0; } }
@keyframes ldSlide { 0% { transform: translateX(-110%); } 100% { transform: translateX(270%); } }
@media (prefers-reduced-motion: reduce) { .ld-ring, .ld-wave, .ld-orb img, .ld-bar i { animation: none; } }

/* ---------- emoji picker ---------- */
#emojiBtn { flex: none; width: 42px; height: 46px; }
#emojiPanel { grid-area: emoji; display: flex; flex-direction: column; height: min(280px, 42vh); background: var(--panel); border-top: 1px solid var(--line); }
#emojiTabs { display: flex; gap: 2px; padding: 6px 8px 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
#emojiTabs::-webkit-scrollbar { display: none; }
#emojiTabs button { flex: 1; min-width: 40px; height: 38px; border-radius: 10px; font-size: 20px; opacity: .55; }
#emojiTabs button.on { opacity: 1; background: var(--panel2); box-shadow: inset 0 -2px 0 var(--a2); }
#emojiGrid { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); align-content: start;
  padding: 6px calc(var(--sar) + 8px) 8px calc(var(--sal) + 8px); scrollbar-width: thin; scrollbar-color: var(--panel3) transparent; }
#emojiGrid button { height: 42px; border-radius: 10px; font-size: 25px; line-height: 1; }
#emojiGrid button:active { background: var(--panel2); transform: scale(1.18); }
@media (hover: hover) { #emojiGrid button:hover, #emojiTabs button:hover { background: var(--panel2); opacity: 1; } }

/* ---------- help sheet ---------- */
#sheetBody p.tip { margin: 2px 8px 6px; padding-left: 14px; position: relative; font-size: 13.5px; }
#sheetBody p.tip::before { content: ""; position: absolute; left: 0; top: .55em; width: 6px; height: 6px; border-radius: 50%; background: var(--a2); }
.row.cmd { flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 12px; min-height: 0; }
.row.cmd code { font: 600 13px var(--mono); color: var(--a2); }
.row.cmd .name { white-space: normal; font-size: 13.5px; color: var(--muted); }
