:root {
  --bg: #f4f7f8;
  --card: #ffffff;
  --text: #17252a;
  --muted: #5d7076;
  --line: #dfe7ea;
  --brand: #0f766e;
  --brand-dark: #0b5952;
  --danger: #dc2626;
  --stage: #0e1a1d;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
  background: var(--brand); color: #fff;
  transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: #eef3f4; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input[type=text] {
  width: 100%; padding: 11px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
input[type=text]:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }

/* ---------- landing page ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.topbar strong { font-size: 17px; }

.container { max-width: 960px; margin: 0 auto; padding: 32px 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
}
.field { margin-bottom: 16px; }

.share {
  margin-top: 18px; padding: 16px; border-radius: 10px;
  background: #ecfdf8; border: 1px solid #b5ebdd;
}
.share-row { display: flex; gap: 8px; margin: 8px 0 14px; }
.share-row input { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.hidden { display: none !important; }

/* ---------- consultation room ---------- */
.room { display: flex; flex-direction: column; height: 100vh; background: var(--stage); color: #e8f1f2; }

.room-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: #12232700; flex-wrap: wrap;
}
.room-header .who { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #f59e0b; }
.status-dot.live { background: #22c55e; }
.status-dot.off { background: #ef4444; }
.timer { font-variant-numeric: tabular-nums; color: #9fb4b8; margin-left: 6px; }

.stage { position: relative; flex: 1; min-height: 0; margin: 0 14px; border-radius: var(--radius); overflow: hidden; background: #000; }
#remoteVideo { width: 100%; height: 100%; object-fit: contain; background: #000; }
#localVideo {
  position: absolute; right: 14px; bottom: 14px;
  width: 24%; max-width: 260px; min-width: 120px; aspect-ratio: 4/3; object-fit: cover;
  border-radius: 10px; border: 2px solid rgba(255,255,255,.25); background: #222;
  transform: scaleX(-1); /* mirror self-view */
}
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  background: radial-gradient(circle at center, #16302f 0%, #0b1517 75%);
}
.overlay .pulse {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
  background: rgba(20, 184, 166, .25); animation: pulse 1.8s infinite;
}
@keyframes pulse { 0% { transform: scale(.85); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

.controls { display: flex; justify-content: center; gap: 14px; padding: 16px; }
.ctrl {
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: #263b40; color: #fff; display: grid; place-items: center;
}
.ctrl:hover { background: #31494f; }
.ctrl.off { background: #fff; color: #17252a; }
.ctrl.end { background: var(--danger); width: 72px; border-radius: 27px; }
.ctrl.end:hover { background: #b91c1c; }
.ctrl svg { width: 24px; height: 24px; }

/* pre-join screen */
.prejoin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.prejoin .card { width: 100%; max-width: 520px; }
.preview { width: 100%; aspect-ratio: 4/3; background: #111; border-radius: 10px; object-fit: cover; transform: scaleX(-1); margin-bottom: 16px; }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  background: #fff; color: var(--text); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 14px; z-index: 10;
}
