:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #2e2e2e;
  --bg-hover: #383838;
  --border: #3d3d3d;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --accent: #6b8f71;
  --accent-hover: #7da683;
  --danger: #c45c5c;
  --danger-hover: #d46e6e;
  --speaking: #5cb85c;
  --audio-idle: #666;
  --link: #8fbc8f;
  --radius: 8px;
  --panel-width: 240px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.login-form input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-form button {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
}

.login-form button:hover { background: var(--accent-hover); }

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

/* Banned */
.banned-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.banned-text {
  font-size: 1.25rem;
  color: var(--text-secondary);
}

/* Chat layout */
.chat-page { height: 100vh; overflow: hidden; }

.app-layout {
  display: flex;
  height: 100vh;
}

.user-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 1rem 1rem 0.5rem;
}

.user-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  cursor: default;
}

.user-item:not(.self):hover { background: var(--bg-hover); }

.user-item.self { font-weight: 600; }

.user-name {
  flex: 1;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.user-item:not(.self) .user-name { cursor: pointer; }

.user-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  padding: 0.15rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  line-height: 0;
}

.icon-btn:hover { color: var(--text-secondary); }

.icon-btn svg { width: 16px; height: 16px; }

.user-item.self .audio-icon {
  visibility: visible;
  flex-shrink: 0;
}

.audio-icon {
  position: relative;
  color: var(--audio-idle);
}

.audio-icon.speaking { color: var(--speaking); }

.audio-icon.muted::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -1px;
  right: -1px;
  height: 2px;
  background: var(--danger);
  transform: rotate(-45deg);
}

.monitor-icon {
  position: relative;
  color: var(--audio-idle);
}

.monitor-icon.streaming {
  color: var(--speaking);
}

.monitor-icon.clickable {
  cursor: pointer;
}

.monitor-icon.clickable:hover {
  color: var(--accent-hover);
}

/* Chat main */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.video-panel {
  flex: 0 0 var(--video-panel-height, 45%);
  min-height: 100px;
  max-height: 85%;
  background: #000;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}

.video-panel.hidden { display: none; }

.video-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.6rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.video-panel-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-panel-actions {
  display: flex;
  gap: 0.25rem;
}

.video-action-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.45rem;
  line-height: 1;
}

.video-action-btn:hover { background: var(--bg-hover); }

.video-action-btn.muted { opacity: 0.55; }

.video-hover-only { opacity: 0; transition: opacity 0.15s; }

.video-panel:hover .video-hover-only { opacity: 1; }

.video-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#stream-video {
  flex: 1;
  width: 100%;
  min-height: 0;
  object-fit: contain;
  background: #000;
}

.chat-divider {
  flex: 0 0 6px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  touch-action: none;
}

.chat-divider:hover,
.chat-divider.dragging {
  background: var(--accent);
}

.chat-divider.hidden { display: none; }

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.msg {
  line-height: 1.45;
  font-size: 0.92rem;
  word-break: break-word;
}

.msg-meta {
  font-weight: 600;
  margin-right: 0.35rem;
}

.msg-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.msg a { color: var(--link); }

.msg img {
  max-width: min(400px, 100%);
  border-radius: var(--radius);
  margin-top: 0.25rem;
  display: block;
}

.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-tertiary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius);
  margin-top: 0.25rem;
  text-decoration: none;
  color: var(--link);
  font-size: 0.85rem;
}

.msg-system {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.chat-input-bar input[type="text"] {
  flex: 1;
  padding: 0.55rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.92rem;
}

.chat-input-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input-bar button {
  padding: 0.55rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
}

.chat-input-bar button:hover { background: var(--accent-hover); }

.attach-btn {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.attach-btn:hover { color: var(--text-secondary); }

/* Modals */
.modal.hidden { display: none; }

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

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

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.5rem;
}

.modal-header h3 { font-size: 1.05rem; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 0.75rem 1.25rem 1.25rem; }

.modal-body h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}

.field span { color: var(--text-secondary); }

.field input[type="text"],
.field input[type="number"],
.field select {
  padding: 0.45rem 0.6rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.88rem;
}

.field input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.field input[type="range"] { width: 100%; accent-color: var(--accent); }

.field.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.field.disabled span { color: var(--text-muted, var(--text-secondary)); }

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-field input { accent-color: var(--accent); }

.secondary-btn {
  padding: 0.45rem 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.88rem;
}

.secondary-btn:hover { background: var(--bg-hover); }

.ptt-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ptt-downloads .secondary-btn {
  text-decoration: none;
  text-align: center;
  flex: 1;
  min-width: 140px;
}

.modal-body code {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.danger-btn {
  display: block;
  width: 100%;
  padding: 0.45rem 0.85rem;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  cursor: pointer;
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

.danger-btn:hover {
  background: var(--danger);
  color: #fff;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.confirm-content { max-width: 360px; }

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.confirm-actions .danger-btn,
.confirm-actions .secondary-btn {
  width: auto;
  margin: 0;
}

.admin-section.hidden { display: none; }

#confirm-duration-field.hidden { display: none; }
