:root {
  --bg: #000000;
  --surface: #0A0A0A;
  --surface2: #111111;
  --surface3: #1A1A1A;
  --border: 1px solid #1A1A1A;
  --text: #E8E8E8;
  --muted: #555555;
  --green: #39D98A;
  --yellow: #F5C542;
  --grey: #666;
  --blue: #4A90E2;
  --purple: #B026FF;
  --cyan: #00FFFF;
  --red: #FF4444;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.02em;
}

a { color: var(--cyan); text-decoration: none; transition: color 0.15s ease-in-out; }
a:hover { color: #33FFFF; }

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* --- Auth page --- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4px;
}

.cyph-logo {
  width: 88px;
  height: 88px;
  display: block;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 24px rgba(176, 38, 255, 0.3));
}

.auth-logo {
  letter-spacing: 0.55em;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-logo--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-sub {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--muted);
  margin-bottom: 40px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: var(--border);
  border-radius: 8px;
  padding: 28px;
}

.auth-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.auth-tab {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.auth-tab.active {
  color: var(--text);
  border-bottom-color: var(--cyan);
}

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.auth-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid #1A1A1A;
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease-in-out;
}

.auth-field input:focus { border-color: rgba(0, 255, 255, 0.5); }

.auth-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  background: var(--cyan);
  border: none;
  border-radius: 4px;
  color: #000;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.auth-btn:hover { background: #33FFFF; transform: translateY(-1px); }

.auth-error {
  color: #ff6b8a;
  font-size: 11px;
  margin-top: 12px;
  min-height: 16px;
}

.auth-divider {
  text-align: center;
  margin: 20px 0 12px;
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.google-wrap { display: flex; justify-content: center; }

.auth-reset { text-align: center; margin-top: 16px; }

.auth-reset-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s ease-in-out;
}

.auth-reset-btn:hover { color: var(--cyan); }

.cyph-app-error {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 138, 0.45);
  background: rgba(255, 107, 138, 0.08);
  border-radius: 6px;
  color: #ff8fa8;
  font-size: 11px;
}

.cyph-app-error--warn {
  border-color: rgba(245, 197, 66, 0.45);
  background: rgba(245, 197, 66, 0.08);
  color: #f5c542;
}

.cyph-app-error-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.cyph-app-error-body {
  flex: 1;
  min-width: 0;
}

.cyph-app-error-link-text {
  margin-top: 6px;
  font-size: 10px;
  word-break: break-all;
  color: var(--text);
  opacity: 0.9;
}

.cyph-app-error-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #1A1A1A;
  background: var(--surface3);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.cyph-app-error-close:hover {
  border-color: var(--yellow);
  color: var(--yellow);
}

.cyph-app-error-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.cyph-app-error-btn {
  background: var(--surface3);
  border: 1px solid #1A1A1A;
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out;
}

.cyph-app-error-btn:hover { border-color: var(--cyan); }

.cyph-app-error-link {
  background: none;
  border: none;
  color: var(--cyan);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: underline;
}

/* --- App shell --- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.left-sidebar {
  width: 240px;
  min-width: 180px;
  max-width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--surface3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.main-chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-panel {
  width: 300px;
  min-width: 250px;
  max-width: 500px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--surface3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.resizer {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s ease-in-out;
  position: relative;
  z-index: 10;
}

.resizer:hover,
.resizer:active {
  background: var(--purple);
}

/* Detach (pop-out) button */
.detach-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease-in-out;
  flex-shrink: 0;
}

.detach-btn:hover {
  color: #B026FF;
}

.detach-btn-icon {
  display: block;
}

.right-panel-placeholder {
  padding: 16px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* ── Right Panel Sections ── */
.rp-section { padding: 12px; }
.rp-header {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rp-badge {
  background: rgba(57, 217, 138, 0.1);
  color: var(--green);
  font-size: 8px;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(57, 217, 138, 0.2);
}
.rp-room-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.rp-room-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.rp-divider {
  height: 1px;
  background: var(--surface3);
  margin: 8px 12px;
}
.rp-members {
  max-height: 120px;
  overflow-y: auto;
}
.rp-member {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 11px;
  color: var(--text);
}
.rp-member-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rp-member-dot.online { background: var(--green); }
.rp-member-dot.offline { background: var(--muted); }
.rp-empty { font-size: 10px; color: var(--muted); }

/* ── Encryption Key Block ── */
.rp-encryption-key {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(57, 217, 138, 0.06);
  border: 1px solid rgba(57, 217, 138, 0.15);
  border-radius: 4px;
  padding: 8px 10px;
  margin-top: 4px;
}
.rp-enc-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.rp-enc-hash {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--green);
  letter-spacing: 0.04em;
  word-break: break-all;
  background: none;
}

/* ── DM Profile Section ── */
.rp-dm-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 8px;
}
.rp-dm-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--surface3);
}
.rp-dm-avatar svg {
  display: block;
}
.rp-dm-details {
  flex: 1;
  min-width: 0;
}
.rp-dm-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.rp-dm-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
}

/* ── PGP Fingerprint Block ── */
.rp-pgp-fingerprint {
  background: var(--surface2);
  border: 1px solid var(--surface3);
  border-radius: 4px;
  padding: 8px 10px;
  margin-top: 4px;
}
.rp-pgp-hash {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.06em;
  word-break: break-all;
  background: none;
}

/* ── Member List Improvements ── */
.rp-member-dot.away { background: var(--yellow); }
.rp-member-name {
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── AI Terminal in Right Panel ── */
.rp-terminal-log {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.6;
}
.rp-terminal-msg {
  padding: 2px 0;
  word-break: break-word;
}
.rp-terminal-msg.rp-system { color: var(--muted); font-style: italic; }
.rp-terminal-msg.rp-user { color: var(--green); }
.rp-terminal-msg.rp-ai { color: var(--purple); }
.rp-terminal-msg.rp-error { color: var(--red); }
.rp-terminal-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--surface3);
  padding-top: 8px;
}
.rp-terminal-prompt {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.rp-terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  caret-color: var(--green);
}
.rp-terminal-input::placeholder { color: var(--muted); }

.sidebar-header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--surface3);
}

.sidebar-logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cyph-logo--sm {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sidebar-logo {
  letter-spacing: 0.08em;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-network {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-top: 2px;
}

.self-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--surface3);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar--clickable {
  cursor: pointer;
  transition: box-shadow 0.15s ease-in-out, transform 0.15s ease-in-out;
}

.avatar--clickable:hover {
  box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.45);
}

.avatar.small { width: 26px; height: 26px; font-size: 9px; }

.self-info { flex: 1; min-width: 0; }

.self-name { font-size: 12px; font-weight: 700; }

.self-status {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buddy-section { flex: 1; overflow-y: auto; padding: 4px 0; }

.section-label {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--muted);
  padding: 10px 12px 5px;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--surface3);
  margin-bottom: 2px;
}

.buddy-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  position: relative;
  border-left: 3px solid transparent;
}

.buddy-item:hover {
  background: var(--surface2);
  border-left-color: var(--green);
}

.buddy-item.active {
  background: var(--surface2);
  border-left-color: var(--green);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s ease-in-out;
}

.status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(57, 217, 138, 0.6); }
.status-dot.away { background: var(--yellow); }
.status-dot.busy { background: #e74c3c; }
.status-dot.offline { background: var(--grey); }

.self-profile--clickable {
  cursor: pointer;
  transition: background 0.15s ease-in-out;
}

.self-profile--clickable:hover {
  background: var(--surface2);
}

.self-edit-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  transition: color 0.15s ease-in-out;
}

.self-edit-btn:hover { color: var(--cyan); }

.buddy-menu-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  line-height: 1;
}

.buddy-item:hover .buddy-menu-btn,
.buddy-item.active .buddy-menu-btn {
  opacity: 1;
}

.buddy-menu-btn:hover { color: var(--text); }

.cyph-context-menu {
  position: fixed;
  z-index: 9000;
  min-width: 140px;
  background: var(--surface);
  border: var(--border);
  border-radius: 6px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.cyph-context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
}

.cyph-context-menu button:hover {
  background: var(--surface2);
}

.cyph-context-menu button.danger {
  color: #ff6b8a;
}

.chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.chat-action-btn {
  background: var(--surface2);
  border: 1px solid #1A1A1A;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.chat-action-btn:hover {
  color: var(--text);
  border-color: rgba(0, 255, 255, 0.45);
}

.chat-action-btn.danger:hover {
  color: #ff6b8a;
  border-color: rgba(255, 107, 138, 0.45);
}

.cyph-modal {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cyph-modal[hidden] {
  display: none;
}

.cyph-modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.cyph-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: var(--border);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cyph-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.15s ease-in-out;
}

.cyph-modal-close:hover { color: var(--cyan); }

.cyph-modal-body {
  padding: 16px;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 14px;
}

.profile-avatar-hint {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
}

.profile-field {
  display: block;
  margin-bottom: 12px;
}

.profile-field span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.profile-field input,
.profile-field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid #1A1A1A;
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 10px;
  outline: none;
  transition: border-color 0.15s ease-in-out;
}

.profile-field input:focus,
.profile-field select:focus {
  border-color: rgba(0, 255, 255, 0.5);
}

.profile-readonly {
  font-size: 10px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.8;
}

.profile-readonly-label {
  display: inline-block;
  width: 64px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 9px;
}

.profile-error {
  color: #ff6b8a;
  font-size: 10px;
  min-height: 14px;
  margin-top: 8px;
}

.cyph-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: var(--border);
  background: var(--surface2);
}

.cyph-modal-footer-right {
  display: flex;
  gap: 8px;
}

.profile-btn {
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #1A1A1A;
  transition: background 0.15s ease-in-out, color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.profile-btn--ghost {
  background: transparent;
  color: var(--muted);
}

.profile-btn--ghost:hover { color: var(--text); }

.profile-btn--primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #000;
  font-weight: 700;
}

.profile-btn--primary:hover { background: #33FFFF; }

.buddy-meta { flex: 1; min-width: 0; }

.buddy-name { font-size: 11px; font-weight: 700; }

.buddy-node {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rooms-section {
  border-top: 1px solid var(--surface3);
  max-height: 140px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  border-left: 3px solid transparent;
}

.room-item:hover {
  background: var(--surface2);
  border-left-color: var(--purple);
}

.room-item.active {
  background: var(--surface2);
  border-left-color: var(--purple);
}

.room-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  padding: 2px 4px;
  line-height: 1;
}

.room-item:hover .room-delete-btn { opacity: 0.6; }
.room-delete-btn:hover { opacity: 1 !important; color: var(--red); }

.room-hash {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple);
  width: 12px;
  flex-shrink: 0;
}

.room-meta { flex: 1; min-width: 0; }

.room-name { font-size: 11px; font-weight: 700; }

.room-slug {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-room-bar {
  padding: 5px 12px;
  border-top: 1px solid var(--surface3);
  display: flex;
  gap: 6px;
}

.add-room-bar.join-room-bar {
  border-top: none;
  padding-top: 0;
}

.room-empty {
  font-size: 9px;
  color: var(--muted);
  padding: 4px 0 8px;
  line-height: 1.4;
}

.add-room-bar input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid #1A1A1A;
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  padding: 6px 8px;
  transition: border-color 0.15s ease-in-out;
}

.add-room-bar input:focus { border-color: rgba(0, 255, 255, 0.5); }

.add-room-bar button {
  background: var(--surface3);
  border: 1px solid #1A1A1A;
  color: var(--text);
  font-family: inherit;
  font-size: 9px;
  padding: 6px 8px;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out;
}

.add-room-bar button:hover { border-color: var(--cyan); }

.radio-bar {
  border-top: 1px solid var(--surface3);
  padding: 8px 12px;
  background: var(--surface);
}

.radio-label {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 6px;
}

.radio-track { font-size: 11px; font-weight: 700; }

.radio-artist { font-size: 10px; color: var(--muted); }

.radio-meta {
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
}

.radio-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.radio-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.radio-btn {
  width: 24px;
  height: 24px;
  background: var(--surface3);
  border: 1px solid var(--surface3);
  color: var(--muted);
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: border-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.radio-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.radio-btn:active {
  background: var(--surface);
}

.radio-progress-wrap {
  width: 100%;
}

.radio-progress {
  position: relative;
  flex: 1;
  height: 4px;
  background: var(--surface3);
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

.radio-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #09f27a 0%, #39D98A 55%, #7dffbf 100%);
  width: 0%;
  box-shadow: 0 0 8px rgba(57, 217, 138, 0.45);
  transition: width 80ms linear;
}

.radio-time {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.radio-options {
  display: flex;
  align-items: center;
  gap: 6px;
}

.radio-btn.radio-mode {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

.radio-btn.radio-mode.active {
  border-color: var(--green);
  color: var(--green);
  background: rgba(57, 217, 138, 0.08);
}

.radio-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.radio-vol-icon {
  font-size: 10px;
  flex-shrink: 0;
}

.radio-vol-slider {
  flex: 1;
  min-width: 0;
  height: 4px;
  accent-color: var(--green);
  cursor: pointer;
}

/* --- Chat --- */
.chat-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
  flex: 1;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--surface3);
  background: var(--surface);
}

.chat-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.chat-peer-name { font-size: 14px; font-weight: 700; }

.chat-peer-status { font-size: 10px; color: var(--muted); margin-top: 2px; }

.chat-window-controls { display: flex; gap: 6px; }

.win-btn {
  width: 14px;
  height: 14px;
  background: var(--surface3);
  border: 1px solid #1A1A1A;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Terminal-style messages — no bubbles */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: msgFadeIn 0.15s ease-in-out;
}

.msg-row.outgoing { align-self: flex-end; align-items: flex-end; }
.msg-row.incoming { align-self: flex-start; }

.msg-bubble {
  padding: 2px 0;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-sender {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.msg-row.outgoing .msg-sender { color: var(--cyan); }

.msg-row.incoming .msg-bubble {
  color: var(--text);
}

.msg-row.outgoing .msg-bubble {
  color: var(--cyan);
}

.msg-time {
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.msg-system {
  align-self: center;
  font-size: 10px;
  color: var(--muted);
  background: var(--surface2);
  padding: 4px 12px;
  border-radius: 12px;
  border: var(--border);
}

/* Chat input — single line, no box */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--surface3);
  background: var(--surface);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--surface3);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 0;
  outline: none;
  transition: border-color 0.15s ease-in-out;
}

.chat-input:focus {
  border-bottom-color: var(--cyan);
}

.chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-send {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 6px 10px;
  transition: color 0.15s ease-in-out;
  flex-shrink: 0;
}

.chat-send:hover {
  color: var(--cyan);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.add-buddy-bar {
  padding: 5px 12px;
  border-top: 1px solid var(--surface3);
  display: flex;
  gap: 6px;
}

.add-buddy-bar input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid #1A1A1A;
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  padding: 6px 8px;
  transition: border-color 0.15s ease-in-out;
}

.add-buddy-bar input:focus { border-color: rgba(0, 255, 255, 0.5); }

.add-buddy-bar button {
  background: var(--surface3);
  border: 1px solid #1A1A1A;
  color: var(--text);
  font-family: inherit;
  font-size: 9px;
  padding: 6px 8px;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out;
}

.add-buddy-bar button:hover { border-color: var(--cyan); }

.empty-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 0 20px rgba(0, 255, 255, 0.08);
  user-select: none;
}

.empty-chat::before {
  content: '◆';
  font-size: 18px;
  color: var(--surface3);
  margin-bottom: 4px;
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.06);
}

.app-error {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 138, 0.45);
  background: rgba(255, 107, 138, 0.08);
  border-radius: 6px;
  color: #ff8fa8;
  font-size: 11px;
}

.app-error-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.app-error-btn {
  background: var(--surface3);
  border: 1px solid #1A1A1A;
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out;
}

.app-error-btn:hover { border-color: var(--cyan); }

.app-error-link {
  color: var(--cyan);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.app-shell--error .chat-pane,
.app-shell--error .buddy-section {
  opacity: 0.35;
  pointer-events: none;
}

@media (max-width: 768px) {
  .left-sidebar { display: none; }
  .right-panel { display: none; }
  .resizer { display: none; }
}

.buddy-unread {
  background: var(--purple);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
  margin-right: 4px;
  box-shadow: 0 0 8px rgba(176, 38, 255, 0.4);
}

.buddy-item.buddy-new-msg {
  animation: buddy-flash 1.0s ease-out;
}

@keyframes buddy-flash {
  0% {
    background-color: rgba(176, 38, 255, 0.3);
  }
  100% {
    background-color: transparent;
  }
}

/* ── Chat Tab Bar ── */
.chat-tab-bar {
  display: flex;
  align-items: stretch;
  background: #000000;
  border-bottom: 1px solid #1A1A1A;
  height: 32px;
  min-height: 32px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  user-select: none;
}

.chat-tab-bar::-webkit-scrollbar {
  display: none;
}

.chat-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 100%;
  border-right: 1px solid #111111;
  cursor: pointer;
  transition: background 0.1s ease-in-out;
  position: relative;
  flex-shrink: 0;
  max-width: 160px;
  min-width: 0;
}

.chat-tab:hover {
  background: #0D0D0D;
}

.chat-tab.active {
  background: #0A0A0A;
}

.chat-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--purple);
}

.chat-tab.has-unread .chat-tab-label {
  color: #39d98a;
}

.chat-tab-icon {
  font-size: 8px;
  color: var(--muted);
  flex-shrink: 0;
  line-height: 1;
}

.chat-tab.active .chat-tab-icon {
  color: var(--cyan);
}

.chat-tab-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chat-tab.active .chat-tab-label {
  color: var(--text);
}

.chat-tab-badge {
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 700;
  background: var(--purple);
  color: #fff;
  border-radius: 8px;
  padding: 0 5px;
  line-height: 16px;
  min-width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.chat-tab-close {
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s ease-in-out, color 0.1s ease-in-out;
}

.chat-tab:hover .chat-tab-close {
  opacity: 0.6;
}

.chat-tab-close:hover {
  opacity: 1 !important;
  color: #ff6b8a;
}

.chat-tab-add {
  font-size: 14px;
  color: var(--muted);
  justify-content: center;
  padding: 0 12px;
  min-width: 32px;
  flex-shrink: 0;
}

.chat-tab-add:hover {
  color: var(--cyan);
}

.chat-tab.dragging {
  opacity: 0.4;
}

/* ── Split View ── */
.main-chat {
  position: relative;
}

.main-chat.split-mode {
  display: flex;
  flex-direction: row;
  overflow: visible;
}

.main-chat.split-mode > .chat-pane {
  flex: 1;
  min-width: 0;
  border-right: 1px solid #1A1A1A;
}

.main-chat.split-mode > .chat-pane-split-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.split-collapse-btn {
  position: absolute;
  top: 32px;
  right: 8px;
  z-index: 50;
}

.split-collapse-button {
  font-size: 14px;
  width: 28px;
  height: 28px;
}

.main-chat.split-drop-right,
.main-chat.split-drop-left {
  outline: 2px dashed var(--purple);
  outline-offset: -2px;
}

.main-chat.split-drop-right::after,
.main-chat.split-drop-left::after {
  content: 'Drop here for split view';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--purple);
  letter-spacing: 0.08em;
  pointer-events: none;
}

.main-chat.split-drop-right::after {
  right: 10%;
}

.main-chat.split-drop-left::after {
  left: 10%;
}

/* ── Split mode responsive ── */
@media (max-width: 768px) {
  .chat-tab-bar {
    display: none;
  }
  .main-chat.split-mode {
    flex-direction: column;
  }
  .main-chat.split-mode > .chat-pane-split-right {
    border-left: none;
    border-top: 1px solid #1A1A1A;
  }
}

@keyframes msgFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Command Palette */
#command-palette {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
}

#command-palette[hidden] {
  display: none;
}

.command-palette-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
}

.command-palette-input-wrap {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: var(--border);
  gap: 10px;
}

.command-palette-input-wrap .prompt {
  color: var(--cyan);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

#command-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  letter-spacing: 0.02em;
}

#command-palette-input::placeholder {
  color: var(--muted);
}

.command-palette-results {
  max-height: 320px;
  overflow-y: auto;
}

.command-palette-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s ease-in-out;
  border-left: 3px solid transparent;
}

.command-palette-result:hover,
.command-palette-result.active {
  background: var(--surface2);
  border-left-color: var(--cyan);
}

.command-palette-result .icon {
  width: 20px;
  text-align: center;
  color: var(--muted);
  flex-shrink: 0;
}

.command-palette-result .label {
  flex: 1;
  font-size: 12px;
}

.command-palette-result .meta {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.command-palette-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: var(--border);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.command-palette-footer kbd {
  background: var(--surface3);
  border: 1px solid #1A1A1A;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text);
}

/* Username color classes for hashed colors */
.msg-sender.c0 { color: #FF6B6B; }
.msg-sender.c1 { color: #FECA57; }
.msg-sender.c2 { color: #48DBFB; }
.msg-sender.c3 { color: #FF9FF3; }
.msg-sender.c4 { color: #54A0FF; }
.msg-sender.c5 { color: #5F27CD; }
.msg-sender.c6 { color: #01A3A4; }
.msg-sender.c7 { color: #F368E0; }
.msg-sender.c8 { color: #FF9F43; }
.msg-sender.c9 { color: #EE5A24; }
.msg-sender.c10 { color: #00D2D3; }
.msg-sender.c11 { color: #C8D6E5; }

/* ── Enclave Explorer ── */
.enclave-section {
  border-bottom: var(--border);
  max-height: 200px;
  overflow-y: auto;
  padding-bottom: 4px;
}

.enclave-item {
  position: relative;
}

.enclave-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  border-left: 4px solid transparent;
}

.enclave-header:hover {
  background: var(--surface2);
  border-left-color: var(--purple);
}

.enclave-icon {
  color: var(--purple);
  flex-shrink: 0;
}

.enclave-name {
  font-size: 11px;
  font-weight: 700;
  flex: 1;
}

.enclave-count {
  font-size: 9px;
  color: var(--muted);
}

.enclave-relays {
  padding-left: 20px;
}

.enclave-partition {
  margin-bottom: 4px;
}

.partition-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 4px 8px 2px;
  text-transform: uppercase;
}

.relay-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  border-radius: 3px;
}

.relay-item:hover {
  background: var(--surface3);
}

.relay-item.active {
  background: var(--surface2);
}

.relay-prefix {
  font-size: 11px;
  font-weight: 700;
  width: 14px;
  flex-shrink: 0;
}

.relay-prefix.relay {
  color: var(--purple);
}

.relay-prefix.uplink {
  color: var(--green);
}

.relay-name {
  font-size: 11px;
  font-family: var(--mono);
  flex: 1;
}

.relay-ephemeral {
  font-size: 9px;
  color: var(--green);
  padding: 1px 4px;
  background: rgba(57, 217, 138, 0.1);
  border-radius: 3px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.enclave-empty {
  font-size: 9px;
  color: var(--muted);
  padding: 4px 0 8px;
  line-height: 1.4;
}

.add-enclave-bar {
  padding: 6px 12px;
  border-top: var(--border);
  display: flex;
  gap: 6px;
}

.add-enclave-bar input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid #1A1A1A;
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  padding: 6px 8px;
  transition: border-color 0.15s ease-in-out;
}

.add-enclave-bar input:focus { border-color: rgba(176, 38, 255, 0.5); }

.add-enclave-bar button {
  background: var(--surface3);
  border: 1px solid #1A1A1A;
  color: var(--purple);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.add-enclave-bar button:hover {
  border-color: var(--purple);
  color: var(--purple);
}

/* ── Pop-out mode (detached fixed window) ── */
body.popout-mode #left-sidebar { display: none !important; }
body.popout-mode #right-panel { display: none !important; }
body.popout-mode #chat-tab-bar { display: none !important; }
body.popout-mode .resizer { display: none !important; }
body.popout-mode #main-chat { flex: 1 1 100% !important; max-width: 100% !important; }
body.popout-mode .app-shell { overflow: hidden; }

.popout-titlebar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  user-select: none;
  flex-shrink: 0;
}

/* ── WebSocket Status Indicator ── */
.ws-status {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 9000;
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  pointer-events: none;
}

.ws-status.visible {
  opacity: 1;
}

.ws-status.connecting {
  background: rgba(245, 197, 66, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(245, 197, 66, 0.3);
}

.ws-status.connected {
  background: rgba(57, 217, 138, 0.15);
  color: var(--green);
  border: 1px solid rgba(57, 217, 138, 0.3);
}

.ws-status.disconnected {
  background: rgba(255, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(255, 68, 68, 0.3);
}

/* ── E2EE Lock Icon ── */
.e2ee-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  cursor: default;
  position: relative;
}

.e2ee-badge svg {
  display: block;
}

.e2ee-badge:hover svg {
  filter: drop-shadow(0 0 4px rgba(57, 217, 138, 0.6));
}

.e2ee-badge .e2ee-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--green);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
}

.e2ee-badge:hover .e2ee-tooltip {
  opacity: 1;
}
