:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel-2: #1f252e;
  --border: #2a313c;
  --text: #e6e9ee;
  --muted: #8b95a5;
  --accent: #e5484d;
  --accent-hover: #f05a5f;
  --ok: #3dd68c;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input, select { font: inherit; color: inherit; }

.connect {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 16px;
}

.card h1 {
  margin: 0;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  box-shadow: inset -7px -7px 0 rgba(0, 0, 0, .25);
}

.lead { margin: 0; color: var(--muted); }

label { display: grid; gap: 6px; font-weight: 500; }
label small { color: var(--muted); font-weight: 400; }

input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus { border-color: var(--accent); }
#remote-id { font-size: 20px; letter-spacing: .06em; font-variant-numeric: tabular-nums; }

button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button[type=submit] {
  background: var(--accent);
  border-color: var(--accent);
  padding: 11px;
  font-weight: 600;
  color: #fff;
}
button[type=submit]:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: default; }
button.danger { color: #ff8a8d; }

.status { margin: 0; min-height: 1.4em; color: var(--muted); }
.status.error { color: #ff8a8d; }

.session { position: fixed; inset: 0; background: #000; }

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  outline: none;
  cursor: default;
}

#screen {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.toolbar {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translate(-50%, 0);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 6px;
  background: rgba(23, 27, 34, .92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  transition: transform .2s ease, opacity .2s ease;
  z-index: 2;
}
.toolbar.hidden { transform: translate(-50%, calc(-100% + 6px)); opacity: .35; }
.toolbar button, .toolbar select { padding: 5px 10px; font-size: 13px; }
.toolbar select { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }

.peer { padding: 0 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.peer::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  min-width: 200px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.menu button { background: none; border: 0; text-align: left; }
.menu button:hover { background: var(--panel-2); }

.stats {
  position: absolute;
  left: 8px;
  bottom: 8px;
  margin: 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, .75);
  border-radius: 8px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
  z-index: 2;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
  z-index: 1;
}
.overlay[hidden] { display: none; }

.files {
  position: absolute;
  top: 60px;
  right: 8px;
  bottom: 8px;
  width: min(420px, calc(100% - 16px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 3;
  font-size: 13px;
}
.files-bar { display: flex; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid var(--border); }
.files-bar button, .files-bar .upload { padding: 4px 9px; font-size: 13px; }
.upload { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.files-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.files-list, .files-transfers { list-style: none; margin: 0; padding: 4px; overflow: auto; }
.files-list { flex: 1; }
.files-transfers { max-height: 30%; border-top: 1px solid var(--border); }
.files-list li, .files-transfers li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: default; white-space: nowrap; overflow: hidden; }
.files-list li:hover { background: var(--panel-2); }
.muted { color: var(--muted); }
.muted.error { color: #ff8a8d; }
