:root {
  --bg: #071b24;
  --panel: #0d2631;
  --panel-2: #113441;
  --line: #214552;
  --text: #e9f5f4;
  --muted: #91aaa9;
  --accent: #20c7b5;
  --accent-dark: #0f766e;
  --danger: #ff7b7b;
  --shadow: 0 20px 55px rgb(0 0 0 / .28);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: radial-gradient(circle at 90% 5%, #164957 0, var(--bg) 38%); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { border: 0; border-radius: .7rem; background: var(--accent); color: #032f2c; font-weight: 700; padding: .7rem 1rem; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: .55; }
button.outline, button.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.secondary { background: var(--panel-2); }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: .7rem; background: #091f29; color: var(--text); padding: .75rem; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(32 199 181 / .12); }
label { display: grid; gap: .4rem; color: var(--muted); font-size: .9rem; }
.checkbox-label { display: flex; align-items: center; gap: .55rem; color: var(--text); }
.checkbox-label input { width: auto; }
small { color: var(--muted); }
.error { color: var(--danger); min-height: 1.25rem; }
#profile-error:empty { display: none; }
#group-edit-error:empty { display: none; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
#app-shell { height: 100dvh; display: grid; grid-template-columns: minmax(280px, 360px) 1fr; max-width: 1500px; margin: auto; background: rgb(7 27 36 / .85); box-shadow: var(--shadow); }
#sidebar { min-width: 0; min-height: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: rgb(13 38 49 / .92); }
.sidebar-header, .chat-header { height: 72px; min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand > span, .brand-logo-button { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; flex: 0 0 2.35rem; padding: 0; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #4dd9ff); color: #07333d; font-size: 1.4rem; }
.brand-logo-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.brand-logo-button { position: relative; }
.header-avatar { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.brand-mark { width: 1.45rem; height: 1.45rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-mark { position: absolute; right: .18rem; bottom: .08rem; display: grid; place-items: center; min-width: 1rem; height: 1rem; padding: 0 .12rem; border-radius: .3rem; background: #07333d; color: #ffffff; font-size: .68rem; line-height: 1; box-shadow: 0 1px 4px rgb(0 0 0 / .28); }
.brand div, .chat-header div { display: grid; min-width: 0; }
.brand strong { white-space: nowrap; }
.profile-trigger { display: grid; min-width: 0; padding: .2rem; text-align: left; background: transparent; color: var(--text); }
.profile-trigger:hover { color: var(--accent); filter: none; }
.profile-trigger small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand.large { justify-content: center; margin-bottom: 1.5rem; }
.brand.large > span { width: 3rem; height: 3rem; flex-basis: 3rem; aspect-ratio: 1; }
.icon-button { background: transparent; color: var(--muted); font-size: 1.4rem; padding: .45rem; }
.chat-header > div:not(.call-buttons) { flex: 1 1 auto; min-width: 0; }
.chat-header .call-buttons { flex: 0 0 auto; display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.call-buttons .icon-button { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; border-radius: 50%; color: var(--text); }
.call-icon { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.call-banner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem clamp(1rem, 4vw, 4rem); border-bottom: 1px solid rgb(32 199 181 / .25); background: rgb(32 199 181 / .1); }
.call-banner.navigate { cursor: pointer; }
.call-banner span { min-width: 0; overflow-wrap: anywhere; }
.call-turn-indicator { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; min-height: 1.8rem; padding: .25rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.call-turn-indicator::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.call-turn-indicator.coturn { background: rgb(40 118 218 / .16); color: #74b8ff; border: 1px solid rgb(116 184 255 / .38); }
.call-turn-indicator.public { background: rgb(139 92 246 / .16); color: #c4b5fd; border: 1px solid rgb(196 181 253 / .4); }
.call-banner audio { width: min(100%, 260px); height: 32px; }
.call-audio-peers { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: end; max-width: min(44vw, 560px); }
.call-audio-peers audio { width: min(100%, 220px); }
.call-actions { display: flex; gap: .45rem; flex-wrap: wrap; justify-content: end; }
.call-banner button { min-height: 2.2rem; padding: .45rem .7rem; }
.call-video-stage { position: relative; width: min(50vw, 560px); aspect-ratio: 16 / 9; background: #020b10; border-radius: .45rem; overflow: hidden; }
.call-video-grid { display: grid; width: 100%; height: 100%; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .2rem; }
.call-video-stage video { display: block; object-fit: cover; background: #020b10; }
#remote-call-video { width: 100%; height: 100%; }
.call-video-grid video { width: 100%; height: 100%; min-width: 0; }
#local-call-video { position: absolute; right: .45rem; bottom: .45rem; width: 28%; min-width: 72px; max-width: 120px; aspect-ratio: 4 / 3; border: 1px solid rgb(255 255 255 / .35); border-radius: .35rem; }
.danger-button { background: #8f2424; color: #ffffff; }
.connection-row { display: flex; gap: .5rem; align-items: center; padding: .55rem 1rem; color: var(--muted); font-size: .78rem; }
.admin-link { margin: 0 1rem .6rem; padding: .65rem .8rem; border: 1px solid #8d6b24; border-radius: .7rem; background: #3b2c12; color: #ffe3a3; text-decoration: none; text-align: center; font-weight: 700; }
#ws-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #ef6464; box-shadow: 0 0 0 3px rgb(239 100 100 / .12); }
#ws-dot.online { background: var(--accent); box-shadow: 0 0 0 3px rgb(32 199 181 / .12); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .5rem 1rem 1rem; }
#conversation-list { min-height: 0; overflow-y: auto; padding: 0 .6rem; flex: 1; }
.swipe-row, .message-row { --swipe-offset: 0px; position: relative; overflow: visible; touch-action: pan-y; }
.conversation-row { margin-bottom: .25rem; border-radius: .7rem; }
.conversation-item { width: 100%; min-width: 0; display: flex; align-items: center; gap: .75rem; text-align: left; background: var(--panel); color: var(--text); padding: .75rem; -webkit-touch-callout: none; user-select: none; }
.conversation-item:hover, .conversation-item.active { background: var(--panel-2); filter: none; }
.swipe-surface { position: relative; z-index: 1; touch-action: pan-y; }
.swipe-actions { position: absolute; z-index: 0; inset-block: 0; right: 0; display: flex; justify-content: end; width: var(--swipe-offset); overflow: hidden; }
.swipe-actions button { width: 56px; height: 100%; padding: 0; border-radius: 0; color: #ffffff; font-size: 1.15rem; }
.swipe-edit { background: #28768a; }
.swipe-delete { background: #ff3b30; }
.action-icon { width: 1.45rem; height: 1.45rem; fill: none; stroke: #ffffff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.conversation-actions-toggle, .swipe-toggle { position: absolute; z-index: 3; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; background: transparent; color: var(--text); font-size: .75rem; letter-spacing: .04rem; }
.conversation-actions-toggle { right: .35rem; top: 50%; transform: translateY(-50%); }
.swipe-toggle { right: .25rem; top: .25rem; }
.message-author-row .swipe-toggle {
  position: static;
  flex: 0 0 2rem;
  margin-left: .25rem;
}
.swipe-open > .conversation-actions-toggle { opacity: 0; pointer-events: none; }
.action-pending { opacity: .55; pointer-events: none; }
.conversation-item > span:nth-child(2) { display: grid; min-width: 0; }
.conversation-item strong, .conversation-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .45rem; min-width: 0; }
.unread-badge { min-width: 1.25rem; height: 1.25rem; padding: 0 .38rem; display: inline-grid; place-items: center; border-radius: 999px; background: var(--accent); color: #032f2c; font-size: .68rem; font-weight: 800; line-height: 1; }
.conversation-item .conversation-description { display: -webkit-box; white-space: normal; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.conversation-item .conversation-description.typing { font-weight: inherit; }
.avatar { flex: 0 0 2.6rem; width: 2.6rem; height: 2.6rem; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #1b5260; color: #a9fff4; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-empty { text-align: center; padding: 2rem; }
#chat-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: linear-gradient(rgb(7 27 36 / .94), rgb(7 27 36 / .94)), radial-gradient(circle, #2f5965 1px, transparent 1px); background-size: auto, 22px 22px; }
.mobile-navigation-button { display: none; }
.sidebar-navigation-button { cursor: default; }
.sidebar-navigation-button .menu-mark { display: none; }
#message-list { overflow-y: auto; padding: 1.5rem clamp(1rem, 4vw, 4rem); display: flex; flex-direction: column-reverse; gap: .65rem; }
#empty-chat { margin: auto; max-width: 30rem; text-align: center; color: var(--muted); background: var(--panel); padding: 1rem 1.3rem; border-radius: .8rem; }
#thread-typing-label { min-height: 1.75rem; padding: .15rem clamp(1rem, 4vw, 4rem) .35rem; color: inherit; font-size: .86rem; font-weight: inherit; }
.typing-dots { display: inline-flex; align-items: center; gap: .18rem; color: currentColor; vertical-align: middle; }
.typing-dots span { width: .34rem; height: .34rem; border-radius: 50%; background: currentColor; opacity: .35; animation: typing-dot 1s ease-in-out infinite; }
.typing-dots span:nth-child(2) { animation-delay: .14s; }
.typing-dots span:nth-child(3) { animation-delay: .28s; }
@keyframes typing-dot {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-.18rem); }
}
.message-row { flex: 0 0 auto; width: fit-content; max-width: min(75%, 680px); min-height: max-content; border-radius: 1rem; }
.message-row.text-message { min-width: 8rem; }
.message-row.file-message { width: min(75%, 680px); }
.message-row.mine { align-self: end; }
.message-row.theirs { align-self: start; }
.message-row.call-history-message { align-self: center; width: min(90%, 420px); min-width: 0; max-width: 90%; }
.call-history-event { display: flex; align-items: center; justify-content: center; gap: .45rem; padding: .42rem .7rem; border: 1px solid rgb(32 199 181 / .18); border-radius: 999px; background: rgb(32 199 181 / .08); color: var(--muted); font-size: .78rem; text-align: center; }
.call-history-event span { min-width: 0; overflow-wrap: anywhere; }
.call-history-event time { flex: none; color: rgb(233 245 244 / .5); font-size: .68rem; }
.message { display: block; width: 100%; max-width: 100%; height: auto; min-height: max-content; margin: 0; padding: .65rem .85rem .45rem; overflow: visible; border-radius: 1rem; box-shadow: 0 4px 14px rgb(0 0 0 / .13); -webkit-touch-callout: none; }
.message.mine { background: #0e695f; border-bottom-right-radius: .25rem; }
.message.theirs { background: var(--panel-2); border-bottom-left-radius: .25rem; }
.message-row.message-deleting { opacity: .55; pointer-events: none; }
.message p { display: block; height: auto; max-height: none; white-space: pre-wrap; overflow: visible; overflow-wrap: anywhere; margin: .25rem 0; line-height: 1.45; }
.message-author-row { display: flex; align-items: center; gap: .4rem; }
.message-avatar { width: 1.55rem; height: 1.55rem; flex: 0 0 1.55rem; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #1b5260; color: #a9fff4; font-size: .65rem; font-weight: 700; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-author { display: block; color: #8cecdf; font-size: .72rem; }
.message time { display: block; text-align: right; color: rgb(233 245 244 / .58); font-size: .68rem; }
.message time.read { color: #74e9ff; }
.file-download-button { margin-left: auto; width: 2rem; height: 2rem; padding: 0; border-radius: 50%; background: rgb(255 255 255 / .12); color: var(--text); font-size: 1.15rem; line-height: 1; }
.file-attachment { display: grid; gap: .45rem; width: min(65vw, 620px); max-width: 100%; margin: .4rem 0; }
.file-title { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.file-title strong { min-width: 0; overflow-wrap: anywhere; }
.file-title small { flex: none; }
.file-preview { display: grid; place-items: center; min-height: 4rem; overflow: hidden; border-radius: .7rem; background: rgb(0 0 0 / .18); color: var(--muted); }
.file-preview img, .file-preview video { display: block; width: 100%; max-height: 420px; object-fit: contain; }
.file-preview audio { width: min(calc(100% - 1.3rem), 420px); margin: .65rem; }
.file-preview-loading { padding: .8rem; color: var(--muted); }
.file-preview .document-page-preview { display: block; width: min(100%, 460px); aspect-ratio: 210 / 297; border: 0; background: #ffffff; }
.file-preview .pdf-page-preview { display: block; max-width: 100%; height: auto !important; background: #ffffff; }
.file-preview .text-document-preview { margin: 0; padding: clamp(.7rem, 3vw, 1.4rem); overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; color: #172124; font: clamp(.55rem, 1.5vw, .76rem)/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; }
.file-preview .text-document-preview + small { padding: .4rem .6rem; }
.file-preview-unavailable { display: grid; place-items: center; gap: .35rem; padding: 1rem; text-align: center; }
.file-preview-unavailable span:first-child { font-size: 2rem; }
.file-preview-error { padding: .8rem; color: var(--danger); text-align: center; }
#composer { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: .65rem; align-items: end; padding: .8rem 1rem max(.8rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.reply-target { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .55rem .7rem; border-left: 3px solid var(--accent); background: rgb(32 199 181 / .08); color: var(--text); }
.reply-target span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-target button { width: 2rem; height: 2rem; padding: 0; border-radius: 50%; background: transparent; color: var(--text); }
.voice-draft { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .65rem; padding: .5rem .65rem; border: 1px solid rgb(32 199 181 / .28); border-radius: .7rem; background: rgb(32 199 181 / .08); }
.voice-draft-status { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.voice-draft audio { width: 100%; min-width: 0; height: 34px; }
.voice-draft button { width: 2rem; height: 2rem; padding: 0; border-radius: 50%; background: transparent; color: var(--text); font-size: 1.2rem; }
#message-input { min-height: 44px; max-height: 140px; resize: vertical; }
.composer-tools { position: relative; display: flex; gap: .25rem; }
.file-picker { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; font-size: 1.35rem; }
.composer-tool-button { width: 44px; height: 44px; padding: 0; background: transparent; color: var(--text); font-size: 1.35rem; }
#send-button.has-expiration { box-shadow: inset 0 -3px 0 rgb(255 227 163 / .65); }
#emoji-picker {
  position: absolute;
  z-index: 10;
  left: 0;
  bottom: calc(100% + .65rem);
  grid-template-columns: repeat(6, 2.5rem);
  gap: .2rem;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}
#emoji-picker:not([hidden]) { display: grid; }
#emoji-picker button { width: 2.5rem; height: 2.5rem; padding: 0; background: transparent; color: var(--text); font-size: 1.35rem; }
.message-pin-badge { padding: .1rem .35rem; border-radius: .4rem; background: rgb(255 227 163 / .16); color: #ffe3a3; }
.message-quick-actions { margin-left: auto; display: inline-flex; gap: .15rem; }
.message-quick-actions button { width: 1.8rem; height: 1.8rem; padding: 0; border-radius: 50%; background: rgb(255 255 255 / .08); color: var(--text); font-size: .9rem; }
.message-reply-preview { width: 100%; margin: .4rem 0 .25rem; padding: .45rem .55rem; border-left: 3px solid var(--accent); border-radius: .45rem; background: rgb(0 0 0 / .13); color: var(--text); text-align: left; font-size: .82rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-reply-preview.has-file { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); align-items: center; gap: .55rem; white-space: normal; }
.message-reply-file-thumb { display: grid; place-items: center; width: 4.5rem; height: 3.2rem; overflow: hidden; border-radius: .35rem; background: rgb(0 0 0 / .22); color: var(--muted); font-size: .68rem; }
.message-reply-file-thumb img, .message-reply-file-thumb video, .message-reply-file-thumb canvas { display: block; width: 100%; height: 100% !important; object-fit: cover; }
.message-reply-file-thumb pre { width: 100%; height: 100%; margin: 0; padding: .25rem; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; background: #fff; color: #172124; font: .42rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.message-reply-file-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-reactions { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .4rem; }
.message-reactions button { padding: .18rem .45rem; border-radius: 999px; background: rgb(255 255 255 / .1); color: var(--text); font-size: .82rem; }
.message-reactions button.mine { background: rgb(32 199 181 / .24); border: 1px solid rgb(32 199 181 / .45); }
dialog { width: min(92vw, 520px); border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 8 12 / .72); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: 1rem; }
dialog h3, dialog p { margin: 0; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.dialog-close { position: absolute; right: .75rem; top: .6rem; background: transparent; color: var(--muted); font-size: 1.4rem; }
.expiration-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .45rem; }
.expiration-options button { min-height: 2.65rem; padding: .55rem .45rem; border: 1px solid var(--line); border-radius: .7rem; background: #091f29; color: var(--text); font-size: .9rem; }
.expiration-options button.selected { border-color: var(--accent); background: rgb(32 199 181 / .18); color: var(--accent); box-shadow: inset 0 0 0 1px rgb(32 199 181 / .28); }
.picker-list { display: grid; gap: .4rem; max-height: 280px; overflow-y: auto; }
.picker-empty { margin: 0; padding: .75rem; text-align: center; color: var(--muted); }
.picker-row { display: flex; align-items: center; justify-content: space-between; text-align: left; background: #0a2029; color: var(--text); border: 1px solid var(--line); }
.picker-row span { display: grid; }
.picker-row .contact-description { color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.picker-row.check { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; gap: 1rem; padding: .7rem; cursor: pointer; }
.picker-row.check input[type="checkbox"] { appearance: auto; width: 1.25rem; height: 1.25rem; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
fieldset { border: 1px solid var(--line); border-radius: .8rem; }
.profile-password { display: grid; gap: .8rem; }
.profile-avatar-editor { display: grid; grid-template-columns: 5rem 1fr; gap: 1rem; align-items: center; }
.profile-avatar-editor > div { display: grid; gap: .55rem; }
.profile-avatar-preview { width: 5rem; height: 5rem; border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, var(--accent), #4dd9ff); border: 2px solid var(--line); }
.profile-theme-label strong { color: var(--text); }
#profile-theme {
  display: block;
  height: 2.75rem;
  padding: 0 .75rem;
  font-size: 1.05rem;
}
.avatar-file-button { display: block; width: fit-content; border-radius: .7rem; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-weight: 700; padding: .65rem .8rem; cursor: pointer; }
.profile-notifications { display: grid; gap: .65rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.profile-notifications h4 { margin: 0; }
.profile-notifications > div { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }
#notification-status { overflow-wrap: anywhere; }
#toasts { position: fixed; z-index: 20; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; }
.toast { max-width: 340px; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: .75rem 1rem; border-radius: .55rem; box-shadow: var(--shadow); }
.toast.popover-toast {
  position: fixed;
  inset: auto 1rem 1rem auto;
  width: max-content;
  margin: 0;
  color: var(--text);
}
.toast.popover-toast::backdrop { background: transparent; }
.toast.error { border-left-color: var(--danger); }
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(100%, 460px); background: rgb(13 38 49 / .96); border: 1px solid var(--line); border-radius: 1.2rem; padding: clamp(1.2rem, 5vw, 2.2rem); box-shadow: var(--shadow); }
.auth-card form { display: grid; gap: 1rem; }
#auth-error { margin: .5rem 0 0; }
#auth-error:empty { min-height: 0; margin: 0; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-bottom: 1.2rem; background: #081f28; padding: .3rem; border-radius: .8rem; }
.auth-tabs button { background: transparent; color: var(--muted); }
.auth-tabs button.active { background: var(--panel-2); color: var(--text); }
.recovery-code-output { display: block; padding: .9rem; border: 1px solid var(--line); border-radius: .7rem; background: #091f29; color: var(--text); font: 700 1.1rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; letter-spacing: .06rem; overflow-wrap: anywhere; }
.admin-page { min-height: 100%; padding: clamp(1rem, 4vw, 3rem); }
.admin-shell { width: min(1200px, 100%); margin: auto; display: grid; gap: 1rem; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.admin-header nav { display: flex; gap: .5rem; }
.admin-header a { color: var(--text); text-decoration: none; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: .7rem; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(100px, 1fr)); gap: .75rem; }
.stat-card, .admin-section { background: rgb(13 38 49 / .94); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
.stat-card { display: grid; gap: .2rem; }
.stat-card strong { font-size: 1.7rem; color: var(--accent); }
.admin-tabs { display: flex; gap: .5rem; overflow-x: auto; margin: .75rem 0; }
.admin-tabs button.active { background: var(--accent); color: #032f2c; }
.admin-toolbar { display: flex; gap: .7rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.admin-toolbar label { flex: 1; max-width: 420px; }
.admin-list { display: grid; gap: 1.15rem; }
.admin-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 1rem; align-items: center; padding: .8rem; border: 1px solid var(--line); border-radius: .8rem; background: #091f29; }
.admin-row-main { display: grid; gap: .25rem; min-width: 0; }
.admin-row-main small { overflow-wrap: anywhere; }
.admin-row-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: .4rem; }
.admin-row-actions button { padding: .5rem .65rem; font-size: .82rem; }
.database-form { display: grid; gap: 1rem; }
.webrtc-settings-form { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.webrtc-settings-form .dialog-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-db-status { min-height: 1.3rem; margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.danger-button { background: #682d36; color: #ffe6e9; }
.warning-button { background: #73551d; color: #fff0c8; }
.badge { display: inline-block; width: fit-content; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .45rem; font-size: .72rem; color: var(--muted); }
.badge.admin { border-color: #8d6b24; color: #ffe3a3; }
.badge.manager { border-color: #2b8793; color: #a8eff8; }
.badge.banned { border-color: #9f4754; color: #ffb7c1; }
@media (max-width: 720px) {
  #app-shell {
    position: relative;
    display: block;
    width: 100%;
    max-width: none;
    overflow: hidden;
  }
  #sidebar,
  #chat-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100dvh;
    transition: transform .22s ease;
    will-change: transform;
  }
  #sidebar {
    z-index: 2;
    transform: translateX(-100%);
    border-right: 0;
  }
  #chat-panel {
    z-index: 1;
    display: grid;
    transform: translateX(0);
  }
  #app-shell.sidebar-open #sidebar {
    transform: translateX(0);
  }
  #app-shell.sidebar-open #chat-panel {
    transform: translateX(30%);
    pointer-events: none;
  }
  #app-shell.sidebar-open .menu-mark { content: ""; }
  #app-shell.sidebar-open .menu-mark { font-size: 0; }
  #app-shell.sidebar-open .menu-mark::after { content: "×"; font-size: .88rem; }
  .mobile-navigation-button { display: grid; }
  .sidebar-navigation-button { cursor: pointer; }
  .sidebar-navigation-button .menu-mark { display: grid; }
  .chat-header { justify-content: flex-start; gap: .75rem; }
  .message-row { max-width: 88%; }
  .message-row.call-history-message { max-width: 94%; }
  .message-row.file-message { width: 88%; }
  .call-banner { align-items: stretch; flex-direction: column; }
  .call-audio-peers { max-width: 100%; justify-content: start; }
  .call-video-stage { width: 100%; max-height: 34vh; }
  .call-actions { justify-content: start; }
  #message-list { padding: 1rem .75rem; }
  #thread-typing-label { padding-inline: .9rem; }
  .voice-draft { grid-template-columns: minmax(0, 1fr) auto; }
  .voice-draft-status { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-row { grid-template-columns: 1fr; }
  .admin-row-actions { justify-content: start; }
  .webrtc-settings-form .dialog-actions { grid-template-columns: 1fr; }
  .admin-header { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar,
  #chat-panel {
    transition: none;
  }
  .typing-dots span {
    animation: none;
    opacity: .7;
  }
}

:root[data-theme="light"] {
  --bg: #edf4f4;
  --panel: #ffffff;
  --panel-2: #e4f0ef;
  --line: #bfd2d1;
  --text: #173337;
  --muted: #607b7d;
  --accent: #0e9f91;
  --accent-dark: #08756c;
  --danger: #b63849;
  --shadow: 0 20px 55px rgb(31 65 68 / .14);
  color-scheme: light;
}

:root[data-theme="light"] body { background: radial-gradient(circle at 90% 5%, #cfe8e7 0, var(--bg) 42%); }
:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select,
:root[data-theme="light"] .recovery-code-output { background: #f8fbfb; }
:root[data-theme="light"] #app-shell { background: rgb(247 251 251 / .94); }
:root[data-theme="light"] #sidebar { background: rgb(255 255 255 / .96); }
:root[data-theme="light"] #chat-panel {
  background:
    linear-gradient(rgb(242 248 248 / .94), rgb(242 248 248 / .94)),
    radial-gradient(circle, #aac8c6 1px, transparent 1px);
  background-size: auto, 22px 22px;
}
:root[data-theme="light"] .message.mine { background: #bdece6; }
:root[data-theme="light"] .message.theirs { background: #ffffff; border: 1px solid var(--line); }
:root[data-theme="light"] .message-author { color: #08756c; }
:root[data-theme="light"] .message time { color: rgb(23 51 55 / .62); }
:root[data-theme="light"] .message time.read { color: #087f9b; }
:root[data-theme="light"] .call-history-event { background: rgb(8 127 113 / .08); color: #426267; }
:root[data-theme="light"] .call-history-event time { color: rgb(23 51 55 / .55); }
:root[data-theme="light"] #composer,
:root[data-theme="light"] .auth-card,
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .admin-section { background: rgb(255 255 255 / .96); }
:root[data-theme="light"] .auth-tabs,
:root[data-theme="light"] .picker-row,
:root[data-theme="light"] .admin-row,
:root[data-theme="light"] .expiration-options button { background: #f4f9f9; }
:root[data-theme="light"] .expiration-options button.selected { background: #dff5f2; color: #08756c; }
:root[data-theme="light"] dialog { background: #ffffff; }
:root[data-theme="light"] dialog::backdrop { background: rgb(37 63 65 / .38); }
:root[data-theme="light"] .avatar { background: #c9e7e4; color: #075e57; }
:root[data-theme="light"] .brand > span,
:root[data-theme="light"] .brand-logo-button { color: #ffffff; }
:root[data-theme="light"] .admin-link { border-color: #cba753; background: #fff4d7; color: #6c4d08; }
:root[data-theme="light"] .danger-button { background: #f8dce0; color: #8e2333; }
:root[data-theme="light"] .warning-button { background: #f7e8bd; color: #6b4c07; }
:root[data-theme="light"] .badge.admin { border-color: #b99032; color: #76540a; }
:root[data-theme="light"] .badge.manager { border-color: #3a9ba6; color: #16717d; }
:root[data-theme="light"] .badge.banned { border-color: #c87480; color: #9b2f40; }
:root[data-theme="light"] .toast { background: #ffffff; }
