:root {
  color-scheme: dark;
  --bg: #06100f;
  --panel: #0f1a1b;
  --panel-2: #172526;
  --line: #284143;
  --text: #f5f7f4;
  --muted: #a9b9b3;
  --accent: #28c6a0;
  --accent-2: #f2c94c;
  --danger: #ff6b6b;
  --ink: #10231d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(40, 198, 160, 0.07) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(40, 198, 160, 0.06), transparent 34%),
    var(--bg);
  background-size: 56px 100%, 100% 100%, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked .shell,
body.locked .exit-focus {
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(7, 16, 21, 0.96), rgba(7, 16, 21, 0.88)),
    radial-gradient(circle at 18% 12%, rgba(37, 199, 162, 0.24), transparent 32%),
    var(--bg);
}

.access-gate.hidden {
  display: none;
}

.access-card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 30, 0.94);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.38);
}

.access-card h1 {
  font-size: 28px;
}

.access-card p {
  margin: 0;
  color: var(--muted);
}

.access-error {
  min-height: 18px;
  color: var(--danger) !important;
  font-size: 13px;
  font-weight: 800;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 26px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(40, 198, 160, 0.2);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 4.6vw, 54px);
  font-weight: 900;
}

h2 {
  font-size: 15px;
}

.clock {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.clock span,
.tile-meta,
.brand,
.toolbar,
.panel-section {
  border: 1px solid var(--line);
  background: rgba(16, 24, 30, 0.84);
}

.clock span {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.portal-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overflow: auto;
  align-content: stretch;
}

.whiteboard-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fbf8;
}

.whiteboard-toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  width: min(560px, calc(100% - 24px));
  max-width: calc(100% - 24px);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(16, 35, 29, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  overflow: visible;
  transform: translateX(-50%);
}

.whiteboard-toolbar button {
  width: 100%;
  aspect-ratio: 1;
  min-height: 42px;
  padding: 0;
  border-color: rgba(16, 35, 29, 0.18);
  background: #edf4f1;
  color: #10231d;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.whiteboard-toolbar button.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #241b00;
}

.whiteboard-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.presentation-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 30, 0.84);
}

.presentation-bar > div:first-child {
  min-width: 0;
}

.presentation-bar.active,
.presentation-mode .presentation-bar {
  display: flex;
}

.presentation-bar span {
  display: block;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.presentation-bar strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
}

.presentation-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presentation-tools strong {
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.presentation-bar button,
.presentation-tools button {
  min-height: 34px;
  padding: 0 12px;
}

.presentation-mode .portal-grid {
  grid-template-columns: minmax(0, 2.4fr) minmax(180px, 0.85fr);
  grid-auto-rows: minmax(120px, auto);
  align-content: start;
}

.presentation-mode .tile {
  aspect-ratio: 16 / 9;
}

.presentation-mode .presenter-tile {
  grid-row: span 3;
  min-height: 0;
  border-color: rgba(244, 201, 93, 0.8);
  overflow: auto;
  overscroll-behavior: contain;
}

.presentation-mode .presenter-tile video,
.presentation-mode .presenter-tile .remote-media video {
  object-fit: contain;
  width: calc(100% * var(--presentation-zoom, 1));
  height: calc(100% * var(--presentation-zoom, 1));
  max-width: none;
  max-height: none;
  transform-origin: top left;
}

.presentation-mode .support-tile {
  aspect-ratio: 16 / 10;
}

.tile {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(40, 198, 160, 0.24);
  border-radius: 8px;
  background: #0c1519;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 16 / 9;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #05090b;
}

.remote-media {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.remote-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.empty-feed {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.tile-meta {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  backdrop-filter: blur(12px);
  background: rgba(10, 18, 19, 0.88);
}

.tile-meta span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.verified-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(40, 198, 160, 0.16);
  color: var(--accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  vertical-align: 1px;
  white-space: nowrap;
}

.control-panel {
  min-width: 0;
  min-height: 0;
  border-left: 1px solid rgba(40, 198, 160, 0.2);
  background: rgba(6, 16, 15, 0.96);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  border-color: rgba(40, 198, 160, 0.45);
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7ae3c4);
  color: var(--ink);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.join-form,
.chat-form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1718;
  color: var(--text);
  padding: 9px 10px;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  background: #132326;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  background: #183033;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button.primary {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
  font-weight: 800;
}

.link-button:hover {
  color: var(--text);
}

.exit-focus {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: none;
  min-height: 42px;
  padding: 0 14px;
  border-color: rgba(37, 199, 162, 0.7);
  background: rgba(16, 24, 30, 0.92);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(19, 35, 38, 0.78);
}

.toolbar button.active {
  background: var(--accent-2);
  color: #241b00;
  border-color: var(--accent-2);
}

.toolbar button.danger,
.toolbar button.off {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.45);
}

.smart-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.presentation-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.presentation-actions button.active {
  background: var(--accent-2);
  color: #241b00;
  border-color: var(--accent-2);
}

.activity-log {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  min-height: 86px;
}

.activity-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
}

.activity-item time {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.activity-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel-section {
  border-radius: 8px;
  padding: 12px;
  box-shadow: inset 3px 0 0 rgba(40, 198, 160, 0.18);
}

.panel-section h2 {
  color: #f8fbf8;
  font-weight: 900;
}

.people {
  list-style: none;
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 12px 0 0;
}

.people li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.people strong,
.people span {
  min-width: 0;
}

.people strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people span,
.messages time {
  color: var(--muted);
  font-size: 12px;
}

.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.health-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.health-item span {
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.health-item.online {
  border-color: rgba(37, 199, 162, 0.7);
}

.health-item.online span {
  color: var(--accent);
}

.health-item.alert {
  border-color: rgba(255, 107, 107, 0.85);
  background: rgba(255, 107, 107, 0.1);
}

.health-item.alert span {
  color: var(--danger);
}

.metrics {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.metrics div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.metrics dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.admin-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-item span {
  color: var(--muted);
  font-size: 12px;
}

.admin-item strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-item strong.ok {
  color: var(--accent);
}

.admin-metrics dd {
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kiosk-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.kiosk-preview {
  margin-top: 10px;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.chat-section {
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  min-height: 130px;
}

.message {
  padding: 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.message strong {
  display: block;
  font-size: 13px;
}

.message p {
  margin: 4px 0 0;
  color: #dce7e3;
}

.chat-form {
  grid-template-columns: 1fr 72px;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .stage {
    min-height: 62dvh;
  }

  .portal-grid {
    overflow: visible;
    grid-auto-rows: auto;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow: visible;
  }
}

.focus-mode .control-panel {
  display: none;
}

.focus-mode .exit-focus {
  display: block;
}

.focus-mode .shell {
  grid-template-columns: 1fr;
}

.focus-mode .stage {
  padding: 18px;
}

.focus-mode .portal-grid {
  overflow: hidden;
}

@media (max-width: 560px) {
  .stage,
  .control-panel {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .clock {
    justify-content: flex-start;
  }

  .portal-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .tile {
    aspect-ratio: 4 / 3;
  }
}
