:root {
  --bg: #0f172a;
  --card: #111827;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --border: #1f2937;
  --accent: #335eea;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Ubuntu,
    Cantarell,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.topbar {
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: #0b1222;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  letter-spacing: .2px;
  margin-right: auto;
}

.identity-fields {
  display: flex;
  gap: 8px;
  flex: 1 1 420px;
}

.topbar input,
.topbar button {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
}

.topbar input {
  min-width: 170px;
  flex: 1;
}

.topbar button {
  cursor: pointer;
}

.session-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.accent {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #fff !important;
}

.hint {
  max-width: 1100px;
  margin: 0 auto;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  padding: 4px 8px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  padding: 10px 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.grid:empty {
  min-height: 8px;
}

.tile {
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  cursor: zoom-in;
  transition:
    box-shadow .15s ease,
    border-color .15s ease;
}

.tile.speaking {
  border-color: var(--danger) !important;
  box-shadow:
    0 0 0 2px var(--danger) inset,
    0 0 16px #ef444466 !important;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
}

.tile:fullscreen video,
video:fullscreen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

.label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #0009;
  color: #fff;
  font-size: 12px;
}

.controls {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: #0b1222;
  border-top: 1px solid var(--border);
}

.controls button {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  cursor: pointer;
}

.controls button.danger {
  border-color: #7f1d1d;
  background: #1b0a0a;
}

.controls button.raise {
  border-color: #4f46e5;
  background: #312e81;
}

.status {
  flex: 1 1 180px;
  min-width: 0;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

button[disabled] {
  opacity: .5;
  pointer-events: none;
}

.sidebar {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 320px;
  max-height: 64vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0b1222;
}

.chat {
  flex: 1;
  min-height: 80px;
  overflow: auto;
  padding: 10px;
}

.chat .msg {
  margin: 6px 0;
  font-size: 14px;
}

.chat .msg.attachment {
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.chat .from {
  margin-right: 6px;
  font-weight: 700;
}

.chat .ts {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}

.chat .att {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chat .att .name {
  font-weight: 600;
  text-decoration: underline;
}

.thumb {
  max-width: 100%;
  display: block;
  margin-top: 6px;
  border-radius: 8px;
}

.cap {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.composer {
  display: flex;
  gap: 6px;
  padding: 9px;
  border-top: 1px solid var(--border);
}

.composer input[type="text"] {
  min-width: 0;
  flex: 1;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
}

.composer button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}

/* ----------------------------------------------------------
   Modalità integrata per assemblea GEQO
   ---------------------------------------------------------- */

html.mode-assemblea .technical-only,
body.mode-assemblea .technical-only,
html.mode-assemblea .attachment-control,
body.mode-assemblea .attachment-control {
  display: none !important;
}

body.mode-assemblea {
  min-height: 0;
  overflow-x: hidden;
  background: #fff;
  color: #111827;
}

body.mode-assemblea .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 8px;
  justify-content: center;
  border: 0;
  background: #fff;
}

body.mode-assemblea .session-actions {
  width: 100%;
  max-width: 560px;
}

body.mode-assemblea #joinBtn {
  min-height: 50px;
  flex: 1;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
}

body.mode-assemblea #leaveBtn {
  min-height: 50px;
  padding-inline: 16px;
  border-radius: 12px;
}

body.mode-assemblea .grid {
  width: 100%;
  max-width: none;
  padding: 6px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

body.mode-assemblea .grid:empty {
  display: none;
}

body.mode-assemblea .tile {
  border-radius: 12px;
}

body.mode-assemblea .controls {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 7px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 0;
  background: #fff;
}

body.mode-assemblea .controls button {
  min-width: 0;
  min-height: 46px;
  padding: 7px 8px;
  border-color: #d1d5db;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-weight: 650;
}

body.mode-assemblea .controls button.raise {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
}

body.mode-assemblea .status {
  grid-column: 1 / -1;
  padding: 2px 4px;
  color: #4b5563;
  text-align: center;
}

body.mode-assemblea .sidebar {
  position: static;
  width: auto;
  max-height: 170px;
  margin: 6px;
  border-color: #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

body.mode-assemblea .chat {
  min-height: 54px;
  max-height: 105px;
  color: #111827;
}

body.mode-assemblea .composer {
  padding: 6px;
  border-color: #e5e7eb;
}

body.mode-assemblea .composer input[type="text"] {
  background: #fff;
  color: #111827;
  border-color: #d1d5db;
}

body.mode-assemblea .composer button {
  border-color: #d1d5db;
  background: #fff;
  color: #111827;
}

@media (max-width: 900px) {
  body:not(.mode-assemblea) .sidebar {
    position: static;
    width: auto;
    max-height: none;
    margin: 12px;
  }
}

@media (max-width: 600px) {
  body.mode-assemblea .topbar {
    padding: 5px;
  }

  body.mode-assemblea .session-actions {
    gap: 5px;
  }

  body.mode-assemblea #joinBtn,
  body.mode-assemblea #leaveBtn {
    min-height: 46px;
    font-size: 15px;
  }

  body.mode-assemblea .grid {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 5px;
  }

  body.mode-assemblea video {
    aspect-ratio: 16 / 10;
  }

  body.mode-assemblea .controls {
    gap: 5px;
    padding: 5px;
  }

  body.mode-assemblea .controls button {
    min-height: 44px;
    padding: 6px 4px;
    font-size: 12px;
  }

  body.mode-assemblea .sidebar {
    margin: 5px;
    max-height: 145px;
  }

  body.mode-assemblea .chat {
    max-height: 82px;
    min-height: 42px;
    padding: 7px;
  }
}
