:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-d: #4338ca;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }

/* ---------- generic ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px; }
.center-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px;
}
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.grow { flex: 1 1 auto; }
.pill {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: .03em;
}
.pill.scheduled { background: #e0e7ff; color: #3730a3; }
.pill.live { background: #dcfce7; color: #166534; }
.pill.finished { background: #f1f5f9; color: #475569; }
.pill.cancelled { background: #fee2e2; color: #991b1b; }

label { font-size: 13px; font-weight: 600; color: #334155; display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #f8fafc; color: var(--ink); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); background: #fff; }
textarea { resize: vertical; min-height: 64px; }

.btn {
  border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 700;
  background: var(--brand); color: #fff; transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--brand-d); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f1f5f9; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; }

.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-mark img { width: 34px; height: 34px; }
.brand-mark b { color: #fff; font-size: 19px; letter-spacing: -.01em; }

/* tenka.cloud wordmark — monochrome SVG masked so it takes the surrounding
   text colour (works on both the white auth card and the dark topbar). */
.tenka-logo {
  display: inline-block; width: 104px; height: 44px;
  background-color: currentColor;
  -webkit-mask: url(/tenka-cloud-logo.svg) no-repeat center / contain;
          mask: url(/tenka-cloud-logo.svg) no-repeat center / contain;
}
.tenka-logo-row { display: flex; justify-content: center; }

/* ---------- auth ---------- */
.auth { width: min(420px, 100%); }
.auth h1 { margin: 6px 0 2px; font-size: 22px; }
.auth .tabs { display: flex; gap: 8px; margin: 18px 0 20px; }
.auth .tabs button {
  flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line);
  background: #f8fafc; color: var(--muted); font-weight: 700;
}
.auth .tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.error-msg { color: var(--bad); font-size: 13px; min-height: 16px; }

/* ---------- app chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: rgba(15,23,42,.8); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar .who { color: #cbd5e1; font-size: 14px; }
.topbar .who b { color: #fff; }

/* ---------- dashboard ---------- */
.meeting-list { display: grid; gap: 16px; }
.meeting { border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.meeting h3 { margin: 0 0 4px; font-size: 17px; }
.meeting .when { color: var(--muted); font-size: 14px; }
.invites { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; display: grid; gap: 10px; }
.invite { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.invite .em { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.invite .st { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.invite img.qr { width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--line); }
details > summary { cursor: pointer; font-weight: 600; color: var(--brand); }

/* ---------- room ---------- */
.room { position: fixed; inset: 0; background: #0b1020; display: flex; flex-direction: column; }
.grid {
  flex: 1; display: grid; gap: 10px; padding: 12px; overflow: auto;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: center;
}
.tile {
  position: relative; background: #111827; border-radius: 12px; overflow: hidden;
  aspect-ratio: 4 / 3; border: 1px solid rgba(255,255,255,.06);
}
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile .nm {
  position: absolute; left: 8px; bottom: 8px; padding: 3px 9px; border-radius: 8px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 600;
}
.tile .badge { position: absolute; right: 8px; top: 8px; font-size: 16px; }
.tile.speaking { border-color: #22c55e; box-shadow: 0 0 0 2px #22c55e inset; }
.tile { cursor: pointer; }
.tile .zoom {
  position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 8px;
  background: rgba(0,0,0,.5); color: #fff; font-size: 14px; line-height: 1; pointer-events: none;
}
/* spotlight: tap a tile to maximise it; the rest hide until tapped again */
.grid.spotlight { grid-template-columns: 1fr; grid-template-rows: 1fr; align-content: stretch; }
.grid.spotlight .tile { display: none; }
.grid.spotlight .tile.max { display: block; aspect-ratio: auto; width: 100%; height: 100%; }
.controls {
  display: flex; gap: 12px; justify-content: center; align-items: center;
  padding: 14px; background: #0b1020; border-top: 1px solid rgba(255,255,255,.08);
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.ctl {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: #1f2937; color: #fff;
  font-size: 20px; display: grid; place-items: center;
}
.ctl:hover { background: #374151; }
.ctl.off { background: #b91c1c; }
.ctl.leave { background: #dc2626; width: auto; border-radius: 26px; padding: 0 20px; font-weight: 700; gap: 8px; }
.ctl.leave.arm { background: #f59e0b; }

/* in-app browser (Gmail/Outlook web-view) warning shown in the lobby on iOS */
.inapp-warn {
  background: #fef3c7; border: 1px solid #fde68a; color: #92400e;
  border-radius: 12px; padding: 12px 14px; text-align: left;
}
.inapp-warn b { display: block; margin-bottom: 4px; }
.inapp-warn p { margin: 0 0 10px; font-size: 13px; line-height: 1.4; }
.inapp-warn .url {
  display: block; margin-top: 8px; font-size: 12px; word-break: break-all;
  background: rgba(0,0,0,.05); border-radius: 8px; padding: 8px; user-select: all;
}
.room-head { color: #cbd5e1; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.room-head b { color: #fff; }

/* in-meeting invite popover */
.invite-pop {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 20;
  width: min(360px, 92vw); background: #111827; color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  padding: 6px 16px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.invite-pop .room-head { padding: 8px 0; }
.invite-pop input { width: 100%; }

/* chat */
.chat {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 86vw);
  background: #0f172a; border-left: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s; z-index: 6;
}
.chat.open { transform: none; }
.chat .msgs { flex: 1; overflow: auto; padding: 14px; display: grid; gap: 10px; align-content: start; }
.chat .m { color: #e2e8f0; font-size: 14px; }
.chat .m b { color: #a5b4fc; }
.chat form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.chat input { background: #1e293b; color: #fff; border-color: #334155; }

.lobby video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 50; font-size: 14px; max-width: 90vw;
  border: 1px solid rgba(255,255,255,.12);
}
.toast.bad { background: #7f1d1d; }
.toast.ok { background: #14532d; }

.spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .wrap { padding: 16px; }
  .card { padding: 20px; }
}
