:root {
  --bg: #0f1117;
  --surface: #171b24;
  --surface-2: #1f2533;
  --border: #2c3446;
  --text: #e8ecf4;
  --muted: #9aa5bc;
  --primary: #ef443b;
  --primary-hover: #d8362d;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #22c55e;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

/* LOGIN */
.login-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 15%, #1d2232 0%, #0f1117 60%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 26px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.3px;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.server-pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.server-pill.online {
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
  background: rgba(34, 197, 94, 0.08);
}

.server-pill.offline {
  border-color: rgba(239, 68, 59, 0.4);
  color: #fca5a5;
  background: rgba(239, 68, 59, 0.08);
}

/* ONLINE DEVICES QUICK-PICKER */
.devices-box {
  margin-bottom: 16px;
}

.devices-title {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.devices-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-chip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.device-chip:hover {
  border-color: #4b556b;
  background: #283042;
}

.device-chip.selected {
  border-color: var(--primary);
  background: rgba(239, 68, 59, 0.12);
}

.device-chip-name {
  font-size: 13px;
  font-weight: 600;
}

.device-chip-id {
  font-size: 11.5px;
  color: #86efac;
  font-family: ui-monospace, Consolas, monospace;
}

.tb-btn.switch-btn.has-peers {
  border-color: rgba(37, 99, 235, 0.7);
  background: rgba(37, 99, 235, 0.18);
  color: #bfdbfe;
}

.tb-btn.audio-btn.active {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.dropdown-menu.wide-menu {
  min-width: 280px;
}

.switch-empty {
  padding: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
  white-space: normal;
}

.switch-section-title {
  padding: 5px 10px 3px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.field input[type="text"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-wrap input {
  padding-right: 40px;
}

.icon-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  padding: 4px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  cursor: pointer;
}

.error-box {
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.primary-btn, .accent-btn {
  width: 100%;
  padding: 11px 16px;
  border-radius: 8px;
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
  display: inline-block;
}

.primary-btn {
  background: var(--primary);
}
.primary-btn:hover { background: var(--primary-hover); }
.primary-btn:disabled { opacity: 0.6; cursor: wait; }

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

.primary-btn.sm, .accent-btn.sm {
  padding: 8px 12px;
  font-size: 13px;
  width: auto;
}

.login-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* SESSION VIEW */
.session-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.toolbar {
  height: 46px;
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
}

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

.tb-brand {
  font-weight: 700;
  color: var(--primary);
  font-size: 15px;
  margin-right: 2px;
}

.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.stats-pill {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 8px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.tb-btn, .tb-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  cursor: pointer;
  outline: none;
}

.tb-btn:hover, .tb-select:hover {
  border-color: #4b556b;
  background: #283042;
}

.tb-btn.danger {
  background: rgba(220, 38, 38, 0.16);
  border-color: rgba(220, 38, 38, 0.45);
  color: #fca5a5;
}
.tb-btn.danger:hover {
  background: var(--danger);
  color: #fff;
}
.tb-btn.xs {
  padding: 3px 8px;
  font-size: 11.5px;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: fixed;
  top: 48px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px;
  z-index: 60;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-menu button {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.dropdown-menu button:hover {
  background: var(--surface-2);
}

.dropdown-menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* CANVAS VIEWPORT */
.canvas-container {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  background: #07090d;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline: none;
  user-select: none;
  touch-action: none;
}

.canvas-container.actual-size {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  touch-action: auto;
}

#screenCanvas {
  display: block;
  margin: auto;
  flex-shrink: 0;
  background: #000;
  box-shadow: 0 0 36px rgba(0, 0, 0, 0.75);
  cursor: default;
  image-rendering: auto;
}

/* FULLSCREEN AUTO-HIDE TOOLBAR */
.fs-hotzone {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  padding: 2px 14px 4px;
  background: rgba(23, 27, 36, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-top: none;
  border-radius: 0 0 10px 10px;
  color: #cbd5e1;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s;
}
.fs-hotzone:hover {
  opacity: 1;
}

body.is-fullscreen .toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 65;
  transform: translateY(-100%);
  transition: transform 0.2s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.55);
}

body.is-fullscreen .toolbar.revealed {
  transform: translateY(0);
}

body.is-fullscreen .drawer {
  top: 0;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 18, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.overlay-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* DRAWERS */
.drawer {
  position: fixed;
  top: 46px;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 96vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.5);
}

.drawer.wide {
  width: 560px;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  margin: 0;
  font-size: 15px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 8px;
}
.close-btn:hover { color: var(--text); }

.drawer-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
}

.hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.inline-row {
  display: flex;
  gap: 6px;
}

/* FILE EXPLORER */
.fs-toolbar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.fs-path {
  flex: 1;
  min-width: 80px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 9px;
  font-size: 12.5px;
  outline: none;
}

.fs-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.upload-label {
  cursor: pointer;
}

.transfer-box {
  padding: 10px 12px;
  background: rgba(37, 99, 235, 0.1);
  border-bottom: 1px solid rgba(37, 99, 235, 0.35);
}

.transfer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  margin-bottom: 6px;
}

.progress-track {
  height: 7px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s;
}

.transfer-detail {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.fs-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
}

.fs-list-wrap.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: -6px;
  background: rgba(239, 68, 59, 0.08);
}

.fs-empty {
  text-align: center;
  padding: 30px;
  color: var(--muted);
}

.fs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fs-table th {
  text-align: left;
  padding: 7px 6px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.fs-table td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(44, 52, 70, 0.5);
  vertical-align: middle;
}

.fs-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.fs-name-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-size: 13px;
  word-break: break-all;
}

.fs-name-btn.dir {
  color: #93c5fd;
  font-weight: 500;
}

.col-size {
  width: 85px;
  color: var(--muted);
  white-space: nowrap;
}

.col-act {
  width: 88px;
  text-align: right;
}

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #f9fafb;
  border: 1px solid #374151;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
