:root {
  --bg-dark: #0f1117;
  --bg-toolbar: #161922;
  --bg-card: #1e2230;
  --border-color: #2a3042;
  --text-main: #e6e9f0;
  --text-muted: #949cb0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 13px;
}

body {
  display: flex;
  flex-direction: column;
}

/* Toolbar */
.toolbar {
  height: 44px;
  min-height: 44px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 10px;
  z-index: 30;
  user-select: none;
}

.toolbar.hidden {
  display: none;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.brand-icon {
  color: var(--accent);
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.status-badge.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-badge.connecting .status-dot {
  background: var(--warning);
}

.status-badge.disconnected .status-dot {
  background: var(--danger);
}

/* URL Bar */
.url-form {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.url-input {
  flex: 1;
  height: 28px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s;
}

.url-input:focus {
  border-color: var(--accent);
}

/* Buttons & Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-main);
  background: var(--bg-card);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #282d40;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
}

.btn-icon {
  width: 28px;
  padding: 0;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #262b3d;
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: #30374f;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-color);
}

.btn-ghost.active {
  background: rgba(59, 130, 246, 0.16);
  border-color: var(--accent);
  color: #60a5fa;
}

.btn-danger-ghost {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
}

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

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

.select-control {
  height: 28px;
  background: var(--bg-dark);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* Clipboard Popover */
.popover-wrapper {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.popover.hidden {
  display: none;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-title {
  font-weight: 600;
  font-size: 12.5px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
}

.clipboard-textarea {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
  outline: none;
}

.clipboard-textarea:focus {
  border-color: var(--accent);
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Floating Restore Toolbar Button */
.floating-restore {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(22, 25, 34, 0.85);
  backdrop-filter: blur(6px);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-size: 11.5px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s;
}

.floating-restore:hover {
  opacity: 1;
}

.floating-restore.hidden {
  display: none;
}

/* Main Viewport */
.viewport-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: auto;
  background: #08090c;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vnc-screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 23, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(59, 130, 246, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: 92%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 16px;
  margin-bottom: 8px;
}

.modal-desc {
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #1e2436;
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 300;
  font-size: 12.5px;
  transition: opacity 0.2s ease;
}

.toast.hidden {
  display: none;
}

