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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.header-logo {
  height: 36px;
  width: auto;
  display: block;
}

.auth-logo {
  display: block;
  margin: 0 auto 16px;
  max-width: 320px;
  width: 100%;
  height: auto;
}

.status {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 500;
}

.status.connected {
  background: #1b4332;
  color: #52b788;
}

.status.disconnected {
  background: #3d0000;
  color: #e94560;
}

main {
  padding: 24px;
}

h2 {
  font-size: 16px;
  margin-bottom: 16px;
  color: #a0a0a0;
}

/* Device list header */
.device-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.device-list-header h2 {
  margin: 0;
}

.btn-multi-view {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-multi-view:hover {
  background: #1a2744;
  border-color: #4895ef;
}

/* Multi-view selection modal */
.multi-view-select-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.multi-view-select-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.multi-view-select-card h3 {
  margin: 0 0 4px 0;
  color: #e0e0e0;
}

.multi-view-select-hint {
  color: #808080;
  font-size: 13px;
  margin-bottom: 16px;
}

.multi-view-select-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.multi-view-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0a0a1a;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.multi-view-select-item:hover {
  background: #1a2744;
}

.multi-view-select-item.selected {
  border-color: #4895ef;
  background: rgba(72, 149, 239, 0.1);
}

.multi-view-select-item .select-order {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0f3460;
  color: #808080;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.multi-view-select-item.selected .select-order {
  background: #4895ef;
  color: #fff;
}

.multi-view-select-item .select-info {
  flex: 1;
}

.multi-view-select-item .select-name {
  color: #e0e0e0;
  font-size: 14px;
}

.multi-view-select-item .select-detail {
  color: #808080;
  font-size: 12px;
}

.multi-view-select-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.multi-view-select-actions button {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.multi-view-select-actions .btn-cancel {
  background: none;
  border: 1px solid #0f3460;
  color: #808080;
}

.multi-view-select-actions .btn-launch {
  background: #4895ef;
  border: 1px solid #4895ef;
  color: #fff;
}

.multi-view-select-actions .btn-launch:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Device grid */
.device-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.device-group-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-group-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.device-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 16px;
  width: 250px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}

.device-card:hover {
  border-color: #4895ef;
  transform: translateY(-2px);
}

.device-card .device-model {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.device-card .device-brand {
  font-size: 12px;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.device-card .device-details {
  font-size: 13px;
  color: #808080;
  line-height: 1.6;
}

.device-card .device-details span {
  display: block;
}

.device-card .badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 8px;
}

.badge.audio-yes {
  background: #1b4332;
  color: #52b788;
}

.badge.audio-no {
  background: #3d0000;
  color: #e94560;
}

.loading {
  color: #808080;
  font-style: italic;
}

/* Stream view */
.hidden {
  display: none !important;
}

#stream-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
}

.stream-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
  margin-bottom: 4px;
}

.stream-toolbar button,
.stream-toolbar select {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  box-sizing: border-box;
}

.stream-toolbar button:hover:not(:disabled) {
  border-color: #4895ef;
}

.stream-toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.stream-controls {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stream-controls-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.btn-control-fixed {
  min-width: 130px;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-control-fixed.control-active-hover:hover {
  background: rgba(231, 76, 60, 0.25);
  border-color: #e74c3c;
  color: #e74c3c;
}

.btn-vol {
  padding: 4px 8px !important;
  font-size: 14px !important;
  min-width: 0;
}

#btn-record {
  width: 80px;
  text-align: left;
}

#btn-mute {
  width: 80px;
  text-align: left;
}

#device-name {
  font-weight: 600;
  font-size: 16px;
}

#device-info {
  font-size: 13px;
  color: #808080;
}

#multi-view-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

/* --- StreamPanel styles --- */

.stream-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 4px;
  background: #0a0a1a;
  transition: border-color 0.2s;
}

.stream-panel.panel-focused {
  border-color: #4895ef;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(22, 33, 62, 0.9);
  font-size: 12px;
  color: #e0e0e0;
  flex-shrink: 0;
}

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

.panel-device-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-stats {
  color: #808080;
  font-size: 11px;
  margin: 0 8px;
  white-space: nowrap;
}

.panel-remove {
  background: none;
  border: none;
  color: #808080;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.panel-remove:hover {
  color: #e74c3c;
}

.panel-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.panel-canvas {
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* Empty slot placeholder */
.panel-empty-slot {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #0f3460;
  border-radius: 4px;
  background: #0a0a1a;
  min-width: 0;
  position: relative;
}

.panel-add-device {
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.panel-add-device:hover {
  background: #1a2744;
}

/* Device picker popover */
.device-picker-popover {
  position: absolute;
  z-index: 80;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.device-picker-title {
  font-size: 13px;
  color: #808080;
  padding: 4px 8px;
  border-bottom: 1px solid #0f3460;
  margin-bottom: 4px;
}

.device-picker-item {
  background: #0a0a1a;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.2s;
}

.device-picker-item:hover {
  background: #1a2744;
}

.device-picker-close {
  background: none;
  color: #808080;
  border: 1px solid #0f3460;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
  font-family: inherit;
}

.device-picker-close:hover {
  color: #e0e0e0;
}

/* Legacy single canvas (kept for backwards compat during transition) */
#video-canvas {
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

/* Stream stats overlay */
.stream-stats {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 12px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: #52b788;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 10px;
  border-radius: 4px;
  pointer-events: none;
}

/* Control status indicator */
.control-active #btn-control {
  background: #1b4332;
  border-color: #52b788;
  color: #52b788;
}

/* Header right section */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* User dropdown menu */
.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 10px;
  color: #a0a0a0;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.user-menu-toggle:hover {
  border-color: #0f3460;
}

.user-badge {
  font-size: 13px;
  color: #808080;
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 140px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 200;
  overflow: hidden;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-family: inherit;
  color: #e0e0e0;
  background: none;
  border: none;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.user-menu-item:hover {
  background: #0f3460;
}

.user-menu-item:last-child {
  border-top: 1px solid #0f3460;
  color: #a0a0a0;
}

/* Auth pages (login, setup) */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: #808080;
  text-align: center;
  margin-bottom: 32px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 13px;
  color: #a0a0a0;
  font-weight: 500;
}

.form-group input,
.form-group select {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #4895ef;
}

.form-hint {
  font-size: 11px;
  color: #606060;
}

.auth-error {
  background: #3d0000;
  color: #e94560;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.btn-primary {
  background: #4895ef;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary:hover {
  background: #3a7bd5;
}

.btn-secondary {
  background: transparent;
  color: #a0a0a0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-secondary:hover {
  border-color: #4895ef;
  color: #e0e0e0;
}

/* Admin page */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #0f3460;
}

.admin-table th {
  font-size: 12px;
  color: #808080;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.admin-table td {
  font-size: 14px;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.action-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-muted {
  font-size: 12px;
  color: #606060;
  font-style: italic;
}

.btn-small {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid #0f3460;
  background: #16213e;
  color: #e0e0e0;
  cursor: pointer;
  font-family: inherit;
}

.btn-small:hover {
  border-color: #4895ef;
}

.btn-edit {
  border-color: #4895ef;
  color: #4895ef;
}

.btn-edit:hover {
  background: #0f3460;
  color: #e0e0e0;
}

.btn-delete {
  border-color: #e94560;
  color: #e94560;
}

.btn-delete:hover {
  background: #3d0000;
  border-color: #e94560;
  color: #fff;
}

.role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.role-admin {
  background: #2d1b4e;
  color: #b794f4;
}

.role-controller {
  background: #1b3a4b;
  color: #63b3ed;
}

.role-viewer {
  background: #1b4332;
  color: #52b788;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-content {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 20px;
  color: #e0e0e0;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.modal-buttons button {
  flex: 1;
}

.btn-danger {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-danger:hover {
  background: #d63851;
}

/* Setup Wizard */
.wizard-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 560px;
}

.wizard-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 32px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 52px;
}

.wizard-step .step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: #1a1a2e;
  border: 2px solid #0f3460;
  color: #606060;
  transition: all 0.2s;
}

.wizard-step .step-label {
  font-size: 10px;
  color: #606060;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wizard-step.active .step-num {
  background: #4895ef;
  border-color: #4895ef;
  border-style: solid;
  color: #fff;
}

.wizard-step.active .step-label {
  color: #4895ef;
}

.wizard-step.completed .step-num {
  background: #52b788;
  border-color: #52b788;
  border-style: solid;
  color: #fff;
}

.wizard-step.completed .step-label {
  color: #52b788;
}

/* Optional step indicators — dashed border (only in default/inactive state) */
.wizard-step[data-optional="true"]:not(.active):not(.completed):not(.skipped) .step-num {
  border-style: dashed;
}

/* Skipped step indicators — muted with strikethrough label */
.wizard-step.skipped .step-num {
  background: #1a1a2e;
  border-color: #404040;
  border-style: dashed;
  color: #404040;
}

.wizard-step.skipped .step-label {
  color: #404040;
  text-decoration: line-through;
}

.wizard-heading {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #e0e0e0;
}

.wizard-desc {
  font-size: 13px;
  color: #808080;
  margin-bottom: 16px;
  line-height: 1.5;
}

.wizard-instructions {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 16px 16px 16px 8px;
  margin-bottom: 20px;
}

.wizard-instructions ol {
  margin: 0;
  padding-left: 24px;
  font-size: 13px;
  color: #a0a0a0;
  line-height: 1.8;
}

.wizard-instructions a {
  color: #4895ef;
  text-decoration: none;
}

.wizard-instructions a:hover {
  text-decoration: underline;
}

.wizard-instructions code {
  background: #0f3460;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: #e0e0e0;
}

.wizard-buttons {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.wizard-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #1a1a2e;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #a0a0a0;
}

.status-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #0f3460;
  border-top-color: #4895ef;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.wizard-success {
  background: #1b4332;
  border: 1px solid #2d6a4f;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #52b788;
}

.wizard-success code {
  background: #2d6a4f;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
}

.wizard-info {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #a0a0a0;
}

.wizard-code {
  background: #0d1117;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  color: #52b788;
  overflow-x: auto;
  margin: 8px 0 16px;
  word-break: break-all;
  white-space: pre-wrap;
}

.wizard-device-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.wizard-device {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a1a2e;
  border: 1px solid #2d6a4f;
  border-radius: 6px;
  padding: 12px 16px;
}

.wizard-device-name {
  font-weight: 600;
  font-size: 14px;
  color: #e0e0e0;
}

.wizard-device-detail {
  font-size: 12px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: #808080;
}

.wizard-done {
  text-align: center;
  padding: 20px 0;
}

.wizard-summary {
  text-align: left;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.summary-item {
  padding: 6px 0;
  font-size: 13px;
  color: #52b788;
  border-bottom: 1px solid #0f3460;
}

.summary-item:last-child {
  border-bottom: none;
}

/* Wizard input variants */
.input-token {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 16px;
  text-align: center;
  font-family: 'Consolas', 'Monaco', monospace;
  transition: border-color 0.2s;
}

/* Token input validation states */
.input-token.input-invalid {
  border-color: #e94560;
}

.input-token.input-valid {
  border-color: #52b788;
}

/* Validation indicator next to token input */
.token-validation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  min-height: 20px;
  transition: opacity 0.2s;
}

.token-validation.valid {
  color: #52b788;
}

.token-validation.invalid {
  color: #e94560;
}

.token-validation.empty {
  opacity: 0;
}

.input-lowercase {
  text-transform: lowercase;
}

.input-monospace {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
}

.btn-skip {
  background: transparent;
  color: #606060;
  border: 1px dashed #404040;
  border-radius: 6px;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.btn-skip:hover {
  border-color: #808080;
  color: #a0a0a0;
}

.summary-skipped {
  color: #606060 !important;
  font-style: italic;
}

.btn-dashboard-link {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  margin-top: 16px;
}

/* Settings page */
.settings-page {
  max-width: 960px;
  margin: 0 auto;
}

.settings-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
}

.settings-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.settings-card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #e0e0e0;
  margin: 0;
}

.settings-status {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: 500;
}

.status-configured {
  background: #1b4332;
  color: #52b788;
}

.status-skipped {
  background: #2a2a2a;
  color: #606060;
}

.status-unconfigured {
  background: #3d0000;
  color: #e94560;
}

.settings-desc {
  font-size: 13px;
  color: #808080;
  margin-bottom: 16px;
}

.settings-value {
  font-size: 14px;
  color: #52b788;
  font-family: 'Consolas', 'Monaco', monospace;
  background: #1a1a2e;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.settings-buttons {
  margin-top: 12px;
}

.settings-result {
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 6px;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.settings-result-success {
  background: #0d2818;
  border: 1px solid #2e7d32;
  color: #81c784;
}

.settings-result-error {
  background: #2d0a0a;
  border: 1px solid #c62828;
  color: #ef9a9a;
}

.settings-result-warning {
  background: #2d2400;
  border: 1px solid #f9a825;
  color: #ffe082;
}

.settings-info {
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  background: #0d1e2d;
  border: 1px solid #1a5276;
  color: #85c1e9;
}

.settings-info code {
  background: #16213e;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* Help button */
.btn-help {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1a1a2e;
  color: #808080;
  border: 1px solid #0f3460;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 8px;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

.btn-help:hover {
  border-color: #4895ef;
  color: #4895ef;
}

/* Help modal */
.help-modal {
  max-width: 580px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.help-content h3 {
  font-size: 20px;
  font-weight: 700;
  color: #e0e0e0;
  margin-bottom: 12px;
}

.help-content .help-desc {
  font-size: 13px;
  color: #808080;
  line-height: 1.6;
  margin-bottom: 16px;
}

.help-content .help-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #a0a0a0;
  margin-bottom: 8px;
}

.help-content ul {
  list-style: disc;
  padding-left: 20px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #a0a0a0;
  line-height: 1.8;
}

.help-content ol {
  padding-left: 20px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #a0a0a0;
  line-height: 1.8;
}

.help-content .help-note {
  font-size: 13px;
  color: #808080;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* Device card enhancements */
.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.conn-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-indicator.connected {
  background: #52b788;
  box-shadow: 0 0 4px #52b788;
}

.conn-indicator.offline {
  border: 2px solid #e94560;
  background: transparent;
}

.device-card-offline {
  opacity: 0.5;
  cursor: default !important;
}

.device-card-offline:hover {
  border-color: #0f3460 !important;
  transform: none !important;
}

.device-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.device-group-badge {
  background: #1b3a4b;
  color: #63b3ed;
}

.device-offline-badge {
  background: #3d0000;
  color: #e94560;
}

.device-group-label {
  font-size: 12px;
  letter-spacing: 0.5px;
  color: #606060;
  padding: 8px 0 4px;
  grid-column: 1 / -1;
}

.btn-device-edit {
  margin-left: auto;
  border: none !important;
  background: transparent !important;
  color: #606060 !important;
  font-size: 14px !important;
  padding: 2px 6px !important;
  cursor: pointer;
}

.btn-device-edit:hover {
  color: #4895ef !important;
}

/* Device label colors (CSP-safe: data-attribute selectors instead of inline styles) */
.device-card[data-label-color="#e94560"] { border-left: 3px solid #e94560; }
.device-card[data-label-color="#52b788"] { border-left: 3px solid #52b788; }
.device-card[data-label-color="#63b3ed"] { border-left: 3px solid #63b3ed; }
.device-card[data-label-color="#b794f4"] { border-left: 3px solid #b794f4; }
.device-card[data-label-color="#f4a261"] { border-left: 3px solid #f4a261; }
.device-card[data-label-color="#e0e0e0"] { border-left: 3px solid #e0e0e0; }

/* Battery display */
.battery-line span { display: inline !important; }
.battery-high { color: #52b788; }
.battery-mid { color: #f4a261; }
.battery-low { color: #e94560; }

.charging-icon::after {
  content: '\26A1';
  margin-left: 2px;
}

/* Serial number */
.serial-line {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  opacity: 0.6;
}

/* Color swatches for device edit */
.color-swatches {
  display: flex;
  gap: 8px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px #4895ef;
}

.color-swatch:hover {
  transform: scale(1.15);
}

/* Swatch preset backgrounds (CSP-safe: no inline styles) */
.swatch-none { background: transparent; border: 1px dashed #606060; }
.swatch-e94560 { background: #e94560; }
.swatch-52b788 { background: #52b788; }
.swatch-63b3ed { background: #63b3ed; }
.swatch-b794f4 { background: #b794f4; }
.swatch-f4a261 { background: #f4a261; }
.swatch-e0e0e0 { background: #e0e0e0; }

/* Form textarea */
.form-group textarea {
  background: #1a1a2e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 10px 12px;
  color: #e0e0e0;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.form-group textarea:focus {
  outline: none;
  border-color: #4895ef;
}

/* Disconnect overlay */
.disconnect-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: 8px;
}

.disconnect-message {
  text-align: center;
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.disconnect-message p {
  font-size: 16px;
}

/* Input with suffix (for .duckdns.org) */
.input-with-suffix {
  display: flex;
  align-items: center;
}

.input-with-suffix input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  flex: 1;
}

.input-suffix {
  background: #0f3460;
  border: 1px solid #0f3460;
  border-left: none;
  border-radius: 0 6px 6px 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #808080;
  white-space: nowrap;
}

/* Recording indicator */
.recording-active {
  background: #e94560 !important;
  color: #fff !important;
  border-color: #e94560 !important;
  animation: recording-pulse 1.5s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Clipboard modal */
.clipboard-modal {
  max-width: 480px;
}

.clipboard-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.clipboard-warning {
  color: #e65100;
  font-size: 12px;
  margin-top: 2px;
}

/* File browser modal */
.file-browser-modal {
  max-width: 640px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.file-browser-modal .file-table {
  display: block;
  max-height: 50vh;
  overflow-y: auto;
}

.file-browser-modal .file-table thead,
.file-browser-modal .file-table tbody {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.file-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  font-size: 13px;
  color: #808080;
  overflow-x: auto;
  white-space: nowrap;
}

.file-breadcrumb-segment {
  cursor: pointer;
  color: #63b3ed;
  background: none;
  border: none;
  font-size: 13px;
  font-family: inherit;
  padding: 2px 4px;
  border-radius: 3px;
}

.file-breadcrumb-segment:hover {
  background: #0f3460;
}

.file-breadcrumb-sep {
  color: #606060;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}

.file-table th,
.file-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #0f3460;
}

.file-table th {
  font-size: 11px;
  color: #808080;
  text-transform: uppercase;
  font-weight: 500;
}

.file-table tr {
  cursor: pointer;
}

.file-table tr:hover {
  background: #0f3460;
}

.file-table tr.selected {
  background: #1b3a4b;
}

.file-icon {
  margin-right: 6px;
}

.file-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-error {
  background: #3d0000;
  color: #e94560;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 8px;
}

.file-loading {
  text-align: center;
  padding: 24px;
  color: #808080;
}

.file-success {
  background: #1b4332;
  color: #52b788;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 8px;
}

.file-empty {
  text-align: center;
  color: #808080;
  font-style: italic;
}

/* Canvas touch handling */
#video-canvas,
.panel-canvas {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Prevent pull-to-refresh on stream view */
#multi-view-container {
  overscroll-behavior: none;
}

/* Responsive: Tablet (768px and below) */
@media (max-width: 768px) {
  .stream-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .stream-controls {
    margin-left: 0;
    width: 100%;
  }

  .stream-controls-row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Multi-view: max 2 panels on tablet */
  #select-layout option[value="3"],
  #select-layout option[value="4"] {
    display: none;
  }

  header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-right {
    flex-wrap: wrap;
    gap: 8px;
  }

  main {
    padding: 12px;
  }

  .modal-content {
    max-width: 100%;
    margin: 12px;
    padding: 20px;
  }

  .wizard-card {
    max-width: 100%;
    padding: 24px;
  }

  .auth-card {
    max-width: 100%;
  }
}

/* Responsive: Phone (480px and below) */
@media (max-width: 480px) {
  header {
    padding: 8px 12px;
  }

  header h1 {
    font-size: 16px;
  }

  .stream-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stream-controls-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .stream-controls-row button,
  .stream-controls-row select {
    font-size: 12px;
    padding: 6px 8px;
  }

  /* Multi-view: force single on phone */
  #select-layout {
    display: none;
  }

  #device-name {
    font-size: 14px;
  }

  #device-info {
    font-size: 11px;
  }

  .device-card {
    padding: 12px;
  }

  .device-card .device-model {
    font-size: 16px;
  }

  .file-browser-modal {
    max-width: 100%;
    padding: 16px;
  }

  .file-table {
    font-size: 12px;
  }

  .file-table th:nth-child(3),
  .file-table td:nth-child(3) {
    display: none;
  }
}

/* Fullscreen recording badge — always visible in top-left corner */
#fs-recording-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(200, 0, 0, 0.85);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 30;
  pointer-events: none;
  animation: fs-rec-pulse 1.2s ease-in-out infinite;
}

@keyframes fs-rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Fullscreen control overlay button */
#btn-fullscreen-control {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(22, 33, 62, 0.7);
  color: #fff;
  border: 1px solid rgba(79, 149, 239, 0.4);
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-family: inherit;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.3s;
}

#btn-fullscreen-control:hover,
#btn-fullscreen-control:active {
  background: rgba(22, 33, 62, 0.9);
}

#btn-fullscreen-control.control-active-hover:hover {
  background: rgba(231, 76, 60, 0.3);
  border-color: #e74c3c;
  color: #e74c3c;
}

#btn-fullscreen-control.fs-fade {
  opacity: 0;
  pointer-events: none;
}

#multi-view-container:fullscreen #btn-fullscreen-control.fs-visible {
  display: block;
}

/* Fullscreen adjustments */
#multi-view-container:fullscreen {
  border-radius: 0;
}

#multi-view-container:fullscreen .panel-canvas {
  max-width: 100%;
  max-height: 100%;
}

#multi-view-container:fullscreen .stream-stats {
  bottom: 16px;
  right: 16px;
  font-size: 14px;
}

/* Fullscreen tray toggle button */
#btn-fs-tray-toggle {
  position: absolute;
  top: 8px;
  left: calc(50% + 90px);
  z-index: 59;
  background: rgba(22, 33, 62, 0.7);
  color: #fff;
  border: 1px solid rgba(79, 149, 239, 0.4);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  min-height: 36px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.3s;
}

#btn-fs-tray-toggle:hover,
#btn-fs-tray-toggle:active {
  background: rgba(22, 33, 62, 0.9);
}

#btn-fs-tray-toggle.fs-fade {
  opacity: 0;
  pointer-events: none;
}

#multi-view-container:fullscreen #btn-fs-tray-toggle.fs-visible {
  display: block;
}

/* Fullscreen tray container */
#fs-tray {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 59;
  background: rgba(22, 33, 62, 0.85);
  border: 1px solid rgba(79, 149, 239, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#fs-tray.fs-tray-open {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#multi-view-container:fullscreen #fs-tray.fs-visible {
  display: flex;
}

.fs-tray-btn {
  width: 40px;
  height: 40px;
  background: rgba(22, 33, 62, 0.7);
  color: #fff;
  border: 1px solid rgba(79, 149, 239, 0.4);
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s, opacity 0.2s;
}

.fs-tray-btn:hover {
  background: rgba(22, 33, 62, 0.95);
}

.fs-tray-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.fs-tray-btn.recording-active {
  background: #e94560;
  border-color: #e94560;
  animation: recording-pulse 1.5s ease-in-out infinite;
}

.fs-tray-select {
  height: 40px;
  background: rgba(22, 33, 62, 0.7);
  color: #fff;
  border: 1px solid rgba(79, 149, 239, 0.4);
  border-radius: 6px;
  font-size: 12px;
  padding: 0 8px;
  cursor: pointer;
  font-family: inherit;
}

.fs-tray-select:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Blind Unlock modal */
.unlock-modal {
  max-width: 400px;
}

.unlock-note {
  font-size: 13px;
  color: #808080;
  margin-bottom: 16px;
  line-height: 1.5;
}

.unlock-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid #0f3460;
  border-radius: 6px;
  overflow: hidden;
}

.unlock-tab {
  flex: 1;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  background: #1a1a2e;
  color: #808080;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.unlock-tab + .unlock-tab {
  border-left: 1px solid #0f3460;
}

.unlock-tab.active {
  background: #4895ef;
  color: #fff;
}

.unlock-tab:hover:not(.active) {
  background: #16213e;
  color: #e0e0e0;
}

.unlock-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.numpad-btn {
  padding: 14px 0;
  font-size: 20px;
  font-family: inherit;
  font-weight: 600;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  min-height: 48px;
}

.numpad-btn:hover {
  background: #16213e;
  border-color: #4895ef;
}

.numpad-btn:active {
  background: #4895ef;
  color: #fff;
}

.numpad-clear {
  color: #e94560;
}

.numpad-back {
  font-size: 18px;
}

.unlock-submit {
  width: 100%;
  margin-top: 8px;
}

/* VPN tables in settings */
.vpn-table {
  width: 100%;
  border-collapse: collapse;
  background: #16213e;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
  font-size: 13px;
}

.vpn-table th,
.vpn-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #0f3460;
}

.vpn-table th {
  font-size: 11px;
  color: #808080;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.vpn-table tr:last-child td {
  border-bottom: none;
}

.vpn-status-online {
  color: #4ade80;
}

.vpn-status-offline {
  color: #808080;
}

.group-select-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.group-select-row select {
  flex: 1;
}

.btn-group-delete {
  padding: 4px 8px !important;
  font-size: 14px !important;
}

.vpn-row-dimmed {
  opacity: 0.5;
}

#vpn-nodes h4,
#vpn-keys h4 {
  font-size: 14px;
  margin: 16px 0 8px;
  color: #c0c0c0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-link {
  background: none;
  border: none;
  color: #4895ef;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: #6bb3ff;
}

.btn-expire {
  background: none;
  border: 1px solid #e94560;
  color: #e94560;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.btn-expire:hover {
  background: #e94560;
  color: #fff;
}

.btn-delete-key {
  background: none;
  border: 1px solid #808080;
  color: #808080;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.btn-delete-key:hover {
  background: #808080;
  color: #fff;
}

.btn-delete-node {
  background: none;
  border: 1px solid #808080;
  color: #808080;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.btn-delete-node:hover {
  background: #808080;
  color: #fff;
}

.vpn-key-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
}

.vpn-key-row .vpn-key-pre {
  flex: 1;
  margin: 0;
}

.btn-copy {
  background: #2a2a2e;
  border: 1px solid #444;
  color: #ccc;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
}

.btn-copy:hover {
  background: #3a3a3e;
  color: #fff;
}

.vpn-enrollment-status {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}

.vpn-enrollment-status.waiting {
  background: #3d3514;
  color: #facc15;
  animation: enrollment-pulse 2s ease-in-out infinite;
}

.vpn-enrollment-status.enrolled {
  background: #1a3d2a;
  color: #4ade80;
}

@keyframes enrollment-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.vpn-qr-code {
  display: block;
  margin: 8px 0 12px;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  max-width: 280px;
}

.vpn-note {
  font-size: 12px;
  color: #808080;
  margin: 4px 0;
}
