/* Inkrypt Webinars - shared UI. One dark theme, one accent (#2f6fed), red only for LIVE and destructive. */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #98a0ad;
  --accent: #2f6fed;
  --accent-hover: #4a82f0;
  --red: #e5484d;
  --green: #3fb27f;
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 32px;
  --radius: 8px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
a { color: var(--accent-hover); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden, [hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s1) var(--s2);
  min-height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 14px; letter-spacing: 0; white-space: nowrap; }
.brand::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  background: var(--accent); border-radius: 2px; margin-right: var(--s1);
}
.topbar .title { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar .spacer { flex: 1; }

.container { max-width: 960px; margin: 0 auto; padding: var(--s3) var(--s2); }
.container.narrow { max-width: 480px; }
.stack { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.row.between { justify-content: space-between; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s2);
}
.card > .card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s1);
  margin-bottom: var(--s2);
}

/* Forms */
label, .label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="url"], input:not([type]), select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font: inherit;
  min-height: 36px;
}
input::placeholder { color: #6b7280; }
select { appearance: none; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 15px, calc(100% - 13px) 15px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.field { display: block; }

/* Buttons. Keeps working on bare <button> so harness-targeted controls look right. */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s1);
  min-height: 36px; padding: 6px 16px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: #262b36; }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover, button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger, button.danger { background: transparent; border-color: var(--red); color: #ff8a8e; }
.btn-danger:hover, button.danger:hover { background: rgba(229, 72, 77, .15); }
.btn-sm, button.sm { min-height: 28px; padding: 2px 8px; font-size: 12px; }
.btn-lg { min-height: 48px; padding: 8px 24px; font-size: 15px; }
:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge-live { background: var(--red); border-color: var(--red); color: #fff; }
.badge-ok { color: var(--green); border-color: rgba(63, 178, 127, .4); }
.badge-accent { color: #8fb3ff; border-color: rgba(47, 111, 237, .5); }

/* Messages */
.alert {
  padding: var(--s1) var(--s2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
}
.alert.error { border-color: rgba(229, 72, 77, .6); color: #ffb4b7; }
.alert.ok { border-color: rgba(63, 178, 127, .5); }
.alert:empty { display: none; }

/* Link rows (dashboard) */
.linkrow { display: grid; grid-template-columns: 1fr auto; gap: var(--s1); align-items: end; }
.linkrow input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: var(--s1); color: var(--muted); }
ol.steps strong { color: var(--text); font-weight: 600; }

/* Player / studio layouts */
.layout {
  display: grid; gap: var(--s2); padding: var(--s2);
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  max-width: 1440px; margin: 0 auto;
}
.layout.studio { grid-template-columns: minmax(0, 1fr) 360px; }
.main-col, .side-col { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.stage-box {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
}
.stage-box video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
  visibility: hidden;
}
.stage-box video.is-active { visibility: visible; }
.stage-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.stage-overlay > * { pointer-events: auto; }
.stage-corner { position: absolute; top: var(--s1); left: var(--s1); display: flex; gap: var(--s1); }
.stage-corner .badge { background: rgba(15, 17, 21, .8); }
.stage-corner .badge-live { background: var(--red); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.controls .spacer { flex: 1; }
.status-line { display: flex; flex-wrap: wrap; gap: var(--s2); color: var(--muted); font-size: 13px; align-items: center; }
#notice, .notice { min-height: 0; color: var(--muted); font-size: 13px; }
#notice:empty { display: none; }
#rendition-state { color: var(--muted); font-size: 13px; padding: 0 var(--s1); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--green); }
.dot.live { background: var(--red); }

/* Lists (participants) */
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plist li, #student-list > div {
  display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap;
  padding: var(--s1) 0; border-top: 1px solid var(--border);
}
.plist li:first-child, #student-list > div:first-child { border-top: 0; }
.plist .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#student-list > div { font-size: 13px; color: var(--muted); }
#student-list:empty::before { content: "No participants have reported in yet."; color: var(--muted); font-size: 13px; }
#student-list button { min-height: 28px; padding: 2px 8px; font-size: 12px; }
.plist:empty::before { content: "Nobody here yet."; color: var(--muted); font-size: 13px; }
.hand { color: #8fb3ff; font-size: 12px; font-weight: 600; }

/* Student page */
.center-card { max-width: 440px; margin: var(--s4) auto; padding: 0 var(--s2); display: flex; flex-direction: column; gap: var(--s2); }
.mic-btn { min-height: 72px; font-size: 18px; width: 100%; }
.mic-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.meter > i { display: block; height: 100%; width: 0; background: var(--green); transition: width 80ms linear; }
.timer { font-variant-numeric: tabular-nums; }

/* Chat widget (stage-chat.mjs). Selectors cover both the current ids and chat- classes. */
.chat-card { display: flex; flex-direction: column; min-height: 320px; }
.chat-card > .card-head { margin-bottom: var(--s1); }
.chat-host { display: flex; flex-direction: column; gap: var(--s1); min-height: 0; }
.chat-panel, .chat-host { display: flex; flex-direction: column; gap: var(--s1); }
.chat-host #who { font-size: 12px; color: var(--muted); }
.chat-host #list, .chat-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: var(--s1);
  max-height: 360px; overflow-y: auto; order: 1;
}
.chat-host #list:empty::before, .chat-list:empty::before { content: "No messages yet."; color: var(--muted); font-size: 13px; }
.chat-host #list > li, .chat-item {
  padding: var(--s1); background: var(--surface-2);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  overflow-wrap: anywhere; font-size: 13px;
}
.chat-pending, .chat-host #list > li[data-state="pending"] { border-color: rgba(47, 111, 237, .6); }
.chat-host #list > li[data-state="hidden"] { opacity: .55; }
.chat-actions { display: flex; gap: var(--s1); margin-top: 4px; flex-wrap: wrap; }
.chat-btn, .chat-host #list button { min-height: 24px; padding: 0 8px; font-size: 12px; }
.chat-host #post { display: flex; gap: var(--s1); order: 2; }
.chat-host #post input, .chat-input { flex: 1; min-width: 0; }
.chat-host #emoji { display: flex; gap: 4px; order: 3; }
.chat-host #emoji button { min-height: 32px; padding: 0 8px; }
.chat-host #counts { order: 4; color: var(--muted); font-size: 12px; }
.chat-host #counts:empty { display: none; }

/* Responsive */
@media (max-width: 960px) {
  .layout, .layout.studio { grid-template-columns: minmax(0, 1fr); padding: var(--s1); }
  .container { padding: var(--s2) var(--s1); }
  .linkrow { grid-template-columns: 1fr; }
  .linkrow button { width: 100%; }
  .chat-host #list, .chat-list { max-height: 280px; }
}
@media (max-width: 420px) {
  .controls button { flex: 1 1 auto; }
  .topbar .title { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.stack > .badge { align-self: flex-start; }
