:root {
  color-scheme: light;
  --canvas: #eee9f8;
  --paper: #fff;
  --panel: #f5f0fa;
  --incoming: #fff;
  --incoming-line: #cec6db;
  --timestamp: #61586c;
  --ink: #211b2c;
  --muted: #51485f;
  --line: #e6deef;
  --input-line: #9181a2;
  --accent: #7052ca;
  --focus: #7448b9;
  --soft: #f1eafb;
  --selected: #e8dbfa;
  --button: #7052ca;
  --button-hover: #57348f;
  --button-ink: #fff;
  --outgoing: #d7bef7;
  --outgoing-line: #cbb4ed;
  --outgoing-ink: #2b1d3d;
  --outgoing-meta: #594769;
  --outgoing-accent: #573588;
  --founder-fill: #4a2d70;
  --avatar: #eee3fb;
  --avatar-ink: #583489;
  --avatar-line: #e2d4f1;
  --voice-track: #8c789f;
  --error: #a02143;
  --error-soft: #fbe4eb;
  --warning: #704515;
  --warning-soft: #fff1d9;
  --muted-badge: #62596f;
  --muted-badge-ink: #fff;
  --backdrop: #21182a61;
  --shadow: 0 22px 65px #3824501a;
  --dialog-shadow: 0 16px 42px #38245026;
  --intro-start: #f3eafd;
  --intro-end: #e9ddf9;
  --wave-opacity: .62;
  font: 16px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

:root[data-appearance="dark"] {
  color-scheme: dark;
  --canvas: #18171f;
  --paper: #201e28;
  --panel: #282530;
  --incoming: #393441;
  --incoming-line: #403b48;
  --timestamp: #c5bccf;
  --ink: #f5f1fa;
  --muted: #d1c8dc;
  --line: #36323f;
  --input-line: #82778e;
  --accent: #b59cfa;
  --focus: #ddc7ff;
  --soft: #302939;
  --selected: #3c2e4c;
  --button: #b59cfa;
  --button-hover: #d3bafa;
  --button-ink: #261638;
  --outgoing: #493464;
  --outgoing-line: #573f75;
  --outgoing-ink: #fbf7ff;
  --outgoing-meta: #dbcee9;
  --outgoing-accent: #edd4ff;
  --founder-fill: #442b64;
  --avatar: #382d47;
  --avatar-ink: #e9d8ff;
  --avatar-line: #50415f;
  --voice-track: #9584aa;
  --error: #ffb1c2;
  --error-soft: #462933;
  --warning: #f8d9aa;
  --warning-soft: #402f21;
  --muted-badge: #746983;
  --backdrop: #0c0a12a1;
  --shadow: 0 22px 65px #0a080e66;
  --dialog-shadow: 0 16px 42px #0a080e80;
  --intro-start: #231d2b;
  --intro-end: #19161f;
  --wave-opacity: 1;
}

@media (prefers-contrast: more) {
  :root, :root[data-appearance="dark"] {
    --muted: var(--ink);
    --timestamp: var(--ink);
    --input-line: var(--ink);
    --incoming-line: var(--ink);
    --line: color-mix(in srgb, var(--ink) 60%, var(--paper));
  }
  .bubble.own { --outgoing-meta: var(--outgoing-ink); --outgoing-error: #761431; }
  :root[data-appearance="dark"] .bubble.own { --outgoing-error: #ffe4e6; }
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .72; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { color: var(--ink); background: var(--selected); }
h1, h2, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.account {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 5vw, 72px);
}

.account-layout {
  width: min(1050px, 100%);
  min-height: min(620px, calc(100dvh - 40px));
  display: grid;
  grid-template-columns: 1.07fr 1fr;
  border: 1px solid var(--line);
  border-radius: 32px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 4vw, 62px);
  background: linear-gradient(155deg, var(--intro-start), var(--intro-end));
}

.hero-logo { width: 90px; height: auto; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 720; letter-spacing: -.04em; }
.brand img { width: 46px; height: auto; }
.brand-name { display: block; width: 112px; aspect-ratio: 580 / 109; background: var(--ink); mask: url("/art/wordmark.png") left center / contain no-repeat; }
.intro .brand-name { width: clamp(135px, 16vw, 224px); }
.intro h1 { font-size: clamp(36px, 5vw, 59px); line-height: 1.04; letter-spacing: -.065em; font-weight: 700; }
.intro-copy p { margin-top: 21px; max-width: 32ch; color: var(--muted); font-size: 16px; line-height: 1.6; }
.account-content {
  display: grid; grid-template-rows: 1fr auto; justify-items: center; gap: 30px;
  padding: clamp(22px, 5vw, 66px) clamp(22px, 5vw, 66px) 20px;
}
.account-card, .account-footer { width: min(100%, 360px); }
.account-card { align-self: center; }
.account-card h2 { font-size: clamp(27px, 3.2vw, 36px); letter-spacing: -.052em; line-height: 1.15; }
.subtitle { margin-top: 12px; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.account-card .subtitle strong { color: var(--ink); }
.account-card form { display: grid; gap: 8px; margin-top: 24px; }
.account-card label { font-size: 14px; font-weight: 650; }
input, textarea { width: 100%; min-width: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--input-line); border-radius: 11px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.account-card input { padding: 12px 14px; min-height: 52px; border-radius: 14px; }
.account-card label:not(:first-child) { margin-top: 6px; }
.account-card input[aria-invalid="true"]:not(#code) { border-color: var(--error); }
.account-card input[aria-invalid="true"]:not(#code):focus-visible {
  outline-color: var(--error);
  outline-offset: -2px;
}
.account-field-error { color: var(--error); font-size: .875rem; line-height: 1.4; }
.account-hint[data-state=available] { color: var(--accent); }
.account-hint[data-state=taken] { color: var(--error); }
.account-hint[data-state=checking] { color: var(--muted); }
.account-request-error {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--error) 35%, var(--line));
  border-radius: 12px;
  background: var(--error-soft);
  color: var(--error);
  font-size: .875rem;
  line-height: 1.4;
}
.account-request-error p { color: var(--ink); }
.account-code { position: relative; }
.account-code-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(4px, 2vw, 8px);
  pointer-events: none;
}
.account-code-slots span {
  display: grid;
  place-items: center;
  min-height: 52px;
  border: 1px solid var(--input-line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.account-code-slots span:empty::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  opacity: .42;
}
.account-code-slots span.current {
  border-color: var(--focus);
  box-shadow: inset 0 0 0 1px var(--focus);
}
.account-code-slots span.selected { background: var(--selected); }
.account-code:has(input[aria-invalid="true"]) span {
  border-color: var(--error);
  box-shadow: none;
}
.account-code input {
  position: absolute;
  inset: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  font-size: 1.375rem;
}
.account-code input[aria-invalid="true"]:focus-visible { outline-color: var(--error); }
.account-code input::selection { color: transparent; background: transparent; }
@media (forced-colors: active) {
  .account-code input { forced-color-adjust: none; }
  .account-code-slots span.current { outline: 2px solid Highlight; outline-offset: -2px; }
  .account-code-slots span.selected { forced-color-adjust: none; color: HighlightText; background: Highlight; }
}
.account-profile-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
}
.account-profile-preview > div { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.account-profile-preview > div > span { color: var(--muted); font-size: .875rem; }
.account-profile-preview + form { margin-top: 16px; }
.account-danger-zone { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.primary { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; padding: 12px 15px; min-height: 49px; border: 0; border-radius: 11px; }
.primary, .send-button { background: var(--button); color: var(--button-ink); font-weight: 700; }
.primary:hover, .send-button:hover { background: var(--button-hover); }
.primary:disabled, .send-button:disabled { color: var(--muted); background: var(--soft); opacity: 1; }
.account-card .primary { justify-content: center; min-height: 52px; margin-top: 6px; border-radius: 14px; }
.account-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 16px; margin-top: 8px; }
.text-button { border: 0; background: transparent; min-height: 40px; color: var(--accent); padding: 4px 0; font-size: 13px; font-weight: 650; }
.text-button:enabled:hover { text-decoration: underline; }
.account-actions .text-button, .account-footer .text-button { min-height: 44px; }
.account-actions .text-button:disabled { color: var(--muted); opacity: 1; }
#resend-code { font-variant-numeric: tabular-nums; }
.account-hint { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.account-footer { padding-top: 6px; border-top: 1px solid var(--line); text-align: center; }
.account-card .logout { margin-top: 14px; }
.status { font-size: 14px; margin-top: 13px; line-height: 1.4; color: var(--accent); }
.status.error { color: var(--error); }

.messenger {
  --group-panel: min(400px, 36vw);
  display: grid;
  grid-template-columns: var(--sidebar-width, clamp(248px, 29vw, 420px)) minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  max-width: 1840px;
  margin: 0 auto;
  background: var(--paper);
}
.group-settings {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  justify-content: flex-end;
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--paper);
  border-left: 1px solid var(--line);
  transition: width .24s ease;
}
.messenger.has-group-settings .group-settings { width: var(--group-panel); }
.group-settings-sheet { display: flex; flex-direction: column; width: var(--group-panel); height: 100%; min-width: var(--group-panel); min-height: 0; }
.group-settings-heading {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center;
  flex: none; min-height: 56px; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.group-settings-heading h2 { grid-column: 2; margin: 0; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 650; }
#close-group-settings { grid-column: 1; --icon-index: 3; }
.group-settings-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px 28px; }
#group-settings-status { flex: none; margin: 0 20px 16px; }
@media (prefers-reduced-motion: reduce) { .group-settings { transition: none; } }
.sidebar, .conversation { min-height: 0; min-width: 0; }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.identity { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 18px 17px 9px 22px; }
.top-actions { display: flex; }
.sidebar-content { flex: 1; min-height: 0; padding: 7px 16px 16px; overflow: auto; }
.chat-title { margin: 0 8px 14px; font-size: 32px; letter-spacing: -.06em; }
.search-form { margin: 0 0 8px; }
.search-field {
  display: flex;
  background: color-mix(in srgb, var(--panel) 70%, var(--paper));
  border: 1px solid var(--line);
  border-radius: 12px;
}
.search-field:focus-within { border-color: var(--focus); }
.search-field .icon-button { color: var(--muted); }
.search-form input {
  padding: 8px 11px 8px 0;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  font-size: 15px;
}
.search-form input:focus-visible { outline: none; }
.icon-button { display: grid; place-items: center; flex: 0 0 44px; min-width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); }
.icon-button:hover { color: var(--accent); background: var(--soft); }
.sidebar-content > .status { margin: 10px 8px 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.sidebar-content > .error { color: var(--error); }
.search-results { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 10px; }
.search-results h2 { margin: 0 8px; font-size: .875rem; }
.search-form.has-query ~ :is(.filters, .inbox-shortcuts, .chat-list, .sidebar-empty) { display: none; }
.search-form:not(.has-query) #clear-inbox-search { display: none; }
#search::-webkit-search-cancel-button { appearance: none; }
#new-group {
  margin-inline-start: 2px;
  background: var(--soft);
  color: var(--accent);
}
#new-group:hover { background: var(--selected); }
.chat-list, .search-results { display: grid; gap: 3px; }
.person-row { display: flex; align-items: center; gap: 11px; width: 100%; min-width: 0; text-align: left; background: transparent; padding: 9px 8px; border: 0; color: var(--ink); border-radius: 12px; }
.person-row:hover { background: var(--soft); }
.person-row[aria-current="true"] { background: var(--selected); }
.avatar { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 50%; background: var(--avatar); color: var(--avatar-ink); box-shadow: inset 0 0 0 1px var(--avatar-line); font-size: 14px; font-weight: 750; }
/* Free monograms are stable across screens. Equipped auras override this wash. */
.avatar[data-tone] {
  background: linear-gradient(145deg, var(--tone-start), var(--tone-end));
  color: var(--tone-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 14%, transparent);
}
.avatar[data-tone=lilac] { --tone-start: #f1e7fc; --tone-end: #ddcef7; --tone-ink: #51317a; }
.avatar[data-tone=sky] { --tone-start: #e4f2fd; --tone-end: #cde4f6; --tone-ink: #254f73; }
.avatar[data-tone=rose] { --tone-start: #f9e9ee; --tone-end: #f3cfdb; --tone-ink: #793c55; }
.avatar[data-tone=sage] { --tone-start: #e8f0da; --tone-end: #d1e3be; --tone-ink: #3e5630; }
:root[data-appearance=dark] .avatar[data-tone=lilac] { --tone-start: #48375f; --tone-end: #342944; --tone-ink: #ebdcff; }
:root[data-appearance=dark] .avatar[data-tone=sky] { --tone-start: #293f59; --tone-end: #243345; --tone-ink: #d1eaff; }
:root[data-appearance=dark] .avatar[data-tone=rose] { --tone-start: #533345; --tone-end: #402b37; --tone-ink: #ffdce8; }
:root[data-appearance=dark] .avatar[data-tone=sage] { --tone-start: #364631; --tone-end: #29362b; --tone-ink: #e0edcd; }
.person-copy, .peer-copy { display: grid; min-width: 0; gap: 2px; flex: 1; }
.person-copy strong, .person-copy small, .peer-copy h2, .peer-copy p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-copy strong { font-size: 14px; }
.person-copy small, .person-row time { color: var(--muted); font-size: 12px; }
.person-row time { align-self: start; padding-top: 3px; }
.sidebar-footer {
  display: grid; grid-template-columns: repeat(2, 1fr);
  flex-shrink: 0; padding: 5px 10px max(5px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--paper);
}
.sidebar-footer > :is(button, a) {
  display: grid; place-items: center; align-content: center; gap: 3px; min-height: 52px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; text-decoration: none; touch-action: manipulation;
}
.sidebar-footer > [aria-current] { color: var(--accent); font-weight: 750; }
@media (hover: hover) {
  .sidebar-footer > :is(button, a):hover { background: var(--panel); }
}
.sidebar-footer .avatar { width: 25px; height: 25px; font-size: 10px; }
.nav-chat-icon { display: grid; place-items: center; width: 47px; height: 25px; border-radius: 20px; }
[aria-current] > .nav-chat-icon { background: var(--selected); }
.nav-chat-icon svg, .call-shortcuts svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.call-shortcuts, .chat-header-actions { display: flex; align-items: center; flex: none; }
.call-shortcuts .icon-button { color: var(--accent); }

.conversation { background: var(--chat-canvas, var(--canvas)); position: relative; isolation: isolate; }
.conversation-empty { display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 9px; height: 100%; padding: 30px; text-align: center; }
.conversation-empty h2 { font-size: 33px; letter-spacing: -.056em; }
.conversation-empty p, .history-empty { color: var(--muted); font-size: 15px; }
.empty-mark { width: 68px; height: auto; margin-bottom: 9px; }
.open-chat {
  --thread-width: 760px;
  --thread-gutter: 12px;
  --thread-start: var(--thread-gutter);
  --thread-end: var(--thread-gutter);
  height: 100%; display: flex; flex-direction: column; }
.conversation-header { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 6px 12px; background: var(--paper); border-bottom: 1px solid var(--line); }
.conversation-header h2 { font-size: 18px; font-weight: 650; line-height: 1.15; }
.conversation-header p { color: var(--muted); font-size: 13px; }
.back { display: none; font-size: 25px; }
.history { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: auto; padding-block: 10px 8px; padding-inline: var(--thread-start) var(--thread-end); overscroll-behavior: contain; }
.messages { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); width: 100%; margin: auto auto 0; }
.history-empty { margin: auto; text-align: center; }
.messages:empty { display: none; }
.date-marker { color: var(--muted); text-align: center; font-size: 12px; margin: 9px 0 4px; }
.bubble { justify-self: start; max-width: min(88%, 58ch); position: relative; background: var(--incoming); padding: 5px 10px 4px; color: var(--ink); border: 1px solid var(--incoming-line); border-radius: 16px 18px 18px 3px; }
.bubble.own { justify-self: end; background-color: var(--outgoing); background-image: linear-gradient(125deg, color-mix(in srgb, white 8%, transparent), transparent 70%); color: var(--outgoing-ink); border-color: var(--outgoing-line); border-radius: 18px 16px 3px 18px; }
.bubble p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; }
.bubble-meta { display: block; color: var(--timestamp); font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.2; text-align: end; }
.bubble .failed { color: var(--error); }
.composer { display: flex; align-items: flex-end; gap: 6px; width: 100%; padding-block: 6px max(8px, env(safe-area-inset-bottom)); padding-inline: var(--thread-start) var(--thread-end); background: var(--chat-canvas, var(--canvas)); border-top: 1px solid var(--line); }
.composer textarea {
  display: block; resize: none; field-sizing: content; min-height: 48px; max-height: min(26dvh, 108px);
  padding-block: 14px; line-height: 20px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--input-line) transparent;
}
.send-button { border: 0; font-size: 23px; }
.connection-status { position: absolute; color: var(--warning); background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning), transparent 68%); border-radius: 9px; padding: 8px 12px; top: 82px; right: 12px; font-size: 13px; max-width: calc(100% - 24px); pointer-events: none; }
.connection-status.error:not([data-connection]) { color: var(--error); background: var(--error-soft); border-color: color-mix(in srgb, var(--error), transparent 68%); }
@media (min-width: 1420px) { .messenger { border-inline: 1px solid var(--line); } }
@media (max-width: 690px) {
  .account { padding: 0; align-items: stretch; }
  .account-layout {
    border: 0; border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr;
    background: var(--intro-end); box-shadow: none;
  }
  .intro {
    padding: max(30px, calc(env(safe-area-inset-top) + 16px)) 24px 44px;
    align-items: center;
  }
  .intro-copy {
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px;
    width: min(100%, 360px);
  }
  .hero-logo { width: 44px; margin: 0; }
  .intro .brand-name { width: min(100%, 124px); }
  .intro-copy p { grid-column: 1 / -1; margin: 0; font-size: .875rem; line-height: 1.45; }
  .account-content {
    position: relative; margin-top: -18px; border-radius: 24px 24px 0 0; background: var(--paper);
    padding: 29px 24px max(12px, env(safe-area-inset-bottom));
  }
  .account-card { align-self: start; }
  .messenger { grid-template-columns: minmax(0, 1fr); }
  .messenger.has-group-settings { --group-panel: 100%; }
  .messenger.has-group-settings > .sidebar,
  .messenger.has-group-settings > .conversation { display: none; }
  .messenger.has-group-settings > .group-settings,
  .messenger.has-group-settings .group-settings-sheet {
    position: fixed; inset: 0; z-index: 8; width: 100%; height: 100%;
    min-width: 0; max-width: none; border: 0;
  }
  #dialog.group-create {
    position: fixed !important; inset: 0 !important; z-index: 8;
    width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important;
    margin: 0 !important; border: 0 !important; border-radius: 0 !important;
  }
  .sidebar { border-right: 0; }
  .messenger:not(.has-chat) .conversation:not(:has(.connection-status:not([hidden]))) { display: none; }
  .messenger:not(.has-chat) .conversation { position: absolute; inset: 0 0 auto; height: 0; z-index: 1; }
  .messenger:not(.has-chat) .conversation-empty { display: none; }
  .messenger.has-chat .sidebar { display: none; }
  .sidebar-footer { justify-content: center; grid-template-columns: repeat(2, minmax(0, 108px)); gap: 6px; }
  .sidebar-footer > :is(button, a) {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 48px; border-radius: 18px; font-size: 14px;
  }
  .sidebar-footer > [aria-current] { background: var(--soft); }
  .sidebar-footer :is(.nav-chat-icon, .nav-profile-icon) { width: 22px; background: transparent; }

  .back { display: grid; }
  .connection-status { top: 70px; }
}
.sidebar-heading, .dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sidebar-heading { margin: 0 8px 14px; }
.sidebar-heading .chat-title { margin: 0; }
.sidebar-heading .icon-button, #close-dialog, #chat-settings { font-size: 24px; }
.composer .voice { font-size: 16px; }
.draft, .attachment-quota { width: 100%; padding-block: 6px 0; padding-inline: var(--thread-start) var(--thread-end); background: var(--chat-canvas, var(--canvas)); }
.draft-row { border-inline-start: 2px solid var(--accent); padding-inline-start: 10px; }
.draft-row .text-button { min-width: 44px; min-height: 44px; font-size: 20px; }
.attachment-quota { color: var(--muted); font-size: 13px; }
.draft-row, .dialog-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.draft-row strong, .dialog-row span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dialog-row > .avatar { flex: 0 0 42px; }
.draft-row strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; font-weight: 600; }
.dialog-row .text-button, .draft-row .text-button { padding-inline: 5px; }
dialog { width: min(560px, calc(100% - 24px)); max-height: 85dvh; padding: 24px; border: 1px solid var(--line); border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: var(--dialog-shadow); }
dialog::backdrop { background: color-mix(in srgb, var(--backdrop) 72%, transparent); }
.dialog-heading { margin-bottom: 6px; }
.dialog-heading h2 { font-size: 23px; letter-spacing: -.04em; }
#close-dialog { min-width: 44px; min-height: 44px; border-radius: 12px; }
:is(#dialog-body, .group-settings-body) { display: grid; gap: 18px; align-content: start; }
:is(#dialog-body, .group-settings-body) > .dialog-subtitle { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
:is(#dialog-body, .group-settings-body) h3 { margin: 0; font-size: 15px; }
:is(#dialog-body, .group-settings-body) form { display: grid; gap: 8px; }
:is(#dialog-body, .group-settings-body) .theme-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
:is(#dialog-body, .group-settings-body) .theme-form .primary { width: auto; min-width: 160px; }
:is(#dialog-body, .group-settings-body) input:not([type=radio]) { min-height: 44px; padding: 8px; }
:is(#dialog-body, .group-settings-body) > .text-button { text-align: left; }
.group-settings-body .theme-form { grid-template-columns: 1fr; }
.group-settings-body .theme-form .primary { width: 100%; }
.group-settings-body .invitation-row { grid-template-columns: minmax(0, 1fr); }
.group-settings-body .dialog-member-actions { flex-basis: 100%; justify-content: flex-start; margin-inline-start: 52px; }
.dialog-section { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.dialog-section:first-of-type { padding-top: 0; border-top: 0; }
.dialog-section > .text-button { justify-content: flex-start; }
.dialog-row { border-top: 1px solid var(--line); padding-block: 8px; }
.history { overflow-x: hidden; }
.bubble.continues { margin-top: -2px; border-start-start-radius: 6px; }
.bubble.own.continues { border-start-start-radius: 21px; border-start-end-radius: 6px; }
.bubble:has(+ .continues) { border-end-start-radius: 9px; }
.bubble.own:has(+ .continues) { border-end-start-radius: 21px; border-end-end-radius: 9px; }
.bubble.has-message-actions { touch-action: pan-y pinch-zoom; }
.bubble.swiping { transform: translateX(var(--swipe-offset, 0)); }
.bubble.swiping .message-actions { visibility: hidden; }
.message-actions { position: absolute; inset-inline-start: 100%; inset-block-start: 50%; display: flex; padding-inline-start: 4px; transform: translateY(-50%); }
.own .message-actions { inset-inline: auto 100%; flex-direction: row-reverse; padding-inline: 0 4px; }
.message-actions .icon-button { color: var(--muted); }
.message-actions .more::before { width: 24px; height: 24px; transform: scale(.8); }
.message-actions .icon-button:hover, .message-actions .icon-button:focus-visible { color: var(--ink); background: var(--soft); }
.message-actions .message-quick-reply { --icon-index: 12; display: none; }
.message-actions { opacity: 0; pointer-events: none; }
.bubble:focus-within .message-actions { opacity: 1; pointer-events: auto; }
@media (hover: hover) and (pointer: fine) {
  .bubble:hover .message-actions { opacity: 1; pointer-events: auto; }
}
@media (min-width: 760px) and (hover: hover) and (pointer: fine) {
  .message-actions .message-quick-reply { display: grid; }
  .bubble.replyable { max-width: min(88%, 58ch, calc(100% - 92px)); }
}
.message-action-menu {
  position: fixed; inset: 0; margin: 0; padding: 0; width: 100%; height: 100%;
  max-width: none; max-height: none; border: 0; background: transparent; box-shadow: none;
  overflow: hidden;
}
.message-action-menu::backdrop { background: color-mix(in srgb, var(--backdrop) 16%, transparent); }
.message-action-content, .message-quick-reactions {
  position: absolute; background: var(--panel); border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow);
}
.message-action-content {
  width: min(244px, calc(100% - 20px)); padding: 4px; border-radius: 15px;
  overflow: auto; overscroll-behavior: contain;
}
.message-action-close:not(:focus-visible) {
  position: absolute; width: 1px; min-width: 1px; height: 1px; padding: 0;
  overflow: hidden; clip-path: inset(50%);
}
.message-action-close:focus-visible { width: 100%; justify-content: end; padding-inline: 8px; outline-offset: -2px; }
.message-quick-reactions { display: flex; padding: 2px; gap: 1px; border-radius: 28px; }
.message-quick-reactions .reaction-choice { min-width: 44px; min-height: 44px; padding: 0; border-color: transparent; background: transparent; font-size: 19px; outline-offset: -2px; }
.message-quick-reactions .reaction-choice:is(:hover, [aria-pressed=true]) { background: var(--selected); }
.message-action-item {
  display: flex; align-items: center; gap: 10px; min-height: 44px; width: 100%; border: 0;
  border-radius: 9px; padding: 8px 10px; color: var(--ink); background: transparent; text-align: start;
}
.message-action-item svg { width: 17px; height: 17px; }
.message-action-item:hover, .message-action-item:focus-visible { background: var(--soft); }
.message-action-item.danger { color: var(--error); }
.media-item { width: 100%; overflow-wrap: anywhere; }
.media-item + .media-item { margin-block-start: 3px; }
.bubble:has(.media-voice) { width: min(85%, 264px); padding-block: 2px; padding-inline: 5px 9px; }
.media-voice {
  --voice-fill: var(--accent);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 3px;
  width: 100%;
}
.own .media-voice { --voice-track: color-mix(in srgb, var(--outgoing-meta), var(--outgoing) 26%); --voice-fill: var(--outgoing-accent); }
.voice-play { --voice-disc: color-mix(in srgb, currentColor 14%, transparent); position: relative; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: radial-gradient(circle closest-side, var(--voice-disc) 61%, transparent 65%); color: var(--voice-fill); }
.voice-play:hover { --voice-disc: color-mix(in srgb, currentColor 25%, transparent); }
.voice-play[aria-busy=true] { cursor: progress; }
.voice-play::before { content: ""; border: solid transparent; border-width: 7px 0 7px 11px; border-left-color: currentColor; transform: translateX(1px); }
.media-voice[data-playing=true] .voice-play::before { width: 10px; height: 13px; border: solid currentColor; border-width: 0 3px; transform: none; }
.voice-details { display: grid; min-width: 0; }
.voice-scrubber { position: relative; height: 18px; border-radius: 5px; }
.voice-scrubber:has(.voice-seek:focus-visible) { outline: 2px solid var(--focus); }
.voice-track { position: absolute; inset: 0 2px; display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; place-items: center; pointer-events: none; }
.voice-track:empty::before { content: ""; width: 100%; height: 3px; background: linear-gradient(90deg, var(--voice-fill) var(--voice-progress, 0%), var(--voice-track) var(--voice-progress, 0%)); mask: radial-gradient(circle at 3px 1.5px, black .9px, transparent 1.25px) 0 center / 6px 3px repeat-x; }
.voice-track span { width: 60%; max-width: 2.5px; border-radius: 2px; background: var(--voice-track); }
.voice-track .played { background: var(--voice-fill); }
.voice-seek { position: absolute; inset: 0; margin: 0; height: 100%; opacity: 0; cursor: pointer; }
.voice-seek:disabled { cursor: default; }
.media-status { display: flex; align-items: center; flex-wrap: wrap; column-gap: 6px; }
.media-status > .bubble-meta { margin-inline-start: auto; white-space: nowrap; }
.voice-time { margin-inline: 2px; color: var(--muted); font-size: 12px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.own .voice-time { color: var(--outgoing-meta); }
.media-voice[data-phase=download] .voice-play::before { position: absolute; width: 15px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px; border-radius: 0 0 3px 3px; transform: translateY(5px); }
.media-voice[data-phase=download] .voice-play::after { content: ""; width: 10px; height: 13px; background: currentColor; clip-path: polygon(41% 0, 59% 0, 59% 68%, 86% 44%, 100% 58%, 50% 100%, 0 58%, 14% 44%, 41% 68%); transform: translateY(-2px); }
.media-voice[data-phase=loading] .voice-play::before { width: 17px; height: 17px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: voice-loading .8s linear infinite; }
@keyframes voice-loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .media-voice[data-phase=loading] .voice-play::before { animation: none; } }
@media (forced-colors: active) {
  .voice-track { display: none; }
  .voice-seek { opacity: 1; }
  .voice-play { border: 1px solid ButtonText; }
}
.voice-notice { grid-column: 1 / -1; color: var(--error); font-size: 12px; }
.media-item:has(> .media-voice + .bubble-meta) {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; grid-template-rows: 24px auto;
  align-items: center; column-gap: 3px;
}
.media-item:has(> .media-voice + .bubble-meta) :is(.media-voice, .voice-details) { display: contents; }
.media-item:has(> .media-voice + .bubble-meta) .voice-play { grid-area: 1 / 1 / 3; }
.media-item:has(> .media-voice + .bubble-meta) .voice-scrubber { grid-area: 1 / 2 / 2 / -1; }
.media-item:has(> .media-voice + .bubble-meta) .voice-time { grid-area: 2 / 2; }
.media-voice + .bubble-meta { grid-area: 2 / 3; white-space: nowrap; }
.media-item:has(> .media-voice + .bubble-meta) .voice-notice { grid-area: 3 / 1 / 4 / -1; margin-block-start: 3px; }
.media-notice { display: block; margin-block: 4px; color: var(--muted); }
.media-file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 6px; padding-inline: 6px 2px; border-radius: 12px; background: color-mix(in srgb, currentColor 5%, transparent); }
.media-file-icon { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--soft); color: var(--accent); }
.media-file-icon::before, .media-file-icon::after { content: ""; position: absolute; }
.media-file-icon::before { width: 14px; height: 17px; border: 1.5px solid currentColor; border-radius: 3px; }
.media-file-icon::after { width: 6px; height: 5px; border-block: 1.5px solid currentColor; }
.media-file-details { display: grid; min-width: 0; font-size: 14px; line-height: 1.2; }
.media-file-details strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.media-file-details small { color: var(--muted); }
.media-download { min-height: 44px; padding-inline: 5px; }
.media-open { grid-column: 2 / -1; justify-self: start; min-height: 44px; }
.own .media-file-details small, .own .media-notice { color: var(--outgoing-meta); }
.own .media-download, .own .media-open { color: var(--outgoing-accent); }
.bubble:has(.media-preview, .media-file) { width: min(85%, 276px); padding: 4px; }
.bubble:has(.media-file):not(:has(.media-preview)) { padding-block: 2px; }
.bubble:has(.media-preview, .media-file) > :is(p, .message-sender, .bubble-meta) { padding-inline: 7px; }
.bubble:has(.media-preview, .media-file) > p { margin-top: 4px; }
.media-preview { display: block; width: 100%; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: transparent; cursor: zoom-in; }
.media-preview:focus-visible { outline-offset: -3px; }
.media-preview img { display: block; width: 100%; max-height: min(320px, 55dvh); object-fit: cover; }
.media-viewer { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--canvas); }
.media-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.media-viewer::backdrop { background: #0e0a16e6; }
.media-viewer-heading { display: flex; align-items: center; gap: 8px; padding-inline-start: 8px; }
.media-viewer-heading h2 { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.media-viewer-download { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 8px; text-decoration: none; }
#media-viewer-stage { display: grid; place-items: center; overflow: hidden; touch-action: none; }
.media-viewer img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; pointer-events: none; }
.person-row .unread { min-width: 27px; min-height: 24px; line-height: 18px; border-radius: 15px; padding: 3px 7px; color: var(--button-ink); font-size: 13px; font-weight: 650; text-align: center; background: var(--button); }
.person-row.muted .unread { color: var(--muted-badge-ink); background: var(--muted-badge); }
.person-row.muted strong::after { content: " ○"; color: var(--muted); }
.message-sender { margin-bottom: 2px; color: var(--accent); font-size: 12px; font-weight: 650; }
.own .message-sender { color: var(--outgoing-accent); }
.message-attachment { font-size: 13px; }
.older { justify-self: center; }
.danger { color: var(--error); }
.dialog-note, .dialog-row small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.dialog-row small { display: block; margin-top: 3px; white-space: pre-wrap; }
.dialog-row small.danger { color: var(--error); }
#dialog-body .dialog-section form { margin-top: 8px; }
#dialog-body .dialog-section h3 { margin-bottom: 6px; }
.dialog-section label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; }
.dialog-section .primary { justify-content: center; }
.dialog-section .primary { min-height: 48px; }
.dialog-action { justify-content: flex-start; width: 100%; padding-inline: 12px; border-radius: 10px; background: var(--soft); }
.dialog-action[aria-pressed="true"] { color: var(--ink); }
.invitation-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-bottom: 6px; }
.invitation-row input { min-width: 0; font-size: 13px; text-overflow: ellipsis; }
.invitation-actions { display: flex; align-items: center; gap: 4px; }
.invitation-actions .text-button { white-space: nowrap; }
.dialog-member-avatar { width: 42px; height: 42px; flex: 0 0 42px; }
.dialog-member-copy { flex: 1; min-width: 0; }
.dialog-member-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.dialog-danger { margin-top: 2px; padding: 10px 12px; border-top: 1px solid color-mix(in srgb, var(--error), var(--line) 75%); }
.draft { max-height: 20dvh; overflow-y: auto; }

@media (max-width: 520px) {
  dialog { padding: 20px; }
  :is(#dialog-body, .group-settings-body) .theme-form { grid-template-columns: 1fr; }
  :is(#dialog-body, .group-settings-body) .theme-form .primary { width: 100%; }
  .invitation-row { grid-template-columns: minmax(0, 1fr); }
  .invitation-actions { justify-content: flex-end; }
  .dialog-member-actions { flex-basis: 100%; justify-content: flex-start; margin-inline-start: 50px; }
}

.wave-art { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; opacity: var(--wave-opacity); filter: var(--wave-filter, none); pointer-events: none; }
.conversation > .wave-art { opacity: calc(var(--wave-opacity) * var(--chat-wave-opacity, 1) * var(--chat-wave-strength, 1)); }
.conversation:has(#chat:not([hidden])) { --chat-wave-strength: .38; }
.conversation-empty { background: color-mix(in srgb, var(--canvas) 34%, transparent); }
.filters { display: flex; align-items: stretch; gap: 4px; margin-block-end: 8px; border-bottom: 1px solid var(--line); }
.filters button {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 2px 8px;
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: .875rem;
  font-weight: 550;
}
.filters button[aria-pressed=true] { color: var(--accent); font-weight: 650; }
.filters button[aria-pressed=true]::after { content: ""; position: absolute; inset: auto 12px 0; height: 2px; border-radius: 2px 2px 0 0; background: currentColor; }
.filters button:hover { color: var(--accent); }
.inbox-shortcuts { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-block-end: 4px; }
.inbox-shortcut {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px 8px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  text-align: start;
}
.inbox-shortcut:hover { background: var(--soft); }
.inbox-shortcut[aria-pressed=true], .inbox-shortcut[aria-current=true] { background: var(--selected); color: var(--accent); }
.saved-shortcut { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.archive-shortcut { font-size: .875rem; color: var(--muted); }
.inbox-shortcut-icon, .sidebar-empty-icon {
  display: grid;
  flex: none;
  place-items: center;
  color: var(--accent);
  background: var(--soft);
  border-radius: 50%;
}
.inbox-shortcut-icon { width: 34px; height: 34px; }
:is(.inbox-shortcut, .sidebar-empty-icon) svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-list { gap: 0; }
.person-row { position: relative; display: grid; grid-template-columns: 48px minmax(0,1fr) auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; padding: 12px 6px; border-radius: 12px; }
.chat-list .person-row + .person-row::before { content: ""; position: absolute; inset: 0 6px auto 64px; height: 1px; background: var(--line); }
.chat-list .person-row[aria-current=true]::before, .chat-list .person-row[aria-current=true] + .person-row::before { visibility: hidden; }
.person-row .avatar { grid-column: 1; grid-row: 1/3; height: 48px; }
.person-row .person-copy { grid-column: 2; grid-row: 1/3; gap: 3px; }
.person-row time { grid-column: 3; grid-row: 1; justify-self: end; padding: 0; font-size: 12px; color: var(--timestamp); font-variant-numeric: tabular-nums; }
.person-row .unread { grid-column: 3; grid-row: 2; justify-self: end; }
.person-copy strong { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.chat-list .person-copy strong { font-size: 16px; font-weight: 550; }
.chat-list .person-row:has(.unread:not([hidden])) .person-copy strong { font-weight: 650; }
.person-copy small { font-size: 14px; }
.text-only { padding: 4px 10px 3px; }
.text-only > p { display: inline; }
.text-only .bubble-meta { display: inline-block; margin-inline-start: 6px; vertical-align: -.16em; }
.bubble .reply { --reply-accent: var(--accent); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: min(100%, 34ch); margin: 0 0 3px; padding: 2px 6px; border-inline-start: 2px solid var(--reply-accent); border-radius: 4px 8px 8px 4px; color: var(--muted); background: color-mix(in srgb, currentColor 6%, transparent); font-size: 13px; overflow-wrap: anywhere; }
.receipt-ticks { margin-inline-start: 4px; letter-spacing: -.23em; margin-inline-end: 2px; }
.message-state.read .receipt-ticks { color: var(--outgoing-accent); font-weight: 750; }
.bubble.own .bubble-meta, .bubble.own .reply, .bubble.own .message-state { color: var(--outgoing-meta); }
.bubble.own .reply { --reply-accent: var(--outgoing-accent); }
.bubble.own .failed, .bubble.own .voice-notice { color: var(--outgoing-error, var(--error)); }
.date-marker { background: var(--paper); border: 1px solid var(--line); padding: 3px 11px; border-radius: 18px; justify-self: center; }
.composer-field { display: flex; align-items: flex-end; flex: 1; min-width: 0; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); border-radius: 24px; }
.composer-field:has(textarea:focus) { outline: 1px solid color-mix(in srgb, var(--accent) 78%, var(--paper)); outline-offset: -1px; }
.composer-field:not([data-pointer-focus]):has(textarea:focus-visible) { outline-width: 2px; outline-offset: -2px; }
.composer textarea { flex: 1; background: transparent; border: 0; padding-inline: 0 12px; border-radius: 24px; }
.composer textarea:focus { outline: none; }
.composer .attach { color: var(--accent); }
@media (forced-colors: active) {
  .composer-field:has(textarea:focus) { outline-color: Highlight; }
}
.composer .icon-button, .composer .send-button { height: 48px; min-width: 48px; flex-basis: 48px; border-radius: 50%; }
.composer .voice { background: var(--button); color: var(--button-ink); }
.composer .voice:hover { background: var(--button-hover); }
.composer .voice.recording { color: var(--error); background: var(--error-soft); }
.glyph { --icon-index: 0; }
.glyph::before { content: ""; display: block; width: 24px; height: 24px; background: currentColor;
  --control-mask: url("/art/controls.png") calc(-24px * var(--icon-index)) center / 312px 24px no-repeat;
  -webkit-mask: var(--control-mask); mask: var(--control-mask); }
.glyph { display: inline-grid; place-items: center; }
.compose-icon { --icon-index: 1; } .profile-icon { --icon-index: 2; } .back { --icon-index: 3; } .more { --icon-index: 4; }
.attach { --icon-index: 5; } .voice { --icon-index: 6; } .send { --icon-index: 7; } .voice.recording { --icon-index: 8; }
.close { --icon-index: 9; }
@media (min-width: 691px) { .back { display: none; } }
@media (max-width: 690px) {
  .identity { padding-top: 12px; }
}
:is(.conversation:has(#chat[data-theme=lagoon]:not([hidden])), .channel-theme-preview[data-theme=lagoon]) {
  --wave-filter: hue-rotate(-100deg);
  --chat-canvas: #edf6f3;
  --outgoing: #d7eee7;
  --outgoing-line: #bcded5;
  --outgoing-ink: #143b33;
  --outgoing-meta: #385e55;
  --outgoing-accent: #1a594b;
}
:is(.conversation:has(#chat[data-theme=ember]:not([hidden])), .channel-theme-preview[data-theme=ember]) {
  --wave-filter: hue-rotate(83deg);
  --chat-canvas: #fcf1f0;
  --outgoing: #f7dedb;
  --outgoing-line: #edc7c3;
  --outgoing-ink: #49232a;
  --outgoing-meta: #70464e;
  --outgoing-accent: #842e45;
}
:root[data-appearance="dark"] :is(.conversation:has(#chat[data-theme=lagoon]:not([hidden])), .channel-theme-preview[data-theme=lagoon]) {
  --chat-canvas: #182524;
  --outgoing: #285047;
  --outgoing-line: #345f54;
  --outgoing-ink: #effcf7;
  --outgoing-meta: #cae7dd;
  --outgoing-accent: #acf3df;
}
:root[data-appearance="dark"] :is(.conversation:has(#chat[data-theme=ember]:not([hidden])), .channel-theme-preview[data-theme=ember]) {
  --chat-canvas: #271a20;
  --outgoing: #673944;
  --outgoing-line: #784652;
  --outgoing-ink: #fff3f4;
  --outgoing-meta: #f4d6db;
  --outgoing-accent: #ffbeca;
  --outgoing-error: #ffd2a8;
}
.profile-palette { display: block; min-height: 44px; margin: 6px 0; padding: 6px 10px; color: var(--ink); background: var(--paper); border: 1px solid var(--input-line); border-radius: 10px; }
.appearance-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.appearance-options legend { margin-bottom: 8px; padding: 0; font-size: 15px; font-weight: 700; }
.appearance-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--input-line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}
.appearance-options label:hover { background: var(--soft); }
.appearance-options label:has(input:checked) { color: var(--accent); border-color: var(--accent); background: var(--selected); }
.appearance-options label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.appearance-options label input[type=radio] { flex: 0 0 16px; width: 16px; height: 16px; margin: 0; accent-color: var(--button); cursor: inherit; }
.appearance-options input:focus-visible { outline: 0; }
@media (forced-colors: active) {
  .appearance-options label:has(input:checked) { border-color: Highlight; }
  .appearance-options label:has(input:focus-visible) { outline-color: Highlight; }
}
.call-alert { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.call-alert button { min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font-weight: 650; }
.call-alert button:hover { background: var(--soft); }
.call-alert button:first-of-type { background: var(--button); border-color: transparent; color: var(--button-ink); }
.call-alert button:first-of-type:hover { background: var(--button-hover); }
.call-alert button:last-of-type:hover { background: var(--error-soft); color: var(--error); }
.call-alert { position: fixed; z-index: 20; top: 10px; left: 50%; transform: translateX(-50%); background: var(--paper); border: 1px solid var(--accent); border-radius: 16px; padding: 10px 14px; width: max-content; max-width: 94vw; box-shadow: var(--dialog-shadow); }
.call-alert strong { min-width: 0; overflow-wrap: anywhere; }
.call-alert-identity, .call-alert-controls { display: flex; align-items: center; gap: 8px; }
.call-alert-identity { flex: 1; min-width: min(220px, 100%); }
.call-alert-identity > div { min-width: 0; }
.call-alert-identity small { display: block; color: var(--muted); font-size: .8125rem; }
.call-alert-controls { margin-inline-start: auto; }
.call-alert-controls button:last-of-type { color: var(--error); }
.call-alert .status { flex-basis: 100%; }
.community-rules {
  display: grid;
  gap: .75rem;
  padding-inline-start: 1.25rem;
}

.dialog-section blockquote {
  margin: .75rem 0;
  padding-inline-start: .75rem;
  border-inline-start: 2px solid currentColor;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#report-reason, #report-details {
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--input-line);
  border-radius: 11px;
  font: inherit;
}

.founder-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border: 1px solid #8367a1; border-radius: 12px;
  color: #fff6fb; background: var(--founder-fill);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.4; white-space: nowrap;
}
.peer-details { display: flex; min-width: 0; gap: 6px; align-items: center; }
.peer-copy .founder-badge { flex: none; width: max-content; }
.sidebar-empty {
  display: grid;
  justify-items: center;
  gap: 9px;
  margin-block: 16px;
  padding: 20px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 72%, var(--paper));
  text-align: center;
}
.sidebar-empty-icon { width: 46px; height: 46px; }
.sidebar-empty-icon svg { width: 22px; height: 22px; }
.sidebar-empty #empty-list-label { font-weight: 650; color: var(--ink); }
.sidebar-empty #empty-list-note { color: var(--muted); font-size: .875rem; line-height: 1.45; }
.sidebar-empty #empty-list-note:empty { display: none; }
.sidebar-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.sidebar-empty-actions button { min-height: 44px; padding: 6px 12px; border-radius: 9px; font-size: .875rem; }
.sidebar-empty-actions #empty-list-action { background: var(--button); color: var(--button-ink); }
.sidebar-empty-actions #empty-list-action:hover { background: var(--button-hover); }
.sidebar-empty-actions #empty-channel-join:hover { background: var(--soft); }
.sidebar-empty-actions:not(:has(button:not([hidden]))) { display: none; }
.chat-list .person-row[aria-current="true"] { border-radius: 12px; border-bottom-color: transparent; }
.chat-list .person-row:focus-visible { outline-offset: -2px; }
#dialog .dialog-heading { position: sticky; z-index: 1; top: -1px; margin: 0 0 8px; padding-block: 4px; background: var(--paper); border-bottom: 1px solid var(--line); }
#dialog { padding-block-start: 0; overscroll-behavior: contain; }
.dialog-heading h2 { min-width: 0; overflow-wrap: anywhere; }
#dialog-body, .dialog-section, #dialog-body form { min-width: 0; }
.dialog-section + .dialog-section { border-top: 1px solid var(--line); padding-top: 14px; }
#dialog.moderation-panel { width: min(680px, calc(100% - 24px)); }
.moderation-panel .moderation-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.moderation-panel .moderation-tabs .text-button { justify-content: center; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; }
.moderation-panel .moderation-tabs .text-button[aria-pressed=true] { background: var(--soft); color: var(--accent); }
.moderation-report-card { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.moderation-report-card blockquote { margin: 4px 0; padding: 10px 12px; border-inline-start: 3px solid var(--accent); background: var(--soft); }
.moderation-report-card .text-button { min-height: 42px; }
.moderation-panel .moderation-tabs .text-button { padding-inline: 3px; font-size: .79rem; }
.moderation-report-card .moderation-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.group-crop-dialog { width: min(460px, calc(100% - 24px)); }
.group-crop-dialog form { display: grid; gap: 8px; }
#dialog .text-button { min-height: 44px; }
@media (max-width: 500px) {
  .call-shortcuts svg { width: 20px; height: 20px; }
}
/* Each equipped aura has a colored outer rim and a fine inner reflection. */
.avatar:is([data-aura=lagoon], [data-aura=ember], [data-aura=aurora], [data-aura=solar], [data-aura=cosmos]) {
  border: 2px solid transparent;
  background: var(--aura-background) padding-box, var(--aura-rim) border-box;
  color: var(--aura-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--paper) 75%, transparent);
}
.avatar[data-aura=lagoon] {
  --aura-background: linear-gradient(155deg, #ddf7e9, #9cdcd4); --aura-ink: #164d48;
  --aura-rim: linear-gradient(155deg, #399687, #b5efe1 52%, #2a817f);
}
.avatar[data-aura=ember] {
  --aura-background: linear-gradient(28deg, #f8bca9, #ffe9dc); --aura-ink: #722936;
  --aura-rim: linear-gradient(28deg, #ac5265, #ffdbb0 55%, #c86a60);
}
.avatar[data-aura=aurora] {
  --aura-background: linear-gradient(128deg, #c0efde 12%, #c2e0ee 54%, #dccafa 92%); --aura-ink: #203d54;
  --aura-rim: conic-gradient(from 25deg, #7476c4, #adf7db, #53bca8, #dfc5ff, #7476c4);
}
.avatar[data-aura=solar] {
  --aura-background: radial-gradient(circle at 30% 22%, #fff5c8, #ffd79a 52%, #eda79a); --aura-ink: #632d25;
  --aura-rim: conic-gradient(from 60deg, #bd6b40, #fff2b0, #ce7c4c, #ffe4a0, #bd6b40);
}
.avatar[data-aura=cosmos] {
  --aura-background: radial-gradient(ellipse at 82% 15%, #efd0fd, #d5c9f8 55%, #b6bced); --aura-ink: #472966;
  --aura-rim: conic-gradient(from -35deg, #7960c8, #eec1fa, #8883dc, #cfcaff, #7960c8);
}
:root[data-appearance=dark] .avatar[data-aura=lagoon] { --aura-background: linear-gradient(155deg, #205349, #173b41); --aura-ink: #dbfff0; }
:root[data-appearance=dark] .avatar[data-aura=ember] { --aura-background: linear-gradient(28deg, #743e42, #482b39); --aura-ink: #ffe6dc; }
:root[data-appearance=dark] .avatar[data-aura=aurora] { --aura-background: linear-gradient(128deg, #17564e, #2e4564 54%, #51437c); --aura-ink: #effff7; }
:root[data-appearance=dark] .avatar[data-aura=solar] { --aura-background: radial-gradient(circle at 30% 22%, #805320, #71412c 52%, #582d36); --aura-ink: #fff4d9; }
:root[data-appearance=dark] .avatar[data-aura=cosmos] { --aura-background: radial-gradient(ellipse at 82% 15%, #703f7e, #49376f 55%, #2c315e); --aura-ink: #f6eaff; }


.group-row .avatar, .group-avatar { border-radius: 16px; }
.chat-list .person-row:has(.unread:not([hidden])) small { color: var(--ink); font-weight: 450; }
.voice-preview .person-copy small::before {
  content: ""; display: inline-block; vertical-align: -.16em; width: 15px; height: 15px;
  margin-inline-end: 4px; background: currentColor;
  mask: url("/art/controls.png") -90px center / 195px 15px no-repeat;
}
.nav-profile-icon { width: 47px; height: 25px; border-radius: 20px; }
[aria-current] > .nav-profile-icon { background: var(--selected); }
.founder-badge::before {
  content: ""; width: 13px; height: 13px; flex: none; background: #e4d4ff;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpath d='M1.5 6 4.5 2.5h7L14.5 6 8 14zM1.5 6h13M6 3l-1 3 3 8 3-8-1-3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.media-download { display: grid; place-items: center; min-width: 44px; }
.media-download::before {
  content: ""; width: 20px; height: 20px; background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12m-4.5-4.5L12 15l4.5-4.5M4 16v4h16v-4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.conversation-header .icon-button { min-width: 48px; height: 48px; flex-basis: 48px; }
#sidebar-divider { display: none; }
@media (min-width: 691px) {
  .sidebar { position: relative; }
  #sidebar-divider {
    display: block; position: absolute; z-index: 3; inset: 0 -4px 0 auto; width: 8px;
    touch-action: none; cursor: col-resize;
  }
  #sidebar-divider:is(:hover, :focus-visible, :active)::after {
    content: ""; position: absolute; inset: 0 3px; background: var(--accent);
  }
  .sidebar > .sidebar-footer { order: -1; display: flex; padding: 0 18px 10px; gap: 6px; border: 0; }
  .sidebar > .identity { order: -2; padding-block: 18px 12px; }
  .sidebar > .sidebar-footer > :is(button, a) { display: flex; align-items: center; gap: 5px; padding: 0 12px; min-height: 40px; }
  .sidebar > .sidebar-footer [aria-current] { background: var(--soft); }
  .sidebar > .sidebar-footer :is(.nav-chat-icon,.nav-profile-icon) { width: 22px; background: transparent; }
  .open-chat {
    --thread-gutter: clamp(16px, 2vw, 24px);
    --thread-start: max(var(--thread-gutter), calc((100% - var(--thread-width)) / 2));
    --thread-end: var(--thread-start);
  }
  .conversation-header { padding-inline: var(--thread-start) var(--thread-end); }
  .conversation { --chat-wave-opacity: .42; }
}
@media (max-width: 690px) {
  .conversation-header {
    gap: 4px; padding-inline: 4px;
  }
  .conversation-header #peer-username { max-width: 100%; }
}
@media (max-width: 390px) {
  .conversation-header .icon-button { min-width: 44px; flex-basis: 44px; }
}

#dialog.group-create {
  display: flex;
  flex-direction: column;
  position: fixed;
  z-index: 6;
  inset: auto;
  margin: 0;
  max-width: none;
  max-height: none;
  padding: 6px 0 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

:root {
  --glass-surface: color-mix(in srgb, var(--paper) 89%, transparent);
  --glass-highlight: #ffffffa6;
  --glass-edge: color-mix(in srgb, var(--ink) 12%, var(--paper));
  --glass-blur: blur(14px) saturate(115%);
  --glass-overlay-blur: blur(5px);
  --glass-shadow: 0 5px 18px #211b2c10;
  --glass-backdrop: color-mix(in srgb, var(--backdrop) 53%, transparent);
}
:root[data-appearance=dark] {
  --glass-highlight: #ffffff0d;
  --glass-edge: color-mix(in srgb, var(--ink) 19%, var(--paper));
  --glass-shadow: 0 5px 18px #09071155;
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
  :root, :root[data-appearance=dark] {
    --glass-surface: var(--paper);
    --glass-highlight: transparent;
    --glass-blur: none;
    --glass-overlay-blur: none;
    --glass-shadow: none;
    --glass-backdrop: var(--backdrop);
  }
}
:is(.conversation-header, .profile-view-header, .group-settings-heading, .composer, #dialog, .call-alert) {
  background-color: var(--glass-surface);
  border-color: var(--glass-edge);
  box-shadow: inset 0 1px var(--glass-highlight);
}
:is(.conversation-header, .profile-view-header, .group-settings-heading, .composer, .call-alert) {
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
#dialog {
  background-image: linear-gradient(155deg, var(--glass-highlight), transparent 45%);
  box-shadow: inset 0 1px var(--glass-highlight), var(--dialog-shadow);
}
#dialog .dialog-heading { background-color: var(--paper); }
#dialog::backdrop {
  background: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-overlay-blur);
  backdrop-filter: var(--glass-overlay-blur);
}
.account-layout { border-color: var(--glass-edge); box-shadow: inset 0 1px var(--glass-highlight), var(--shadow); }
@media (max-width: 690px) {
  .sidebar-footer { background: transparent; }
  .sidebar-footer > [aria-current] {
    background: linear-gradient(155deg, var(--glass-highlight), transparent 60%), var(--soft);
    box-shadow: inset 0 0 0 1px var(--glass-edge), 0 1px 5px #211b2c0c;
  }
  .account-layout { box-shadow: none; }
}
