:root {
  color-scheme: dark;
  --bg: #0d1014;
  --surface: #151a20;
  --panel: #1d232a;
  --panel-strong: #27303a;
  --text: #edf2f7;
  --muted: #96a3b3;
  --line: #323c48;
  --accent: #35c28a;
  --accent-2: #58a6ff;
  --danger: #f07178;
  --warning: #ffd166;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #06110d;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1419;
  color: var(--text);
  min-height: 40px;
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent-2);
}

.view[hidden],
.hidden-input {
  display: none !important;
}

.view {
  min-height: 100vh;
}

.auth-view {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #06110d;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-card label,
.panel label,
.panel-title,
.path-dialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.auth-card label:not(:first-of-type) {
  margin-top: 14px;
}

.path-dialog label:not(:first-of-type) {
  margin-top: 12px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.auth-download {
  width: 100%;
  margin-top: 10px;
}

.auth-status,
.dashboard-status,
.transfer-status {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.auth-status {
  margin-top: 10px;
}

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

.secondary-auth,
.ghost,
.toolbar-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.cabinet-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.cabinet-header {
  min-height: 78px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.cabinet-header .brand {
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  min-width: 92px;
  text-align: center;
  padding: 7px 12px;
}

.status-pill.online {
  border-color: rgba(53, 194, 138, 0.45);
  color: var(--accent);
}

.cabinet-grid {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 26px 24px;
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  align-content: start;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.connect-line {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.connect-line input {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  font-size: 18px;
}

.connect-line button {
  width: 100%;
  min-height: 42px;
  padding-inline: 12px;
  white-space: nowrap;
}

#deleteDeviceButton {
  grid-column: 1 / -1;
}

.connect-panel {
  height: fit-content;
}

.dashboard-status {
  margin-top: 10px;
}

.devices-panel {
  min-height: 320px;
}

.panel-title {
  margin-bottom: 12px;
}

.ghost {
  min-height: 32px;
  padding: 0 10px;
}

.devices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.devices.empty {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.device {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  min-height: 66px;
  padding: 12px;
}

.device.offline {
  opacity: 0.78;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.device:hover,
.device:focus-visible,
.remote-entry:hover,
.remote-entry:focus-visible,
.toolbar-button:hover,
.ghost:hover {
  border-color: var(--accent-2);
}

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

.users-panel {
  grid-column: 1 / -1;
}

.users-list {
  display: grid;
  gap: 8px;
}

.users-list.empty {
  color: var(--muted);
  font-size: 14px;
}

.user-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 8px;
  padding: 10px 12px;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  color: var(--muted);
  font-size: 12px;
}

.session-view {
  height: 100vh;
  overflow: hidden;
  background: #050607;
  position: relative;
}

.session-toolbar-wrap {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  top: 0;
  transform: translateY(calc(-100% + 12px));
  transition: transform 160ms ease;
}

.session-toolbar-wrap:hover,
.session-toolbar-wrap:focus-within {
  transform: translateY(0);
}

.toolbar-grip {
  width: 90px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent-2);
  margin: 6px auto 0;
}

.session-toolbar {
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 22, 28, 0.96);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.session-meta {
  min-width: 240px;
  margin-right: auto;
}

.session-title {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.session-toolbar .transfer-status {
  max-width: 280px;
  margin: 0 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-button,
.toolbar-select,
.danger {
  min-height: 36px;
}

.toolbar-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0 10px;
}

.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(240, 113, 120, 0.45);
}

.remote-stage {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #030405;
  overflow: hidden;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  cursor: crosshair;
}

.remote-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.remote-stage.has-frame img {
  display: block;
}

.drop-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  background: rgba(3, 4, 5, 0.64);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
  z-index: 3;
}

.drop-hint[hidden] {
  display: none;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.remote-stage.has-frame .placeholder {
  display: none;
}

.placeholder strong {
  color: var(--text);
  font-size: 18px;
}

.path-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.path-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.path-dialog-body {
  padding: 18px;
}

.path-dialog h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.remote-browser {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11161b;
  max-height: 340px;
  overflow: auto;
  padding: 8px;
}

.remote-browser-header,
.browser-note {
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}

.remote-entry {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 8px;
}

.remote-entry span {
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
}

.remote-entry strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.transfer-status {
  margin-top: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .cabinet-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .cabinet-grid {
    grid-template-columns: 1fr;
    padding: 18px 14px;
  }

  .connect-line,
  .auth-actions {
    grid-template-columns: 1fr;
  }

  .session-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-meta {
    min-width: 0;
    width: 100%;
  }
}
