:root {
  --bg: #0b1120;
  --bg-elev: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: rgba(148, 163, 184, 0.12);
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --bubble-own: #4f46e5;
  --bubble-own-text: #ffffff;
  --bubble-other: #1e293b;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: rgba(15, 23, 42, 0.06);
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --bubble-own: #4f46e5;
  --bubble-own-text: #ffffff;
  --bubble-other: #eef2f6;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 0.84rem; border-radius: 8px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-subtle); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

.notify-btn.notify-on { color: var(--ok); }
.notify-btn-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  border: 1.5px solid var(--bg-elev);
}
.notify-btn.notify-on .notify-btn-dot {
  background: var(--ok);
}

.muted { color: var(--text-muted); }
.small { font-size: 0.84rem; }
.hint-text { font-size: 0.82rem; color: var(--text-muted); margin: 0; line-height: 1.45; }
.error-text { font-size: 0.86rem; color: var(--danger); }
.max-w-sm { max-width: 380px; }
.flex-1 { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-gap { display: flex; gap: 10px; align-items: center; }
.row-gap-sm { display: flex; gap: 6px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider { height: 1px; background: var(--border); margin: 2px 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.field > span { font-weight: 500; color: var(--text-muted); }
.input-with-btn { display: flex; gap: 8px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.92rem; }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--accent); }

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 310px 1fr;
  height: 100%;
  width: 100%;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.brand-row { display: flex; align-items: center; gap: 10px; }
.logo-sm { width: 28px; height: 28px; }
.logo-lg { width: 56px; height: 56px; }
.brand-name { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }

.sidebar-actions {
  display: flex;
  gap: 8px;
  padding: 0 14px 12px;
}

.section-label {
  padding: 4px 16px 6px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-empty-hint {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}
.room-item:hover { background: var(--bg-hover); }
.room-item.active { background: var(--accent-soft); }

.room-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

.room-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-meta-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.room-item-name {
  font-weight: 600;
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-item-time {
  font-size: 0.74rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.room-meta-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.room-item-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}
.status-pill:hover { color: var(--text); }

.sidebar-username {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 115px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-err { background: var(--danger); }

/* Chat Main */
.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 12px;
}
.empty-state h2 { margin: 4px 0 0; font-size: 1.35rem; }
.empty-state p { margin: 0; line-height: 1.5; }

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lock-icon { font-size: 0.78rem; opacity: 0.85; }

.chat-subtitle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-relay-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relay-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.relay-mode-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  transition: border-color 0.14s, background 0.14s;
}
.relay-mode-option input {
  accent-color: var(--accent);
  margin: 0;
}
.relay-mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.relay-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.relay-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
}
.relay-check-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.relay-check-left input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.relay-check-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot-off { background: var(--text-muted); opacity: 0.45; }

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  width: fit-content;
}
.online-pill:hover { color: var(--text); }

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Call Banner & Active Panel (Compact, Grid, Split 50/50, Spotlight + PiP) */
.call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  flex-wrap: wrap;
}

.call-panel {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.call-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.call-status-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.call-status {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ok);
}

.call-layout-switcher {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.layout-pill {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.layout-pill:hover { color: var(--text); }
.layout-pill.active {
  background: var(--accent);
  color: #fff;
}

.call-stage {
  position: relative;
  width: 100%;
  min-height: 0;
}

.call-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.call-ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
}
.call-ctrl-btn:hover { background: var(--bg-hover); }
.call-ctrl-btn:active { transform: scale(0.94); }
.call-ctrl-btn.is-off {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.45);
}
.call-ctrl-btn.is-off:hover {
  background: rgba(239, 68, 68, 0.26);
}
.call-ctrl-btn-danger {
  width: 54px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  border-color: transparent;
}
.call-ctrl-btn-danger:hover {
  background: #dc2626;
}

/* Mode 1: Compact docked above chat */
.call-panel.call-layout-compact .call-media-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.call-panel.call-layout-compact .media-tile {
  width: 168px;
  height: 112px;
}

.call-panel.call-layout-compact .call-controls-bar {
  justify-content: flex-start;
  gap: 8px;
}

.call-panel.call-layout-compact .call-ctrl-btn {
  width: 38px;
  height: 38px;
}
.call-panel.call-layout-compact .call-ctrl-btn-danger {
  width: 46px;
}

/* Fullscreen overlay base for Grid, Split 50/50, and Spotlight + PiP */
.call-panel.call-layout-grid,
.call-panel.call-layout-split,
.call-panel.call-layout-spotlight {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #060913;
  color: #f8fafc;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-bottom: none;
  gap: 10px;
}

.call-panel.call-layout-grid .call-layout-switcher,
.call-panel.call-layout-split .call-layout-switcher,
.call-panel.call-layout-spotlight .call-layout-switcher {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(255, 255, 255, 0.16);
}

.call-panel.call-layout-grid .layout-pill,
.call-panel.call-layout-split .layout-pill,
.call-panel.call-layout-spotlight .layout-pill {
  color: rgba(241, 245, 249, 0.78);
}

.call-panel.call-layout-grid .layout-pill:hover,
.call-panel.call-layout-split .layout-pill:hover,
.call-panel.call-layout-spotlight .layout-pill:hover,
.call-panel.call-layout-grid .layout-pill.active,
.call-panel.call-layout-split .layout-pill.active,
.call-panel.call-layout-spotlight .layout-pill.active {
  color: #ffffff;
}

.call-panel.call-layout-grid .call-fs-btn,
.call-panel.call-layout-split .call-fs-btn,
.call-panel.call-layout-spotlight .call-fs-btn {
  color: #e2e8f0;
}
.call-panel.call-layout-grid .call-fs-btn:hover,
.call-panel.call-layout-split .call-fs-btn:hover,
.call-panel.call-layout-spotlight .call-fs-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.call-panel.call-layout-grid .call-ctrl-btn,
.call-panel.call-layout-split .call-ctrl-btn,
.call-panel.call-layout-spotlight .call-ctrl-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.18);
}
.call-panel.call-layout-grid .call-ctrl-btn:hover,
.call-panel.call-layout-split .call-ctrl-btn:hover,
.call-panel.call-layout-spotlight .call-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}
.call-panel.call-layout-grid .call-ctrl-btn.is-off,
.call-panel.call-layout-split .call-ctrl-btn.is-off,
.call-panel.call-layout-spotlight .call-ctrl-btn.is-off {
  background: rgba(239, 68, 68, 0.26);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.55);
}
.call-panel.call-layout-grid .call-ctrl-btn-danger,
.call-panel.call-layout-split .call-ctrl-btn-danger,
.call-panel.call-layout-spotlight .call-ctrl-btn-danger {
  background: #ef4444;
  color: #ffffff;
  border-color: transparent;
}
.call-panel.call-layout-grid .call-ctrl-btn-danger:hover,
.call-panel.call-layout-split .call-ctrl-btn-danger:hover,
.call-panel.call-layout-spotlight .call-ctrl-btn-danger:hover {
  background: #dc2626;
}

.call-cam-select {
  height: 40px;
  max-width: 170px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  text-overflow: ellipsis;
}
.call-cam-select:focus {
  border-color: var(--accent);
}
.call-cam-select option {
  background: #0f172a;
  color: #f8fafc;
}

.call-panel.call-layout-grid .call-stage,
.call-panel.call-layout-split .call-stage,
.call-panel.call-layout-spotlight .call-stage {
  flex: 1;
  display: flex;
  overflow: hidden;
  border-radius: 14px;
}

.call-panel.call-layout-grid .call-controls-bar,
.call-panel.call-layout-split .call-controls-bar,
.call-panel.call-layout-spotlight .call-controls-bar {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  width: fit-content;
  margin: 0 auto;
}

/* Mode 2: Equal Fullscreen Grid */
.call-panel.call-layout-grid .call-media-grid {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(var(--grid-cols, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

.call-panel.call-layout-grid .media-tile {
  width: 100%;
  height: 100%;
}

/* Mode 3: 50/50 Split Screen */
.call-panel.call-layout-split .call-media-grid {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.call-panel.call-layout-split .media-tile {
  width: 100%;
  height: 100%;
}

@media (max-width: 768px) and (orientation: portrait) {
  .call-panel.call-layout-split .call-media-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

/* Mode 4: Spotlight Fullscreen + Floating Bottom-Right PiP */
.call-panel.call-layout-spotlight .call-media-grid {
  width: 100%;
  height: 100%;
  display: flex;
}

.call-panel.call-layout-spotlight .call-media-grid .media-tile {
  width: 100%;
  height: 100%;
  border-radius: 14px;
}

.call-pip-slot {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: min(210px, 34vw);
  aspect-ratio: 4 / 3;
  z-index: 5;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}

.call-pip-slot .media-tile {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(255, 255, 255, 0.28);
}

.call-strip-slot {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 8px;
  max-width: calc(100% - min(240px, 38vw) - 24px);
  overflow-x: auto;
  z-index: 5;
}

.call-strip-slot .media-tile {
  width: 112px;
  height: 82px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Video Tile Base */
.media-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #131c31;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.media-tile:hover {
  border-color: var(--accent);
}

.media-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-tile.is-local video {
  transform: scaleX(-1);
}

.media-tile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
}

.call-layout-compact .media-tile-avatar,
.call-strip-slot .media-tile-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}

.media-tile-label {
  position: absolute;
  left: 8px;
  bottom: 7px;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 500;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.72rem;
}

.media-tile-conn {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.92);
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 700;
}
.media-tile-conn.is-failed {
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
}

/* Messages Stream */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  scroll-behavior: smooth;
}

.messages-list {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
  font-size: 0.92rem;
}

.date-divider {
  align-self: center;
  margin: 12px 0 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.msg-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 78%;
  position: relative;
}

.msg-row.own {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.grouped {
  margin-top: -2px;
}

.msg-author {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 4px 3px;
  font-size: 0.8rem;
}

.msg-author-name { font-weight: 650; }
.msg-author-fp { font-size: 0.72rem; color: var(--text-muted); font-family: monospace; }

.msg-bubble-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.msg-row.own .msg-bubble-wrap {
  flex-direction: row-reverse;
}

.msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  background: var(--bubble-other);
  line-height: 1.45;
  font-size: 0.94rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  position: relative;
}

.msg-row.own .msg-bubble {
  background: var(--bubble-own);
  color: var(--bubble-own-text);
  border-bottom-right-radius: 5px;
}

.msg-row:not(.own) .msg-bubble {
  border-bottom-left-radius: 5px;
}

.msg-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-reply-quote {
  padding: 5px 8px;
  margin-bottom: 6px;
  border-left: 3px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.14);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.msg-row:not(.own) .msg-reply-quote {
  border-left-color: var(--accent);
  background: var(--bg-hover);
}

.msg-reply-quote-author {
  font-weight: 600;
  display: block;
  margin-bottom: 1px;
}

.msg-reply-quote-text {
  opacity: 0.85;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  margin-left: 4px;
  margin-right: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.14s;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 4px;
}

.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions {
  opacity: 1;
}

.msg-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 999px;
  font-size: 0.86rem;
  line-height: 1;
  color: var(--text-muted);
}
.msg-act-btn svg { display: block; }
.msg-act-btn:hover { background: var(--bg-hover); color: var(--text); }
.msg-act-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

.msg-reply-deleted { font-style: italic; opacity: 0.65; }

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 0.78rem;
  cursor: pointer;
}
.reaction-pill.reacted {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.msg-highlight .msg-bubble {
  box-shadow: 0 0 0 3px var(--accent);
  transition: box-shadow 0.3s;
}

/* Typing, Reply Bar & Composer */
.typing-bar {
  padding: 4px 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
}

.reply-bar-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.reply-bar-content span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}

.composer textarea {
  resize: none;
  max-height: 130px;
  min-height: 40px;
  line-height: 1.4;
  padding: 9px 12px;
  border-radius: 12px;
}

.send-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  flex-shrink: 0;
}

.emoji-wrap { position: relative; }

.picker-popover {
  position: absolute;
  bottom: 50px;
  left: 0;
  width: min(352px, calc(100vw - 24px));
  height: 390px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 60;
}

.picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.picker-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 650;
  padding: 9px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.picker-tab:hover { color: var(--text); }
.picker-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-elev);
}

.picker-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.picker-search-wrap {
  padding: 8px 10px 6px;
}
.picker-search-wrap input {
  padding: 7px 10px;
  font-size: 0.86rem;
  border-radius: 9px;
}

.emoji-cat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 6px;
  border-bottom: 1px solid var(--border);
  gap: 2px;
}

.emoji-cat-btn {
  flex: 1;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.62;
  transition: opacity 0.12s, background 0.12s;
}
.emoji-cat-btn:hover { opacity: 1; background: var(--bg-hover); }
.emoji-cat-btn.active {
  opacity: 1;
  background: var(--accent-soft);
}

.emoji-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-content: start;
  gap: 3px;
}

.emoji-btn {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.emoji-btn:hover { background: var(--bg-hover); transform: scale(1.12); }

.picker-empty {
  grid-column: 1 / -1;
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

/* GIF Picker Grid & In-Bubble GIF */
.gif-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-content: start;
  gap: 6px;
}

.gif-thumb-btn {
  border: none;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-subtle);
  cursor: pointer;
  height: 98px;
}
.gif-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gif-thumb-btn:hover { outline: 2px solid var(--accent); }

.gif-url-bar {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.gif-url-bar input {
  padding: 7px 9px;
  font-size: 0.8rem;
}

.msg-gif {
  display: block;
  max-width: min(280px, 65vw);
  max-height: 260px;
  border-radius: 10px;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.12);
}

/* Read Receipts ("Nähtud") */
.msg-seen-bar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 3px;
  margin-bottom: 2px;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
}
.msg-seen-bar:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.seen-dots {
  display: inline-flex;
  align-items: center;
}
.seen-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -3px;
  border: 1.5px solid var(--bg);
}
.seen-dot:first-child { margin-left: 0; }

/* Modals & Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal.card {
  width: 100%;
  max-width: 440px;
  max-height: 90dvh;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal.modal-sm { max-width: 340px; }
.modal.modal-lg { max-width: 520px; }
.modal.modal-xl { max-width: 760px; max-height: 88dvh; }
.modal.modal-scroll { overflow-y: auto; }

/* Rendered README Markdown Body */
.md-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.md-body h1 { font-size: 1.35rem; margin: 4px 0 2px; }
.md-body h2 { font-size: 1.12rem; margin: 14px 0 2px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1rem; margin: 10px 0 2px; }
.md-body h4 { font-size: 0.92rem; margin: 8px 0 2px; color: var(--text-muted); }
.md-body p { margin: 0; }
.md-body ul, .md-body ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.md-body blockquote {
  margin: 4px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 0.86rem;
}
.md-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 5px;
}
.md-body pre {
  margin: 2px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.md-body pre code {
  background: transparent;
  padding: 0;
  white-space: pre;
}
.md-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.md-body th, .md-body td {
  text-align: left;
  padding: 7px 9px;
  border: 1px solid var(--border);
}
.md-body th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.info-box {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.info-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.info-box summary::before {
  content: "ℹ️";
  font-size: 0.9rem;
}
.info-list {
  margin: 8px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.45;
}

.identity-status-pill {
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
}

.settings-scroll {
  overflow-y: auto;
  padding-right: 4px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }

.modal-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.brand-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.brand-center h1, .brand-center h2 { margin: 4px 0 0; }
.brand-center p { margin: 0; font-size: 0.92rem; line-height: 1.45; }

.e2ee-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}

.invite-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  text-align: center;
  font-size: 0.9rem;
}

.cred-box {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.settings-group h4 {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.danger-zone {
  border-bottom: none;
  padding-bottom: 0;
}

.relay-status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.relay-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  font-family: monospace;
}

.online-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55dvh;
  overflow-y: auto;
}

.online-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.online-row-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
  border-radius: 10px;
  cursor: pointer;
  padding: 7px 8px;
  transition: background 0.14s, border-color 0.14s;
}
.online-row-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}

.members-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 6px 4px 2px;
}

.member-status-wrap {
  position: relative;
  flex-shrink: 0;
}

.member-status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-elev);
  background: var(--text-muted);
}
.member-status-dot.is-online {
  background: var(--ok);
}

.member-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.member-status-badge {
  font-size: 0.68rem;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.member-status-badge.is-online {
  background: rgba(16, 185, 129, 0.16);
  color: var(--ok);
}

.archived-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  opacity: 0.88;
}

.archived-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.archived-handle {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Room Admin Badges & Controls */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 750;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.member-item-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-item-wrap .online-row-btn {
  flex: 1;
  min-width: 0;
}

.member-admin-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-xs {
  padding: 4px 7px;
  font-size: 0.72rem;
  border-radius: 7px;
  font-weight: 650;
}

.admin-panel-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  margin-top: 4px;
}

.online-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

/* Unique Per-Room Handles & Verified Name-Chain ("Plokiahel") */
.my-handle-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 185px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.14s, background 0.14s;
}
.my-handle-pill:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.msg-author-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px 1px 4px;
  margin-left: -4px;
  border: none;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  transition: background 0.14s;
}
.msg-author-btn:hover {
  background: var(--bg-hover);
}
.msg-author-btn:hover .msg-author-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-author-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0 5px;
  border-radius: 5px;
  line-height: 1.35;
}

.msg-author-chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0 5px;
  border-radius: 999px;
  margin-left: 3px;
}

.nick-change-row {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}

.nick-change-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.77rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.nick-change-pill:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.user-history-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-history-avatar {
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
}

.user-history-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-history-handle {
  font-size: 1.08rem;
  font-weight: 750;
  word-break: break-word;
}

.user-history-status {
  font-size: 0.8rem;
  color: var(--ok);
  font-weight: 600;
}

.chain-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 36dvh;
  overflow-y: auto;
  padding: 4px 2px 4px 14px;
  border-left: 2px solid var(--accent);
  margin-left: 6px;
}

.chain-block {
  position: relative;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.chain-block::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 15px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
}
.chain-block.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chain-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.chain-block-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.94rem;
}

.chain-block-seq {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.chain-block-current {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

.chain-block-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.chain-block-hashes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.9;
  word-break: break-all;
}

.chain-block-verified {
  color: var(--ok);
  font-weight: 600;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  font-weight: 500;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive Mobile Layout */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .mobile-only { display: inline-flex; }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell:not(.mobile-chat-open) .chat-main {
    display: none;
  }

  .app-shell.mobile-chat-open .sidebar {
    display: none;
  }

  .msg-row { max-width: 88%; }

  /* Always make reply/react buttons gently reachable on touch devices */
  .msg-actions { opacity: 0.7; }
}
