/* WAP · iOS 19+ Dark Theme · RTL · Noto Sans Arabic */
:root {
  --bg: #0a0a0a;
  --surface: #161618;
  --surface2: #1c1c1e;
  --surface3: #242426;
  --border: rgba(255, 255, 255, .07);
  --border2: rgba(255, 255, 255, .12);
  --text: #f2f2f7;
  --muted: #8e8e93;
  --dim: #aeaeb2;
  --green: #30d158;
  --gdim: rgba(48, 209, 88, .1);
  --yellow: #ffd60a;
  --ydim: rgba(255, 214, 10, .08);
  --red: #ff453a;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, .4);
  --shadow: 0 6px 28px rgba(0, 0, 0, .55);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, .7);
  --mono: 'Courier New', monospace;
  --ui: 'Noto Sans Arabic', -apple-system, 'SF Pro Text', system-ui, sans-serif;
}

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

html,
body {
  height: 90%;
  margin: 0;
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[x-cloak] {
  display: none !important
}

::-webkit-scrollbar {
  width: 0
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px
}

/* ── Layout ── */
.wrap {
  max-width: 430px;
  margin: 0 auto;
  padding: 0 18px
}

.page {
  padding: 18px 0
}

/* ── Top bar (iOS · glass · centered title) ── */
.topbar {
  background: rgba(10, 10, 10, .82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: .5px solid var(--border);
  padding: 0 16px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 52px;
  position: sticky;
  top: 0;
  z-index: 100
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: -.01em
}

.topbar-back {
  background: none;
  border: none;
  color: var(--green);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 50%;
  line-height: 1;
  font-family: var(--ui);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: background .15s
}

.topbar-back:hover {
  background: rgba(255, 255, 255, .07)
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: .5px solid var(--border2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 10px 0;
  box-shadow: var(--shadow-sm)
}

.card-p {
  padding: 16px
}

/* ── Divider ── */
.div {
  border: none;
  border-top: .5px solid var(--border);
  margin: 0
}

/* ── Info rows ── */
.info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  transition: background .15s
}

.info-row:hover {
  background: rgba(255, 255, 255, .03)
}

.info-row:active {
  background: var(--surface2)
}

.info-icon {
  width: 34px;
  height: 34px;
  background: var(--gdim);
  border: .5px solid rgba(48, 209, 88, .18);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  font-size: 15px;
  flex-shrink: 0
}

.info-icon.y {
  background: var(--ydim);
  border-color: rgba(255, 214, 10, .18);
  color: var(--yellow)
}

.info-lbl {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
  font-weight: 500
}

.info-val {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3
}

.info-val.gm {
  font-family: var(--mono);
  letter-spacing: .14em;
  color: var(--green);
  font-size: 17px
}

.info-val.ym {
  font-family: var(--mono);
  letter-spacing: .2em;
  color: var(--yellow);
  font-size: 15px
}

.info-copy {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0
}

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 30px 0 14px
}

.hero-icon {
  font-size: 54px;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, .45))
}

.hero-title {
  font-size: 23px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em
}

.hero-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 400
}

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--radius-xl);
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  margin: 6px 0;
  letter-spacing: -.01em
}

.btn:active {
  transform: scale(.97);
  opacity: .88
}

.btn:disabled {
  opacity: .3;
  pointer-events: none
}

.btn-green {
  background: var(--green);
  color: #000;
  box-shadow: 0 4px 20px rgba(48, 209, 88, .28)
}

.btn-green:hover {
  opacity: .9
}

.btn-outline {
  background: var(--surface2);
  color: var(--text);
  border: .5px solid var(--border2)
}

.btn-outline:hover {
  background: var(--surface3)
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--green);
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius)
}

.btn-ghost:hover {
  opacity: .75
}

/* ── Form ── */
.lbl {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500
}

.inp {
  width: 100%;
  background: var(--surface2);
  border: .5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s
}

.inp:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(48, 209, 88, .12)
}

.inp.code {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: .22em;
  text-align: center;
  color: var(--green);
  text-transform: uppercase;
  font-weight: 700
}

.inp.pin {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: .28em;
  text-align: center;
  color: var(--yellow);
  font-weight: 700
}

/* ── Error ── */
.err {
  background: rgba(255, 69, 58, .08);
  border: .5px solid rgba(255, 69, 58, .25);
  color: #ff9f9a;
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13px;
  margin: 8px 0
}

/* ── Spinner ── */
.spin {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, .18);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
  vertical-align: middle
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

/* ── Toast ── */
.toast-wrap {
  position: fixed;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  max-width: 300px;
  min-width: 220px
}

.toast-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: 14px;
  border-right: 3px solid transparent;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  animation: tIn .22s cubic-bezier(.22, 1, .36, 1) forwards;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55);
  pointer-events: none;
  overflow: hidden
}

.toast-pill::before {
  font-family: 'bootstrap-icons';
  font-size: 15px;
  flex-shrink: 0;
  font-style: normal;
  font-variant: normal;
  font-weight: normal;
  line-height: 1;
  speak: none;
  -webkit-font-smoothing: antialiased
}

@keyframes tIn {
  from {
    opacity: 0;
    transform: translateX(-18px)
  }

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

.toast-success {
  background: rgba(48, 209, 88, .11);
  border-color: var(--green);
  color: #b8f5d0;
  border-top: .5px solid rgba(48, 209, 88, .2);
  border-bottom: .5px solid rgba(48, 209, 88, .2);
  border-left: .5px solid rgba(48, 209, 88, .2)
}

.toast-success::before {
  content: "\F26A";
  color: var(--green)
}

.toast-error {
  background: rgba(255, 69, 58, .1);
  border-color: var(--red);
  color: #ffb3b0;
  border-top: .5px solid rgba(255, 69, 58, .2);
  border-bottom: .5px solid rgba(255, 69, 58, .2);
  border-left: .5px solid rgba(255, 69, 58, .2)
}

.toast-error::before {
  content: "\F623";
  color: var(--red)
}

.toast-info {
  background: rgba(90, 90, 200, .1);
  border-color: #7b7bd0;
  color: #c5c5f0;
  border-top: .5px solid rgba(90, 90, 200, .2);
  border-bottom: .5px solid rgba(90, 90, 200, .2);
  border-left: .5px solid rgba(90, 90, 200, .2)
}

.toast-info::before {
  content: "\F431";
  color: #9090e0
}

/* ── Note ── */
.note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 8px 0;
  font-weight: 400
}

/* ── Separator ── */
.sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0
}

.sep hr {
  flex: 1;
  border: none;
  border-top: .5px solid var(--border);
  margin: 0
}

.sep span {
  font-size: 12px;
  color: var(--muted)
}

/* ── Room badge ── */
.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gdim);
  border: .5px solid rgba(48, 209, 88, .16);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  justify-content: center
}

.room-code {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: .12em
}

/* ── Section label ── */
.sect {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 0 4px;
  font-weight: 600
}

/* ── Call type ── */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0
}

.type-btn {
  background: var(--surface2);
  border: .5px solid var(--border2);
  border-radius: var(--radius-lg);
  color: var(--muted);
  padding: 14px 8px;
  cursor: pointer;
  font-family: var(--ui);
  text-align: center;
  transition: all .15s;
  font-size: 13px;
  font-weight: 500
}

.type-btn i {
  font-size: 22px;
  display: block;
  margin-bottom: 5px
}

.type-btn.active {
  background: var(--gdim);
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 4px 14px rgba(48, 209, 88, .14)
}

/* ── Link box ── */
.link-box {
  background: var(--surface2);
  border: .5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  cursor: pointer;
  transition: border-color .15s;
  line-height: 1.4;
  width: 100%
}

.link-box:hover {
  border-color: var(--border2);
  color: var(--dim)
}

/* ── Host badge ── */
.host-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  background: var(--ydim);
  border: .5px solid rgba(255, 214, 10, .2);
  color: var(--yellow);
  border-radius: 6px;
  padding: 3px 8px;
  font-weight: 600
}

/* ═══ CALL PAGE ═══ */
.call-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden
}

/* Call topbar */
.call-topbar {
  background: rgba(0, 0, 0, .85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: .5px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  flex-shrink: 0
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(48, 209, 88, .1);
  border: .5px solid rgba(48, 209, 88, .22);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 11px;
  color: var(--green);
  font-weight: 700
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 1.6s ease-in-out infinite
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .2
  }
}

/* Audio body */
.audio-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
  min-height: 0
}

.call-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: var(--green);
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4)
}

.call-avatar.speaking {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(48, 209, 88, .2), 0 8px 32px rgba(0, 0, 0, .4)
}

.call-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em
}

.call-timer-badge {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--green);
  background: var(--gdim);
  border: .5px solid rgba(48, 209, 88, .15);
  border-radius: 20px;
  padding: 4px 14px
}

.peer-card {
  background: var(--surface2);
  border: .5px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  box-shadow: var(--shadow-sm)
}

.peer-card.speaking {
  border-color: var(--green)
}

.peer-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface3);
  border: .5px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0
}

.waiting {
  text-align: center;
  color: var(--muted);
  font-size: 13px
}

display: flex;
align-items: center;
justify-content: space-between;
font-size: 12px;
flex-shrink: 0
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 212, 106, .1);
  border: 1px solid rgba(0, 212, 106, .2);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--green);
  font-weight: 700
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 1.6s ease-in-out infinite
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .2
  }
}

/* Audio body */
.audio-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  overflow-y: auto;
  min-height: 0;
}

.call-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: var(--green);
  transition: border-color .2s, box-shadow .2s
}

.call-avatar.speaking {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(0, 212, 106, .28)
}

.call-name {
  font-size: 16px;
  font-weight: 700
}

.call-timer-badge {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--green);
  background: var(--gdim);
  border: 1px solid rgba(0, 212, 106, .15);
  border-radius: 18px;
  padding: 4px 13px
}

.peer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 270px
}

.peer-card.speaking {
  border-color: var(--green)
}

.peer-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0
}

.waiting {
  text-align: center;
  color: var(--muted);
  font-size: 13px
}

/* Video body */
.video-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  min-height: 0;
}

#tilesContainer {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  gap: 2px
}

@media (orientation: landscape) {
  #tilesContainer {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: auto;
  }
}

.video-tile {
  position: relative;
  background: var(--surface2);
  border: .5px solid var(--border);
  overflow: hidden;
  min-height: 120px
}

.video-tile.speaking {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(48, 209, 88, .3)
}

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

.tile-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  font-size: 26px;
  font-weight: 700;
  color: var(--green)
}

.tile-label {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 10px;
  font-size: 11px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px
}

/* Controls */
.call-controls {
  background: rgba(10, 10, 10, .92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--border);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 70px
}

.ctrl {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface2);
  border: .5px solid var(--border2);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35)
}

.ctrl:hover {
  background: var(--surface3)
}

.ctrl:active {
  transform: scale(.92)
}

.ctrl.off {
  background: rgba(255, 69, 58, .12);
  border-color: rgba(255, 69, 58, .25);
  color: #ff9f9a
}

.ctrl.on {
  background: var(--gdim);
  border-color: rgba(48, 209, 88, .28);
  color: var(--green)
}

.ctrl-end {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--red);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(255, 69, 58, .4)
}

.ctrl-end:hover {
  opacity: .85
}

.ctrl-end:active {
  transform: scale(.92)
}

.dur {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--green);
  background: var(--gdim);
  border: .5px solid rgba(48, 209, 88, .15);
  border-radius: 18px;
  padding: 4px 12px
}

/* ── Responsive: small screens ── */
@media (max-width: 400px) {
  .call-controls {
    gap: 6px;
    padding: 8px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 64px;
  }

  .ctrl {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  .ctrl-end {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .dur {
    font-size: 11px;
    padding: 3px 9px;
  }

  .call-topbar {
    padding: 6px 12px;
  }

  .wrap {
    padding: 0 12px;
  }

  .btn {
    font-size: 14px;
    padding: 13px 16px;
  }

  .audio-body {
    gap: 10px;
    padding: 12px 16px;
  }

  .call-avatar {
    width: 76px;
    height: 76px;
    font-size: 28px;
  }
}

/* ── Quick Invite Popup ── */
.qi-popup {
  background: var(--surface);
  border: .5px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 18px;
  width: calc(100% - 64px);
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: qiIn .2s cubic-bezier(.22, 1, .36, 1);
}

@keyframes qiIn {
  from {
    opacity: 0;
    transform: scale(.93)
  }
}

.qi-handle {
  display: none;
}