:root {
  --bg: #f5f7fb;
  --nav: #071326;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #5146f0;
  --danger: #ef4444;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.presence-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--nav);
  color: white;
  padding: 22px;
}

.brand {
  font-weight: 800;
  letter-spacing: .08em;
  margin-bottom: 28px;
}

.nav {
  width: 100%;
  padding: 14px;
  margin-bottom: 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: white;
  text-align: left;
  cursor: pointer;
}

.nav.active,
.nav:hover {
  background: rgba(255,255,255,.12);
}

.main {
  padding: 22px;
}

.topbar,
.controls,
.card,
.side-panel,
.video-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
}

.topbar {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.visit-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
}

.video-card {
  position: relative;
  overflow: hidden;
  min-height: 440px;
  background: #0b1220;
}

video {
  width: 100%;
  height: 440px;
  object-fit: cover;
  background: #111827;
}

.video-label {
  position: absolute;
  left: 18px;
  bottom: 18px;
  color: white;
  background: rgba(0,0,0,.42);
  padding: 8px 12px;
  border-radius: 999px;
}

.side-panel {
  padding: 18px;
}

.controls {
  margin-top: 18px;
  padding: 14px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.cards {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.card {
  padding: 16px;
}

textarea {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-family: inherit;
}

pre {
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.invite-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(81,70,240,.14), transparent 35%),
    linear-gradient(135deg, #f8fafc, #eef2ff);
  display: grid;
  place-items: center;
  padding: 24px;
}

.invite-main {
  width: min(900px, 100%);
}

.invite-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 24px 70px rgba(15,23,42,.14);
}

.brand.dark {
  color: #071326;
  font-weight: 900;
  letter-spacing: .08em;
  margin-bottom: 20px;
}

.invite-card h1 {
  margin: 0 0 8px;
  font-size: 34px;
}

.invite-card p {
  color: var(--muted);
}

.invite-video-card {
  margin: 22px 0;
  background: #0b1220;
  border-radius: 22px;
  overflow: hidden;
  min-height: 360px;
}

#inviteVideo {
  width: 100%;
  height: 360px;
  object-fit: cover;
}

.invite-details {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
}

.invite-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fine-print {
  font-size: 13px;
  margin-top: 18px;
}

.participant-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.danger-btn {
  background: var(--danger);
}

.participant-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}

.participant-row p {
  margin: 4px 0;
}

.call-stage {
  position: relative;
}

#remoteVideo,
#inviteRemoteVideo {
  width: 100%;
  height: 440px;
  object-fit: cover;
  background: #0b1220;
}

.self-view {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 180px;
  height: 120px;
  object-fit: cover;
  border: 3px solid white;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
  background: #111827;
  z-index: 5;
}

.invite-video-card {
  position: relative;
}

#inviteRemoteVideo {
  height: 360px;
}

.call-stage {
  position: relative;
  min-height: 520px;
  background: #050b16;
}

.remote-screen {
  position: relative;
  height: 520px;
}

#remoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050b16;
}

.self-view {
  position: absolute;
  right: 18px;
  bottom: 86px;
  width: 180px;
  height: 120px;
  object-fit: cover;
  border: 3px solid white;
  border-radius: 18px;
  z-index: 5;
}

.call-toolbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 6;
  background: rgba(15, 23, 42, 0.72);
  padding: 10px;
  border-radius: 999px;
  backdrop-filter: blur(12px);
}

/* Patient / consultant video stage */
.invite-video-card {
  position: relative;
  height: 420px;
  background: #050b16;
  border-radius: 22px;
  overflow: hidden;
}

#inviteRemoteVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050b16;
}

/* Patient self-view thumbnail */
#inviteVideo.self-view {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 118px;
  height: 160px;
  object-fit: cover;
  border: 3px solid white;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
  z-index: 10;
}

/* iPhone/small screen tuning */
@media (max-width: 640px) {
  .invite-video-card {
    height: 520px;
  }

  #inviteVideo.self-view {
    width: 96px;
    height: 132px;
    right: 10px;
    bottom: 10px;
  }
}
