:root {
  --bg: #070a14;
  --card: rgba(255, 255, 255, 0.045);
  --card-solid: #0f1424;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eaf0ff;
  --muted: #8b96b4;
  --accent: #5eead4;
  --accent-2: #818cf8;
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 18px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "SF Arabic", "Segoe UI", "Noto Kufi Arabic", Tahoma, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.glow-a { width: 420px; height: 420px; background: #1e3a8a; top: -140px; right: -80px; }
.glow-b { width: 380px; height: 380px; background: #0f766e; bottom: -160px; left: -60px; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px);
  backdrop-filter: blur(14px);
  background: rgba(7, 10, 20, 0.72);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(94, 234, 212, 0.7);
}

.room-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.room-chip b { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ------------------------------------------------------------------ layout */

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) clamp(14px, 4vw, 32px) 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view { display: flex; flex-direction: column; gap: 18px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 24px);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.card.mini { padding: 16px 20px; }

h1 { font-size: clamp(22px, 3.4vw, 30px); margin: 0 0 8px; line-height: 1.35; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 16px; margin: 0; }
.lead { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.fineprint { color: #6b7694; font-size: 12px; margin: 14px 0 0; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.center { align-items: center; }
.gap { gap: 12px; }
.between { justify-content: space-between; }

/* ------------------------------------------------------------------ inputs */

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input:not([type]), .field input, .chat-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .chat-form input:focus {
  border-color: rgba(94, 234, 212, 0.55);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 11px 18px;
  transition: transform 0.12s, filter 0.15s, opacity 0.15s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  width: 100%;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  font-weight: 700;
}

.secondary-btn {
  background: rgba(94, 234, 212, 0.12);
  border-color: rgba(94, 234, 212, 0.35);
  color: var(--accent);
  font-weight: 600;
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 999px;
}

.danger-btn {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
  font-weight: 600;
  padding: 8px 14px;
}

.error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }

/* ------------------------------------------------------------------- peers */

.peers { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.peer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.peer .meta { flex: 1; min-width: 0; }
.peer .meta b { display: block; font-size: 14.5px; }
.peer .meta span { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #06121a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex: 0 0 auto;
}

.peer button { padding: 8px 16px; }

.pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(94, 234, 212, 0.12);
  color: var(--accent);
  border: 1px solid rgba(94, 234, 212, 0.25);
  font-variant-numeric: tabular-nums;
}

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  font-size: 13.5px;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: left; word-break: break-all; }

/* ------------------------------------------------------------------ status */

.status-card { position: relative; overflow: hidden; }
.status-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0.8;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.5);
}
.dot.busy { background: var(--warn); animation: pulse 1.4s infinite; }
.dot.ok { background: var(--ok); box-shadow: 0 0 12px rgba(52, 211, 153, 0.8); }
.dot.bad { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(251, 191, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.steps {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
  transition: color 0.2s;
}

.steps li i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex: 0 0 auto;
  position: relative;
}

.steps li.active { color: var(--text); }
.steps li.active i { border-color: var(--warn); animation: pulse 1.4s infinite; }

.steps li.done { color: var(--text); }
.steps li.done i {
  border-color: var(--ok);
  background: rgba(52, 211, 153, 0.18);
}
.steps li.done i::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--ok);
}

/* -------------------------------------------------------------- endpoints */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.endpoint-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.endpoint-head h3 { font-size: 15.5px; margin: 0; }
.endpoint.me { border-color: rgba(129, 140, 248, 0.25); }

/* ------------------------------------------------------------------- speed */

.speed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.speed-box {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.speed-box b { font-size: 22px; font-variant-numeric: tabular-nums; }
.speed-box b small { font-size: 12px; color: var(--muted); font-weight: 500; }

/* -------------------------------------------------------------------- chat */

.messages {
  margin-top: 14px;
  height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  align-self: flex-start;
}

.msg.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.22), rgba(129, 140, 248, 0.22));
  border-color: rgba(94, 234, 212, 0.3);
}

.msg.sys {
  align-self: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  max-width: 100%;
}

.msg time { display: block; font-size: 10.5px; color: rgba(255, 255, 255, 0.45); margin-top: 3px; }

.chat-form { display: flex; gap: 10px; margin-top: 12px; }
.chat-form input { flex: 1; }
.chat-form button { width: auto; margin: 0; padding: 11px 22px; }

/* ------------------------------------------------------------------ footer */

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px clamp(14px, 4vw, 32px) 26px;
  color: #5d6785;
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  max-width: 1080px;
  margin: 0 auto;
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .messages { height: 220px; }
  .footer { flex-direction: column; }
}
