* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #1a1a1a;
  color: #e0e0e0;
  font-family: system-ui, sans-serif;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Login --- */

#login {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

#login input {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 12px 16px;
  font-size: 16px;
  border-radius: 4px;
  outline: none;
  width: 300px;
}

#login input:focus {
  border-color: #666;
}

#login button {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 10px 16px;
  font-size: 16px;
  border-radius: 4px;
  cursor: pointer;
  width: 300px;
}

#login button:hover:not(:disabled) {
  background: #333;
}

#login button:disabled {
  opacity: 0.4;
  cursor: default;
}

#error {
  color: #e55;
  min-height: 1.2em;
}

/* --- App layout --- */

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* --- Video grid --- */

#videos {
  flex: 1;
  display: grid;
  gap: 4px;
  background: #111;
  min-height: 0;
}

.video-cell {
  position: relative;
  overflow: hidden;
  background: #000;
}

.video-cell video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 13px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 1;
}

.theater-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: #fff;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-cell:hover .theater-btn,
.video-cell:hover .mute-btn:not(.hidden) {
  opacity: 1;
}

/* --- Local preview (PiP) --- */

#local {
  display: none;
  position: fixed;
  bottom: 60px;
  right: 16px;
  width: 240px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #000;
  z-index: 10;
}

#local.active {
  display: block;
}

/* --- Controls bar --- */

#controls {
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#identity {
  font-size: 13px;
  color: #aaa;
  margin-left: auto;
}

#e2ee-secret {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  outline: none;
  width: 140px;
}

#e2ee-secret:focus {
  border-color: #666;
}

#e2ee-secret:disabled {
  opacity: 0.4;
  cursor: default;
}

#share-btn, #sessions-btn, #shares-btn, #audio-btn {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
}

#share-btn:hover, #sessions-btn:hover, #shares-btn:hover, #audio-btn:hover {
  background: #333;
}

/* --- Overlays --- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.overlay-content {
  position: relative;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 20px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
}

.overlay-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.overlay-close:hover {
  color: #fff;
}

.overlay-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #ccc;
}

/* --- Session rows --- */

.session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #333;
}

.session-name {
  font-weight: 600;
  min-width: 80px;
}

.session-detail {
  color: #888;
}

.session-delete {
  margin-left: auto;
  background: none;
  border: 1px solid #644;
  color: #e55;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
}

.session-delete:hover {
  background: #422;
}

/* --- Shares table --- */

.shares-table {
  width: 100%;
  border-collapse: collapse;
  font: inherit;
  color: inherit;
}

.shares-table td, .shares-table th {
  padding: 6px 8px;
  text-align: left;
}

.shares-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.share-name-cell {
  cursor: pointer;
  font-weight: 600;
}

.share-name-cell:hover {
  text-decoration: underline;
}

.btn-join, .btn-leave {
  border: none;
  color: #e0e0e0;
  padding: 4px 14px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-join {
  background: #2a5a2a;
}

.btn-join:hover:not(:disabled) {
  background: #3a6a3a;
}

.btn-leave {
  background: #5a2a2a;
}

.btn-leave:hover {
  background: #6a3a3a;
}

.btn-join:disabled {
  opacity: 0.4;
  cursor: default;
}

.active-type {
  background: rgba(68, 170, 68, 0.2);
}

/* --- Audio controls --- */

#audio-btn.hidden {
  display: none;
}

.mute-btn {
  position: absolute;
  top: 8px;
  right: 48px;
  opacity: 0;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mute-btn.muted {
  background: rgba(180, 40, 40, 0.7);
}

.mute-btn.hidden {
  display: none;
}
