/* Minva Messenger — styles. Palette: #0088CC #5865F2 #0D1117 #161B22 #30363D #F0F6FC #8B949E #00CC88 #FF4444 */
:root {
  --bg: #F6F8FA; --surface: #FFFFFF; --surface2: #EEF1F5; --border: #D0D7DE;
  --text: #1F2328; --muted: #59636E; --primary: #0088CC; --primary-ink: #FFFFFF; --link: #006EA6;
  --accent: #5865F2; --ok: #00A36C; --danger: #D1242F; --bubble-in: #FFFFFF; --bubble-out: #D6EEFA;
  --shadow: 0 8px 28px rgba(31, 35, 40, .16); --radius: 14px; --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --hover: rgba(0, 136, 204, .08); --focus: 0 0 0 3px rgba(0, 136, 204, .35);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D1117; --surface: #161B22; --surface2: #1C232C; --border: #30363D;
  --text: #F0F6FC; --muted: #8B949E; --link: #4DB8F0; --ok: #00CC88; --danger: #FF4444;
  --bubble-in: #1C232C; --bubble-out: #0B4A6E; --shadow: 0 10px 32px rgba(0, 0, 0, .55); --hover: rgba(240, 246, 252, .06);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); overflow: hidden; -webkit-text-size-adjust: 100%;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.ic.sm { width: 16px; height: 16px; }

#app { height: var(--app-h, 100dvh); position: relative; z-index: 1; }
#app.boot { display: grid; place-items: center; }
.boot-logo { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; font-size: 38px; font-weight: 800; color: #F0F6FC; background: linear-gradient(135deg, #0088CC, #5865F2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; transition: background .15s, transform .05s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); position: relative; flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { color: var(--primary); }
.badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, textarea.input, select.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); }
.err { font-size: 13px; color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--primary); flex: none; }
.banner { padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); font-size: 14px; margin-bottom: 14px; }
.banner.warn { background: color-mix(in srgb, #E3B341 16%, var(--surface)); border-color: color-mix(in srgb, #E3B341 50%, var(--border)); }
.banner.bad { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); overflow-y: auto; height: var(--app-h, 100dvh); background: radial-gradient(1000px 500px at 80% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent), radial-gradient(800px 500px at -10% 110%, color-mix(in srgb, var(--primary) 22%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 12px 0 4px; font-size: 24px; }
.auth-card .sub { color: var(--muted); margin: 0 0 20px; }
.logo { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(135deg, #0088CC, #5865F2); color: #F0F6FC; font-weight: 800; font-size: 28px; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
a.btn { color: inherit; text-decoration: none; }
a.btn.primary { color: var(--primary-ink); }
.gelink-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 8px; background: linear-gradient(135deg, #0084ff, #00c6ff); color: #fff; font-weight: 800; font-size: 13px; }
.oauth-user { display: flex; align-items: center; gap: 12px; padding: 12px; margin: 16px 0 12px; border-radius: 14px; background: var(--hover); }
.oauth-user .grow { display: flex; flex-direction: column; min-width: 0; }
.oauth-user small { color: var(--muted); }
.oauth-user .btn { flex: none; white-space: nowrap; min-height: 34px; padding: 0 10px; font-size: 13px; }
.oauth-scopes { list-style: none; margin: 0 0 18px; padding: 0; }
.oauth-scopes li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 14px; }
.oauth-scopes li:last-child { border-bottom: 0; }
.oauth-scopes li .ic { color: var(--primary); flex: none; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: 14px; }
.auth-foot { align-items: center; display: flex; gap: 14px; justify-content: center; margin-top: 18px; font-size: 13px; flex-wrap: wrap; }
.auth-foot button { background: none; border: 0; color: var(--muted); padding: 4px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 380px minmax(0, 1fr); height: var(--app-h, 100dvh); padding-left: var(--sal); padding-right: var(--sar); }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); position: relative; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: calc(6px + var(--sat)) 10px 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.topbar h2 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .grow { flex: 1; min-width: 0; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.conn.off i { background: var(--danger); } .conn.wait i { background: #E3B341; }
.searchbox { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; padding: 6px 10px 0; }
.tab { background: none; border: 0; padding: 8px 12px; border-radius: 10px 10px 0 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent); }
.row:hover { background: var(--hover); } .row.sel { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.row .body { flex: 1; min-width: 0; }
.row .l1, .row .l2 { display: flex; gap: 8px; align-items: center; }
.row .title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .time { font-size: 12px; color: var(--muted); flex: none; }
.row .snip { color: var(--muted); font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .snip b { color: var(--text); font-weight: 600; }
.unread { background: var(--primary); color: #fff; border-radius: 10px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.unread.muted { background: var(--muted); }
.pin { color: var(--muted); }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin: 8px 0; }
.placeholder { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; position: relative; background: var(--accent); overflow: hidden; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; } .avatar.lg { width: 96px; height: 96px; font-size: 34px; }
.avatar-wrap { position: relative; flex: none; }
.dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }
.bottom-nav { display: none; }

/* ---------- chat ---------- */
.wallpaper { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.wp-default { background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 7%, var(--bg)), var(--bg)); }
.wp-winter { background: radial-gradient(circle at 20% 10%, color-mix(in srgb, #9bd7ff 30%, transparent), transparent 40%), linear-gradient(180deg, color-mix(in srgb, #5865F2 14%, var(--bg)), var(--bg)); }
.wp-aurora { background: linear-gradient(160deg, color-mix(in srgb, #00CC88 16%, var(--bg)), color-mix(in srgb, #5865F2 18%, var(--bg))); }
.wp-dusk { background: linear-gradient(180deg, color-mix(in srgb, #5865F2 22%, var(--bg)), color-mix(in srgb, #FF4444 8%, var(--bg))); }
.wp-plain { background: var(--bg); }
.msgs { flex: 1; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.msgs .spacer { flex: 1; }
.day { align-self: center; margin: 10px 0 6px; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 3px 12px; border-radius: 12px; border: 1px solid var(--border); }
.sys { align-self: center; font-size: 13px; color: var(--muted); margin: 6px 0; text-align: center; max-width: 80%; }
.m { display: flex; gap: 8px; max-width: min(78%, 620px); align-self: flex-start; margin-top: 2px; }
.m.mine { align-self: flex-end; flex-direction: row-reverse; }
.m .avatar { align-self: flex-end; }
.bubble { background: var(--bubble-in); border: 1px solid var(--border); border-radius: 16px 16px 16px 5px; padding: 7px 11px 5px; min-width: 56px; position: relative; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.m.mine .bubble { background: var(--bubble-out); border-radius: 16px 16px 5px 16px; border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.m .who { font-size: 13px; font-weight: 700; color: var(--accent); margin-bottom: 1px; }
.m .txt { white-space: pre-wrap; }
.m .txt a { word-break: break-all; }
.m.deleted .txt { color: var(--muted); font-style: italic; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-top: 1px; user-select: none; }
.ticks { display: inline-flex; color: var(--muted); } .ticks.read { color: var(--primary); } .ticks.failed { color: var(--danger); }
.m.failed .bubble { border-color: var(--danger); }
.quote { border-left: 3px solid var(--primary); padding: 2px 8px; margin: 2px 0 5px; background: color-mix(in srgb, var(--primary) 9%, transparent); border-radius: 6px; font-size: 13.5px; cursor: pointer; }
.quote b { display: block; color: var(--primary); font-size: 12.5px; }
.quote span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.fwd { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 1px 8px; font-size: 13px; display: inline-flex; gap: 4px; align-items: center; min-height: 26px; }
.react.mine { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 16%, var(--surface)); }
.att-img { display: block; max-width: min(100%, 320px); max-height: 320px; border-radius: 10px; cursor: zoom-in; margin: 2px 0; background: var(--surface2); }
.att-media { display: block; max-width: min(100%, 320px); margin: 2px 0; border-radius: 10px; }
.att-file { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface) 70%, transparent); text-decoration: none; color: inherit; margin: 3px 0; max-width: 280px; }
.att-file .fi { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.att-file small { color: var(--muted); display: block; }
.att-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing { height: 22px; padding: 0 16px; font-size: 13px; color: var(--muted); flex: none; }
.jump { position: absolute; right: 14px; bottom: 82px; z-index: 3; box-shadow: var(--shadow); background: var(--surface); border: 1px solid var(--border); }
.composer-wrap { flex: none; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--sab); }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 8px; }
.composer textarea { flex: 1; resize: none; max-height: 140px; min-height: 42px; padding: 10px 14px; border-radius: 21px; border: 1px solid var(--border); background: var(--bg); line-height: 1.35; }
.composer textarea:focus { outline: none; border-color: var(--primary); }
.send { background: var(--primary); color: #fff; } .send:hover { background: var(--primary); filter: brightness(1.1); color: #fff; }
.ctx { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.ctx .bar { width: 3px; align-self: stretch; background: var(--primary); border-radius: 2px; }
.ctx .body { flex: 1; min-width: 0; } .ctx .body b { color: var(--primary); display: block; }
.ctx .body span { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface2); font-size: 13px; max-width: 220px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .progress { width: 40px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.chip .progress i { display: block; height: 100%; background: var(--primary); width: 0; }
.readonly { padding: 14px; text-align: center; color: var(--muted); }
.dropzone { position: absolute; inset: 0; z-index: 5; background: color-mix(in srgb, var(--primary) 18%, transparent); border: 3px dashed var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 18px; pointer-events: none; }
.pinned-bar { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface); font-size: 13.5px; cursor: pointer; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(1, 4, 9, .6); display: grid; place-items: center; padding: 16px; animation: fade .14s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 100%; max-width: 440px; max-height: calc(var(--app-h, 100dvh) - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.dialog.wide { max-width: 640px; }
.dialog header { padding: 16px 18px 6px; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.dialog header .grow { flex: 1; }
.dialog .content { padding: 6px 18px 12px; overflow-y: auto; }
.dialog footer { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px 16px; flex-wrap: wrap; }
.menu { position: fixed; z-index: 110; min-width: 200px; max-width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; animation: fade .1s; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border: 0; background: none; border-radius: 9px; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); }
.menu .danger { color: var(--danger); } .menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; max-width: 280px; }
.emoji-row button { width: 38px; height: 38px; justify-content: center; font-size: 22px; padding: 0; }
.lightbox { background: rgba(0, 0, 0, .92); display: grid; place-items: center; padding: 0; }
.lightbox img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.lightbox .close { position: absolute; top: calc(10px + var(--sat)); right: 10px; color: #fff; background: rgba(255,255,255,.14); }
#toasts { position: fixed; z-index: 200; left: 0; right: 0; bottom: calc(20px + var(--sab)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 480px; font-size: 14px; animation: fade .15s; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- settings / pages ---------- */
.page { flex: 1; overflow-y: auto; padding: 14px 14px calc(24px + var(--sab)); -webkit-overflow-scrolling: touch; }
.page-in { max-width: 680px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 14px; overflow: hidden; }
.card h3 { margin: 0; padding: 14px 16px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.card .pad { padding: 12px 16px 16px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; min-height: 52px; }
.card > .item:first-of-type { border-top: 0; }
button.item:hover { background: var(--hover); }
.item .grow { flex: 1; min-width: 0; } .item small { display: block; color: var(--muted); }
.item.danger { color: var(--danger); }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--border); border-radius: 13px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--primary); } .switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { box-shadow: var(--focus); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; font-size: 14px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; } .seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 16px 6px; text-align: center; }
.profile-head h2 { margin: 6px 0 0; } .profile-head .sub { color: var(--muted); }
.legal { line-height: 1.6; } .legal h1 { font-size: 22px; } .legal h2 { font-size: 18px; margin-top: 24px; } .legal h3 { font-size: 16px; }
.legal table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; } .legal td, .legal th { border: 1px solid var(--border); padding: 6px 10px; }
.members .row { cursor: default; }
.tag { font-size: 11.5px; padding: 1px 8px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 700; }
.sticky-foot { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.wp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 12px 16px 16px; }
.wp-grid button { aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--border); padding: 0; } .wp-grid button[aria-pressed="true"] { border-color: var(--primary); }
.skeleton { height: 64px; margin: 8px 14px; border-radius: 12px; background: linear-gradient(90deg, var(--surface2), var(--hover), var(--surface2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Minva Winter ---------- */
html.winter .topbar, html.winter .auth-card { background-image: linear-gradient(180deg, color-mix(in srgb, #9bd7ff 12%, transparent), transparent); }
html.winter .garland { display: flex; }
.garland { display: none; position: absolute; left: 0; right: 0; top: 0; height: 8px; z-index: 4; pointer-events: none; justify-content: space-around; }
.garland i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #FF4444); box-shadow: 0 0 8px var(--c, #FF4444); animation: blink 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes blink { 50% { opacity: .35; } }
html.winter .logo, html.winter .boot-logo { box-shadow: 0 0 0 3px color-mix(in srgb, #9bd7ff 55%, transparent); }
html.winter .m.mine .bubble { background: color-mix(in srgb, var(--bubble-out) 85%, #9bd7ff); }
html.winter .unread { background: #E5484D; }
.hat { position: absolute; top: -9px; left: 22px; width: 24px; height: 18px; pointer-events: none; display: none; }
html.winter .avatar.has-hat .hat { display: block; }

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

/* ---------- adaptive ---------- */
@media (max-width: 899px) {
  .shell { display: block; }
  .shell .side, .shell .main { height: var(--app-h, 100dvh); width: 100%; }
  .shell[data-pane="chat"] .side, .shell[data-pane="chat"] .bottom-nav { display: none; }
  .shell[data-pane="list"] .main { display: none; }
  .shell[data-pane="list"] .bottom-nav { display: flex; }
  .bottom-nav { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 6px calc(4px + var(--sab)); justify-content: space-around; z-index: 5; }
  .bottom-nav button { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 11.5px; border-radius: 10px; position: relative; }
  .bottom-nav button[aria-current="page"] { color: var(--primary); }
  .shell[data-pane="list"] .list, .shell[data-pane="list"] .page { padding-bottom: calc(64px + var(--sab)); }
  .m { max-width: 88%; }
  .back-only-mobile { display: inline-grid; }
  .menu { max-width: calc(100vw - 16px); }
}
@media (min-width: 900px) {
  .back-only-mobile { display: none; }
  .topbar { padding-top: 6px; }
}
@media (min-width: 900px) and (max-width: 1100px) { .shell { grid-template-columns: 320px minmax(0, 1fr); } }
@media (max-width: 420px) { .auth-card { padding: 22px 16px; } .wp-grid { grid-template-columns: repeat(3, 1fr); } }
@media print { #snow, .composer-wrap, .bottom-nav { display: none; } }

@media (max-width: 899px) { .desk-only { display: none !important; } }

/* standalone legal documents (opened from the login / registration screens): own scroll container */
.legal-sa { display: flex; flex-direction: column; height: var(--app-h, 100dvh); max-width: 860px; margin: 0 auto; background: var(--bg); }
.legal-sa .page { min-height: 0; overscroll-behavior: contain; }

/* pinned messages */
.pinbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; font-size: 13.5px; }
.pinbar .bar { width: 3px; align-self: stretch; background: var(--primary); border-radius: 2px; }
.pinbar .body { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; color: inherit; cursor: pointer; }
.pinbar .body b { color: var(--primary); display: block; font-size: 12.5px; }
.pinbar .body span { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinmark { display: inline-flex; color: var(--muted); }

/* voice messages and video circles */
.composer .rec { color: var(--primary); touch-action: none; user-select: none; -webkit-user-select: none; }
.rec-panel { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 58px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e5484d; animation: recpulse 1.1s ease-in-out infinite; flex: none; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; }
.rec-label { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-hint { color: var(--muted); font-size: 12.5px; text-align: right; max-width: 48%; }
.rec-panel[data-locked="1"] .rec-label { flex: 1; }
.rec-preview { display: grid; place-items: center; padding: 12px 0 4px; }
.rec-preview video { width: 220px; height: 220px; object-fit: cover; border-radius: 50%; background: #000; transform: scaleX(-1); box-shadow: 0 0 0 3px #e5484d; }
@keyframes recpulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 300px; padding: 2px 0; }
.voice .play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary, #fff); display: grid; place-items: center; flex: none; cursor: pointer; }
.voice .play svg { fill: currentColor; }
.voice .wavebox { flex: 1; min-width: 0; }
.voice .wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; border-radius: 6px; }
.voice .wave:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.voice .wave i { flex: 1; min-width: 2px; background: color-mix(in srgb, var(--text) 28%, transparent); border-radius: 2px; }
.voice .wave i.on { background: var(--primary); }
.voice .row2, .vnote .row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.voice.failed .time, .vnote.failed .time { color: #e5484d; }
.rate { border: 0; border-radius: 10px; padding: 1px 7px; font-size: 11.5px; font-weight: 700; background: color-mix(in srgb, var(--text) 12%, transparent); color: inherit; cursor: pointer; }

.bubble.vn { background: transparent !important; border-color: transparent !important; box-shadow: none; padding: 0; }
.bubble.vn .meta { padding: 2px 6px 0; }
.vnote { position: relative; width: 230px; max-width: 70vw; cursor: pointer; border-radius: 50%; }
.vnote .vn-video { display: block; width: 230px; height: 230px; max-width: 70vw; max-height: 70vw; object-fit: cover; border-radius: 50%; background: #000; }
.vnote .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.vnote .ring circle { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.vnote .playmark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #fff; }
.vnote .playmark svg { width: 46px; height: 46px; fill: currentColor; filter: drop-shadow(0 1px 4px rgba(0,0,0,.6)); }
.vnote.playing .playmark { display: none; }
.vnote .row2 { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0,0,0,.5); color: #fff; border-radius: 12px; padding: 2px 8px; }
.vnote .rate { background: rgba(255,255,255,.22); }
.media-expired { display: flex; align-items: center; gap: 8px; color: var(--muted); font-style: italic; }
.meta .expiry { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }

/* holding the record button must never select text or open the system callout */
.composer .rec, .rec-panel, .rec-preview { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
body.no-select, body.no-select * { -webkit-user-select: none !important; user-select: none !important; -webkit-touch-callout: none !important; }

.birth-row { display: grid; grid-template-columns: 1fr 1.6fr 1.4fr; gap: 8px; }
.birth-row select { min-width: 0; }

/* text styles */
.m .txt code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, var(--text) 12%, transparent); }
.m .txt s { opacity: .8; }
.spoiler { border-radius: 4px; background: color-mix(in srgb, var(--text) 28%, transparent); color: transparent; cursor: pointer; user-select: none; transition: background .2s, color .2s; }
.spoiler * { color: transparent; }
.spoiler.open { background: color-mix(in srgb, var(--text) 8%, transparent); color: inherit; user-select: text; cursor: text; }
.spoiler.open * { color: inherit; }
html[data-msgfont="serif"] .m .txt, html[data-msgfont="serif"] .composer textarea { font-family: Georgia, "Times New Roman", "PT Serif", serif; font-size: 16px; }
html[data-msgfont="mono"] .m .txt, html[data-msgfont="mono"] .composer textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.composer .style-btn { width: 34px; }

/* gallery */
.gallery .tabs { margin-bottom: 10px; }
.gal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.gal-cell { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--hover); }
.gal-open { all: unset; display: block; width: 100%; height: 100%; cursor: pointer; }
.gal-open img, .gal-open video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-badge { position: absolute; left: 6px; bottom: 6px; color: #fff; background: rgba(0,0,0,.55); border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; }
.gal-go { position: absolute; right: 4px; top: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s; }
.gal-cell:hover .gal-go, .gal-cell:focus-within .gal-go { opacity: 1; }
@media (hover: none) { .gal-go { opacity: 1; } }
.gal-list { display: flex; flex-direction: column; gap: 4px; }
.gal-file { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.gal-file a { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.gal-file small { display: block; color: var(--muted); }

/* live message counter in the search view */
.row .l2 { gap: 8px; }

/* multi-account */
.acc-btn { border: 0; background: none; padding: 0; margin-right: 8px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.acc-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.acc-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.acc-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: inherit; cursor: pointer; font: inherit; }
.acc-row:hover { background: var(--surface2); }
.acc-row.active { border-color: var(--primary); }
.acc-row small { display: block; color: var(--muted); }
.acc-check { color: var(--primary); display: grid; }
.acc-foot { display: flex; flex-direction: column; gap: 2px; }
.acc-row .grow { flex: 1; min-width: 0; }

/* channels */
.m.post { max-width: min(92%, 640px); }
.m.post .bubble { border-radius: 16px; }
.handle-in { display: flex; align-items: center; gap: 4px; }
.handle-in span { color: var(--muted); font-weight: 600; }
.channel-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.row .title svg { vertical-align: -2px; margin-right: 4px; color: var(--muted); }
.readonly .btn { min-height: 40px; }

/* search panel above a chat */
.chatsearch { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.chatsearch[hidden] { display: none; }
.chatsearch .field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--muted); }
.chatsearch .field:focus-within { border-color: var(--primary); }
.chatsearch input { flex: 1; min-width: 0; border: 0; background: none; box-shadow: none; padding: 9px 0; color: var(--text); outline: none; }
.chatsearch .counter { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chatsearch.none .counter { color: var(--muted); }
.chatsearch .sl { color: var(--muted); font-weight: 400; }
.chatsearch .icon-btn:disabled { opacity: .35; }
.roll { display: inline-flex; line-height: 1.25em; }
.roll .dg { display: inline-block; height: 1.25em; width: .62em; overflow: hidden; text-align: center; transition: width .25s ease, opacity .25s ease; }
.roll .dg.enter, .roll .dg.leave { width: 0; opacity: 0; }
.roll .strip { display: block; transition: transform .38s cubic-bezier(.2, .8, .2, 1); }
.roll .strip span { display: block; height: 1.25em; }
.roll.still .dg, .roll.still .strip { transition: none; }
::highlight(minva-search) { background: color-mix(in srgb, #ffd54a 70%, transparent); color: inherit; }
@media (prefers-reduced-motion: reduce) { .roll .dg, .roll .strip { transition: none; } }
.chatsearch .field input.input { border: 0; background: none; box-shadow: none; outline: none; min-height: 0; height: auto; border-radius: 0; }
.chatsearch .field input.input:focus { border: 0; box-shadow: none; outline: none; }

/* full-screen photo viewer and photo editor */
.overlay.viewer-ov { background: rgba(0, 0, 0, .94); padding: 0; place-items: stretch; display: block; }
.viewer { position: absolute; inset: 0; display: flex; flex-direction: column; color: #fff; }
.viewer .v-head { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--sat)) 10px 8px 8px; background: linear-gradient(180deg, rgba(0,0,0,.65), transparent); z-index: 2; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.14); }
.viewer .v-who { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.viewer .v-who b, .viewer .v-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .v-who small { opacity: .7; }
.viewer .v-count { font-size: 13px; opacity: .8; padding: 0 6px; white-space: nowrap; }
.v-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; user-select: none; }
.v-img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .12s ease-out; will-change: transform; cursor: zoom-in; }
.v-stage.zoomed .v-img { cursor: grab; transition: none; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.45); z-index: 2; }
.v-nav.prev { left: 10px; } .v-nav.next { right: 10px; } .v-nav.next svg { transform: rotate(180deg); }
.v-nav:disabled { opacity: .25; }
.v-cap { padding: 12px 18px calc(14px + var(--sat)); background: linear-gradient(0deg, rgba(0,0,0,.7), transparent); max-height: 32vh; overflow: auto; z-index: 2; }
.v-cap .txt { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.v-cap a { color: #8fd0ff; }
.overlay.pe { background: #0b0d10; display: block; }
.pe-box { position: absolute; inset: 0; display: flex; flex-direction: column; color: #fff; }
.pe-box .icon-btn { color: #fff; } .pe-box .icon-btn:hover { background: rgba(255,255,255,.14); }
.pe-head { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--sat)) 10px 8px 8px; }
.pe-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; overflow: hidden; }
.pe-wrap { position: relative; display: inline-block; line-height: 0; max-width: 100%; max-height: 100%; }
.pe-canvas { max-width: 100%; max-height: calc(100dvh - 300px); touch-action: none; background: #222; }
.pe-crop { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); touch-action: none; cursor: move; }
.pe-crop i { position: absolute; background: rgba(255,255,255,.35); pointer-events: none; }
.pe-crop .g1 { left: 33.3%; top: 0; bottom: 0; width: 1px; } .pe-crop .g2 { left: 66.6%; top: 0; bottom: 0; width: 1px; }
.pe-crop .g3 { top: 33.3%; left: 0; right: 0; height: 1px; } .pe-crop .g4 { top: 66.6%; left: 0; right: 0; height: 1px; }
.pe-crop .hd { position: absolute; width: 22px; height: 22px; background: transparent; }
.pe-crop .hd::after { content: ''; position: absolute; inset: 6px; background: #fff; border-radius: 3px; }
.pe-crop .nw { left: -11px; top: -11px; cursor: nwse-resize; } .pe-crop .ne { right: -11px; top: -11px; cursor: nesw-resize; }
.pe-crop .sw { left: -11px; bottom: -11px; cursor: nesw-resize; } .pe-crop .se { right: -11px; bottom: -11px; cursor: nwse-resize; }
.pe-crop .n { left: calc(50% - 11px); top: -11px; cursor: ns-resize; } .pe-crop .s { left: calc(50% - 11px); bottom: -11px; cursor: ns-resize; }
.pe-crop .w { top: calc(50% - 11px); left: -11px; cursor: ew-resize; } .pe-crop .e { top: calc(50% - 11px); right: -11px; cursor: ew-resize; }
.pe-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; padding: 8px 12px; }
.pe-modes { display: flex; gap: 4px; }
.pe-modes .icon-btn.on { background: var(--primary); }
.pe-extra { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.pe-colors { display: flex; gap: 6px; }
.pe-color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); cursor: pointer; padding: 0; }
.pe-color.on { border-color: #fff; transform: scale(1.18); }
.chip-btn { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; border-radius: 14px; padding: 4px 12px; cursor: pointer; font: inherit; }
.chip-btn.on { background: #fff; color: #111; }
.pe-foot { display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(12px + var(--sat)); flex-wrap: wrap; }
.pe-foot .input { flex: 1; min-width: 160px; }
.pe-actions { display: flex; gap: 8px; }
.menu { z-index: 400; }
.overlay.viewer-ov { background: rgba(0, 0, 0, .97); }
.pe-foot .btn:not(.primary), .viewer .btn:not(.primary) { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); }

/* ---------- music panel ---------- */
.music-bar { position: relative; display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; overflow: hidden; }
.music-bar[hidden] { display: none; }
.music-bar .bar-body { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 2px; color: inherit; cursor: pointer; }
.music-bar .bar-body b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-bar .bar-body span { display: block; font-size: 12px; color: var(--muted); }
.music-bar .bar-prog { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--primary); transform-origin: left; transform: scaleX(0); transition: transform .25s linear; }
.pp { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary, #fff); display: grid; place-items: center; flex: none; cursor: pointer; padding: 0; }
.pp .pp-svg { width: 20px; height: 20px; fill: currentColor; stroke: none; overflow: visible; }
.pp .pp-svg path { transform-box: fill-box; transform-origin: center; transition: opacity .22s ease, transform .22s ease; }
.pp .pp-play { opacity: 1; transform: scale(1); }
.pp .pp-l, .pp .pp-r { opacity: 0; transform: scaleY(.3); }
.pp.is-playing .pp-play { opacity: 0; transform: scale(.4) rotate(-45deg); }
.pp.is-playing .pp-l, .pp.is-playing .pp-r { opacity: 1; transform: scaleY(1); }
.pp:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tracks { display: grid; gap: 2px; max-height: 60vh; overflow: auto; }
.track, .trackfile { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; }
.track.cur { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.trackfile { border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 70%, transparent); margin: 3px 0; max-width: 300px; min-width: 220px; padding: 6px 4px 6px 8px; }
.trackfile.cur { border-color: var(--primary); }
.track .tt, .trackfile .tt { flex: 1; min-width: 0; }
.track .tt b, .trackfile .tt b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .tt small, .trackfile .tt small { color: var(--muted); }
.trackfile .tsave.on { color: var(--primary); }
.trackfile .tsave.on svg { fill: color-mix(in srgb, var(--primary) 25%, transparent); }
@media (min-width: 900px) { .side .music-bar.side-bar { display: none; } }

.icon-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.icon-opt { display: grid; justify-items: center; gap: 4px; padding: 8px; border: 2px solid transparent; border-radius: 14px; background: none; color: inherit; font-size: 12px; cursor: pointer; }
.icon-opt img { border-radius: 14px; }
.icon-opt.on { border-color: var(--primary); }
.icon-opt:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.item.col { flex-direction: column; align-items: flex-start; }

/* ---------- discussions ---------- */
.topics { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: auto; }
.topics[hidden] { display: none; }
.disc-head { padding: 8px 12px; display: grid; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.topic-chip { border: 1px solid var(--border); background: transparent; color: inherit; border-radius: 14px; padding: 4px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.topic-chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary, #fff); }
.topic-chip.sort { margin-left: auto; color: var(--muted); }
.cat-badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); margin-left: 6px; flex: none; }

.bot-note { padding: 6px 12px; font-size: 12px; color: var(--muted); text-align: center; border-top: 1px solid var(--border); }
.bot-note[hidden] { display: none; }

/* ---------- responsive hardening (phones, tablets, laptops) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; }
img, video, canvas, svg { max-width: 100%; }
.overlay { padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); }
.dialog header { min-width: 0; overflow-wrap: anywhere; }
.dialog header .grow { min-width: 0; }
.dialog .content { overflow-wrap: anywhere; min-height: 0; }
.dialog footer .btn { flex: 1 1 auto; }
.card h3, .item .grow, .profile-head h2, .profile-head .sub { overflow-wrap: anywhere; }
.item { flex-wrap: wrap; }
.item .grow { flex: 1 1 140px; }
.seg { max-width: 100%; flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-height: 36px; }
.item:has(> .seg) .seg { flex: 1 1 100%; }
@media (min-width: 560px) { .item:has(> .seg) .seg { flex: 0 1 auto; margin-left: auto; } }
.att-img { width: auto; height: auto; object-fit: contain; }
.att-media, .att-img { max-width: min(100%, 320px); }
.m > div, .m .bubble { min-width: 0; }
.m .txt { overflow-wrap: anywhere; }
.bubble pre, .bubble table { max-width: 100%; overflow-x: auto; }
.msgs { scroll-padding-bottom: 12px; }
.topbar .btn, .topbar .icon-btn { flex: none; }
.main > .topbar h2, .main .topbar .title { min-width: 0; }
.wallpaper { min-width: 0; }
.composer { padding-left: max(8px, var(--sal)); padding-right: max(8px, var(--sar)); }
.composer textarea { min-width: 0; font-size: 16px; }
input, select, textarea { font-size: max(16px, 1em); }
@media (max-width: 899px) {
  .m, .m.post { max-width: 92%; }
  .jump { bottom: calc(76px + var(--sab)); }
  .kbd .bottom-nav { display: none !important; }
  .kbd .composer-wrap { padding-bottom: 0; }
  .kbd #toasts { bottom: 12px; }
  .row .snip { font-size: 13.5px; }
  .topbar { padding-left: max(14px, var(--sal)); padding-right: max(10px, var(--sar)); }
  .shell { padding-left: 0; padding-right: 0; }
  .shell .side, .shell .main { padding-left: var(--sal); padding-right: var(--sar); box-sizing: border-box; }
}
@media (max-width: 380px) {
  .topbar h2 { font-size: 16.5px; }
  .dialog { border-radius: 14px; }
  .dialog header { padding: 14px 14px 4px; } .dialog .content { padding: 6px 14px 10px; } .dialog footer { padding: 8px 14px 14px; }
  .page { padding-left: 10px; padding-right: 10px; }
  .item { padding: 11px 12px; }
  .card h3 { padding-left: 12px; padding-right: 12px; }
}
@media (orientation: landscape) and (max-height: 480px) {
  .topbar { min-height: 44px; padding-top: calc(3px + var(--sat)); padding-bottom: 3px; }
  .bottom-nav button { padding: 3px 0; }
  .shell[data-pane="list"] .list, .shell[data-pane="list"] .page { padding-bottom: calc(52px + var(--sab)); }
  .msgs { padding-top: 6px; }
  .dialog { max-height: calc(var(--app-h, 100dvh) - 16px); }
}
@media (min-width: 1500px) { .shell { grid-template-columns: 420px minmax(0, 1fr); } .m { max-width: min(70%, 680px); } }

/* ---------- accessibility: text size, high contrast, shortcuts list ---------- */
html[data-textsize="large"] { --ts: 1.15; } html[data-textsize="xlarge"] { --ts: 1.32; }
html[data-textsize] body { font-size: calc(15px * var(--ts, 1)); }
html[data-textsize] .row .snip { font-size: calc(14px * var(--ts, 1)); }
html[data-textsize] .row .time, html[data-textsize] .item small, html[data-textsize] .hint { font-size: calc(12.5px * var(--ts, 1)); }
html[data-textsize] .composer textarea { font-size: max(16px, calc(15px * var(--ts, 1))); }
html[data-textsize] .btn, html[data-textsize] .seg button, html[data-textsize] .menu button, html[data-textsize] .tab { font-size: calc(14px * var(--ts, 1)); }
html[data-textsize] .topbar h2 { font-size: calc(18px * var(--ts, 1)); }
html[data-textsize] .bubble .meta, html[data-textsize] .m .who { font-size: calc(12.5px * var(--ts, 1)); }
html[data-contrast="high"] { --text: #000; --muted: #2b3138; --border: #6e7781; --primary: #00598a; --link: #003f66; --bubble-in: #fff; --bubble-out: #bfe4f7; --focus: 0 0 0 3px #000; --danger: #a40e19; --ok: #00704a; }
html[data-contrast="high"][data-theme="dark"] { --text: #fff; --muted: #d0d7de; --border: #8b949e; --primary: #3fb4f2; --link: #79c8f6; --bubble-in: #0d1117; --bubble-out: #08507a; --focus: 0 0 0 3px #fff; --danger: #ff7b72; --ok: #3ddc97; }
html[data-contrast="high"] .bubble, html[data-contrast="high"] .card, html[data-contrast="high"] .row { border-width: 2px; }
html[data-contrast="high"] .send, html[data-contrast="high"] .btn.primary, html[data-contrast="high"] .seg button[aria-pressed="true"] { color: #fff; }
html[data-contrast="high"][data-theme="dark"] .send, html[data-contrast="high"][data-theme="dark"] .btn.primary, html[data-contrast="high"][data-theme="dark"] .seg button[aria-pressed="true"] { color: #000; }
.hk-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 4px 0; align-items: center; }
.hk-list dt, .hk-list dd { margin: 0; }
kbd { font: 600 12.5px ui-monospace, Menlo, Consolas, monospace; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); white-space: nowrap; }

/* ---------- staff, reports, PIN lock ---------- */
.tag.staff-owner { background: color-mix(in srgb, #E3B341 28%, transparent); color: #8a6500; }
.tag.staff-coowner { background: color-mix(in srgb, #FF8A3D 24%, transparent); color: #a14a00; }
.tag.staff-admin { background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary); }
.tag.staff-moderator { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
:root[data-theme="dark"] .tag.staff-owner { color: #F2CC60; } :root[data-theme="dark"] .tag.staff-coowner { color: #FFB27A; }
.rep-quote { margin: 0; padding: 6px 10px; border-left: 3px solid var(--border); background: var(--surface2); border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.pin-lock { position: fixed; inset: 0; z-index: 500; background: var(--bg); display: grid; place-items: center; padding: calc(16px + var(--sat)) 16px calc(16px + var(--sab)); overflow-y: auto; }
.pin-box { width: 100%; max-width: 320px; display: grid; gap: 12px; text-align: center; justify-items: center; }
.pin-box > * { width: 100%; } .pin-box .logo { width: 52px; margin: 0 auto; } .pin-box h2 { margin: 0; }
.pin-input { text-align: center; font-size: 22px; letter-spacing: .4em; }

/* ---- stage 3: message tools -------------------------------------------------------------- */
.m .txt .rich-code { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--text) 8%, transparent); font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-x: auto; max-width: 100%; word-break: normal; }
.m .txt .rich-list { margin: 2px 0; padding-left: 22px; white-space: normal; }
.m .txt .rich-list li { margin: 1px 0; white-space: pre-wrap; }
.m .txt .rich-link { color: var(--link); text-decoration: underline; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; word-break: break-word; text-align: left; }
.edited-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline dotted; opacity: .85; }
.ttlmark { display: inline-flex; align-items: center; color: var(--muted); }
.hist-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.hist-row .txt { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.hist-row.now .txt { font-weight: 600; }

/* selecting several messages */
.selbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; flex-wrap: wrap; }
.selbar[hidden] { display: none; }
.selbar .btn { min-height: 38px; padding: 0 10px; gap: 6px; }
.selbar .btn.danger { color: var(--danger); }
.selbar .grow { flex: 1 1 80px; min-width: 0; padding: 0 6px; }
.m.selectable { cursor: pointer; align-items: center; max-width: 100%; width: 100%; padding-inline: 6px; }
.m.selectable .bubble { max-width: min(78%, 620px); pointer-events: none; }
.m.selectable.mine { justify-content: flex-start; align-self: stretch; flex-direction: row-reverse; }
.m.selectable.mine .bubble { margin-left: auto; margin-right: 0; }
.m.selectable .selbox { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: transparent; background: var(--surface); }
.m.selectable.picked .selbox { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.m.selectable.picked .bubble { outline: 2px solid var(--primary); }

/* folders and search filters */
.folders { display: flex; gap: 6px; padding: 6px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
.folders::-webkit-scrollbar { display: none; }
.folders[hidden], .sfilters[hidden] { display: none; }
.fchip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.fchip[aria-selected="true"], .fchip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.fchip.add { padding: 0 9px; color: var(--muted); }
.fchip.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.searchbox { display: flex; align-items: center; gap: 6px; }
.searchbox .input { flex: 1; min-width: 0; }
.searchbox .icon-btn.on { color: var(--primary); }
.sfilters { padding: 8px 12px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; background: var(--surface); }
.sfilters .kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.sfilters .drow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sfilters .dfield { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); flex: 1 1 130px; min-width: 0; }
.sfilters .dfield .input { min-height: 38px; }

/* chat colour labels */
.cdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex: none; vertical-align: middle; background: var(--muted); }
.c-red { --c: #E5484D; } .c-orange { --c: #F76B15; } .c-yellow { --c: #E5B800; } .c-green { --c: #30A46C; } .c-blue { --c: #0091FF; } .c-purple { --c: #8E4EC6; } .c-pink { --c: #E93D82; }
.cdot[class*="c-"], .swatch[class*="c-"] { background: var(--c); }
.swatches { display: flex; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.menu .swatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid transparent; justify-content: center; color: #fff; }
.menu .swatch[aria-pressed="true"] { border-color: var(--text); }
.menu-note { padding: 6px 12px 0; font-size: 12px; color: var(--muted); }
/* in dialogs a segmented control may need several lines on a narrow phone */
.dialog .seg { display: flex; flex-wrap: wrap; width: 100%; }
.dialog .seg button { flex: 1 1 auto; }

/* ---- Stage 4: community, polls, comments, ideas ---- */
.poll { min-width: min(280px, 72vw); display: grid; gap: 6px; padding: 2px 0; }
.poll-q { display: flex; gap: 8px; align-items: flex-start; } .poll-q b { overflow-wrap: anywhere; }
.poll-opts { display: grid; gap: 6px; }
.poll-opt { position: relative; display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 6px 10px; text-align: left; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: inherit; }
.poll-opt .bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--primary) 18%, transparent); transition: width .3s; pointer-events: none; }
.poll-opt.mine { border-color: var(--primary); }
.poll-opt .mark { position: relative; width: 20px; height: 20px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--muted); color: var(--primary-ink); }
.poll-opt.mine .mark { background: var(--primary); border-color: var(--primary); }
.poll-opt .txt { position: relative; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.poll-opt .pct { position: relative; font-size: 12px; color: var(--muted); flex: none; }
.poll-opt:disabled { opacity: .85; cursor: default; }
.poll-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 12px; color: var(--muted); }
.linklike { background: none; border: 0; padding: 4px 0; color: var(--link); text-decoration: underline; font: inherit; min-height: 28px; }
.comments-btn { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; padding: 6px 10px; min-height: 34px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--link); font-weight: 600; }
.views { display: inline-flex; gap: 3px; align-items: center; }
.cemoji { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; }
.emoji-row .cemoji { width: 24px; height: 24px; }
.comments { display: grid; gap: 8px; max-height: 45vh; overflow-y: auto; margin-bottom: 10px; }
.comment { padding: 8px 10px; border-radius: 12px; background: var(--surface2); overflow-wrap: anywhere; }
.comment-post { padding: 8px 10px; margin-bottom: 8px; border-left: 3px solid var(--primary); color: var(--muted); border-radius: 4px; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; } .comment-form .input { flex: 1; }
.rules-text { white-space: pre-wrap; padding: 10px 12px; margin: 6px 0; border-radius: 10px; background: var(--surface2); max-height: 38vh; overflow-y: auto; overflow-wrap: anywhere; }
.check-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.emoji-item { display: inline-flex; gap: 6px; align-items: center; padding: 4px 8px; border-radius: 10px; background: var(--surface2); }
.emoji-item img { object-fit: contain; }
.code-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; } .code-line code { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; padding: 8px; border-radius: 8px; background: var(--surface2); font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.community { display: grid; gap: 12px; align-content: start; }
.community-tabs { display: flex; }
.community .card.pad h3 { margin: 0 0 8px; } .community h4 { margin: 4px 0; }
.disc-row { display: flex; align-items: center; border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent); }
.disc-row .row { border-bottom: 0; flex: 1; min-width: 0; }
.disc-row .like { display: inline-flex; gap: 4px; align-items: center; margin-right: 8px; min-width: 44px; min-height: 44px; justify-content: center; border: 0; background: none; color: var(--muted); border-radius: 10px; }
.disc-row .like.on { color: var(--danger); }
.idea { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent); }
.idea .vote { display: grid; justify-items: center; gap: 2px; min-width: 48px; min-height: 52px; align-content: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: inherit; }
.idea .vote.on { border-color: var(--primary); color: var(--primary); }
.idea .body { flex: 1; min-width: 0; overflow-wrap: anywhere; } .idea .title { font-weight: 650; }
.idea-status { margin-left: 8px; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--surface2); color: var(--muted); }
.idea-status.s-planned { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--link); }
.idea-status.s-done { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.idea-controls { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 520px) { .poll { min-width: 0; width: 100%; } .comment-form { flex-direction: column; align-items: stretch; } }

/* ---- Stage 5: albums, player controls ---- */
.album { display: grid; gap: 3px; width: min(100%, 320px); margin: 2px 0; border-radius: 12px; overflow: hidden; grid-template-columns: repeat(2, 1fr); }
.album .att-img { width: 100%; height: 100%; max-width: none; max-height: none; aspect-ratio: 1; object-fit: cover; margin: 0; border-radius: 0; }
.album.n3 .att-img:first-child { grid-column: 1 / -1; aspect-ratio: 2 / 1; }
.album.n5, .album.n6 { grid-template-columns: repeat(3, 1fr); }
.music-bar .bar-skip { flex: none; } .music-bar .bar-skip[hidden] { display: none; }
.player-ctl { display: grid; gap: 6px; padding: 4px 4px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.player-ctl[hidden] { display: none; }
.player-ctl .np-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seek-row { display: flex; align-items: center; gap: 8px; color: var(--muted); } .seek-row small { min-width: 38px; text-align: center; font-variant-numeric: tabular-nums; }
.seek { flex: 1; min-width: 0; accent-color: var(--primary); height: 28px; }
.ctl-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.big-pp { width: 48px; height: 48px; flex: none; }
.ctl-row .icon-btn.active { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.ctl-row .icon-btn:disabled { opacity: .4; }
.trackfile .tq { flex: none; }
.up-progress { height: 4px; border-radius: 3px; background: color-mix(in srgb, var(--text) 14%, transparent); overflow: hidden; margin-top: 6px; }
.up-progress i { display: block; height: 100%; background: var(--primary); transition: width .25s; }
.queued-note { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- bots: buttons, link cards, command menu, developer page ---- */
.bkb { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; min-width: min(220px, 100%); }
.bkb-row { display: flex; gap: 4px; }
.bkb-btn { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--primary); font: inherit; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; overflow-wrap: anywhere; }
.bkb-btn:hover { background: color-mix(in srgb, var(--primary) 12%, var(--surface2)); }
.bkb-btn:disabled, .bkb-btn.busy { opacity: .6; cursor: progress; }
.link-card { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 8px 10px; border-left: 3px solid var(--primary); border-radius: 6px; background: color-mix(in srgb, var(--text) 6%, transparent); color: inherit; text-decoration: none; max-width: 100%; overflow: hidden; }
.link-card .lc-site { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.link-card .lc-title { font-weight: 600; overflow-wrap: anywhere; }
.link-card .lc-desc { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cmd-menu { max-height: 40vh; overflow-y: auto; border-bottom: 1px solid var(--border); background: var(--surface); }
.cmd-menu[hidden] { display: none; }
.cmd-menu .cmd { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left; padding: 8px 12px; min-height: 40px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; flex-wrap: wrap; }
.cmd-menu .cmd:hover, .cmd-menu .cmd.on { background: var(--surface2); }
.cmd-menu .cmd-d { color: var(--muted); font-size: 13px; flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.cmd-menu small { color: var(--muted); }
.dev { max-width: 760px; }
.dev-sec { margin-bottom: 12px; }
.dev .code { margin: 8px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface2); font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; max-width: 100%; white-space: pre; }
.dev .dev-out { min-height: 60px; max-height: 50vh; overflow: auto; }
.dev-methods { padding-left: 18px; } .dev-methods li { margin: 4px 0; overflow-wrap: anywhere; }
.dev code { overflow-wrap: anywhere; }
