:root {
  --bg: #f4f1eb;
  --bg-soft: #fbfaf7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --surface-muted: #f1ede6;
  --border: rgba(34, 34, 34, 0.1);
  --border-strong: rgba(34, 34, 34, 0.16);
  --text: #171513;
  --muted: #726c64;
  --button: #2b2927;
  --button-hover: #1f1d1c;
  --button-text: #faf8f4;
  --accent: #0f766e;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(28, 28, 28, 0.08);
  --shadow-soft: 0 14px 40px rgba(28, 28, 28, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow: hidden;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34, 34, 34, 0.05), transparent 30%),
    linear-gradient(180deg, #fcfbf8 0%, #f4f1eb 52%, #ece7df 100%);
}

button,
input {
  font: inherit;
}

.viewer-app,
.viewer-stage,
.viewer-shell {
  min-height: 100vh;
  height: 100vh;
}

.viewer-app {
  position: relative;
  isolation: isolate;
}

.viewer-controls {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.status-anchor {
  position: relative;
}

.status-indicator,
.files-fab {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--button-text);
  background: rgba(43, 41, 39, 0.94);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.status-indicator::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
}

.status-indicator[data-state="connected"]::before {
  background: var(--accent);
}

.status-indicator:hover,
.files-fab:hover {
  transform: translateY(-1px);
  background: var(--button-hover);
  border-color: rgba(255, 255, 255, 0.92);
}

.status-tooltip {
  position: absolute;
  top: 50%;
  right: calc(100% + 10px);
  transform: translateY(-50%);
  max-width: min(42vw, 320px);
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-soft);
  transition: opacity 120ms ease;
}

.status-anchor:hover .status-tooltip,
.status-anchor:focus-within .status-tooltip {
  opacity: 1;
}

.files-fab svg {
  width: 16px;
  height: 16px;
}

.viewer-stage {
  position: relative;
  width: 100vw;
  padding: 0;
}

.viewer-shell {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 100vw;
  min-height: 100vh;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 242, 235, 0.94)),
    linear-gradient(135deg, rgba(34, 34, 34, 0.04), transparent 50%);
  box-shadow: var(--shadow);
}

#remote-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  outline: none;
  cursor: crosshair;
  background: #111111;
  border-radius: 0;
  box-shadow: 0 20px 55px rgba(17, 17, 17, 0.16);
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
  padding: 32px;
  background: linear-gradient(180deg, rgba(251, 250, 247, 0.82), rgba(244, 241, 235, 0.92));
  transition: opacity 180ms ease;
}

.video-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#overlay-title,
#overlay-subtitle {
  margin: 0;
}

#overlay-title {
  font-size: clamp(26px, 3vw, 40px);
  font-weight: 600;
  letter-spacing: -0.03em;
}

#overlay-subtitle {
  max-width: 560px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.token-input {
  min-width: 0;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface-strong);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.token-input:focus {
  outline: none;
  border-color: rgba(43, 41, 39, 0.3);
  box-shadow: 0 0 0 4px rgba(43, 41, 39, 0.08);
}

.toggle-button,
.topbar-toggle,
.files-download {
  border: 1px solid var(--button);
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button);
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    opacity 140ms ease;
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.12);
}

.toggle-button:hover,
.topbar-toggle:hover,
.files-download:hover {
  transform: translateY(-1px);
  background: var(--button-hover);
  border-color: var(--button-hover);
}

.toggle-button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.toggle-button.active {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    0 10px 24px rgba(17, 17, 17, 0.16);
}

.toggle-button.secondary {
  background: #383533;
  border-color: #383533;
}

.toggle-button.slim,
.topbar-toggle {
  padding: 6px 10px;
  font-size: 11px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(247, 243, 236, 0.72);
  backdrop-filter: blur(12px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.auth-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-form {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 243, 236, 0.96)),
    linear-gradient(135deg, rgba(34, 34, 34, 0.04), transparent 52%);
  box-shadow: var(--shadow);
}

.auth-prompt,
.auth-message {
  margin: 0;
}

.auth-prompt {
  margin-bottom: 18px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.auth-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.auth-message {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-message.error {
  color: var(--danger);
}

@media (max-width: 900px) {
  .status-tooltip {
    max-width: min(56vw, 280px);
  }
}

@media (max-width: 720px) {
  .viewer-stage {
    padding: 0;
  }

  .viewer-shell {
    min-height: 100vh;
    border-radius: 0;
  }

  #remote-canvas {
    border-radius: 0;
  }

  .auth-form {
    padding: 22px;
    border-radius: 22px;
  }

  .auth-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .viewer-controls {
    top: 8px;
    right: 8px;
  }

  .status-tooltip {
    right: 0;
    top: calc(100% + 8px);
    transform: none;
    white-space: normal;
  }
}

/* --- Shared folder panel --- */
.files-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(420px, 92vw);
  height: 100vh;
  padding: 22px 18px 18px;
  gap: 14px;
  background: rgba(251, 250, 247, 0.96);
  border-left: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: -18px 0 50px rgba(28, 28, 28, 0.08);
  backdrop-filter: blur(12px);
  transition: transform 0.18s ease;
  border-radius: 0;
}

.files-panel.hidden {
  transform: translateX(105%);
  pointer-events: none;
}

.files-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.files-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.files-dir {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.files-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.files-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(34, 34, 34, 0.18);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.76);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.files-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
  color: var(--text);
}

.files-dropzone p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.files-transfers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 30vh;
  overflow-y: auto;
}

.files-transfer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  font-size: 12px;
}

.files-transfer-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.files-transfer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-transfer-state {
  color: var(--muted);
  flex-shrink: 0;
}

.files-transfer.error .files-transfer-state {
  color: var(--danger);
}

.files-progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(34, 34, 34, 0.08);
  overflow: hidden;
}

.files-progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--button);
  transition: width 0.12s ease;
}

.files-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.files-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border);
}

.files-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.files-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-item-meta {
  color: var(--muted);
  font-size: 11px;
}

.files-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
  list-style: none;
}

.files-download {
  flex-shrink: 0;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 16px;
  display: grid;
  place-items: center;
}
