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

html, body { height: 100%; }

body {
  background: #0d1117;
  color: #e6edf3;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

#login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

#login form {
  background: #161b22;
  border: 1px solid #30363d;
  padding: 32px;
  border-radius: 10px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#login h1 { font-size: 20px; font-weight: 700; }

#login input {
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 14px;
}

#login input:focus { outline: none; border-color: #58a6ff; }

#login button {
  padding: 10px;
  background: #238636;
  color: #fff;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

#login button:hover { background: #2ea043; }

#login-error { color: #f85149; font-size: 13px; min-height: 16px; }

#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  font-size: 13px;
}

#status {
  padding: 3px 10px;
  border-radius: 20px;
  background: #21262d;
  color: #8b949e;
  font-weight: 600;
}

#status.on { background: rgba(31, 111, 235, 0.25); color: #58a6ff; }
#status.off { background: rgba(248, 81, 73, 0.2); color: #f85149; }

#info { color: #8b949e; }

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-controls button {
  width: 28px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  cursor: pointer;
  font-size: 15px;
}

.zoom-controls button:hover { background: #30363d; }

#zoom-label {
  color: #8b949e;
  font-size: 12px;
  min-width: 42px;
  text-align: center;
}

#toolbar button {
  margin-left: auto;
  padding: 5px 12px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  cursor: pointer;
  font-size: 13px;
}

#toolbar button:hover { background: #30363d; }

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: none;
  outline: none;
}

#screen, #cursor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#screen {
  touch-action: none;
}

#cursor { pointer-events: none; }

#no-agent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b949e;
  font-size: 18px;
  pointer-events: none;
}

#controls-toggle {
  font-weight: 600;
}

#device-select {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 13px;
  padding: 5px 8px;
  max-width: 180px;
}

#panel button.danger {
  background: rgba(248, 81, 73, 0.15);
  border-color: rgba(248, 81, 73, 0.4);
  color: #f85149;
}

#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 94vw;
  background: #161b22;
  border-left: 1px solid #30363d;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  z-index: 20;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 16px;
  cursor: pointer;
}

#panel-close:hover { color: #e6edf3; background: #21262d; }

#panel section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b949e;
  margin-bottom: 8px;
}

#panel .kv {
  font-size: 13px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0 0 10px;
}

#panel .kv dt { color: #8b949e; }
#panel .kv dd { margin: 0; text-align: right; word-break: break-all; }

#panel .btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#panel .row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

#panel button {
  padding: 7px 12px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  cursor: pointer;
  font-size: 13px;
}

#panel button:hover:not(:disabled) { background: #30363d; }
#panel button:disabled { opacity: 0.5; cursor: default; }

#panel input[type="search"] {
  flex: 1;
  padding: 7px 10px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 13px;
}

#panel input[type="search"]:focus { outline: none; border-color: #58a6ff; }

#panel select,
#panel textarea {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 13px;
  padding: 7px 10px;
}

#panel select { flex: 1; }

#panel select:focus,
#panel textarea:focus { outline: none; border-color: #58a6ff; }

#panel textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 6px;
}

#panel textarea[rows] { min-height: 42px; }

.output {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 10px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #e6edf3;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 5px;
  background: #0d1117;
  font-size: 12px;
}

.file-row:hover { background: #21262d; }

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.file-size { color: #8b949e; white-space: nowrap; }

.file-actions { display: flex; gap: 4px; }

.file-actions button {
  padding: 2px 8px !important;
  font-size: 11px !important;
}

.shot {
  max-width: 100%;
  margin-top: 8px;
  border: 1px solid #30363d;
  border-radius: 6px;
}

a#shot-download { color: #58a6ff; font-size: 13px; }

#proc-list {
  max-height: 40vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: #8b949e;
}

.proc-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 5px;
  background: #0d1117;
}

.proc-row:hover { background: #21262d; }

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

.proc-pid { color: #8b949e; white-space: nowrap; }

.proc-kill {
  padding: 3px 10px !important;
  background: rgba(248, 81, 73, 0.15) !important;
  border-color: rgba(248, 81, 73, 0.4) !important;
  color: #f85149 !important;
}

.proc-kill:hover:not(:disabled) { background: rgba(248, 81, 73, 0.3) !important; }
