/* ==========================================================================
   MyZNC — Persistent Web & Mobile IRC Client
   Themes: classic (IRCCloud dark sidebar + crisp light chat), dark, light
   Densities: cozy (grouped), compact (classic IRC line grid)
   ========================================================================== */

:root,
[data-theme="classic"] {
  /* Left Sidebar (IRCCloud signature deep navy-slate) */
  --sb-bg: #121722;
  --sb-bg-elevated: #1a2130;
  --sb-bg-hover: rgba(255, 255, 255, 0.06);
  --sb-bg-active: #2563eb;
  --sb-border: rgba(255, 255, 255, 0.075);
  --sb-text: #cbd5e1;
  --sb-text-strong: #f8fafc;
  --sb-text-muted: #7c8ba1;
  --sb-unread-text: #ffffff;

  /* Chat Workspace & Right Sidebar (crisp neutral light) */
  --bg-main: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-code: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Brand & Semantic Signals */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-text: #ffffff;

  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;

  --hl-bg: #fef2f2;
  --hl-border: #ef4444;
  --notice-bg: #eff6ff;
  --notice-border: #3b82f6;
  --link: #1d4ed8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.22);
  --scrim: rgba(10, 14, 23, 0.55);
}

[data-theme="dark"] {
  --sb-bg: #0c1017;
  --sb-bg-elevated: #141a25;
  --sb-bg-hover: rgba(255, 255, 255, 0.055);
  --sb-bg-active: #2563eb;
  --sb-border: rgba(255, 255, 255, 0.07);
  --sb-text: #b8c4d6;
  --sb-text-strong: #f1f5f9;
  --sb-text-muted: #6e7d94;
  --sb-unread-text: #ffffff;

  --bg-main: #121620;
  --bg-subtle: #161b27;
  --bg-elevated: #1a2130;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-input: #0e121b;
  --bg-code: #0d1118;
  --border: #222a3a;
  --border-strong: #2f3a4f;

  --text-main: #e5ebf3;
  --text-secondary: #a8b5c8;
  --text-muted: #7f8ea3;
  --text-faint: #5c6b82;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-text: #ffffff;

  --hl-bg: rgba(239, 68, 68, 0.11);
  --hl-border: #ef4444;
  --notice-bg: rgba(59, 130, 246, 0.1);
  --notice-border: #3b82f6;
  --link: #60a5fa;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.65);
  --scrim: rgba(4, 6, 11, 0.7);
}

[data-theme="light"] {
  --sb-bg: #f1f5f9;
  --sb-bg-elevated: #ffffff;
  --sb-bg-hover: rgba(15, 23, 42, 0.055);
  --sb-bg-active: #2563eb;
  --sb-border: #e2e8f0;
  --sb-text: #334155;
  --sb-text-strong: #0f172a;
  --sb-text-muted: #64748b;
  --sb-unread-text: #0f172a;

  --bg-main: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-code: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-text: #ffffff;

  --hl-bg: #fef2f2;
  --hl-border: #ef4444;
  --notice-bg: #eff6ff;
  --notice-border: #3b82f6;
  --link: #1d4ed8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.2);
  --scrim: rgba(15, 23, 42, 0.48);
}

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
  --sidebar-w: 264px;
  --nicklist-w: 226px;
  --header-h: 54px;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 13px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-main);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.mt-12 {
  margin-top: 12px;
}

/* Scrollbar polish */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 135, 160, 0.28);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 135, 160, 0.46);
}

/* ==================== BOOT LOADER ==================== */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f141f;
}
.boot-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.boot-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.14);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== STATUS DOTS ==================== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #64748b;
}
.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
}
.status-dot.connecting,
.status-dot.reconnecting {
  background: var(--warn);
  animation: pulseDot 1.3s ease-in-out infinite;
}
.status-dot.disconnected {
  background: transparent;
  border: 1.6px solid var(--sb-text-muted);
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ==================== AUTH SCREEN ==================== */
.auth-view {
  height: 100dvh;
  overflow-y: auto;
  background: #0d121c;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.auth-shell {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 52px;
  align-items: center;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 24px;
}
.brand-wordmark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f8fafc;
}
.brand-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.28);
}

.auth-headline {
  font-size: 36px;
  line-height: 1.14;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #ffffff;
  margin: 0 0 14px;
}
.auth-subcopy {
  font-size: 15px;
  line-height: 1.6;
  color: #94a3b8;
  margin: 0 0 24px;
  max-width: 470px;
}

.auth-preview {
  background: #131a28;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}
.ap-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #0f1521;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12.5px;
}
.ap-chan {
  font-weight: 700;
  color: #f8fafc;
}
.ap-net {
  color: #64748b;
  font-size: 12px;
}
.ap-pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 8px;
  border-radius: 99px;
}
.ap-lines {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.ap-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 2px 6px;
  border-radius: 4px;
}
.ap-line.hl {
  background: rgba(239, 68, 68, 0.12);
  border-left: 2px solid #ef4444;
}
.ap-ts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #64748b;
  flex-shrink: 0;
}
.ap-nick {
  font-weight: 650;
  flex-shrink: 0;
}
.ap-nick.c1 { color: #60a5fa; }
.ap-nick.c2 { color: #34d399; }
.ap-nick.c3 { color: #fbbf24; }
.ap-txt { color: #cbd5e1; }
.ap-fold {
  font-size: 11.5px;
  color: #64748b;
  padding: 1px 6px 1px 46px;
}

.auth-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13.5px;
  color: #cbd5e1;
}
.auth-features li {
  display: flex;
  align-items: center;
  gap: 9px;
}
.auth-features svg {
  width: 17px;
  height: 17px;
  color: #10b981;
  flex-shrink: 0;
}

.auth-card {
  background: #151c2b;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.48);
}

.auth-mobile-brand {
  display: none;
  align-items: center;
  gap: 11px;
  margin-bottom: 20px;
}
.auth-mobile-sub {
  font-size: 12px;
  color: #94a3b8;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #0d121c;
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.auth-tab {
  padding: 9px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13.5px;
  color: #94a3b8;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: #2563eb;
  color: #ffffff;
}

.auth-form .field label {
  color: #cbd5e1;
}
.auth-form input {
  background: #0d121c;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}
.auth-form input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.auth-switch-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
}
.link-btn {
  color: #60a5fa;
  font-weight: 600;
}
.link-btn:hover {
  text-decoration: underline;
}

/* ==================== FORMS & BUTTONS ==================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 13px;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.label-hint {
  font-weight: 400;
  color: var(--text-muted);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="number"],
.field input[type="search"],
.field textarea,
.field select {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.field textarea {
  resize: vertical;
  min-height: 58px;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 0.95fr;
  gap: 12px;
}
.field-port-tls {
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
}
.field-port-tls > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.check-pill input {
  accent-color: var(--accent);
  margin: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  margin-bottom: 10px;
  user-select: none;
}
.checkbox-row input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}
.checkbox-stack {
  justify-content: center;
}

.form-alert {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
}
.form-alert.error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}
[data-theme="classic"] .modal-card .form-alert.error,
[data-theme="light"] .modal-card .form-alert.error {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
  transition: background 0.14s, border-color 0.14s, opacity 0.14s, transform 0.06s;
  white-space: nowrap;
}
.btn:active {
  transform: translateY(0.5px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-main);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
}
.btn-block { width: 100%; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 5px; }

/* ==================== MAIN 3-PANE APP SHELL ==================== */
.app-shell {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--bg-main);
}

.drawer-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.drawer-scrim.visible {
  display: block;
  opacity: 1;
}

/* ==================== LEFT SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sb-bg);
  color: var(--sb-text);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
  z-index: 50;
}

.sidebar-top {
  height: var(--header-h);
  padding: 0 12px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-logo {
  border-radius: 6px;
}
.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--sb-text-strong);
}
.ws-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}
.ws-indicator.offline {
  background: var(--warn);
  animation: pulseDot 1.2s infinite;
}

.sidebar-top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.sb-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-text-muted);
  transition: background 0.14s, color 0.14s;
}
.sb-icon-btn:hover {
  background: var(--sb-bg-hover);
  color: var(--sb-text-strong);
}
.sb-icon-btn svg {
  width: 17px;
  height: 17px;
}

.sidebar-search-wrap {
  padding: 10px 10px 6px;
  flex-shrink: 0;
}
.sidebar-search-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--sb-bg-elevated);
  border: 1px solid var(--sb-border);
  color: var(--sb-text-muted);
  font-size: 12.5px;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
}
.sidebar-search-btn:hover {
  color: var(--sb-text-strong);
  border-color: rgba(148, 163, 184, 0.3);
}
.sidebar-search-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.sidebar-search-btn kbd {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sb-bg-hover);
  color: var(--sb-text-muted);
}

/* Network & Buffer Tree */
.network-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 14px;
}

.sb-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--sb-text-muted);
  font-size: 13px;
}
.sb-empty p {
  margin: 0 0 14px;
  line-height: 1.5;
}

.net-group {
  margin-bottom: 12px;
}
.net-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 6px 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--sb-text-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
}
.net-header:hover {
  background: var(--sb-bg-hover);
}
.net-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.net-lag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--sb-text-muted);
  text-transform: none;
}
.net-actions {
  display: flex;
  align-items: center;
  gap: 1px;
}
.net-act-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-text-muted);
}
.net-act-btn:hover {
  background: var(--sb-bg-hover);
  color: var(--sb-text-strong);
}
.net-act-btn svg {
  width: 14px;
  height: 14px;
}

.buf-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
}

.buf-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6.5px 9px 6.5px 12px;
  border-radius: var(--radius-sm);
  color: var(--sb-text);
  font-size: 13.5px;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  position: relative;
}
.buf-item:hover {
  background: var(--sb-bg-hover);
  color: var(--sb-text-strong);
}
.buf-item.has-unread {
  color: var(--sb-unread-text);
  font-weight: 650;
}
.buf-item.has-unread::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3.5px;
  height: 14px;
  border-radius: 99px;
  background: #3b82f6;
}
.buf-item.has-highlight::before {
  background: var(--danger);
}
.buf-item.active {
  background: var(--sb-bg-active);
  color: #ffffff;
  font-weight: 600;
}
.buf-item.active::before {
  display: none;
}
.buf-item.parted:not(.active) {
  opacity: 0.52;
}
.buf-item.muted:not(.active) {
  opacity: 0.56;
}

.buf-sym {
  width: 14px;
  text-align: center;
  font-weight: 600;
  color: var(--sb-text-muted);
  flex-shrink: 0;
  font-size: 13px;
}
.buf-item.active .buf-sym,
.buf-item.has-unread .buf-sym {
  color: inherit;
  opacity: 0.85;
}
.buf-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.buf-pin {
  font-size: 10px;
  opacity: 0.65;
}
.buf-badge {
  min-width: 19px;
  height: 18px;
  padding: 0 5.5px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.22);
  color: var(--sb-text-strong);
  flex-shrink: 0;
}
.buf-badge.highlight {
  background: var(--danger);
  color: #ffffff;
}
.buf-item.active .buf-badge:not(.highlight) {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.buf-subhead {
  font-size: 11px;
  font-weight: 600;
  color: var(--sb-text-muted);
  padding: 7px 12px 3px;
}
.archived-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 11.5px;
  color: var(--sb-text-muted);
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
}
.archived-toggle:hover {
  color: var(--sb-text);
  background: var(--sb-bg-hover);
}

.sidebar-footer {
  padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  background: var(--sb-bg);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.sb-avatar {
  width: 31px;
  height: 31px;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-user-meta {
  min-width: 0;
}
.sb-username {
  font-size: 13px;
  font-weight: 650;
  color: var(--sb-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-status {
  font-size: 11px;
  color: var(--sb-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-footer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* ==================== CENTER CHAT PANE ==================== */
.main-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--bg-main);
}

.chat-header {
  min-height: var(--header-h);
  padding: env(safe-area-inset-top) 12px 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}

.mobile-menu-btn {
  display: none;
  position: relative;
}
.mobile-unread-badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-unread-badge.highlight {
  background: var(--danger);
}

.header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  overflow: hidden;
}
.header-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  max-width: 100%;
}
.header-prefix {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
}
.header-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-modes {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}
.header-net-pill {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
}
.header-topic {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: left;
  padding: 3px 6px;
  border-radius: 4px;
}
.header-topic:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.hdr-btn {
  height: 34px;
  min-width: 34px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.14s, color 0.14s;
}
.hdr-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.hdr-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.hdr-btn svg {
  width: 18px;
  height: 18px;
}

/* Status Banners */
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.status-banner.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}
[data-theme="dark"] .status-banner.warn { color: #fbbf24; }
.status-banner.offline {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}
.status-banner.info {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}
.status-banner.unread {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.status-banner.invite {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  font-weight: 600;
}
[data-theme="dark"] .status-banner.invite { color: #34d399; }
.banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==================== ONBOARDING (0 NETWORKS) ==================== */
.onboarding-view {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.onboarding-inner {
  width: 100%;
  max-width: 760px;
  margin: auto 0;
}
.onboarding-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 12px;
}
.onboarding-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}
.onboarding-inner h2 {
  margin: 0 0 8px;
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.025em;
}
.onboarding-inner > p {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 14.5px;
  max-width: 600px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 11px;
  margin-bottom: 22px;
}
.preset-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 14px 15px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.preset-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.pc-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.pc-name {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-main);
}
.pc-tls {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  font-weight: 600;
}
.pc-tls.plain {
  background: var(--bg-hover);
  color: var(--text-muted);
}
.pc-host {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.pc-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.onboarding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==================== MESSAGE TIMELINE ==================== */
.message-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0 12px;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 16px 10px;
}
.load-more-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 14px;
  border-radius: 99px;
}
.load-more-btn:hover {
  opacity: 0.85;
}

.message-list {
  display: flex;
  flex-direction: column;
}

/* Date Divider & Unread Marker (classic IRCCloud style) */
.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 6px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-muted);
  user-select: none;
}
.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.unread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--danger);
  user-select: none;
}
.unread-divider::before,
.unread-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--danger);
  opacity: 0.55;
}

/* Cozy Mode Messages */
.msg-row {
  padding: 2px 18px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-row:hover {
  background: var(--bg-hover);
}
.msg-row.group-start {
  margin-top: 7px;
  padding-top: 3px;
}
.msg-row.is-highlight {
  background: var(--hl-bg);
  border-left: 3px solid var(--hl-border);
  padding-left: 15px;
}
.msg-row.jump-flash {
  animation: flashJump 2.2s ease;
}
@keyframes flashJump {
  0%, 25% { background: rgba(245, 158, 11, 0.25); }
  100% { background: transparent; }
}

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 1px;
}
.msg-sender {
  font-weight: 700;
  font-size: 13.8px;
  color: var(--text-main);
  cursor: pointer;
}
.msg-sender:hover {
  text-decoration: underline;
}
.msg-role {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  opacity: 0.78;
  margin-right: 1px;
}
.msg-time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  flex-shrink: 0;
  user-select: none;
}
.msg-hover-time {
  display: none;
  position: absolute;
  left: 4px;
  top: 4px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}
.msg-row.group-cont {
  padding-left: 18px;
}
.msg-body {
  font-size: 14px;
  line-height: 1.48;
  color: var(--text-main);
  white-space: pre-wrap;
}

/* Action (/me) */
.msg-row.type-action {
  padding-top: 3px;
  padding-bottom: 3px;
  font-style: italic;
  color: var(--text-secondary);
}
.msg-action-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.action-star {
  color: var(--accent);
  font-weight: 700;
  font-style: normal;
}

/* Notice */
.msg-row.type-notice {
  background: var(--notice-bg);
  border-left: 3px solid var(--notice-border);
  padding: 4px 18px 4px 15px;
  margin: 2px 0;
}
.notice-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Compact Mode (classic IRC single-line table alignment) */
[data-density="compact"] .msg-row {
  padding: 1.5px 14px;
  margin-top: 0;
}
[data-density="compact"] .msg-compact-grid {
  display: grid;
  grid-template-columns: 54px 112px 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 13.3px;
  line-height: 1.42;
}
[data-density="compact"] .mc-nick {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
  border-right: 1px solid var(--border);
  font-weight: 650;
  cursor: pointer;
}
[data-density="compact"] .mc-nick:hover {
  text-decoration: underline;
}
[data-density="compact"] .msg-body {
  font-size: 13.3px;
  line-height: 1.42;
}

/* Presence, System, Error, Topic Events */
.event-row {
  padding: 2px 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.event-description { min-width: 0; overflow-wrap: anywhere; }
.event-userhost { color: var(--text-faint); }
.event-icon {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 700;
}
.event-row.ev-join .event-icon { color: var(--success); }
.event-row.ev-part .event-icon,
.event-row.ev-quit .event-icon { color: var(--text-faint); }
.event-row.ev-kick { color: var(--danger); }
.event-row.ev-error {
  color: var(--danger);
  background: var(--hl-bg);
  padding-top: 4px;
  padding-bottom: 4px;
}
.event-row.ev-topic {
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-left: 3px solid var(--accent);
  padding: 5px 18px 5px 15px;
  margin: 4px 0;
}

/* Folded Join/Part/Quit Summary Pill (signature IRCCloud UX) */
.folded-events {
  padding: 2px 18px;
}
.folded-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s;
}
.folded-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.folded-details {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

/* MOTD Card */
.motd-card {
  margin: 6px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-code);
  overflow: hidden;
}
.motd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-secondary);
}
.motd-pre {
  margin: 0;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.8px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-x: auto;
  color: var(--text-secondary);
}
.motd-pre.collapsed {
  max-height: 132px;
  overflow: hidden;
  position: relative;
}

/* Rich WHOIS & /help Cards */
.info-card {
  margin: 6px 18px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  max-width: 640px;
}
.whois-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.whois-nick {
  font-size: 15px;
  font-weight: 750;
  color: var(--text-main);
}
.whois-host {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.whois-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.w-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.w-badge.tls { color: var(--success); border-color: rgba(16, 185, 129, 0.35); }
.w-badge.acct { color: var(--accent); border-color: rgba(37, 99, 235, 0.35); }
.w-badge.oper { color: var(--warn); border-color: rgba(245, 158, 11, 0.4); }
.whois-grid {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 4px 10px;
  font-size: 12.5px;
}
.whois-k {
  color: var(--text-muted);
  font-weight: 600;
}
.whois-v {
  color: var(--text-main);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 5px 16px;
  margin-top: 8px;
  font-size: 12.5px;
}
.help-cmd {
  font-family: var(--font-mono);
  font-weight: 650;
  color: var(--accent);
}

/* Inline Channel Chips & Search Highlights */
.inline-chan {
  color: var(--link);
  font-weight: 600;
  padding: 0 2px;
  border-radius: 3px;
}
.inline-chan:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}
.search-mark {
  background: rgba(245, 158, 11, 0.35);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

/* mIRC formatting styles */
.irc-b { font-weight: 700; }
.irc-i { font-style: italic; }
.irc-u { text-decoration: underline; }
.irc-s { text-decoration: line-through; }
.irc-m { font-family: var(--font-mono); font-size: 0.93em; background: var(--bg-code); padding: 1px 4px; border-radius: 3px; }
.irc-rev { background: var(--text-main); color: var(--bg-main); padding: 0 3px; border-radius: 2px; }

/* Inline Link & Image Previews (IRCCloud embeds) */
.msg-embeds {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 5px;
}
.embed-img-wrap {
  position: relative;
  display: inline-block;
  max-width: min(380px, 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}
.embed-img-wrap img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  cursor: zoom-in;
}
.embed-card {
  display: flex;
  align-items: stretch;
  gap: 12px;
  max-width: 500px;
  padding: 9px 28px 9px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  position: relative;
}
.embed-body {
  flex: 1;
  min-width: 0;
}
.embed-site {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.embed-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--link);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.embed-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.embed-thumb {
  width: 68px;
  height: 68px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  cursor: zoom-in;
}
.embed-dismiss {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
}
.embed-dismiss:hover {
  opacity: 1;
  color: var(--text-main);
}

/* Scroll-to-Bottom FAB */
.scroll-bottom-fab {
  position: absolute;
  right: 20px;
  bottom: 76px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 99px;
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  font-weight: 650;
}
.scroll-bottom-fab svg {
  width: 15px;
  height: 15px;
}

/* ==================== COMPOSER ==================== */
.composer-wrap {
  padding: 8px 14px max(10px, env(safe-area-inset-bottom));
  background: var(--bg-main);
  border-top: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 6px 5px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-main);
}

.nick-pill {
  height: 32px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-secondary);
  max-width: 125px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  margin-bottom: 1px;
}
.nick-pill:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}
.nick-pill.is-away {
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.4);
}

.composer-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  padding: 6px 2px;
  max-height: 132px;
  line-height: 1.42;
  font-size: 14px;
  color: var(--text-main);
}
.composer-input::placeholder {
  color: var(--text-faint);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-bottom: 1px;
}
.comp-tool-btn {
  width: 31px;
  height: 31px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.comp-tool-btn:hover,
.comp-tool-btn.active {
  background: var(--bg-hover);
  color: var(--text-main);
}
.send-btn {
  width: 33px;
  height: 33px;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s;
}
.send-btn:hover {
  background: var(--accent-hover);
}
.send-btn svg {
  width: 16px;
  height: 16px;
}

/* Format Bar */
.format-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 2px 7px;
}
.fmt-btn {
  height: 26px;
  min-width: 26px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-main);
}
.fmt-btn:hover {
  background: var(--bg-hover);
}
.fmt-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
}
.fmt-colors {
  display: flex;
  align-items: center;
  gap: 4px;
}
.fmt-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.fmt-swatch:hover {
  transform: scale(1.15);
}

/* Slash & Nick Autocomplete Popup */
.autocomplete-popup {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(100% - 4px);
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 5px;
  z-index: 30;
  max-height: 270px;
  overflow-y: auto;
}
.ac-item {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
}
.ac-item:hover,
.ac-item.selected {
  background: var(--accent-soft);
}
.ac-main {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.ac-args {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}
.ac-desc {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== RIGHT SIDEBAR: NICKLIST ==================== */
.nicklist-pane {
  width: var(--nicklist-w);
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 50;
}
.nicklist-header {
  height: var(--header-h);
  padding: 0 10px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nicklist-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.nicklist-filter-wrap {
  padding: 8px 10px 6px;
}
.nicklist-filter {
  width: 100%;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-main);
  font-size: 12.5px;
  outline: none;
}
.nicklist-filter:focus {
  border-color: var(--accent);
}
.nicklist-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
}
.nick-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 6px 4px;
}
.nick-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4.5px 7px;
  border-radius: 5px;
  font-size: 13px;
  text-align: left;
  color: var(--text-main);
}
.nick-item:hover {
  background: var(--bg-hover);
}
.nick-item.is-away {
  opacity: 0.48;
}
.nick-badge {
  width: 14px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.role-owner { color: #eab308; }
.role-admin { color: #a855f7; }
.role-op { color: #10b981; }
.role-halfop { color: #06b6d4; }
.role-voice { color: #3b82f6; }
.role-member { color: var(--text-faint); }
.nick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal-card {
  width: 100%;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 540px; }
.modal-lg { max-width: 660px; }

.modal-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 21px;
  line-height: 1;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.modal-body {
  padding: 16px 18px 18px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Preset & Popular Channel Chips */
.preset-chips,
.popular-chan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.popular-chan-chips {
  margin-top: 6px;
}
.preset-chip {
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.preset-chip:hover {
  border-color: var(--accent);
  color: var(--text-main);
}
.preset-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.chan-chip {
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
}
.chan-chip:hover {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

.form-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  margin-top: 6px;
}
.form-details summary {
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  color: var(--text-main);
  user-select: none;
}
.details-inner {
  padding: 12px 13px 4px;
  border-top: 1px solid var(--border);
}

/* Segmented Tabs */
.seg-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.seg-tab {
  flex: 1;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.seg-tab.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .seg-tab.active {
  background: var(--accent);
  color: #ffffff;
}

/* Search Modal */
.search-modal {
  height: min(600px, calc(100dvh - 32px));
}
.search-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.search-top-bar svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-top-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-main);
}
.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.search-filters select,
.search-filters input[type="text"] {
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-main);
  font-size: 12.5px;
  outline: none;
}
.search-filters input[type="text"] {
  width: 130px;
}
.search-filters .check-pill {
  height: 32px;
  padding: 0 9px;
  font-size: 12px;
  background: var(--bg-main);
}
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}
.sr-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 8px 4px;
}
.sr-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
}
.sr-item:hover {
  background: var(--bg-hover);
}
.sr-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.sr-chan {
  font-weight: 700;
  color: var(--accent);
}
.sr-sender {
  font-weight: 650;
  color: var(--text-main);
}
.sr-time {
  margin-left: auto;
}
.sr-text {
  font-size: 13px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sr-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Channel List Browser */
.chanlist-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.chanlist-bar input {
  flex: 1;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  outline: none;
}
.chanlist-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chanlist-results {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.cl-info {
  flex: 1;
  min-width: 0;
}
.cl-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cl-name {
  font-weight: 700;
  color: var(--text-main);
}
.cl-users {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.cl-topic {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Topic Modal */
.topic-rendered {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.topic-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 14px;
}

/* Settings Modal */
.setting-group {
  margin-bottom: 16px;
}
.setting-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.theme-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-subtle);
}
.theme-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tc-preview {
  width: 100%;
  height: 46px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(128, 128, 128, 0.25);
}
.tc-preview span { width: 32%; height: 100%; }
.tc-preview i { flex: 1; height: 100%; }
.tc-classic span { background: #121722; }
.tc-classic i { background: #ffffff; }
.tc-dark span { background: #0c1017; }
.tc-dark i { background: #141925; }
.tc-light span { background: #e2e8f0; }
.tc-light i { background: #ffffff; }
.tc-name {
  font-size: 12.5px;
  font-weight: 650;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  background: var(--bg-subtle);
  cursor: pointer;
}
.toggle-row + .toggle-row {
  border-top: 1px solid var(--border);
}
.toggle-row strong {
  display: block;
  font-size: 13.2px;
  color: var(--text-main);
}
.toggle-row span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}
.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.pwa-box,
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  margin-top: 12px;
}
.pwa-box p,
.account-note {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
.account-bar {
  margin-top: 0;
  margin-bottom: 14px;
}
.account-user {
  font-size: 15px;
  font-weight: 700;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat-tile {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.stat-val {
  font-size: 18px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}
.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.session-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== USER POPOVER & CONTEXT MENU ==================== */
.user-popover {
  position: fixed;
  z-index: 140;
  width: 260px;
  padding: 13px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.up-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}
.up-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  font-size: 15px;
  color: #ffffff;
  flex-shrink: 0;
}
.up-nick {
  font-size: 14.5px;
  font-weight: 750;
  color: var(--text-main);
  word-break: break-all;
}
.up-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}
.up-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.up-mod {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.context-menu {
  position: fixed;
  z-index: 150;
  min-width: 190px;
  padding: 5px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  text-align: left;
}
.ctx-item:hover {
  background: var(--bg-hover);
}
.ctx-item.danger {
  color: var(--danger);
}
.ctx-item.danger:hover {
  background: var(--hl-bg);
}
.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ==================== LIGHTBOX & TOASTS ==================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 8, 15, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 12px;
}
.lightbox img {
  max-width: min(94vw, 1200px);
  max-height: 82dvh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.lightbox-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 24px;
}
.lightbox-open {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
}

.toast-stack {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  right: 18px;
  z-index: 220;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #141b29;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 550;
  max-width: 320px;
  pointer-events: auto;
}
.toast.error {
  border-left: 3px solid var(--danger);
}
.toast.success {
  border-left: 3px solid var(--success);
}

.mobile-only {
  display: none;
}

/* ==================== RESPONSIVE: TABLET (<= 1024px) ==================== */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 244px;
  }
  /* Nicklist becomes right slide-over drawer on tablets & phones */
  .nicklist-pane {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 84vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .nicklist-pane.hidden {
    display: flex !important;
    pointer-events: none;
  }
  .nicklist-pane.drawer-open {
    transform: translateX(0);
    pointer-events: auto;
  }
}

/* ==================== RESPONSIVE: MOBILE (<= 768px) ==================== */
@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: inline-flex;
  }

  /* Auth screen single-column mobile card */
  .auth-view {
    align-items: flex-start;
    padding-top: max(24px, env(safe-area-inset-top));
  }
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 440px;
    margin: auto;
  }
  .auth-showcase {
    display: none;
  }
  .auth-mobile-brand {
    display: flex;
  }
  .auth-card {
    padding: 22px 18px;
  }
  .auth-form input {
    font-size: 16px; /* prevent iOS input zoom */
  }

  /* Left Sidebar becomes native IRCCloud mobile drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(296px, 86vw);
    transform: translateX(-102%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top);
  }
  .sidebar.drawer-open {
    transform: translateX(0);
  }
  .buf-item {
    padding: 9px 10px 9px 13px;
    font-size: 14.5px;
  }
  .net-act-btn {
    width: 30px;
    height: 30px;
  }

  /* Mobile chat header */
  .chat-header {
    padding-left: 8px;
    padding-right: 8px;
    gap: 6px;
  }
  .mobile-menu-btn {
    display: inline-flex;
    width: 38px;
    height: 38px;
  }
  .header-main {
    flex-direction: column;
    gap: 0;
    justify-content: center;
  }
  .header-title {
    font-size: 15px;
  }
  .header-modes,
  .header-net-pill {
    display: none !important;
  }
  .header-topic {
    padding: 0;
    font-size: 11.5px;
    max-width: 100%;
  }
  .hdr-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 6px;
  }

  /* Messages & composer tuned for phone thumb ergonomics */
  .msg-row,
  .event-row,
  .folded-events {
    padding-left: 12px;
    padding-right: 12px;
  }
  .msg-row.is-highlight {
    padding-left: 9px;
  }
  .info-card,
  .motd-card {
    margin-left: 12px;
    margin-right: 12px;
  }
  [data-density="compact"] .msg-compact-grid {
    grid-template-columns: 44px 82px 1fr;
    gap: 6px;
    font-size: 13px;
  }

  .composer-wrap {
    padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  }
  .composer-input {
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
  }
  .nick-pill {
    max-width: 86px;
    padding: 0 7px;
    font-size: 12px;
  }
  .desktop-sm {
    display: none;
  }
  .send-btn {
    width: 36px;
    height: 36px;
  }

  /* Modals become clean mobile bottom sheets */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-card input,
  .modal-card textarea,
  .modal-card select {
    font-size: 16px;
  }
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .theme-cards {
    grid-template-columns: 1fr;
  }
  .theme-card {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
  }
  .tc-preview {
    width: 64px;
    height: 36px;
    flex-shrink: 0;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* User popover docks neatly as mobile bottom card */
  .user-popover {
    left: 10px !important;
    right: 10px !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
    top: auto !important;
    width: auto;
  }

  .onboarding-view {
    padding: 20px 14px;
  }
  .onboarding-inner h2 {
    font-size: 21px;
  }
  .preset-grid {
    grid-template-columns: 1fr;
  }
}

/* Authentication fields retain their dark surface. */
.auth-form .field input { background:#0d121c; border-color:rgba(255,255,255,.12); color:#f8fafc; }

/* Public IRCCloud avatars: initials remain visible if the image fails. */
.irc-avatar { position:relative; display:inline-flex; align-items:center; justify-content:center; flex:none; overflow:hidden; width:24px; height:24px; border-radius:50%; color:#fff; background:#64748b; font-size:10px; font-weight:700; vertical-align:middle; }
.irc-avatar img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; background:var(--bg-subtle); }
.irc-avatar-large { width:40px; height:40px; font-size:16px; }
.msg-head .irc-avatar { width:25px; height:25px; }
.mc-nick .irc-avatar { width:18px; height:18px; margin-right:4px; }
.nick-item .irc-avatar { width:23px; height:23px; }

/* Buffer actions remain reachable on touch devices without nested buttons. */
.buf-row { display:flex; align-items:center; min-width:0; position:relative; }
.buf-row .buf-item { flex:1; min-width:0; }
.buf-options { width:30px; height:30px; margin-left:2px; flex:none; border-radius:6px; color:var(--sb-text-muted); font-size:20px; line-height:1; }
.buf-options:hover, .buf-options:focus-visible { background:var(--sb-bg-hover); color:var(--sb-text-strong); }
.archived-row { padding-left:12px; color:var(--sb-text-muted); font-size:12px; }
.archived-label { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.buf-restore { color:var(--sb-text); font-size:11px; padding:5px; border-radius:4px; }
.buf-restore:hover { color:var(--sb-text-strong); background:var(--sb-bg-hover); }
.popover-close { margin-left:auto; flex:none; align-self:flex-start; width:32px; height:32px; border-radius:6px; font-size:22px; line-height:1; color:var(--text-muted); }
.popover-close:hover, .popover-close:focus-visible { background:var(--bg-hover); color:var(--text-main); }

/* Appearance preferences, with system font fallbacks and no remote fonts. */
:root { --avatar-size:24px; --avatar-compact:18px; --avatar-large:40px; --chat-font-size:14px; }
:root[data-avatar-size="small"] { --avatar-size:19px; --avatar-compact:16px; --avatar-large:32px; }
:root[data-avatar-size="large"] { --avatar-size:34px; --avatar-compact:27px; --avatar-large:52px; }
:root[data-font-size="12"] { --chat-font-size:12px; }
:root[data-font-size="16"] { --chat-font-size:16px; }
:root[data-font-size="18"] { --chat-font-size:18px; }
:root[data-font-size="20"] { --chat-font-size:20px; }
:root[data-font-style="serif"] { --font-sans: Georgia, 'Times New Roman', serif; }
:root[data-font-style="mono"] { --font-sans: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace; }
.irc-avatar, .msg-head .irc-avatar, .nick-item .irc-avatar { width:var(--avatar-size); height:var(--avatar-size); }
.irc-avatar-large { width:var(--avatar-large); height:var(--avatar-large); }
.mc-nick .irc-avatar { width:var(--avatar-compact); height:var(--avatar-compact); }
.avatar-clickable { cursor:zoom-in; }
.avatar-clickable:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.nick-item { cursor:default; }
.nick-click { display:flex; align-items:center; gap:6px; flex:1; min-width:0; text-align:left; padding:2px 0; }
.nick-click:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:3px; }
.msg-body, [data-density="compact"] .msg-body, [data-density="compact"] .msg-compact-grid { font-size:var(--chat-font-size); }
.msg-sender, .buf-item, .nick-item, .nick-name, .composer-input { font-size:var(--chat-font-size); }
.event-row, .folded-toggle { font-size:calc(var(--chat-font-size) * .9); }
.msg-time { font-size:calc(var(--chat-font-size) * .8); }
.settings-tip { margin:0 0 14px; font-size:12px; color:var(--text-muted); }
@media (max-width:768px) {
  /* Prevent Safari from zooming into the text input on focus. */
  .composer-input { font-size:max(16px, var(--chat-font-size)); }
}
/* Detailed IRC WHOIS and explicit, optional IP lookup. */
.whois-card { overflow-wrap:anywhere; font-size:var(--chat-font-size); }
.whois-caption { color:var(--text-muted); font-size:11px; font-weight:700; letter-spacing:.07em; }
.whois-card .whois-grid { grid-template-columns:minmax(78px,auto) minmax(0,1fr); font-size:calc(var(--chat-font-size) * .93); }
.whois-missing { color:var(--text-muted); font-weight:400; }
.whois-extra-title { margin-top:10px; font-size:12px; font-weight:700; color:var(--text-secondary); }
.whois-extra { margin:4px 0 0; padding-left:20px; color:var(--text-secondary); }
.whois-ip { margin-top:12px; border-top:1px solid var(--border); padding-top:10px; }
.whois-ip-title { margin-bottom:8px; font-weight:650; }
.whois-ip-note, .whois-ip-error { margin-top:7px; color:var(--text-muted); font-size:12px; }
.whois-ip-error { color:var(--danger); }
.whois-ip .ip-result { margin-bottom:9px; }
.whois-identity { display:flex; align-items:center; gap:10px; min-width:0; }
.whois-identity > div { min-width:0; }
.whois-ip-entry { margin:10px 0; }
.whois-ip-entry + .whois-ip-entry { padding-top:10px; border-top:1px solid var(--border); }
/* YouTube preview is a card; the privacy-enhanced player loads only on click. */
.yt-card { display:flex; align-items:stretch; max-width:520px; width:100%; border:1px solid var(--border); border-radius:var(--radius-md); overflow:hidden; background:var(--bg-subtle); white-space:normal; }
.yt-thumbnail { width:170px; min-width:170px; aspect-ratio:16/9; background:#181818; position:relative; overflow:hidden; }
.yt-thumbnail img { width:100%; height:100%; object-fit:cover; display:block; }
.yt-play-icon { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); display:flex; align-items:center; justify-content:center; width:42px; height:30px; border-radius:8px; color:#fff; background:#e62117; font-size:15px; }
.yt-thumbnail:hover .yt-play-icon { background:#b91c1c; }
.yt-details { display:flex; flex-direction:column; align-items:flex-start; gap:4px; padding:9px 12px; min-width:0; }
.yt-provider { color:#dc2626; font-size:10px; font-weight:750; text-transform:uppercase; letter-spacing:.06em; }
.yt-title { color:var(--text-main); font-size:13px; font-weight:700; line-height:1.35; overflow-wrap:anywhere; }
.yt-author { color:var(--text-muted); font-size:12px; }
.yt-watch { color:var(--accent); font-size:12px; font-weight:700; margin-top:auto; padding-top:5px; }
.yt-watch:hover { text-decoration:underline; }
.youtube-frame-wrap { width:100%; aspect-ratio:16/9; background:#000; }
.youtube-frame-wrap iframe { width:100%; height:100%; border:0; display:block; }
.youtube-player-footer { padding:10px 16px; display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; color:var(--text-muted); font-size:12px; }
#youtube-player-title { white-space:nowrap; text-overflow:ellipsis; overflow:hidden; padding-right:10px; }
@media (max-width:480px) { .yt-thumbnail { width:120px; min-width:120px; } .yt-details { padding:7px 9px; } }
/* Network collapse, administrator reviews and channel action menu. */
.net-collapse { width:24px; height:24px; flex:none; color:var(--sb-text-muted); font-size:13px; border-radius:5px; }
.net-collapse:hover, .net-collapse:focus-visible { color:var(--sb-text-strong); background:var(--sb-bg-hover); }
.net-name { text-align:left; color:inherit; font-weight:inherit; letter-spacing:inherit; text-transform:inherit; }
.net-name:hover { text-decoration:underline; }
.form-alert.success { background:rgba(16,185,129,.13); border:1px solid rgba(16,185,129,.35); color:#6ee7b7; }
.admin-title-row { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.admin-title-row .setting-label { margin:0; }
.admin-users-list { margin-top:10px; }
.admin-user-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; border:1px solid var(--border); background:var(--bg-subtle); border-radius:var(--radius-sm); }
.admin-user-details { min-width:0; overflow-wrap:anywhere; }
.admin-user-actions { display:flex; gap:5px; flex-shrink:0; }
.user-popover { max-height:min(75dvh,600px); overflow-y:auto; }
.up-mod-title { margin-top:12px; padding-top:10px; border-top:1px solid var(--border); font-size:12px; font-weight:700; color:var(--text-secondary); }
.up-mod-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin-top:8px; }
.up-mod-note { font-size:11px; line-height:1.4; color:var(--text-muted); margin-top:8px; }
/* Compact mobile composer; allow multiline expansion without covering the chat. */
@media (max-width:768px) {
  .composer-input { font-size:14px; line-height:1.4; min-height:34px; max-height:140px; overflow-y:auto; }
  .composer-box { min-width:0; }
  .admin-user-row { flex-wrap:wrap; }
  .admin-user-actions { flex-wrap:wrap; }
}
.admin-user-row { align-items:flex-start; }
.admin-user-actions { flex-wrap:wrap; }
.admin-log { margin-top:6px; font-size:12px; color:var(--text-muted); overflow-wrap:anywhere; }
.admin-log strong { display:block; margin-top:6px; color:var(--text-secondary); }
.admin-log div { margin:4px 0; }
.admin-user-details summary { cursor:pointer; font-size:12px; color:var(--accent); margin-top:5px; }
.sidebar-read-wrap { padding:0 10px 7px; flex-shrink:0; }
.sidebar-read-all { display:flex; align-items:center; gap:8px; width:100%; min-height:34px; padding:6px 10px; border-radius:var(--radius-sm); color:var(--sb-text-muted); font-size:12px; text-align:left; }
.sidebar-read-all:hover, .sidebar-read-all:focus-visible { background:var(--sb-bg-hover); color:var(--sb-text-strong); }
.sidebar-read-all:disabled { opacity:.5; cursor:wait; }
.sidebar-read-all svg { width:16px; height:16px; flex:none; }
.sidebar-organize { display:flex; align-items:center; gap:8px; padding:2px 10px 5px; flex-shrink:0; }
.sidebar-organize label { display:flex; align-items:center; min-width:0; gap:4px; color:var(--sb-text-muted); font-size:11px; }
.sidebar-organize select { min-width:0; max-width:95px; background:var(--sb-bg-elevated); color:var(--sb-text); border:1px solid var(--sb-border); border-radius:5px; padding:4px 3px; font-size:11px; }
.highlight-symbol { display:inline-flex; justify-content:center; width:16px; flex:none; color:var(--accent); font-weight:750; font-size:16px; }
.pinned-marker { color:#d49b36; font-size:12px; flex:none; }
.highlights-body { padding:12px 14px 16px; min-height:0; overflow-y:auto; }
.highlights-note { color:var(--text-muted); font-size:12px; margin:0 0 10px; }
#highlights-status { margin-top:8px; }
#highlights-results { overflow:visible; padding:4px 0; }
#highlights-results .sr-meta { flex-wrap:wrap; }
.highlights-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.highlights-actions button:disabled { opacity:.55; cursor:not-allowed; }
.highlights-show-cleared { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--text-secondary); padding:5px 2px; cursor:pointer; }
/* Compact browser radio. Audio is independent of the IRC bouncer. */
.radio-shell{flex:none;margin:5px 10px 8px;padding:8px;border:1px solid rgba(140,164,196,.22);border-radius:8px;background:var(--sb-bg-elevated);color:var(--sb-text);min-width:0}
.radio-heading-row{display:flex;align-items:center;gap:7px;min-width:0}.radio-icon{display:grid;place-items:center;width:27px;height:27px;flex:none;border-radius:7px;background:#29405f;color:#c2d9ff;font-size:15px}.radio-heading-text{min-width:0;flex:1}.radio-heading-text strong{display:block;color:var(--sb-text-strong);font-size:11px}.radio-heading-text span{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--sb-text-muted);font-size:10px;margin-top:2px}
.radio-collapse,.radio-mini-play{width:29px;height:29px;flex:none;border-radius:6px;color:var(--sb-text);font-size:16px}.radio-collapse:hover,.radio-mini-play:hover{background:var(--sb-bg-hover);color:var(--sb-text-strong)}.radio-mini-play{font-size:12px;color:#e6f0ff;background:#2563eb}.radio-shell.expanded .radio-mini-play{display:none}
.radio-details{padding-top:8px}.radio-label{display:block;font-size:10px;color:var(--sb-text-muted);margin-bottom:4px}.radio-select{width:100%;min-width:0;height:32px;border:1px solid var(--sb-border);border-radius:6px;padding:0 7px;background:var(--sb-bg);color:var(--sb-text-strong);font-size:11px}.radio-controls-row{display:flex;align-items:center;gap:9px;margin-top:9px}.radio-play{width:32px;height:32px;flex:none;border-radius:50%;background:#2563eb;color:white;font-size:13px}.radio-playing{min-width:0}.radio-playing strong,.radio-playing span{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:11px}.radio-playing strong{color:var(--sb-text-strong)}.radio-playing span{font-size:10px;color:var(--sb-text-muted);margin-top:2px}.radio-volume{display:flex;align-items:center;gap:8px;margin-top:9px;font-size:10px;color:var(--sb-text-muted)}.radio-volume input{width:100%;accent-color:#4e8efb}.radio-manage{width:100%;min-height:30px;margin-top:7px;border:1px solid var(--sb-border);border-radius:6px;background:var(--sb-bg-hover);color:var(--sb-text);font-size:11px}.radio-pending{display:inline-block;min-width:18px;margin-left:4px;padding:1px 4px;border-radius:9px;background:#db3c45;color:white;font-size:10px}.radio-error{margin-top:6px;color:#fca5a5;font-size:10px;line-height:1.4}.radio-error:empty{display:none}.radio-disclosure{color:var(--sb-text-muted);font-size:10px;line-height:1.4;margin:7px 0 0}.network-tree{min-height:0}
.radio-modal-note{font-size:12px;line-height:1.5;color:var(--text-muted);margin:0 0 12px}.radio-form-status{min-height:17px;margin:7px 0;font-size:12px;color:var(--text-secondary);overflow-wrap:anywhere}.radio-requests-head{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--border);margin-top:15px;padding-top:12px}.radio-requests-head h4{margin:0;font-size:13px}.radio-requests{display:flex;flex-direction:column;gap:8px;margin-top:8px}.radio-request{display:flex;align-items:flex-start;gap:8px;border:1px solid var(--border);border-radius:7px;padding:9px}.radio-request-info{min-width:0;flex:1}.radio-request-name{font-size:12px;font-weight:700;overflow-wrap:anywhere}.radio-request-meta,.radio-request-url{font-size:11px;color:var(--text-muted);overflow-wrap:anywhere;margin-top:3px}.radio-request-actions{display:flex;gap:5px;flex-wrap:wrap}.radio-requests-empty{font-size:12px;color:var(--text-muted);padding:8px 0}
@media(max-width:768px){.radio-shell{margin:4px 8px 6px}.radio-request{flex-wrap:wrap}.radio-request-actions{width:100%}.radio-modal-body{padding:12px}}
.radio-edit-form{padding:12px;border:1px solid var(--border);border-radius:7px;background:var(--bg-subtle);margin:8px 0}.radio-edit-form h4{font-size:13px;margin:0 0 10px}.radio-edit-actions{display:flex;gap:8px;flex-wrap:wrap}.radio-edit-form .field:last-of-type{margin-bottom:10px}

/* Upload result stays visible while switching conversations. */
.upload-status{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:4px 2px 8px;font-size:12px;color:var(--text-secondary)}
.upload-status a{color:var(--accent);overflow-wrap:anywhere;min-width:0}.upload-status #upload-dismiss{margin-left:auto;width:26px;height:26px}
