/* ============ Confi — "On Air" design system ============ */

:root {
  --ink: #10151a;        /* cool graphite — room stage */
  --ink-2: #171e25;      /* raised dark surface */
  --ink-3: #202a34;      /* dark controls */
  --line-d: #2c3844;
  --paper: #f0f3f5;      /* admin background */
  --card: #ffffff;
  --line: #dbe2e8;
  --text: #16202a;
  --text-dim: #5f6b76;
  --text-inv: #e9eef2;
  --text-inv-dim: #96a3ae;
  --green: #0e9384;      /* fresh teal — primary actions */
  --green-strong: #0b7a6e;
  --green-soft: #e0f2f0;
  --amber: #ffb02e;      /* "on air" — live states only */
  --red: #e0474d;
  --red-deep: #b73538;
  --red-soft: #fdecec;
  --radius: 14px;
  --radius-s: 9px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--paper);
  color: var(--text);
}

h1, h2 { line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .8rem; letter-spacing: -.01em; }

.muted { color: var(--text-dim); }
.small { font-size: .82rem; }

:focus-visible { outline: 2px solid var(--green-strong); outline-offset: 2px; border-radius: 4px; }
.room-body :focus-visible { outline-color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- wordmark + status lamp (the signature) ---------- */

.wordmark {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.03em;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: inherit;
  text-decoration: none;
}
h1.wordmark { font-size: 1.6rem; margin: 0 0 .35rem; }

.lamp {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #b9c4bb;
  display: inline-block;
  flex: none;
}
.lamp.on {
  background: var(--amber);
  animation: lamp 2.2s ease-out infinite;
}
@keyframes lamp {
  0%   { box-shadow: 0 0 0 0 rgba(255, 176, 46, .45); }
  70%  { box-shadow: 0 0 0 8px rgba(255, 176, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 176, 46, 0); }
}

.eyebrow {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-dim);
  margin: 0 0 .5rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-inv-dim);
}
.live-badge .lamp.on ~ span, .live-badge.is-live { color: var(--amber); }

/* ---------- layout shells ---------- */

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.container { max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .7rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar.dark {
  background: var(--ink-2);
  border-color: var(--line-d);
  color: var(--text-inv);
}

/* ---------- forms ---------- */

label { display: block; margin-bottom: .9rem; font-size: .88rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%;
  margin-top: .3rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  font: inherit;
  color: inherit;
  background: var(--card);
  transition: border-color .12s;
}
input:focus, textarea:focus { border-color: var(--green); outline: none; }
textarea { resize: vertical; }

.error {
  color: var(--red-deep);
  background: var(--red-soft);
  padding: .55rem .8rem;
  border-radius: var(--radius-s);
  margin: .5rem 0 .9rem;
  font-size: .88rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  background: var(--green);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: .55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s;
}
.btn:hover { background: var(--green-strong); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--green-soft); border-color: var(--green); color: var(--green-strong); }
.btn-danger { background: transparent; color: var(--red-deep); border-color: var(--line); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-small { padding: .38rem .75rem; font-size: .84rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 15px; height: 15px; flex: none; }

.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row input[type=text] { flex: 1; margin-top: 0; }

/* ---------- admin: conference cards ---------- */

.conf-item { padding: 1.05rem 1.25rem; }
.conf-item.fresh { border-color: var(--green); animation: fresh-in .35s ease-out; }
@keyframes fresh-in {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.conf-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.conf-title { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.conf-title strong { font-size: 1rem; letter-spacing: -.01em; }
.conf-title .lamp { margin-top: 2px; }
.online { color: #c07d00; font-weight: 600; }
.conf-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.link-line {
  display: block;
  width: 100%;
  margin-top: .6rem;
  padding: .45rem .6rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--text-dim);
  font: inherit;
  font-size: .8rem;
  text-align: left;
  word-break: break-all;
  cursor: copy;
}
.link-line:hover { border-color: var(--green); color: var(--green-strong); }

.empty-state {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 2.2rem 1.5rem;
  text-align: center;
  color: var(--text-dim);
}

/* ---------- dialog ---------- */

dialog.card { max-width: 500px; width: 92vw; border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(15, 22, 19, .25); }
dialog::backdrop { background: rgba(15, 22, 19, .45); }

.mail-results { list-style: none; margin: .3rem 0 .6rem; padding: 0; font-size: .85rem; }
.mail-results li { padding: .15rem 0; }
.mail-results li.ok { color: var(--green-strong); }
.mail-results li.fail { color: var(--red-deep); }

/* ---------- join screen ---------- */

.preview-wrap { position: relative; margin-bottom: .4rem; }
.preview {
  width: 100%;
  border-radius: 10px;
  background: var(--ink);
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}
.preview-toggles {
  position: absolute;
  bottom: .6rem;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: .6rem;
}

/* ---------- room ---------- */

.room-body { background: var(--ink); color: var(--text-inv); }
.room-body .card { background: var(--card); color: var(--text); }

#room-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.room-main { flex: 1; display: flex; min-height: 0; }

.video-grid {
  flex: 1;
  display: grid;
  gap: .5rem;
  padding: .5rem;
  align-content: center;
  min-width: 0;
}

.tile {
  position: relative;
  background: var(--ink-2);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16/9;
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color .15s;
}
.tile.speaking { outline-color: var(--amber); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.self.mirror video { transform: scaleX(-1); }
.tile.screen video { object-fit: contain; background: #000; }
.tile.cam-off video { opacity: 0; }
.tile.cam-off::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, var(--ink-3) 0 12%, transparent 13%),
    radial-gradient(circle at 50% 78%, var(--ink-3) 0 24%, transparent 25%);
}
.tile-name {
  position: absolute;
  left: .5rem;
  bottom: .5rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(10, 15, 12, .65);
  padding: .18rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  max-width: calc(100% - 1rem);
  white-space: nowrap;
  overflow: hidden;
}
.tile.self .tile-name { background: rgba(11, 122, 110, .8); }
.mute-flag { display: none; color: var(--red); flex: none; }
.mute-flag svg { width: 12px; height: 12px; display: block; }
.tile.muted .mute-flag { display: inline-flex; }

/* ---------- side panel ---------- */

.side-panel {
  width: 330px;
  display: flex;
  flex-direction: column;
  background: var(--ink-2);
  border-left: 1px solid var(--line-d);
}
.side-tabs { display: flex; border-bottom: 1px solid var(--line-d); }
.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-inv-dim);
  padding: .7rem;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { color: var(--text-inv); border-bottom-color: var(--amber); }

.pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: .8rem; }
.chat-msg { margin-bottom: .75rem; font-size: .9rem; overflow-wrap: break-word; }
.chat-msg a { color: #7cd0c5; }
.chat-msg.system { color: var(--text-inv-dim); font-size: .8rem; }
.chat-head { font-size: .74rem; color: var(--text-inv-dim); margin-bottom: .1rem; }

.chat-form {
  display: flex;
  gap: .4rem;
  padding: .6rem;
  border-top: 1px solid var(--line-d);
  align-items: center;
}
.chat-form input[type=text] {
  flex: 1;
  margin: 0;
  background: var(--ink);
  border-color: var(--line-d);
  color: var(--text-inv);
}
.icon-btn {
  background: none;
  border: none;
  color: var(--text-inv-dim);
  cursor: pointer;
  padding: .45rem;
  border-radius: var(--radius-s);
  display: inline-flex;
}
.icon-btn:hover { color: var(--text-inv); background: var(--ink-3); }
.icon-btn svg { width: 19px; height: 19px; }
label.icon-btn { margin: 0; }

.people-list { list-style: none; margin: 0; padding: .5rem .9rem; }
.people-list li {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--line-d);
  font-size: .9rem;
}
.people-list .lamp { background: var(--green); }

/* ---------- control bar ---------- */

.controls {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: .55rem;
  padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom, 0px));
  background: var(--ink-2);
  border-top: 1px solid var(--line-d);
}
.ctrl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .22rem;
  min-width: 72px;
  padding: .5rem .8rem .4rem;
  border: none;
  border-radius: 12px;
  background: var(--ink-3);
  color: var(--text-inv);
  font: inherit;
  cursor: pointer;
  transition: background .12s;
}
.ctrl:hover { background: #28343f; }
.ctrl svg { width: 21px; height: 21px; }
.ctrl-label { font-size: .67rem; color: var(--text-inv-dim); letter-spacing: .02em; }
.ctrl .icon-off { display: none; }
.ctrl.off { background: var(--red); }
.ctrl.off:hover { background: var(--red-deep); }
.ctrl.off .icon-on { display: none; }
.ctrl.off .icon-off { display: block; }
.ctrl.off .ctrl-label, .ctrl.active .ctrl-label, .ctrl.leave .ctrl-label { color: #fff; }
.ctrl.active { background: var(--green-strong); }
.ctrl.leave { background: var(--red); }
.ctrl.leave:hover { background: var(--red-deep); }
.ctrl:disabled { opacity: .45; cursor: default; }

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--amber);
  color: var(--ink);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
}

/* ---------- left / ended screen ---------- */

.farewell { text-align: center; max-width: 400px; width: 100%; }
.farewell .actions { display: flex; gap: .6rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .side-panel {
    position: fixed;
    right: 0; top: 0;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    width: min(330px, 90vw);
    z-index: 10;
    box-shadow: -12px 0 30px rgba(0, 0, 0, .4);
  }
  .video-grid { align-content: start; }
  .ctrl { min-width: 58px; padding: .45rem .5rem .35rem; }
  .conf-head { flex-direction: column; align-items: flex-start; }
}
