/* White-label space pages. Ink & Paper base; the space's colour comes from
   --brand / --brand-ink / --accent / --brand-soft (set inline per space). */
:root {
  --bg: #0F1626; --card: #151E33; --raise: #1C2740; --line: #26324D;
  --text: #EEF1F8; --muted: #9AA5BD; --danger: #F87171; --ok: #34D399;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F7F6F2; --card: #FFFFFF; --raise: #F0EEE7; --line: #E2DFD5;
  --text: #0E1525; --muted: #5B6478; --danger: #B91C1C; --ok: #047857;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
  font: 16px/1.55 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Bricolage Grotesque", "Geist", sans-serif; line-height: 1.1; margin: 0 0 12px; }
h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 750; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
a { color: var(--accent); }
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }
.muted { color: var(--muted); }
.lead { font-size: 18px; color: var(--muted); max-width: 60ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--accent); margin: 0 0 10px; }

/* Header and footer */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1080px; width: 100%; margin: 0 auto; padding: 16px; }
.space-name { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 700 18px/1.2 "Bricolage Grotesque", sans-serif; min-width: 0; }
.space-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 15px; white-space: nowrap; }
.top nav a:hover { color: var(--text); }
.powered { text-align: center; padding: 20px 16px 28px; font-size: 13px; }
.powered a { color: var(--muted); text-decoration: none; }
.powered a:hover { color: var(--text); }

/* Logo */
.logo { width: 36px; height: 36px; border-radius: 9px; object-fit: contain; flex: none; }
.logo.badge { display: inline-grid; place-items: center; background: var(--brand); color: var(--brand-ink); font: 700 15px/1 "Bricolage Grotesque", sans-serif; }
.logo.big { width: 84px; height: 84px; border-radius: 20px; font-size: 30px; margin-bottom: 18px; }

/* Buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
  font: 600 15px/1 "Geist", sans-serif; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px; min-height: 44px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { font-size: 17px; padding: 14px 22px; }
.btn.small { min-height: 34px; padding: 7px 11px; font-size: 14px; border-radius: 9px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; width: 100%; min-width: 0;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
input[type="color"] { padding: 2px; height: 44px; width: 64px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
label.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; color: var(--text); }
.error { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; font-size: 15px; }
.ok { color: var(--ok); }

/* Home */
.hero { padding: 48px 0 28px; }
.rooms { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.room-card {
  display: grid; gap: 6px; padding: 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.room-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.room-card b { font: 700 20px/1.2 "Bricolage Grotesque", sans-serif; }
.room-kind { color: var(--muted); font-size: 13px; }
.room-card .join { justify-self: start; margin-top: 8px; background: var(--brand); color: var(--brand-ink); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 14px; }
.have-link { margin-top: 32px; max-width: 460px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: none; }

/* Lobby */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; padding: 40px 0; }
.join-form { max-width: 420px; }
.join-form .btn { margin-top: 18px; width: 100%; }
.host-note { font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.preview-card { margin: 0; }
.preview-card figcaption { color: var(--muted); font-size: 14px; margin-top: 10px; }
.center-card { text-align: center; max-width: 560px; margin: 0 auto; padding: 72px 0; }

/* Tiles */
.tile {
  position: relative; overflow: hidden; border-radius: 16px; aspect-ratio: 16 / 9;
  background: radial-gradient(80% 80% at 50% 40%, var(--raise), var(--card)); border: 1px solid var(--line);
}
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.tile.self video, .preview video { transform: scaleX(-1); }
.tile.cam-on video { opacity: 1; }
.tile.screen video { object-fit: contain; background: #000; }
.tile .avatar {
  position: absolute; inset: 0; margin: auto; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; font: 700 26px/1 "Bricolage Grotesque", sans-serif;
  background: var(--brand-soft); color: var(--accent);
}
.preview .avatar { font-size: 16px; }
.tile.cam-on .avatar { display: none; }
.tile .name {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 4px 9px; border-radius: 8px;
  font-size: 13px; color: #fff; background: rgba(7, 10, 19, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile.muted .name::after { content: " · muted"; color: #cbd5e1; }
.tile.speaking { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }

/* Call */
.call { padding: 8px 0 24px; }
.call-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.call-top b { font: 700 20px/1.2 "Bricolage Grotesque", sans-serif; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid[data-count="1"] { max-width: 860px; margin: 0 auto; grid-template-columns: 1fr; }
.controls { display: flex; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.ctl { cursor: pointer; font: 600 15px/1 "Geist", sans-serif; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 12px 18px; min-height: 44px; }
.ctl:hover { border-color: var(--accent); }
.ctl.off { border-color: var(--danger); color: var(--danger); }
.ctl.leave { background: #DC2626; border-color: #DC2626; color: #fff; }
.host-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--brand-soft); margin-bottom: 12px; font-size: 14px; }
.host-bar b { margin-right: 4px; }
.waiting-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.banner { background: #FBBF24; color: #1a1300; padding: 8px 12px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }

/* Admin */
.admin { padding: 16px 0; }
.admin-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: 600 15px/1 "Geist", sans-serif; padding: 12px 10px; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--raise); color: var(--muted); }
.pill.live { background: #16A34A22; color: var(--ok); }
.pill.warn { background: #F59E0B22; color: #F59E0B; }
.grid2 { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.notice { padding: 12px 14px; border-radius: 12px; background: #F59E0B22; color: var(--text); margin-bottom: 14px; }
.code { font-family: ui-monospace, "Geist Mono", monospace; background: var(--raise); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; vertical-align: middle; background: var(--brand); }

@media (max-width: 760px) {
  .lobby { grid-template-columns: 1fr; gap: 20px; padding: 20px 0; }
  .preview-card { order: -1; }
  .hero { padding: 28px 0 20px; }
  .ctl { padding: 12px 14px; }
}

/* Appsocom UI kits (classroom / meeting), in the space's colours. */
/* The call fills the screen below the space's header; the space's extras sit above it. */
.call.kit-mode { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 120px); min-height: 480px; }
/* In a call the page is exactly one screen tall: header, call, a slim "Powered by", and no page scroll. */
body:has(.call.kit-mode:not([hidden])) { height: 100dvh; min-height: 0; }
body:has(.call.kit-mode:not([hidden])) main { display: flex; flex-direction: column; min-height: 0; padding-bottom: 0; }
body:has(.call.kit-mode:not([hidden])) .call.kit-mode { flex: 1; height: auto; min-height: min(480px, calc(100dvh - 110px)); padding-bottom: 8px; }
body:has(.call.kit-mode:not([hidden])) .powered { padding: 4px 16px 8px; font-size: 12px; }
.kit-host { flex: 1; min-height: 0; }
.kit-extras:empty, .kit-bar:not(.host-bar):not(:has(> :not([hidden]))) { display: none; }
.kit-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kit-bar.host-bar { margin-bottom: 0; }
.kit-bar .ctl { min-height: 36px; padding: 8px 14px; font-size: 14px; }
.kit-mode .ai-notice { margin: 8px 0 0; }
.kit-mode .ai-panel { position: fixed; z-index: 30; right: 16px; bottom: 96px; width: min(400px, calc(100vw - 32px)); max-height: min(70vh, 640px); overflow: auto; margin: 0; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.sfk-kit { --sfk-accent: var(--brand); --sfk-accent-text: var(--brand-ink); --sfk-speaking: var(--brand); }
.preview-card #cam-retry { margin-top: 8px; }
.call-notice { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.call-notice p { margin: 0; flex: 1 1 240px; }

/* AI participants */
.tile.ai .avatar { background: var(--raise); color: var(--accent); border: 2px solid var(--brand); }
.ai-notice { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); font-size: 14px; }
.ai-panel { margin-top: 14px; display: grid; gap: 12px; }
.ai-heads { display: grid; gap: 10px; }
.ai-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ai-title b { font: 700 17px/1.2 "Bricolage Grotesque", sans-serif; }
.ai-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ai-actions { margin-top: 8px; }
.ai-teach { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-teach input, .ai-teach select { width: auto; min-height: 34px; padding: 6px 10px; font-size: 14px; border-radius: 9px; }
.ai-teach .ai-topic { width: min(220px, 60vw); }
.ai-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 340px; overflow-y: auto; }
.ai-feed li { padding: 10px 12px; border-radius: 12px; background: var(--raise); border: 1px solid var(--line); }
.ai-feed li b { font-size: 13px; color: var(--muted); }
.ai-feed li p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-feed li.ai { border-left: 3px solid var(--brand); }
.ai-feed li.mine { background: transparent; }
.ai-feed li.question { border-left: 3px solid var(--accent); }
.ai-feed li.flag { border-left: 3px solid #F59E0B; background: #F59E0B14; }
.ai-feed li.flag.high { border-left-color: var(--danger); background: #F8717114; }
.ai-feed li.minutes { border-left: 3px solid var(--ok); }
.ai-ask textarea { resize: vertical; }
.ai-ask-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.ai-ask-row .spacer { flex: 1; }
.ai-note { font-size: 13px; margin: 6px 0 0; min-height: 0; }
.ctl.on { border-color: var(--brand); }
.ctl.alert { border-color: #F59E0B; box-shadow: 0 0 0 2px #F59E0B55; }
.ai-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.ai-dialog::backdrop { background: rgba(7, 10, 19, .6); }
.ai-checks { display: grid; gap: 10px; margin-top: 16px; }

/* Knowledge base */
.kb-from { font-size: 14px; overflow-wrap: anywhere; }
.kb-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.kb-review .notice ul { margin: 6px 0 0; padding-left: 20px; }
.kb-summary { margin: 0; }
.kb-text { font-family: ui-monospace, "Geist Mono", monospace; font-size: 14px; line-height: 1.5; }
.tile .tile-act { position: absolute; top: 8px; right: 8px; z-index: 2; }

/* AI looks: drawn on each device, so they cost no streaming. Livelier while the AI speaks. */
.tile .look { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; overflow: hidden; border-radius: inherit; }
.tile.cam-on .look { display: none; }
.tile.ai:has(.look:not(.look-halo)) .avatar { display: none; }
.look-orb::before { content: ""; width: 34%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffffffcc, var(--brand) 45%, transparent 72%); filter: blur(1px); animation: look-breathe 3.2s ease-in-out infinite; }
.tile.speaking .look-orb::before { animation-duration: .9s; }
.look-aurora { background: linear-gradient(120deg, var(--brand), #7F8FFF, #2BD9C1, var(--brand)); background-size: 300% 300%; opacity: .45; animation: look-aurora 9s ease-in-out infinite; }
.tile.speaking .look-aurora { opacity: .85; animation-duration: 3s; }
.look-pulse::before, .look-pulse::after { content: ""; position: absolute; width: 22%; aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--brand); animation: look-ring 2.4s ease-out infinite; }
.look-pulse::after { animation-delay: 1.2s; }
.tile.speaking .look-pulse::before, .tile.speaking .look-pulse::after { animation-duration: 1s; }
.look-wave { grid-auto-flow: column; gap: 6px; place-content: center; }
.look-wave span { width: 8px; height: 64px; border-radius: 4px; background: var(--brand); transform: scaleY(.25); animation: look-bar 1.6s ease-in-out infinite; }
.look-wave span:nth-child(2) { animation-delay: .15s; } .look-wave span:nth-child(3) { animation-delay: .3s; }
.look-wave span:nth-child(4) { animation-delay: .45s; } .look-wave span:nth-child(5) { animation-delay: .6s; }
.tile.speaking .look-wave span { animation-duration: .55s; }
.look-halo::before { content: ""; width: 104px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--brand), transparent, var(--brand)); -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%); animation: look-spin 6s linear infinite; }
.tile.speaking .look-halo::before { animation-duration: 1.5s; }
.look-logo img { max-width: 38%; max-height: 50%; object-fit: contain; border-radius: 12px; transition: filter .3s; }
.tile.speaking .look-logo img { filter: drop-shadow(0 0 14px var(--brand)); }
@keyframes look-breathe { 50% { transform: scale(1.12); opacity: .85; } }
@keyframes look-aurora { 50% { background-position: 100% 50%; } }
@keyframes look-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
@keyframes look-bar { 50% { transform: scaleY(1); } }
@keyframes look-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .look, .look *, .look::before, .look::after { animation: none !important; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 14px; }
