:root {
  --bg-deep: #070a12;
  --bg-surface: rgba(15, 23, 42, 0.76);
  --bg-card: rgba(30, 41, 59, 0.6);
  --bg-card-hover: rgba(51, 65, 85, 0.72);
  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-accent: rgba(56, 189, 248, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-indigo: #818cf8;
  --accent-emerald: #34d399;
  --accent-amber: #fbbf24;
  --accent-rose: #fb7185;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-glow: 0 12px 40px -10px rgba(56, 189, 248, 0.24);
}

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

html,
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 18% 15%, rgba(56, 189, 248, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 82% 85%, rgba(129, 140, 248, 0.09) 0%, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.mobile-only-block {
  display: none;
}

/* ==================== HEADER ==================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 24px;
  background: rgba(7, 10, 18, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #070a12;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
  flex-shrink: 0;
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.status-Sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  flex-shrink: 0;
}

.status-dot.connecting {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
  color: var(--text-main);
  background: var(--bg-card);
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-lg-touch {
  min-height: 46px;
  padding: 11px 18px;
  font-size: 0.92rem;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-indigo));
  color: #060911;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25);
}

.btn-accent:hover {
  filter: brightness(1.07);
}

.btn-trust {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--accent-emerald);
}

.btn-primary-outline {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.38);
  color: var(--accent);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.7);
  border-color: var(--border-subtle);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.btn-sm {
  padding: 8px 13px;
  font-size: 0.82rem;
  min-height: 38px;
}

.btn-xs {
  padding: 6px 11px;
  font-size: 0.76rem;
  min-height: 32px;
}

.btn-block {
  width: 100%;
}

.icon-btn-sm,
.icon-btn-close {
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.icon-btn-close {
  width: 38px;
  height: 38px;
  font-size: 1rem;
}

.icon-btn-sm:hover,
.icon-btn-close:hover {
  color: var(--text-main);
  background: rgba(51, 65, 85, 0.8);
}

.icon-btn-sm svg {
  width: 16px;
  height: 16px;
}

.badge {
  background: var(--accent);
  color: #070a12;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 99px;
}

/* ==================== MAIN WORKSPACE LAYOUT ==================== */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 20px;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ==================== RADAR & SELF IDENTITY ==================== */
.radar-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.self-identity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
}

.self-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.device-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.device-avatar svg {
  width: 22px;
  height: 22px;
}

.self-text {
  min-width: 0;
}

.self-label-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.you-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  letter-spacing: 0.05em;
}

.self-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.self-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.code-pill {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.32);
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  cursor: pointer;
}

.e2ee-pill {
  color: var(--accent-emerald);
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
}

.quick-pair-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-input-inline {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.26);
  color: var(--text-main);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px prevents iOS Safari auto-zoom on focus */
  width: 175px;
  min-height: 44px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.06em;
}

.code-input-inline:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.btn-connect-inline {
  min-height: 44px;
  padding: 0 18px;
}

/* ==================== ORBITAL RADAR STAGE ==================== */
.radar-stage {
  position: relative;
  flex: 1;
  min-height: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px;
}

.radar-rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}

.radar-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(56, 189, 248, 0.14);
}

.ring-1 {
  width: 190px;
  height: 190px;
}

.ring-2 {
  width: 340px;
  height: 340px;
}

.ring-3 {
  width: 500px;
  height: 500px;
}

.radar-sweep {
  position: absolute;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 290deg,
    rgba(56, 189, 248, 0.09) 360deg
  );
  animation: radarSpin 8s linear infinite;
}

@keyframes radarSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.peers-empty-state {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.radar-center-beacon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 32px rgba(56, 189, 248, 0.25);
  animation: pulseBeacon 2.4s ease-in-out infinite;
}

.radar-center-beacon svg {
  width: 30px;
  height: 30px;
}

@keyframes pulseBeacon {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.25);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 42px rgba(56, 189, 248, 0.48);
  }
}

.peers-empty-state h3 {
  font-size: 1.12rem;
  font-weight: 700;
}

.peers-empty-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.48;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  width: 100%;
}

/* ==================== PEER DEVICE CARDS ==================== */
.peers-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  width: 100%;
  align-content: start;
}

.peer-card {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.18s ease;
  backdrop-filter: blur(12px);
  cursor: pointer;
  position: relative;
}

.peer-card:hover,
.peer-card.drag-over {
  border-color: var(--accent);
  background: rgba(30, 41, 59, 0.94);
  box-shadow: var(--shadow-glow);
}

.peer-card.trusted-peer {
  border-color: rgba(52, 211, 153, 0.45);
}

.peer-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.peer-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.peer-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peer-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.mode-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
}

.trust-toggle-btn {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.trust-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.trust-toggle-btn.active {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.55);
  color: var(--accent-emerald);
}

.trust-toggle-btn.delete-peer-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.55);
  color: #f87171;
}

.peer-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.peer-card-actions .btn {
  flex: 1 1 auto;
  min-height: 42px;
  padding: 8px 10px;
}

/* ==================== SIDEBAR: DROPZONE & TRANSFERS ==================== */
.transfer-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  backdrop-filter: blur(12px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.panel-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.dropzone-box {
  border: 2px dashed rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  transition: all 0.18s ease;
  background: rgba(15, 23, 42, 0.45);
}

.dropzone-box.drag-active,
.dropzone-box:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.05);
}

.dropzone-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}

.dropzone-icon-wrap svg {
  width: 24px;
  height: 24px;
}

.dropzone-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.dropzone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 4px 0 16px;
}

.dropzone-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==================== STAGED FILES QUEUE ==================== */
.staged-queue {
  margin-top: 14px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.staged-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.pill-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
}

.staged-files-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.staged-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
}

.staged-file-path {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.staged-file-size {
  color: var(--text-muted);
  font-size: 0.76rem;
  flex-shrink: 0;
}

.staged-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--accent);
  text-align: center;
  font-weight: 600;
}

/* ==================== ACTIVE TRANSFER TELEMETRY ==================== */
.active-transfers-card {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: var(--shadow-glow);
}

.active-transfers-list,
.recent-received-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transfer-item-card {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.transfer-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.86rem;
}

.transfer-file-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  width: 100%;
  height: 9px;
  background: rgba(51, 65, 85, 0.65);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-emerald));
  border-radius: 99px;
  transition: width 0.12s linear;
}

.transfer-telemetry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==================== CLIPBOARD & LINK SHARING ==================== */
.link-share-row {
  display: flex;
  gap: 8px;
}

.link-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text-main);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px prevents iOS zoom */
  min-height: 46px;
}

.link-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.received-links-card {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: var(--shadow-glow);
}

.received-link-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.received-link-text {
  font-size: 0.88rem;
  word-break: break-all;
  line-height: 1.45;
  color: var(--text-main);
}

.received-link-text a {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}

.received-link-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.received-link-from {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* ==================== MOBILE BOTTOM NAVIGATION ==================== */
.mobile-bottom-nav {
  display: none;
}

/* ==================== MODALS & BOTTOM SHEETS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.sheet-handle {
  display: none;
  width: 42px;
  height: 5px;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 99px;
  margin: 0 auto 12px;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 540px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.pair-modal-card {
  max-width: 680px;
}

.drawer-modal-card {
  max-width: 640px;
  display: flex;
  flex-direction: column;
}

.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.modal-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Incoming Transfer Modal */
.incoming-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.incoming-pulse-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.incoming-pulse-icon svg {
  width: 24px;
  height: 24px;
}

.incoming-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.incoming-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: rgba(30, 41, 59, 0.55);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.incoming-file-preview {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.incoming-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Pair / QR Modal */
.pair-grid {
  display: grid;
  grid-template-columns: 235px 1fr;
  gap: 22px;
  align-items: center;
}

.qr-box {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.qr-svg-wrap {
  width: 184px;
  height: 184px;
  margin: 0 auto 10px;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-svg-wrap svg {
  width: 100%;
  height: 100%;
}

.qr-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.network-url-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.network-select,
.code-input-lg,
.room-input {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px prevents iOS zoom */
  width: 100%;
  min-height: 44px;
}

.section-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.big-code-display {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  margin: 6px 0;
  cursor: pointer;
}

.pair-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 14px 0;
}

.modal-connect-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.code-input-lg {
  font-size: 1.2rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
  font-weight: 700;
}

/* History & Trusted Lists */
.privacy-controls-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.drawer-section-heading {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-chip {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

.drawer-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
  padding-right: 2px;
}

.drawer-item {
  background: rgba(30, 41, 59, 0.52);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.drawer-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.drawer-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ==================== IN-APP CAMERA QR SCANNER ==================== */
.qr-scanner-card {
  max-width: 460px;
}

.scanner-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 330px;
  background: #020617;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.scanner-target-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle, transparent 48%, rgba(2, 6, 23, 0.65) 75%);
}

.scanner-frame {
  position: relative;
  width: 200px;
  height: 200px;
}

.scanner-frame .corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}

.scanner-frame .corner.tl {
  top: 0;
  left: 0;
  border-top-width: 4px;
  border-left-width: 4px;
  border-top-left-radius: 10px;
}

.scanner-frame .corner.tr {
  top: 0;
  right: 0;
  border-top-width: 4px;
  border-right-width: 4px;
  border-top-right-radius: 10px;
}

.scanner-frame .corner.bl {
  bottom: 0;
  left: 0;
  border-bottom-width: 4px;
  border-left-width: 4px;
  border-bottom-left-radius: 10px;
}

.scanner-frame .corner.br {
  bottom: 0;
  right: 0;
  border-bottom-width: 4px;
  border-right-width: 4px;
  border-bottom-right-radius: 10px;
}

.scanner-laser {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
  animation: laserScan 2.2s ease-in-out infinite;
}

@keyframes laserScan {
  0%, 100% {
    top: 10px;
  }
  50% {
    top: 186px;
  }
}

.scanner-status-pill {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.78rem;
  color: var(--text-main);
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.scanner-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

/* Full-window drag overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 18, 0.88);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay-box {
  border: 2px dashed var(--accent);
  border-radius: 24px;
  padding: 48px 64px;
  text-align: center;
  background: rgba(56, 189, 248, 0.08);
}

.drop-overlay-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  color: var(--accent);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: #1e293b;
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  animation: toastIn 0.2s ease-out;
}

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

/* ==================== MOBILE & TABLET RESPONSIVENESS ==================== */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: 14px 16px 96px;
    gap: 16px;
  }
  .radar-stage {
    min-height: 290px;
    padding: 18px 14px;
  }
  .pair-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 720px) {
  .desktop-only-flex,
  .desktop-only-block {
    display: none !important;
  }

  .mobile-only-block {
    display: block !important;
  }

  .app-header {
    padding: 11px 16px;
  }

  .self-identity-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
    gap: 12px;
  }

  .quick-pair-inline {
    width: 100%;
  }

  .code-input-inline {
    flex: 1;
    width: auto;
  }

  .peers-grid {
    grid-template-columns: 1fr;
  }

  .empty-actions {
    flex-direction: column;
  }

  .empty-actions .btn {
    width: 100%;
  }

  .dropzone-buttons {
    flex-direction: column;
  }

  .dropzone-buttons .btn {
    width: 100%;
  }

  /* Native-Style Bottom Navigation Bar on Phones */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: rgba(10, 15, 28, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .mob-nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 2px;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
  }

  .mob-nav-item svg {
    width: 21px;
    height: 21px;
  }

  .mob-nav-item:active {
    color: var(--accent);
    background: rgba(56, 189, 248, 0.1);
  }

  .mob-nav-highlight {
    color: var(--accent);
  }

  /* Native-Style Bottom Sheet Modals on Phones */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .sheet-handle {
    display: block;
  }

  .modal-card {
    border-radius: 24px 24px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    max-width: 100%;
    max-height: 88dvh;
    padding: 14px 18px calc(22px + env(safe-area-inset-bottom, 0px));
    animation: sheetUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes sheetUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .drawer-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .drawer-item-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 4px;
  }

  .toast-container {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    left: 14px;
    right: 14px;
    max-width: none;
  }
}

/* ==================== MOBILE LAYOUT REFINEMENTS (no overflow / comfortable spacing) ==================== */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.peer-card,
.transfer-item-card,
.modal-card,
.staged-file-item,
.drawer-item {
  min-width: 0;
  max-width: 100%;
}

.peer-identity > div,
.drawer-item-info,
.transfer-file-title,
.staged-file-path {
  min-width: 0;
}

.transfer-top-row {
  flex-wrap: wrap;
}

.transfer-top-row .transfer-file-title {
  flex: 1 1 140px;
}

.transfer-telemetry-row {
  flex-wrap: wrap;
  gap: 4px 10px;
}

.transfer-telemetry-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .workspace {
    padding: 12px 12px calc(88px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
  }

  .peers-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .peer-card {
    padding: 14px;
    gap: 12px;
  }

  .peer-card-top {
    gap: 8px;
  }

  .peer-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .peer-card-actions .btn {
    width: 100%;
    min-height: 44px;
    padding: 8px 8px;
    font-size: 0.84rem;
    white-space: normal;
    line-height: 1.2;
  }

  .peer-card-actions .btn:only-child,
  .peer-card-actions .btn:nth-child(odd):last-child {
    grid-column: 1 / -1;
  }

  .transfer-item-card {
    padding: 12px;
    gap: 10px;
  }

  .transfer-top-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .transfer-top-row .transfer-file-title {
    flex: none;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .transfer-top-row > div {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .transfer-top-row .btn {
    min-height: 38px;
    padding: 6px 12px;
  }

  .progress-track {
    height: 10px;
  }

  .transfer-telemetry-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-card {
    padding-left: 16px;
    padding-right: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-top {
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-connect-row {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-connect-row .btn,
  .modal-connect-row input {
    width: 100%;
  }

  .link-share-row {
    flex-direction: column;
  }

  .link-share-row .btn {
    width: 100%;
  }

  .mobile-bottom-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .mob-nav-item {
    min-height: 48px;
    font-size: 0.64rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .staged-file-item {
    flex-wrap: wrap;
    gap: 4px 8px;
  }
}

@media (max-width: 360px) {
  .peer-card-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .mob-nav-item {
    font-size: 0.58rem;
  }

  .mob-nav-item svg {
    width: 19px;
    height: 19px;
  }
}
