:root {
  --bg: #07080C;
  --surface: #10131C;
  --surface-variant: #171C28;
  --primary: #F5C451;
  --on-primary: #08090D;
  --primary-container: #2A210B;
  --on-primary-container: #FFE599;
  --secondary: #D4AF37;
  --secondary-container: #161922;
  --tertiary: #10B981;
  --on-surface: #F8FAFC;
  --on-surface-variant: #C4CBD6;
  --outline: #D4AF37;
  --border: rgba(245, 196, 81, 0.22);
  --danger: #F15C6D;
  --read-blue: #34B7F1;
  --wallpaper-bg: none;
  --wallpaper-size: 52px 52px;
  --vvh: 100dvh;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--on-surface);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.mono-dim {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--on-surface-variant);
}
.mono-wrap {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  word-break: break-all;
  color: var(--primary);
}
.m-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.full-w { width: 100%; }

/* Root fixed shell matching APK edge-to-edge dimensions */
.app-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: var(--vvh, 100dvh);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Desktop Master-Detail Split Workspace (same APK chrome on both panes) */
.workspace {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
}

/* ==================== HOME / CHAT LIST PANE (APK ChatListScreen) ==================== */
.apk-home-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.apk-home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: calc(58px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 6px 16px;
  background: var(--surface);
  flex-shrink: 0;
}

.apk-home-title-col {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
}

.apk-brand-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.apk-brand-word {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--primary);
  line-height: 1.15;
}

.apk-pro-pill {
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.apk-status-subrow {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.apk-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--on-surface-variant);
  opacity: 0.65;
}
.apk-status-dot.connected { background: #25D366; opacity: 1; }
.apk-status-dot.connecting { background: #FFB300; opacity: 1; }
.apk-status-dot.error { background: var(--danger); opacity: 1; }

.apk-status-alias {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 115px;
}
.apk-status-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apk-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

/* Material 42-44dp Touch IconButtons */
.apk-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.14s ease;
  flex-shrink: 0;
}
.apk-icon-btn:hover { background: color-mix(in srgb, var(--on-surface) 10%, transparent); }
.apk-icon-btn:active { background: color-mix(in srgb, var(--on-surface) 16%, transparent); }
.apk-icon-btn.apk-icon-sm {
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
}
.apk-icon-btn.danger-tint { color: var(--danger); }

/* Dropdown Menu (APK TopAppBar MoreVert) */
.menu-anchor { position: relative; }
.apk-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 245px;
  max-width: min(86vw, 310px);
  max-height: calc(var(--vvh, 100dvh) - 100px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 12%, transparent);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.58);
  padding: 6px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.apk-dropdown button,
.apk-dropdown a {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--on-surface);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}
.apk-dropdown button:hover,
.apk-dropdown a:hover {
  background: color-mix(in srgb, var(--on-surface) 8%, transparent);
}
.apk-dropdown .menu-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-variant);
}
.apk-dropdown .menu-ico-primary { color: var(--primary); }
.apk-dropdown .danger-item,
.apk-dropdown .danger-item .menu-ico {
  color: var(--danger);
}

/* Search Bar */
.apk-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  flex-shrink: 0;
}
.apk-search-icon { color: var(--on-surface-variant); display: inline-flex; }
.apk-search-bar input {
  flex: 1;
  min-width: 0;
  background: var(--surface-variant);
  color: var(--on-surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
}
.apk-search-bar input:focus {
  border-color: var(--primary);
}

/* Material 3 Underline TabRow (text-only tabs matching ChatListScreen.kt) */
.apk-tab-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  flex-shrink: 0;
}
.apk-tab-row.two-tabs { grid-template-columns: repeat(2, 1fr); }
.apk-tab-row.three-tabs { grid-template-columns: repeat(3, 1fr); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.apk-tab-row.four-tabs { grid-template-columns: repeat(4, 1fr); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }

.apk-tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 6px;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.apk-tab-btn.active {
  color: var(--primary);
  font-weight: 700;
}
.apk-tab-btn.active::after {
  content: '';
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}
.apk-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 10.5px;
  font-weight: 800;
}

/* Home Scrollable Pane */
.apk-home-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

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

/* Archived folder accordion */
.archived-section {
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 6%, transparent);
}
.archived-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: transparent;
  border: none;
  color: var(--on-surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.archived-toggle-left {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--primary);
}
.archived-toggle-left span:last-child { color: var(--on-surface); }

/* Exact APK ChatItemRow (52dp circle avatar, title + Lock + HH.mm, divider inset 84dp) */
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--on-surface);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
.chat-item::after {
  content: '';
  position: absolute;
  left: 82px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background: color-mix(in srgb, var(--on-surface) 7%, transparent);
}
.chat-item:hover {
  background: color-mix(in srgb, var(--on-surface) 5%, transparent);
}
.chat-item.selected {
  background: color-mix(in srgb, var(--primary) 11%, transparent);
}

.avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--primary);
  border: 1.5px solid color-mix(in srgb, var(--primary) 28%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-circle.unread-ring {
  border-color: var(--primary);
  border-width: 2px;
}
.avatar-circle.avatar-sm {
  width: 40px;
  height: 40px;
  font-size: 15px;
}
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-item-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-name-cluster {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}
.chat-name-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-lock-ico { color: var(--primary); flex-shrink: 0; }
.disappear-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-time-label {
  font-size: 12px;
  color: var(--on-surface-variant);
  flex-shrink: 0;
}
.chat-time-label.unread { color: var(--primary); font-weight: 700; }

.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-item-preview {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  font-size: 13.5px;
  color: var(--on-surface-variant);
}
.chat-item-preview-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-preview.typing { color: var(--primary); font-weight: 600; }

.chat-right-indicators {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.chat-ind-ico { color: var(--on-surface-variant); opacity: 0.78; }
.chat-ind-ico.pinned { color: var(--primary); opacity: 0.9; }
.unread-pill {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}
.blocked-pill {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(241, 92, 109, 0.16);
  color: var(--danger);
  border: 1px solid rgba(241, 92, 109, 0.4);
  font-size: 10px;
  font-weight: 700;
}
.chat-row-more-btn {
  min-width: 34px;
  min-height: 34px;
  width: 34px;
  height: 34px;
  color: var(--on-surface-variant);
  opacity: 0.72;
}
.chat-item:hover .chat-row-more-btn { opacity: 1; }

/* Mobile-only Welcome Banner inside Chats Tab when 0 chats */
.mobile-welcome-slot {
  display: none;
  padding: 16px;
}
.mobile-welcome-slot:empty { display: none !important; }

/* Estado (Status) Tab */
.apk-status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
}
.apk-status-card:hover { background: color-mix(in srgb, var(--on-surface) 5%, transparent); }
.apk-status-avatar-wrap { position: relative; flex-shrink: 0; }
.apk-status-add-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: 2px solid var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.apk-status-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.apk-status-meta strong { font-size: 15.5px; }
.apk-status-meta small { font-size: 13px; color: var(--on-surface-variant); }
.apk-section-label {
  padding: 8px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-empty-card {
  margin: 8px 16px;
  padding: 22px 18px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  border: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  color: var(--on-surface-variant);
}
.status-empty-card strong { color: var(--on-surface); font-size: 14.5px; }
.status-empty-card small { font-size: 12.5px; line-height: 1.4; }
.status-item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  cursor: pointer;
}
.status-item-row:hover { background: color-mix(in srgb, var(--on-surface) 5%, transparent); }
.status-ring-avatar {
  border: 2.5px solid var(--primary);
  padding: 2px;
}

/* Circular APK FAB */
.apk-fab {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  touch-action: manipulation;
  transition: transform 0.14s ease, filter 0.14s ease;
}
.apk-fab:hover { filter: brightness(1.06); }
.apk-fab:active { transform: scale(0.95); }

/* ==================== DETAIL STAGE (Conversation / Welcome / Pairing / Security / Settings) ==================== */
.apk-detail-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

/* Welcome Card matching ChatListScreen empty state */
.welcome-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.apk-welcome-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface-variant);
  border: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  border-radius: 16px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}
.apk-welcome-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.apk-welcome-card h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--on-surface);
  line-height: 1.3;
}
.apk-welcome-card .lead {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--on-surface-variant);
}
.apk-welcome-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.apk-welcome-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

/* Common Subscreen Container (Pairing / Security Kademlia / Settings) */
.apk-subscreen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--bg);
}
.apk-sub-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(58px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 10px 6px 8px;
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  flex-shrink: 0;
}
.apk-sub-topbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--on-surface);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apk-sub-title-stack {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.apk-sub-title-stack small {
  font-size: 11px;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apk-subscreen-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.sub-pane { display: none; flex-direction: column; gap: 14px; }
.sub-pane.active { display: flex; }

/* Cards & Buttons strictly colored from active theme tokens */
.card-block {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-block h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface);
}
.hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--on-surface-variant);
}

.apk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary,
.btn-primary-sm,
.btn-secondary,
.btn-secondary-sm,
.btn-outline,
.btn-ghost,
.btn-ghost-sm,
.btn-danger,
.btn-chip {
  font-family: inherit;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  transition: filter 0.14s ease, background 0.14s ease;
}

.btn-primary,
.btn-primary-sm {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  padding: 10px 16px;
  font-size: 13.5px;
}
.btn-primary-sm { min-height: 36px; padding: 8px 13px; font-size: 12.5px; }
.btn-primary:hover, .btn-primary-sm:hover { filter: brightness(1.06); }

.btn-secondary,
.btn-secondary-sm {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  padding: 10px 14px;
  font-size: 13px;
}
.btn-secondary-sm { min-height: 36px; padding: 7px 12px; font-size: 12px; }
.btn-secondary-sm.active-on {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 10px 14px;
  font-size: 13.5px;
}

.btn-ghost,
.btn-ghost-sm {
  background: color-mix(in srgb, var(--surface-variant) 75%, transparent);
  color: var(--on-surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 14%, transparent);
  padding: 9px 14px;
  font-size: 13px;
}
.btn-ghost-sm { min-height: 34px; padding: 6px 11px; font-size: 12px; }

.btn-danger {
  background: rgba(241, 92, 109, 0.16);
  color: var(--danger);
  border: 1px solid rgba(241, 92, 109, 0.45);
  padding: 10px 14px;
  font-size: 13px;
}
.btn-chip {
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-variant);
  color: var(--on-surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 12%, transparent);
}

.btn-stack { display: flex; flex-direction: column; gap: 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: flex; gap: 8px; align-items: center; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="search"],
textarea,
select {
  background: var(--surface-variant);
  color: var(--on-surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 14%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}
.inline-form input { flex: 1; min-width: 0; }

/* Pairing QR & PIN */
.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: #ffffff;
  border-radius: 14px;
  align-self: center;
}
#myQrCanvas { display: block; width: 200px; height: 200px; }
.pin-hero-card { align-items: center; text-align: center; }
.apk-pin-display-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.apk-big-pin {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--primary);
  background: var(--surface-variant);
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}
.camera-box {
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
#qrVideo { width: 100%; max-height: 240px; object-fit: cover; display: block; }
.camera-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-variant);
}

/* ==================== KADEMLIA RADAR + HORIZONTAL CHIPS + DIRECTORY (APK SecurityDashboardScreen) ==================== */
.kad-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--on-surface-variant);
}
.kad-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
.kad-canvas {
  width: 100%;
  height: 270px;
  display: block;
  background: #081116;
  border: 1px solid rgba(0, 230, 118, 0.28);
  border-radius: 16px;
  cursor: pointer;
}

/* Strictly HORIZONTAL scrollable chips strip below radar (fixes vertical stacking!) */
.kad-chips-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.kad-node-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  white-space: nowrap;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface-variant);
  color: var(--on-surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 14%, transparent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.kad-node-chip.active {
  background: var(--primary-container);
  color: var(--primary);
  border-color: var(--primary);
}
.kad-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kad-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.kad-inspector-title {
  font-size: 14px;
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kad-role-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
  flex-shrink: 0;
}
.kad-kv-row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 7%, transparent);
  padding: 4px 0;
}
.kad-kv-row span { color: var(--on-surface-variant); flex-shrink: 0; }
.kad-kv-row strong { text-align: right; word-break: break-all; color: var(--on-surface); }

.kad-dir-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kad-dir-row {
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--on-surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kad-dir-row.selected { border-color: var(--primary); }
.kad-dir-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kad-dir-top strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kad-dir-sub {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== CONVERSATION SCREEN (Exact APK ConversationScreen) ==================== */
.active-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: calc(58px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 6px 6px 4px;
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  flex-shrink: 0;
}

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

.chat-header-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 10px;
}
.chat-header-identity:hover {
  background: color-mix(in srgb, var(--on-surface) 6%, transparent);
}

.chat-avatar-dot-wrap {
  position: relative;
  flex-shrink: 0;
}
.peer-online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.peer-online-dot.online { background: #25D366; }

.chat-header-titles {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-title-row {
  display: flex;
  align-items: center;
  min-width: 0;
}
.chat-title-row strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-sub-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.chat-sub-lock { color: var(--primary); display: inline-flex; flex-shrink: 0; }
.chat-sub-row small {
  font-size: 11.5px;
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-sub-row small.live-typing {
  color: var(--primary);
  font-weight: 600;
}

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

/* Sub-banners */
.pinned-msg-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-variant);
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  color: var(--primary);
  font-size: 12.5px;
  flex-shrink: 0;
}
.pinned-msg-text {
  flex: 1;
  min-width: 0;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blocked-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(241, 92, 109, 0.14);
  border-bottom: 1px solid rgba(241, 92, 109, 0.35);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Messages Feed with exact APK Wallpaper Canvas styling */
.messages-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: var(--bg);
  background-image: var(--wallpaper-bg);
  background-size: var(--wallpaper-size);
}

/* Top E2EE APK Banner */
.e2ee-system-card {
  width: 100%;
  margin: 4px 0 8px;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-variant) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--on-surface) 6%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  cursor: pointer;
}
.e2ee-system-card .e2ee-lock { color: var(--primary); }
.e2ee-system-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--on-surface-variant);
}

/* Date Badge Pill */
.date-pill-row {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}
.date-pill {
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--surface-variant);
  color: var(--on-surface-variant);
  font-size: 11.5px;
  font-weight: 600;
}

/* Asymmetric APK Message Bubbles */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: min(82%, 340px);
}
.msg-row.self { align-self: flex-end; align-items: flex-end; }
.msg-row.peer { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  position: relative;
  padding: 8px 12px 6px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.42;
  cursor: pointer;
}
.msg-bubble.self {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: 16px 16px 2px 16px;
}
.msg-bubble.peer {
  background: var(--surface-variant);
  color: var(--on-surface);
  border-radius: 16px 16px 16px 2px;
}
.msg-bubble.search-hit {
  outline: 2px solid var(--primary);
}
.msg-bubble a { color: var(--primary); text-decoration: underline; }

.msg-sender-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}
.msg-forwarded-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-style: italic;
  opacity: 0.8;
  margin-bottom: 3px;
}
.msg-quote-box {
  border-left: 3px solid var(--primary);
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 5px;
  font-size: 12px;
}
.msg-quote-box strong { display: block; color: var(--primary); font-size: 11.5px; }
.msg-quote-box span { opacity: 0.85; }

.msg-media-img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 12px;
  margin-top: 4px;
  cursor: pointer;
  object-fit: cover;
}
.view-once-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 35%, transparent);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* Inline Audio Player Card (1 element, no duplicate .msg-file-card, Safari + Desktop compatible) */
.msg-audio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 280px;
  padding: 4px 2px;
  margin-top: 2px;
}
.msg-audio-player {
  flex: 1;
  min-width: 160px;
  height: 36px;
  color-scheme: dark;
}
.msg-audio-speed {
  padding: 3px 6px;
  border-radius: 8px;
  border: none;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary);
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.msg-audio-dl {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.msg-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  margin-top: 4px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 35%, transparent);
}
.msg-file-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.msg-file-meta { display: flex; flex-direction: column; min-width: 0; }
.msg-file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 11px; opacity: 0.75; }
.msg-file-dl {
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* Poll & Location cards inside bubble */
.msg-poll-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 210px;
  margin-top: 4px;
}
.msg-poll-q { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.msg-poll-opt {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  background: color-mix(in srgb, var(--bg) 35%, transparent);
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: inherit;
  cursor: pointer;
}
.msg-poll-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--primary) 24%, transparent);
  pointer-events: none;
}
.msg-poll-opt span { position: relative; z-index: 1; }

.msg-location-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 38%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  margin-top: 4px;
}
.msg-location-head { display: flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 700; font-size: 13px; }
.msg-location-link { font-size: 12px; font-weight: 700; color: var(--primary); text-decoration: none; }

/* Message Footer (Star, Editado, HH.mm dot time, SVG Ticks) */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
  font-size: 10.5px;
  opacity: 0.78;
}
.msg-tick-read { color: var(--read-blue); opacity: 1; }
.msg-star-ico { color: #FFB300; }

/* Message Reactions Pill */
.msg-reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.msg-reaction-pill {
  padding: 2px 7px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 14%, transparent);
  font-size: 12px;
  color: var(--on-surface);
  cursor: pointer;
}

.typing-banner {
  padding: 4px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  flex-shrink: 0;
}

.chat-drop-overlay {
  position: absolute;
  inset: 60px 12px 76px;
  z-index: 90;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 2px dashed var(--primary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  font-weight: 700;
}

/* Reply/Edit Banner + Attachment 2x3 Sheet + Emoji Picker + Voice Bar */
.reply-edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  flex-shrink: 0;
}
.reply-edit-bar { width: 3px; height: 30px; border-radius: 3px; background: var(--primary); flex-shrink: 0; }
.reply-edit-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-edit-info strong { font-size: 12px; color: var(--primary); }
.reply-edit-info small { font-size: 12px; color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.apk-attach-drawer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px;
  padding: 16px 14px;
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  flex-shrink: 0;
}
.attach-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--on-surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.attach-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.apk-emoji-drawer {
  padding: 8px 12px 10px;
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  max-height: 240px;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.picker-mode-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  padding-bottom: 6px;
}
.picker-pack-pills {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 6px;
  padding-bottom: 4px;
}
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.sticker-tile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface-variant);
  color: var(--on-surface-variant);
  font-size: 10.5px;
  cursor: pointer;
}
.sticker-tile-btn:hover { border-color: var(--primary); color: var(--on-surface); }
.sticker-tile-btn img { width: 52px; height: 52px; object-fit: contain; }
.msg-bubble.sticker-only {
  background: transparent !important;
  padding: 2px 4px;
}
.msg-sticker-img {
  width: 148px;
  height: 148px;
  object-fit: contain;
  display: block;
}
.msg-bubble.sticker-only .msg-meta {
  background: color-mix(in srgb, var(--surface-variant) 88%, transparent);
  border-radius: 10px;
  padding: 2px 8px;
  margin-top: 2px;
  display: inline-flex;
  float: right;
}
.msg-jumbo-emoji {
  font-size: 48px;
  line-height: 1.15;
  padding: 2px 4px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
}
.emoji-btn {
  height: 36px;
  font-size: 20px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-btn:hover { background: var(--surface-variant); }

.pending-attachment-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  flex-shrink: 0;
}
.pending-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--surface-variant);
  font-size: 12px;
}

.voice-record-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--on-surface) 8%, transparent);
  flex-shrink: 0;
}
.voice-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulseRec 1s infinite ease-in-out;
  flex-shrink: 0;
}
@keyframes pulseRec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.voice-rec-timer {
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--on-surface);
}
.apk-fab-mini {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Exact APK Bottom Composer Bar (Storefront?, Emoji, Attach, Pill("Mensaje"), Camera, Mic/Send 44px Circle FAB) */
.apk-composer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)) 4px;
  background: var(--bg);
  flex-shrink: 0;
}
.composer-btn {
  min-width: 38px;
  min-height: 42px;
  width: 38px;
  height: 42px;
  color: var(--on-surface-variant);
}
.composer-pill {
  flex: 1;
  min-width: 0;
  background: var(--surface-variant);
  border-radius: 24px;
  padding: 3px 14px;
  display: flex;
  align-items: center;
  min-height: 44px;
}
.composer-pill textarea {
  border: none;
  background: transparent;
  padding: 6px 0;
  margin: 0;
  resize: none;
  max-height: 110px;
  font-size: 15px;
  line-height: 1.35;
  color: var(--on-surface);
}
.apk-composer-fab {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 4px;
  flex-shrink: 0;
  touch-action: manipulation;
}

/* ==================== SETTINGS & THEME GRID ==================== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.theme-swatch-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-variant);
  border: 1.5px solid color-mix(in srgb, var(--on-surface) 12%, transparent);
  color: var(--on-surface);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.theme-swatch-btn.active {
  border-color: var(--primary);
  background: var(--primary-container);
}
.theme-dots { display: inline-flex; gap: 3px; flex-shrink: 0; }
.theme-dots i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,0.2); }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
}
.setting-row strong { display: block; font-size: 13.5px; }
.setting-row small { display: block; font-size: 12px; color: var(--on-surface-variant); }
.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ==================== CALL OVERLAY (Desktop, Android, iPhone Notch Safe Areas) ==================== */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  background: linear-gradient(180deg, #0A101D 0%, #17183B 55%, #070A12 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 10px) env(safe-area-inset-right, 10px) env(safe-area-inset-bottom, 10px) env(safe-area-inset-left, 10px);
  overflow: hidden;
}
.call-box {
  width: 100%;
  max-width: min(96vw, 520px);
  height: min(92vh, calc(var(--vvh, 100dvh) - 20px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  padding: 12px;
  gap: 8px;
}
.call-overlay.video-mode.call-fullscreen {
  padding: 0;
}
.call-overlay.video-mode.call-fullscreen .call-box {
  max-width: 100%;
  width: 100%;
  height: var(--vvh, 100dvh);
  border-radius: 0;
  border: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.call-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  flex-shrink: 0;
  z-index: 4;
}
.call-badges-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.e2ee-pill, .call-net-pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.16);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.call-net-pill {
  background: var(--primary-container);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 38%, transparent);
}
.call-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #05080F;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.remote-video-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.remote-video-canvas.fit-cover { object-fit: cover; }

.stage-hud-controls {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  z-index: 15;
}
.btn-stage-hud {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(8, 12, 24, 0.78);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.btn-stage-hud.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

.audio-call-stage {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-xl {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--primary);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  z-index: 2;
}
.local-pip-wrap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 140px;
  height: 102px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--primary);
  background: #000;
  z-index: 18;
  display: flex;
  flex-direction: column;
}
.local-pip-wrap.minimized { height: 28px; width: 92px; }
.local-pip-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 10px;
}
.pip-mini-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 2px 6px;
}
.local-pip { width: 100%; height: 100%; object-fit: cover; flex: 1; }
.local-pip.mirrored { transform: scaleX(-1); }

.call-device-pickers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  flex-shrink: 0;
}
.device-select-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-variant);
  border-radius: 10px;
  padding: 3px 8px;
  max-width: 160px;
}
.device-select-chip select {
  padding: 3px 4px;
  font-size: 11.5px;
  border: none;
  background: transparent;
}

.call-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 4px 0 calc(2px + env(safe-area-inset-bottom, 0px));
}
.btn-call-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--on-surface) 18%, transparent);
  background: var(--surface-variant);
  color: var(--on-surface);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-call-ctrl.active-off {
  background: rgba(241, 92, 109, 0.22);
  border-color: var(--danger);
  color: #fecaca;
}
.btn-call-accept {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 22px;
  border-radius: 999px;
  border: none;
  background: #25D366;
  color: #041309;
  font-weight: 800;
  cursor: pointer;
}
.btn-call-hangup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: #EF4444;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

/* Modals (Safe Area + Touch Scrollable) */
.modal-dialog {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--on-surface);
  width: min(94vw, 480px);
  max-width: 94vw;
  max-height: calc(var(--vvh, 100dvh) - 24px);
}
.modal-dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.modal-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--on-surface) 12%, transparent);
  border-radius: 20px;
  padding: 16px;
  max-height: calc(var(--vvh, 100dvh) - 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-head h2 { margin: 0; font-size: 16.5px; font-weight: 700; }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-body h3 { margin: 8px 0 2px; font-size: 13.5px; color: var(--primary); }

.apk-sheet-actions { display: flex; flex-direction: column; gap: 4px; }
.apk-sheet-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--on-surface);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.apk-sheet-btn:hover { background: var(--surface-variant); }
.apk-sheet-btn.danger { color: var(--danger); }

.msg-react-bar {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
}
.react-pick-btn {
  font-size: 22px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--surface-variant);
  cursor: pointer;
}

.perm-list { display: flex; flex-direction: column; gap: 8px; }
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-variant);
}
.perm-row small { display: block; margin-top: 2px; }
.kv-box {
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.diagnostic-box {
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 230px;
  overflow-y: auto;
  text-align: left;
}
.spec-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.status-note { font-size: 12px; color: var(--primary); min-height: 16px; }
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-variant);
  border: 1px dashed color-mix(in srgb, var(--primary) 40%, transparent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.divider { border: none; border-top: 1px solid color-mix(in srgb, var(--on-surface) 10%, transparent); margin: 6px 0; }
.guide-step {
  background: var(--surface-variant);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}
.guide-step p { margin: 4px 0 0; color: var(--on-surface-variant); }
.safari-note { background: color-mix(in srgb, var(--primary) 10%, transparent); padding: 10px 12px; border-radius: 12px; }
.lightbox-body { display: flex; justify-content: center; }
.lightbox-body img { max-width: 100%; max-height: 68vh; border-radius: 12px; object-fit: contain; }
.shared-media-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 54vh;
  overflow-y: auto;
}
.shared-media-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}
.shared-list-row {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-variant);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ==================== MOBILE & IPHONE / ANDROID SINGLE-PANE BREAKPOINT ==================== */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .apk-home-pane {
    border-right: none;
  }
  .workspace.detail-open .apk-home-pane {
    display: none;
  }
  .workspace:not(.detail-open) .apk-detail-stage {
    display: none;
  }
  .mobile-welcome-slot {
    display: block;
  }
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    font-size: 16px;
  }
  .composer-pill textarea { font-size: 16px; }
  .local-pip-wrap {
    width: 100px;
    height: 136px;
  }
  .btn-stage-hud {
    padding: 4px 8px;
    font-size: 10.5px;
  }
}
