:root {
  --bg: #101316;
  --panel: #1b2025;
  --panel-soft: #242a30;
  --line: #39414a;
  --text: #eef2f4;
  --muted: #aeb8c2;
  --accent: #2aa876;
  --accent-2: #d18f34;
  --danger: #d95757;
  --blue: #4d8fd6;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

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

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #0d1013;
  color: var(--text);
}

.entry-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(16, 19, 22, 0.74), rgba(16, 19, 22, 0.92)),
    url("/assets/default-avatar.png") center / 260px no-repeat,
    var(--bg);
}

.entry-shell {
  width: min(520px, calc(100vw - 28px));
}

.entry-panel,
.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-panel {
  padding: 28px;
}

.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.brand-avatar {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: var(--panel-soft);
  object-fit: cover;
}

.brand-row h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.brand-row p,
.entry-note {
  color: var(--muted);
}

.join-form {
  display: grid;
  gap: 16px;
}

.join-form label {
  display: grid;
  gap: 7px;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #06110c;
  font-weight: 700;
}

.room-page {
  height: 100vh;
  overflow: hidden;
}

.room-app {
  height: 100vh;
  display: grid;
  grid-template-rows: 58px 1fr;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: #171b1f;
  border-bottom: 1px solid var(--line);
}

.room-header strong {
  display: block;
}

#roomMeta,
.status-strip {
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  display: flex;
  gap: 12px;
  align-items: center;
}

.room-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 58px;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.message {
  margin: 0 0 8px;
  line-height: 1.35;
  word-break: break-word;
}

.message .name {
  color: var(--accent);
  font-weight: 700;
}

.message.system .name {
  color: var(--accent-2);
}

.message.error {
  color: #ffd7d7;
}

.message-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 110px;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #15191d;
}

.talk-button {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  font-weight: 700;
}

.talk-button.active {
  background: var(--danger);
  border-color: var(--danger);
}

.side-panel {
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}

.side-panel section {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.side-panel h2,
.admin-section h2 {
  margin: 0 0 10px;
  font-size: 15px;
  letter-spacing: 0;
}

.side-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.side-list button {
  width: 100%;
  min-height: 34px;
  text-align: left;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side-list button.current {
  border-color: var(--accent);
  color: var(--accent);
}

.webcam-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
}

.webcam-window {
  position: absolute;
  width: 260px;
  min-width: 220px;
  max-width: min(620px, calc(100vw - 20px));
  min-height: 0;
  background: #12161a;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  pointer-events: auto;
}

.webcam-window.full {
  width: min(720px, calc(100vw - 24px));
}

.webcam-titlebar {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px 0 10px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  cursor: move;
}

.webcam-titlebar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-actions {
  display: flex;
  gap: 4px;
}

.window-actions button,
.cam-actions button {
  min-height: 26px;
  min-width: 30px;
  padding: 0 8px;
}

.webcam-body {
  position: relative;
  aspect-ratio: 4 / 3;
  min-height: 0;
  overflow: hidden;
  background: #050607;
  display: grid;
  place-items: center;
}

.webcam-body video,
.webcam-body img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
  align-self: stretch;
  justify-self: stretch;
}

.waiting-video {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.cam-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.74);
  color: #fff;
  font-size: 12px;
}

.cam-badge.hidden {
  display: none;
}

.cam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: #15191d;
  border-top: 1px solid var(--line);
}

.webcam-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(255, 255, 255, 0.45) 46% 52%, transparent 53%),
    linear-gradient(135deg, transparent 0 62%, rgba(255, 255, 255, 0.35) 63% 69%, transparent 70%);
}

.audio-layer {
  display: none;
}

.admin-header {
  min-height: 64px;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 360px) 70px;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: #171b1f;
}

.admin-header h1 {
  margin: 0;
}

.admin-token {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.admin-section {
  padding: 14px;
  min-height: 240px;
}

.compact-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.compact-form button {
  white-space: nowrap;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.admin-row,
.log-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.admin-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.log-list {
  max-height: 360px;
  overflow: auto;
  color: var(--muted);
}

@media (max-width: 820px) {
  .room-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 240px;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .message-bar {
    grid-template-columns: 1fr;
    grid-auto-rows: 42px;
  }

  .webcam-window {
    width: min(260px, calc(100vw - 20px));
  }

  .admin-header,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .compact-form {
    grid-template-columns: 1fr;
  }
}
