/* aiopro: calm, document-like UI. System fonts only (the CSP allows no third-party assets). */

:root {
  color-scheme: light dark;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --border: #e3dfd4;
  --text: #1c2321;
  --muted: #66706b;
  --accent: #0f6b62;
  --accent-hover: #0b5750;
  --accent-soft: #dff1ed;
  --on-accent: #ffffff;
  --mine: #0f6b62;
  --on-mine: #ffffff;
  --theirs: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-soft: #fdf3d8;
  --ok-soft: #e2f4e6;
  --shadow: 0 8px 28px rgb(20 30 28 / 0.14);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1413;
    --surface: #162120;
    --surface-2: #1b2928;
    --border: #2a3a37;
    --text: #e7eeeb;
    --muted: #93a39e;
    --accent: #3cc9b6;
    --accent-hover: #5fdbc9;
    --accent-soft: #17332f;
    --on-accent: #06201c;
    --mine: #1f7a6f;
    --on-mine: #f2fffc;
    --theirs: #1d2c2a;
    --danger: #ff8a7d;
    --danger-soft: #3a1d1a;
    --warn-soft: #3a3015;
    --ok-soft: #173321;
    --shadow: 0 8px 28px rgb(0 0 0 / 0.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
ul, ol { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.noscript { padding: 24px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { display: flex; justify-content: center; padding: 12px 0; }
.icon { width: 20px; height: 20px; flex: none; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--danger); border-color: var(--danger); }
.btn-danger-quiet { color: var(--danger); }
.btn.grow { flex: 1; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  background: transparent; border: 0; border-radius: 10px; color: var(--muted); position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; font-size: 18px; }

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700;
}
.bell .badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; font-size: 11px; }
.btn .badge { margin-left: 2px; }

/* -------------------------------------------------------------------- forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label, .label-row label, legend { font-weight: 600; font-size: 14px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
input:not([type=checkbox]):not([type=file]), textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--danger); }
.hint { color: var(--muted); font-size: 13px; }
.hint.inline { margin-left: 4px; }
.hint.pad { padding: 12px 16px; }
.field-error, .form-error { color: var(--danger); font-size: 13px; font-weight: 600; }
.form-error { background: var(--danger-soft); padding: 10px 12px; border-radius: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.form-actions.left { justify-content: flex-start; }
.field-check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.checks { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; max-height: 260px; overflow: auto; min-width: 0; }
.checks legend { padding: 0 6px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.check-row input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check-row label { font-weight: 500; }
.secret { display: block; padding: 14px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; font: 600 18px var(--mono); letter-spacing: .04em; text-align: center; user-select: all; word-break: break-all; }

.callout { padding: 14px 16px; border-radius: 12px; display: grid; gap: 10px; }
.callout-ok { background: var(--ok-soft); }
.callout-warn { background: var(--warn-soft); }

/* ---------------------------------------------------------------- tabs / seg */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg-btn { background: none; border: 0; border-radius: 8px; padding: 6px 14px; font-weight: 600; text-transform: capitalize; color: var(--muted); }
.seg-btn[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

/* ------------------------------------------------------------- brand / auth */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 8px 7px 9px; border-radius: 4px 4px 4px 1px; background: var(--on-accent); opacity: .92; }

.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(300px, 5fr) minmax(360px, 6fr); }
.auth-aside {
  padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background: linear-gradient(160deg, #0c4a44 0%, #0f6b62 60%, #14877b 100%); color: #f1fbf9;
}
.auth-aside .brand-mark { background: #f1fbf9; }
.auth-aside .brand-mark::after { background: #0f6b62; }
.auth-pitch { max-width: 30rem; display: grid; gap: 14px; }
.auth-pitch h1 { font-size: clamp(26px, 3.2vw, 40px); line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.auth-pitch p { color: #c8e8e3; font-size: 16px; }
.auth-main { display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 440px; display: grid; gap: 18px; }
.auth-card h2 { font-size: 24px; letter-spacing: -.01em; }
.auth-card .tabs { margin-bottom: 2px; }
.auth-flow { display: grid; gap: 16px; }
.auth-flow h2 { margin-top: 4px; }
.auth-alt { text-align: center; }
.auth-alt .link-btn { font-size: 14px; }
.steps { display: grid; gap: 14px; margin: 4px 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--muted); }
.steps li div { display: grid; }
.steps li span:not(.step-dot) { font-size: 13px; }
.step-dot { width: 14px; height: 14px; margin-top: 5px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.steps .done .step-dot { background: var(--accent); border-color: var(--accent); }
.steps .current { color: var(--text); }
.steps .current .step-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.boot-error { max-width: 420px; margin: 20vh auto; padding: 24px; display: grid; gap: 12px; text-align: center; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: minmax(300px, 360px) 1fr; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; position: relative; }
.me { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); line-height: 1.25; }
.me strong, .me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { color: var(--muted); font-size: 13px; }
.sidebar-actions { display: flex; gap: 8px; padding: 4px 16px 12px; }
.sidebar-actions .btn { white-space: nowrap; padding-inline: 12px; }
.conv-nav { flex: 1; overflow-y: auto; border-top: 1px solid var(--border); }
.conv-empty { padding: 28px 20px; display: grid; gap: 6px; text-align: center; }
.conv {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
}
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
/* minmax(0,1fr): grid items otherwise refuse to shrink below their text, so ellipsis never kicks in */
.conv-text { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.conv-top, .conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { color: var(--muted); font-size: 12px; flex: none; }
.conv-preview { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
}
.avatar-group { border-radius: 12px; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.empty { margin: auto; padding: 24px; text-align: center; display: grid; gap: 6px; color: var(--muted); }
.empty h2 { color: var(--text); }

/* popovers */
.popover-host { position: absolute; right: 8px; top: 100%; z-index: 20; }
.popover { width: min(340px, calc(100vw - 24px)); max-height: 70dvh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu { display: grid; padding: 6px; }
.menu-id { padding: 10px 12px; display: grid; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-id span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.menu-item { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; }
.menu-item:hover { background: var(--surface-2); }
.notes-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.note { display: grid; gap: 2px; width: 100%; text-align: left; padding: 12px 16px; background: none; border: 0; border-bottom: 1px solid var(--border); }
.note:hover { background: var(--surface-2); }
.note.unread { background: var(--accent-soft); }
.note span { color: var(--muted); font-size: 13.5px; }
.note time { color: var(--muted); font-size: 12px; }
.people { display: grid; max-height: 50dvh; overflow-y: auto; margin: 0 -4px; }
.people .conv { border-radius: 10px; border: 0; }

/* ------------------------------------------------------------------ thread */
.thread, .admin { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.thread-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 64px; }
.thread-title { min-width: 0; }
.thread-title h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title p { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; margin-left: -8px; }
.thread-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 4vw, 40px); display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.messages:focus-visible { outline-offset: -2px; }
.load-more { align-self: center; margin-top: 8px; }
.empty-thread { margin: auto; color: var(--muted); text-align: center; padding: 24px; }
.day { display: flex; justify-content: center; margin: 14px 0 6px; }
.day span { background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 600; padding: 3px 12px; border-radius: 999px; }
.msg { max-width: min(560px, 82%); align-self: flex-start; background: var(--theirs); border: 1px solid var(--border); padding: 8px 12px; border-radius: 14px 14px 14px 4px; display: grid; gap: 4px; }
.msg.mine { align-self: flex-end; background: var(--mine); border-color: transparent; color: var(--on-mine); border-radius: 14px 14px 4px 14px; }
.msg.mine a { color: inherit; }
.msg.deleted .msg-body { font-style: italic; color: var(--muted); }
.msg.mine.deleted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.msg-author { font-size: 13px; font-weight: 700; color: var(--accent); display: flex; gap: 6px; align-items: center; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.msg-files { display: grid; gap: 6px; }
.msg-meta { display: flex; justify-content: flex-end; gap: 10px; font-size: 11.5px; opacity: .75; }
.msg-meta .link-btn { color: inherit; font-size: 11.5px; }
.msg-meta { align-items: center; }
.ticks { display: inline-flex; align-items: center; line-height: 0; background: none; border: 0; padding: 2px; margin: -2px; color: inherit; cursor: pointer; border-radius: 6px; }
.ticks:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.ticks .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.ticks-sent, .ticks-delivered { opacity: .8; }
.ticks-seen { color: #8fdcff; opacity: 1; }
.tag { display: inline-block; margin-left: 6px; padding: 0 7px; font-size: 11px; font-weight: 700; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.att-img img { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; background: var(--surface-2); }
.att-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgb(0 0 0 / .06); color: inherit; text-decoration: none; }
.msg:not(.mine) .att-file { background: var(--surface-2); }
.att-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; flex: none; }
.att-meta { display: grid; min-width: 0; }
.att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 12px; opacity: .75; }
.drop-hint { position: absolute; inset: 8px; display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 88%, transparent); font-weight: 700; color: var(--accent); pointer-events: none; }

.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 10px clamp(10px, 3vw, 24px) calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; border-radius: 22px; padding: 10px 16px; line-height: 1.4; }
.composer .send { border-radius: 22px; min-height: 44px; }
.tray { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; flex: none; max-width: 260px; }
.chip img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; }
.chip-icon { font-size: 20px; color: var(--muted); }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.chip-size { color: var(--muted); font-size: 12px; flex: none; }

/* ------------------------------------------------------------------- admin */
.admin-tabs { background: var(--surface); padding: 0 12px; }
.admin-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px clamp(12px, 4vw, 40px) 40px; width: 100%; max-width: 920px; margin: 0 auto; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 220px; width: auto; }
.toolbar select { width: auto; min-width: 140px; }
.cards { display: grid; gap: 10px; }
.card { display: grid; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.card-btn:hover { border-color: var(--accent); }
.card-row { display: flex; align-items: center; gap: 12px; }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-title { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.card-title span { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.card-title h3 { font-size: 18px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.empty-note { padding: 28px 12px; text-align: center; color: var(--muted); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pill { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill-approved { background: var(--ok-soft); color: #1d7a37; border-color: transparent; }
.pill-pending { background: var(--warn-soft); color: #8a6100; border-color: transparent; }
.pill-rejected, .pill-suspended { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill-role { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
@media (prefers-color-scheme: dark) { .pill-approved { color: #7be39a; } .pill-pending { color: #f0c860; } }
.perm-list { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-chip { font: 12px var(--mono); padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.log { display: grid; }
.log-row { display: grid; gap: 2px; padding: 10px 4px; border-bottom: 1px solid var(--border); }

/* ------------------------------------------------------------------ dialog */
.dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: auto; }
.dialog-wide { width: min(640px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(8 14 13 / .55); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 16px 4px 20px; }
.dialog-head h2 { font-size: 18px; }
.dialog-desc { padding: 0 20px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.dialog-body { padding: 16px 20px 20px; }

/* ------------------------------------------------------------------- toasts */
#toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: #1c2321; color: #f2f6f4; box-shadow: var(--shadow); font-weight: 500; pointer-events: auto; animation: rise .18s ease-out; }
.toast-error { background: #8f1d14; }
.toast-success { background: #135c43; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------- small screens */
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { padding: 20px 20px 24px; gap: 14px; }
  .auth-pitch h1 { font-size: 22px; }
  .auth-pitch p { display: none; }
  .auth-main { align-items: start; padding-top: 24px; }

  .shell { grid-template-columns: 1fr; }
  .shell[data-pane=list] .main { display: none; }
  .shell[data-pane=main] .sidebar { display: none; }
  .back { display: inline-grid; }
  input:not([type=checkbox]):not([type=file]), textarea, select { font-size: 16px; } /* stops iOS zooming on focus */
  .msg { max-width: 90%; }
  .card-head { flex-wrap: wrap; }
  .card-head .pills { justify-content: flex-start; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------ message info */
.receipts { display: grid; gap: 16px; }
.receipt-group h3 { font-size: 14px; margin-bottom: 6px; }
.receipt-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.receipt-group li { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

/* ------------------------------------------------- group photo and info */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-xl { width: 96px; height: 96px; font-size: 32px; }
.avatar-xl .icon { width: 44px; height: 44px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.thread-info-btn { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; background: none; border: 0; padding: 4px 8px; margin: -4px -8px; border-radius: 10px; text-align: left; color: inherit; cursor: pointer; }
.thread-info-btn:hover { background: var(--accent-soft); }
.thread-info-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info { display: grid; gap: 16px; }
.info-head { display: grid; justify-items: center; gap: 6px; text-align: center; }
.info-head h3 { font-size: 20px; overflow-wrap: anywhere; }
.info-about h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.info-desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.media-tile { position: relative; display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--accent-soft); }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-file { display: grid; place-content: center; gap: 4px; text-align: center; padding: 6px; color: var(--accent); text-decoration: none; font-weight: 700; }
.media-file small { font-weight: 400; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-list { display: grid; gap: 4px; }
.info-link { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; min-width: 0; }
.info-link:hover { background: var(--accent-soft); }
.info-row { min-width: 0; display: grid; }
.info-row-text { display: grid; min-width: 0; }
.info-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.info-row span { color: var(--muted); font-size: 13px; }
.load-more-info { justify-self: center; margin-top: 8px; }
.card-head .avatar-lg { border-radius: 14px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------ emoji & stickers */
.emoji-toggle[aria-expanded=true] { background: var(--accent-soft); color: var(--accent); }
.emoji-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; display: flex; flex-direction: column; max-height: min(300px, 42vh); }
.emoji-panel[hidden] { display: none; }
.emoji-tabs { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); }
.emoji-tab { background: none; border: 0; border-radius: 8px; padding: 6px 14px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.emoji-tab:hover { background: var(--surface); color: var(--text); }
.emoji-tab[aria-selected=true] { background: var(--accent-soft); color: var(--accent); }
.emoji-cats { display: flex; gap: 2px; overflow-x: auto; padding: 4px 6px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.emoji-cat { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 8px; width: 38px; height: 34px; flex: 0 0 auto; font-size: 20px; cursor: pointer; }
.emoji-cat:hover { background: var(--surface); }
.emoji-cat.active { border-bottom-color: var(--accent); background: var(--accent-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; padding: 6px; overflow-y: auto; overscroll-behavior: contain; }
.emoji-btn, .emoji-cat, .msg-emoji .msg-body { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", var(--font); }
.emoji-btn { background: none; border: 0; border-radius: 8px; height: 40px; font-size: 26px; line-height: 1; cursor: pointer; }
.emoji-btn:hover, .emoji-btn:focus-visible { background: var(--accent-soft); }
.sticker-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.sticker-btn { height: 68px; font-size: 44px; }
.msg.msg-emoji, .msg.mine.msg-emoji { background: transparent; border-color: transparent; color: var(--text); padding: 2px 4px; }
.msg-emoji .msg-body { line-height: 1.15; }
.msg-emoji-1 .msg-body { font-size: 64px; }
.msg-emoji-2 .msg-body { font-size: 48px; }
.msg-emoji-3 .msg-body { font-size: 38px; }

/* ------------------------------------------- profile photos and notification prompt */
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-sm .icon { width: 12px; height: 12px; }
.me-avatar-btn { background: none; border: 0; padding: 0; border-radius: 50%; cursor: pointer; flex: none; line-height: 0; }
.me-avatar-btn:hover .avatar { filter: brightness(.95); }
.profile { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 4px 0 8px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.push-banner { margin: 0 16px 10px; padding: 12px; border-radius: var(--radius); background: var(--accent-soft); display: grid; gap: 8px; font-size: 14px; }
.push-banner[hidden] { display: none; }
.push-banner p { margin: 0; }
.push-banner .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ photo adjust (crop) dialog */
.crop { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crop-stage { position: relative; width: 280px; max-width: 100%; aspect-ratio: 1; overflow: hidden; background: #808080; border-radius: 12px; cursor: grab; touch-action: none; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-canvas { width: 100%; height: 100%; display: block; }
.crop-mask { position: absolute; inset: 0; pointer-events: none; box-shadow: 0 0 0 400px rgb(0 0 0 / .55); border: 2px solid #fff; }
.crop-circle .crop-mask { border-radius: 50%; }
.crop-square .crop-mask { border-radius: 12px; }
.crop-controls { display: flex; align-items: center; gap: 10px; width: 280px; max-width: 100%; }
.crop-controls .crop-zoom { flex: 1; accent-color: var(--accent); }
.crop-label { font-size: 20px; line-height: 1; color: var(--muted); width: 14px; text-align: center; }
.crop-tools { display: flex; gap: 8px; }
.crop .form-actions { align-self: stretch; }

/* ---- meetings ---- */
.meet-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.meet-btn .icon { width: 18px; height: 18px; }
.meeting-card { display: flex; align-items: center; gap: 12px; min-width: 240px; padding: 4px 0; }
.meeting-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.meeting-ico .icon { width: 20px; height: 20px; }
.meeting-text { display: grid; flex: 1; min-width: 0; }
.meeting-text span { color: var(--muted); font-size: 0.85em; }

/* ---- in-app calls ---- */
body.in-call { overflow: hidden; }
.call { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: #14161a; color: #fff; }
.call-head { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; }
.call-status { margin: 0; color: #aab0bb; font-size: 0.9em; }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px 12px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.call-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.call-grid[data-count="3"], .call-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.call-grid[data-count="5"], .call-grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
.call-grid[data-count="7"], .call-grid[data-count="8"] { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) {
  .call-grid[data-count="2"], .call-grid[data-count="3"], .call-grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
  .call-grid[data-count="5"], .call-grid[data-count="6"], .call-grid[data-count="7"], .call-grid[data-count="8"] { grid-template-columns: 1fr 1fr; }
}
.tile { position: relative; background: #23262d; border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 0; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.is-screen video { object-fit: contain; }
.tile.mirror video { transform: scaleX(-1); }
.tile video[hidden], .tile-avatar[hidden] { display: none; }
.tile-avatar { display: grid; place-items: center; }
.tile-pin { position: absolute; top: 8px; right: 8px; z-index: 2; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-pin, .tile-pin:focus-visible, .tile-pin.is-pinned { opacity: 1; }
@media (hover: none) { .tile-pin { opacity: .85; } }
.tile-pin .icon { width: 16px; height: 16px; }
.tile-pin.is-pinned { background: #2d7be5; }
.tile-badge { position: absolute; top: 8px; left: 8px; z-index: 2; background: #1f6b46; padding: 2px 8px; border-radius: 6px; font-size: 0.75em; }
.tile-badge[hidden] { display: none; }
/* Spotlight: a pinned person or a screen share fills the main area, everyone else in a strip below. */
.call-grid.has-stage[data-count] { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); grid-template-rows: minmax(0, 1fr); grid-auto-rows: 100px; overflow-y: auto; }
.call-grid.has-stage .tile.is-stage { grid-column: 1 / -1; grid-row: 1; }
.call-grid.has-stage .tile:not(.is-stage) .tile-name { font-size: 0.7em; }
.tile-foot { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; align-items: center; gap: 6px; }
.tile-name { background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 6px; font-size: 0.85em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mic { background: rgba(0, 0, 0, .55); border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; }
.tile-mic .icon { width: 14px; height: 14px; }
.tile.is-reconnecting::after { content: 'Reconnecting…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); }
.tile.is-lost::after { content: 'Connection lost — reconnecting…'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .6); }
.call-bar { display: flex; justify-content: center; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.call-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; padding: 10px 14px; border: 0; border-radius: 12px; background: #2e323a; color: #fff; cursor: pointer; font: inherit; font-size: 0.75em; }
.call-btn:hover { background: #3a3f48; }
.call-btn .icon { width: 22px; height: 22px; }
.call-btn.is-off { background: #7a2d2d; }
.call-btn.is-on[aria-label="Stop sharing"] { background: #1f6b46; }
.call-leave { background: #c0392b; }
.call-leave:hover { background: #d44636; }
.call-end { background: #8e1f14; }
.call-end[hidden] { display: none; }
.meeting-banner { position: fixed; z-index: 900; top: 16px; right: 16px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); max-width: min(420px, calc(100vw - 32px)); }
