:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #181d24;
  --panel-2: #222936;
  --line: #343d4e;
  --text: #f2f5f8;
  --muted: #a7b0bf;
  --accent: #47c78e;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.user-bar {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--muted); margin-top: 4px;
}
.user-bar a { color: var(--accent); text-decoration: none; cursor: pointer; }
.user-bar a:hover { text-decoration: underline; }

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.host-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.host-list-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: var(--panel-2);
  font-size: 12px; color: var(--muted); cursor: pointer;
  user-select: none;
}
.host-list-header:hover { background: #2a3240; }
.host-count {
  background: var(--accent); color: #07120d;
  border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.host-list-body { max-height: 180px; overflow-y: auto; }
.host-list-body:empty::after {
  content: "暂无在线主机"; display: block;
  padding: 16px; text-align: center;
  color: var(--muted); font-size: 12px;
}
.host-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-top: 1px solid var(--line); transition: background 0.1s;
}
.host-item:hover { background: var(--panel-2); }
.host-item .host-name { color: var(--text); font-weight: 600; }
.host-item .host-room { color: var(--muted); font-size: 11px; }
.host-item .host-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-right: 8px;
}
.host-item .host-dot.online { background: var(--accent); }
.host-item .host-dot.offline { background: var(--line); }

.connect,
.controls {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

textarea {
  width: 100%;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
  resize: vertical;
}

input:focus {
  border-color: var(--accent);
}

textarea:focus {
  border-color: var(--accent);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #07120d;
  font-weight: 700;
  cursor: pointer;
}

button.secondary,
#disconnect {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.active {
  background: var(--accent);
  color: #07120d;
  border-color: var(--accent);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.dot.online {
  background: var(--accent);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
}

.stat-label {
  color: var(--muted);
}

.stat-value {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
}

.check input {
  min-height: auto;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.upload-progress {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.upload-progress progress {
  width: 100%;
  height: 6px;
  border-radius: 3px;
}

.upload-progress progress::-webkit-progress-bar {
  background: var(--panel-2);
  border-radius: 3px;
}

.upload-progress progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 3px;
}

.viewer {
  display: grid;
  min-width: 0;
  padding: 20px;
}

.screen-wrap {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07090d;
}

.screen-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

#screen {
  display: none;
  max-width: 100%;
  max-height: calc(100vh - 42px);
  user-select: none;
  cursor: none;
}

.screen-wrap:fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen-wrap:fullscreen #screen {
  max-width: none;
  max-height: none;
}

.empty {
  color: var(--muted);
}

#cursorLayer {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  display: none;
  width: 0;
  height: 0;
  border-left: 10px solid #fff;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

#imeInput {
  position: absolute;
  width: 1px;
  height: 1px;
  left: 50%;
  top: 50%;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  pointer-events: none;
  clip-path: inset(50%);
}

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; width: 380px;
  display: grid; gap: 12px;
}
.modal h2 { margin: 0; font-size: 18px; color: var(--text); }
.modal .error-msg { display: none; color: var(--danger); font-size: 12px; margin: 0; }
.modal .error-msg.show { display: block; }

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #screen {
    max-height: 65vh;
  }
}
