:root{
  --bg:#050816;
  --bg2:#081124;
  --panel:#101a31;
  --panel2:#16213f;

  --text:#eef4ff;
  --muted:#9db0d3;

  --yellow:#ffcc33;
  --yellowGlow:#ffd84d;

  --blue:#6ca7ff;
  --blue2:#4e8cff;

  --green:#5cff98;

  --border:rgba(255,255,255,.08);
  --glass:rgba(255,255,255,.05);

  --shadow:
    0 20px 60px rgba(0,0,0,.45);

  --radius:28px;
}

*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  padding:0;

  width:100%;
  height:100%;

  background:
    radial-gradient(circle at top,#0d1b3d 0%,#050816 55%),
    #050816;

  color:var(--text);

  font-family:
    Inter,
    system-ui,
    sans-serif;

  overflow:hidden;
}

body{
  min-height:100vh;
}

.hidden{
  display:none !important;
}

/* APP */

.app-shell{
  width:100%;
  height:100vh;

  display:flex;
  flex-direction:column;
}

/* TOPBAR */

.topbar{
  height:104px;

  display:flex;
  align-items:center;
  justify-content:space-between;

  padding:
    0 24px;

  border-bottom:
    1px solid var(--border);

  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.03),
      rgba(255,255,255,.01)
    );

  backdrop-filter:blur(22px);
}

.brand-wrap{
  display:flex;
  flex-direction:column;
  gap:4px;
}

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

.brand-icon{
  font-size:38px;

  color:var(--yellow);

  filter:
    drop-shadow(0 0 14px rgba(255,210,60,.55));
}

.brand-title{
  font-size:28px;
  font-weight:950;
  letter-spacing:-.03em;

  color:var(--yellow);
}

.brand-title span{
  color:var(--blue);

  text-shadow:
    0 0 20px rgba(108,167,255,.45);
}

.brand-subtitle{
  padding-left:50px;

  font-size:14px;
  font-weight:700;

  color:#bdd5ff;

  opacity:.72;

  text-shadow:
    0 0 16px rgba(108,167,255,.32);
}

/* ONLINE */

.topbar-center{
  flex:1;

  display:flex;
  justify-content:center;
}

.online-indicator{
  display:flex;
  align-items:center;
  gap:10px;

  padding:
    12px 22px;

  border-radius:999px;

  font-size:18px;
  font-weight:900;

  color:var(--green);

  background:
    rgba(30,255,120,.05);

  border:
    1px solid rgba(92,255,152,.12);

  box-shadow:
    0 0 30px rgba(92,255,152,.15);
}

/* SETTINGS BTN */

.topbar-actions{
  display:flex;
  align-items:center;
}

.topbar-btn{
  width:58px;
  height:58px;

  border:0;
  border-radius:22px;

  cursor:pointer;

  font-size:28px;

  color:white;

  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.10),
      rgba(255,255,255,.04)
    );

  border:
    1px solid rgba(255,255,255,.08);

  box-shadow:
    0 10px 28px rgba(0,0,0,.35);

  transition:
    transform .18s ease,
    box-shadow .18s ease;
}

.topbar-btn:hover{
  transform:translateY(-2px);

  box-shadow:
    0 18px 40px rgba(0,0,0,.45);
}

/* LAYOUT */

.layout{
  flex:1;

  display:flex;

  min-height:0;
}

/* SIDEBAR */

.sidebar{
  width:340px;

  display:flex;
  flex-direction:column;

  border-right:
    1px solid var(--border);

  background:
    linear-gradient(
      180deg,
      rgba(0,0,0,.12),
      rgba(255,255,255,.01)
    );
}

.sidebar-title{
  padding:
    22px 24px 12px;

  font-size:14px;
  font-weight:950;
  letter-spacing:.14em;

  color:#d7e5ff;

  opacity:.92;
}

.devices-grid{
  flex:1;

  overflow:auto;

  padding:
    0 18px 18px;
}

/* EMPTY */

.empty-devices{
  margin-top:26px;

  border-radius:32px;

  padding:
    42px 24px;

  text-align:center;

  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.05),
      rgba(255,255,255,.02)
    );

  border:
    1px solid rgba(255,255,255,.06);

  box-shadow:var(--shadow);
}

.empty-devices-icon{
  font-size:74px;

  margin-bottom:18px;
}

.empty-devices-title{
  font-size:22px;
  font-weight:950;

  margin-bottom:10px;
}

.empty-devices-subtitle{
  color:var(--muted);

  line-height:1.5;
}

/* DEVICE CARD */

.device-card{
  display:flex;
  align-items:center;
  gap:16px;

  margin-bottom:14px;

  padding:
    18px;

  border-radius:24px;

  cursor:pointer;

  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.06),
      rgba(255,255,255,.02)
    );

  border:
    1px solid rgba(255,255,255,.06);

  transition:
    transform .18s ease,
    border-color .18s ease;
}

.device-card:hover{
  transform:translateY(-2px);

  border-color:
    rgba(108,167,255,.24);
}

.device-avatar{
  width:58px;
  height:58px;

  display:grid;
  place-items:center;

  border-radius:18px;

  font-size:28px;

  background:
    rgba(108,167,255,.12);
}

.device-body{
  flex:1;
}

.device-title{
  font-size:18px;
  font-weight:900;

  margin-bottom:4px;
}

.device-meta{
  font-size:13px;

  color:var(--muted);
}

/* MAIN */

.main-content{
  flex:1;

  min-width:0;

  padding:
    18px;

  overflow:auto;
}

.screen{
  display:flex;
  flex-direction:column;

  gap:16px;

  height:100%;
}

/* CHAT */

.chat-header{
  min-height:74px;

  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;

  padding:
    0 28px;

  border-radius:32px;

  font-size:22px;
  font-weight:950;

  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.06),
      rgba(255,255,255,.02)
    );

  border:
    1px solid rgba(255,255,255,.06);

  box-shadow:var(--shadow);
}

.peer-status-pill,
.turn-status-pill,
.trust-status-pill{
  min-height:30px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  padding:0 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.07);
  color:#dbeafe;
  font-size:12px;
  font-weight:900;
  line-height:1;
  white-space:nowrap;
}

.trust-status-pill{
  cursor:pointer;
  font-family:inherit;
}

.peer-status-pill.ready,
.turn-status-pill.ready,
.trust-status-pill.verified{
  color:#081124;
  background:linear-gradient(135deg,#5cff98,#9cffbd);
  border-color:rgba(92,255,152,.42);
  box-shadow:0 0 22px rgba(92,255,152,.18);
}

.peer-status-pill.connecting,
.turn-status-pill.warning,
.trust-status-pill.unknown{
  color:#081124;
  background:linear-gradient(135deg,#ffcc33,#ffd84d);
  border-color:rgba(255,204,51,.42);
  box-shadow:0 0 20px rgba(255,204,51,.15);
}

.peer-status-pill.danger,
.turn-status-pill.danger{
  color:white;
  background:linear-gradient(135deg,#ef4444,#be123c);
  border-color:rgba(239,68,68,.45);
}

.peer-status-pill.idle,
.turn-status-pill.unknown{
  color:#c7d2fe;
  background:rgba(255,255,255,.07);
}

.chat-messages{
  flex:1;

  min-height:120px;

  overflow:auto;

  padding:
    16px;

  border-radius:32px;

  background:
    linear-gradient(
      180deg,
      rgba(255,255,255,.03),
      rgba(255,255,255,.01)
    );

  border:
    1px solid rgba(255,255,255,.05);
}

/* MESSAGE */

.msg{
  max-width:72%;

  margin-bottom:12px;

  padding:
    14px 18px;

  border-radius:22px;

  line-height:1.45;

  word-break:break-word;
}

.msg.own{
  margin-left:auto;

  background:
    linear-gradient(
      135deg,
      #4e8cff,
      #6ca7ff
    );

  color:white;
}

.msg.remote{
  background:
    rgba(255,255,255,.08);
}

/* INPUT */

.chat-input-row{
  display:flex;
  gap:14px;
}

.chat-input{
  flex:1;

  height:72px;

  border:0;
  outline:none;

  border-radius:28px;

  padding:
    0 26px;

  font-size:22px;

  color:white;

  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.05),
      rgba(255,255,255,.02)
    );

  border:
    1px solid rgba(255,255,255,.06);

  box-shadow:var(--shadow);
}

.chat-input::placeholder{
  color:#aabce0;
}

.send-btn{
  width:140px;

  border:0;
  border-radius:28px;

  cursor:pointer;

  font-size:26px;
  font-weight:950;

  color:white;

  background:
    linear-gradient(
      135deg,
      #4e8cff,
      #6ca7ff
    );

  box-shadow:
    0 0 36px rgba(108,167,255,.35);
}

/* ACTIONS */

.chat-actions-row{
  display:flex;
  align-items:center;
  gap:12px;

  flex-wrap:wrap;
}

.action-btn{
  min-height:54px;

  border:0;
  border-radius:18px;

  padding:
    0 18px;

  cursor:pointer;

  font-size:16px;
  font-weight:900;

  color:white;

  background:
    rgba(255,255,255,.08);
}

.file-action-btn{
  background:
    linear-gradient(
      135deg,
      rgba(255,204,51,.92),
      rgba(255,170,40,.88)
    ) !important;

  color:#081124 !important;

  box-shadow:
    0 0 28px rgba(255,204,51,.24);
}

.encrypt-toggle{
  display:flex;
  align-items:center;
  gap:10px;

  margin-left:auto;

  font-size:15px;
  font-weight:700;

  color:#c6d7ff;
}

/* FILE TRANSFER */

.transfer-progress{
  display:flex;
  flex-direction:column;
  gap:10px;

  max-height:260px;

  overflow:auto;
}

.progress-bar{
  width:100%;
  height:12px;

  border-radius:999px;

  overflow:hidden;

  background:rgba(255,255,255,.08);

  margin-top:8px;
}

.progress-bar > div{
  height:100%;
  width:0%;

  border-radius:999px;

  background:
    linear-gradient(
      135deg,
      #4e8cff,
      #6ca7ff
    );

  transition:width .12s linear;
}

#chatScreen.drag-over{
  outline:
    2px dashed rgba(255,204,51,.8);

  outline-offset:-10px;

  border-radius:34px;

  background:
    radial-gradient(
      circle at center,
      rgba(255,204,51,.10),
      transparent 60%
    );
}

#chatScreen.drag-over::after{
  content:"Drop file to send";

  position:fixed;

  inset:auto 24px 24px 24px;

  z-index:9999;

  min-height:72px;

  display:grid;
  place-items:center;

  border-radius:26px;

  color:#081124;

  font-size:22px;
  font-weight:950;

  background:
    linear-gradient(
      135deg,
      #ffcc33,
      #ffd84d
    );

  box-shadow:
    0 20px 60px rgba(0,0,0,.45);
}

.received-file-card,
.transfer-safety-notice{
  animation:transferFadeIn .2s ease both;
}

@keyframes transferFadeIn{
  from{
    opacity:0;
    transform:translateY(8px);
  }

  to{
    opacity:1;
    transform:translateY(0);
  }
}

/* CALL */

.call-layout{
  flex:1;

  display:flex;
  flex-direction:column;

  gap:14px;
}

#remoteVideo{
  flex:1;

  width:100%;

  object-fit:cover;

  border-radius:30px;

  background:black;
}

#localVideo{
  position:fixed;

  right:26px;
  bottom:110px;

  width:220px;
  height:150px;

  object-fit:cover;

  border-radius:24px;

  border:
    2px solid rgba(255,255,255,.18);

  background:black;

  z-index:1000;
}

.call-controls{
  display:flex;
  justify-content:center;
  gap:12px;

  flex-wrap:wrap;
}

.call-btn{
  min-width:140px;
  min-height:58px;

  border:0;
  border-radius:22px;

  cursor:pointer;

  font-size:18px;
  font-weight:950;

  color:white;
}

.call-btn.accept{
  background:
    linear-gradient(
      135deg,
      #27d86f,
      #5cff98
    );
}

.call-btn.decline{
  background:
    linear-gradient(
      135deg,
      #ff9f43,
      #ffc371
    );
}

.call-btn.end{
  background:
    linear-gradient(
      135deg,
      #ff4d6d,
      #ff6b81
    );
}

/* INCOMING CALL */

.incoming-call-overlay{
  position:fixed;
  inset:0;

  z-index:999999;

  display:none;
  align-items:center;
  justify-content:center;

  padding:24px;

  background:
    radial-gradient(circle at 50% 20%, rgba(108,167,255,.28), transparent 34%),
    radial-gradient(circle at 30% 100%, rgba(255,204,51,.14), transparent 36%),
    rgba(3,7,18,.92);

  backdrop-filter:blur(28px);
}

.incoming-call-card{
  width:min(480px,94vw);

  min-height:520px;

  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;

  text-align:center;

  padding:34px 26px;

  border-radius:38px;

  background:
    linear-gradient(180deg,rgba(255,255,255,.16),rgba(255,255,255,.06)),
    rgba(10,18,38,.96);

  border:1px solid rgba(255,255,255,.14);

  box-shadow:
    0 34px 120px rgba(0,0,0,.72),
    inset 0 1px 0 rgba(255,255,255,.12);
}

.incoming-pulse-ring{
  width:150px;
  height:150px;

  display:grid;
  place-items:center;

  margin-bottom:26px;

  border-radius:44px;

  background:
    radial-gradient(circle,rgba(108,167,255,.22),transparent 70%);

  animation:incomingPulse 1.35s ease-in-out infinite;
}

.incoming-avatar{
  width:118px;
  height:118px;

  display:grid;
  place-items:center;

  border-radius:36px;

  font-size:58px;

  background:
    linear-gradient(135deg,#ffcc33,#6ca7ff);

  box-shadow:
    0 0 44px rgba(108,167,255,.4),
    0 0 30px rgba(255,204,51,.22);
}

@keyframes incomingPulse{
  0%,100%{
    transform:scale(1);
    box-shadow:0 0 0 0 rgba(108,167,255,.18);
  }

  50%{
    transform:scale(1.045);
    box-shadow:0 0 0 22px rgba(108,167,255,.06);
  }
}

.incoming-title{
  max-width:100%;

  font-size:clamp(26px,4vw,36px);

  line-height:1.12;

  font-weight:950;

  letter-spacing:-.04em;

  color:#eef4ff;

  margin-bottom:12px;

  word-break:break-word;
}

.incoming-subtitle{
  font-size:16px;
  font-weight:800;

  color:#bdd5ff;

  opacity:.78;

  margin-bottom:8px;
}

.incoming-brand{
  font-size:13px;
  font-weight:800;

  color:#9ec4ff;

  opacity:.72;

  text-shadow:0 0 16px rgba(108,167,255,.28);

  margin-bottom:34px;
}

.incoming-actions{
  width:100%;

  display:grid;
  grid-template-columns:1fr 1fr;

  gap:16px;
}

.incoming-accept-btn,
.incoming-decline-btn{
  min-height:78px;

  border:0;
  border-radius:26px;

  color:white;

  font-size:18px;
  font-weight:950;

  cursor:pointer;

  box-shadow:0 18px 54px rgba(0,0,0,.42);
}

.incoming-accept-btn{
  background:
    linear-gradient(135deg,#22c55e,#5cff98);
}

.incoming-decline-btn{
  background:
    linear-gradient(135deg,#ef4444,#be123c);
}

/* MOBILE */

@media (max-width:920px){

  .layout{
    flex-direction:column;
  }

  .sidebar{
    width:100%;
    max-height:240px;
  }

  .topbar{
    height:auto;

    flex-wrap:wrap;
    gap:14px;

    padding:
      16px;
  }

  .brand-title{
    font-size:22px;
  }

  .brand-subtitle{
    padding-left:42px;
  }

  .chat-input{
    height:62px;
    font-size:18px;
  }

  .send-btn{
    width:110px;
    font-size:22px;
  }

  #localVideo{
    width:120px;
    height:92px;

    right:12px;
    bottom:92px;
  }

  .encrypt-toggle{
    width:100%;
    margin-left:0;
  }

  .transfer-progress{
    max-height:220px;
  }

  #chatScreen.drag-over::after{
    font-size:18px;
    inset:auto 14px 14px 14px;
  }

  .incoming-call-overlay{
    padding:14px;
  }

  .incoming-call-card{
    width:100%;
    min-height:calc(100dvh - 28px);
    border-radius:34px;
  }

  .incoming-actions{
    gap:12px;
  }

  .incoming-accept-btn,
  .incoming-decline-btn{
    min-height:76px;
    font-size:17px;
  }

  .peer-status-pill,
  .turn-status-pill,
  .trust-status-pill{
    min-height:26px;
    padding:0 8px;
    font-size:11px;
  }
}

/* =========================================================
   GLOBAL / LOCAL MODE
========================================================= */

.network-mode-stack{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:8px;
}

.mode-switch{
  display:inline-flex;
  align-items:center;
  gap:6px;

  padding:5px;

  border-radius:999px;

  background:
    rgba(255,255,255,.055);

  border:
    1px solid rgba(255,255,255,.09);

  box-shadow:
    0 10px 28px rgba(0,0,0,.24);
}

.mode-btn{
  min-height:34px;

  padding:
    0 13px;

  border:0;
  border-radius:999px;

  cursor:pointer;

  color:#cfe0ff;

  background:transparent;

  font-family:inherit;

  font-size:13px;
  font-weight:950;

  transition:
    transform .16s ease,
    background .16s ease,
    color .16s ease,
    box-shadow .16s ease;
}

.mode-btn:hover{
  transform:translateY(-1px);

  background:
    rgba(255,255,255,.08);
}

.mode-btn.active{
  color:#081124;

  background:
    linear-gradient(
      135deg,
      #5cff98,
      #9cffbd
    );

  box-shadow:
    0 0 22px rgba(92,255,152,.2);
}

.mode-status{
  min-height:24px;

  padding:
    0 10px;

  display:inline-flex;
  align-items:center;
  justify-content:center;

  border-radius:999px;

  color:#afc7ff;

  background:
    rgba(255,255,255,.04);

  border:
    1px solid rgba(255,255,255,.06);

  font-size:11px;
  font-weight:900;

  white-space:nowrap;
}

@media (max-width:920px){

  .network-mode-stack{
    width:100%;
    gap:6px;
  }

  .mode-switch{
    width:100%;
    max-width:340px;
  }

  .mode-btn{
    flex:1;

    min-height:36px;

    padding:
      0 8px;

    font-size:12px;
  }

  .mode-status{
    font-size:10px;
  }
}
