:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-soft: #151821;
  --panel: #181b22;
  --panel-elevated: #1e222b;
  --panel-border: #2f3542;
  --panel-border-soft: rgba(202, 211, 224, 0.13);
  --text: #f4f0e8;
  --muted: #a8acb6;
  --accent: #8fbf9f;
  --accent-strong: #a8d8b8;
  --accent-soft: rgba(143, 191, 159, 0.13);
  --success: #48c774;
  --danger: #ff7b7b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 240px),
    linear-gradient(135deg, #111317 0%, #0d1016 52%, #12110e 100%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 14px;
}

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

button,
input,
select,
textarea {
  outline: none;
}

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

h1,
h2,
h3,
p,
dl,
dd,
dt {
  margin-top: 0;
}

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

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 0 clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--panel-border-soft);
  background: rgba(15, 17, 21, 0.72);
  backdrop-filter: blur(18px);
}

.brand-bar.compact {
  border-bottom-color: var(--panel-border-soft);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark h1 {
  max-width: none;
  margin: 0;
  font-size: 1rem;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 650;
}

.brand-mark strong {
  display: block;
  font-size: 1rem;
}

.brand-mark p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(168, 216, 184, 0.42);
  border-radius: 8px;
  background: #171d19;
  color: var(--accent-strong);
  font-size: 0.95rem;
  font-weight: 700;
}

.brand-status {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-card {
  min-width: 168px;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: #182235;
}

.status-card strong,
.status-card .status-meta,
.status-card .status-label {
  display: block;
}

.status-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.77rem;
}

.status-card.live .status-meta {
  color: #d7e0ef;
}

.welcome-view {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.welcome-content {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 430px);
  gap: 28px;
  align-items: start;
  padding: 34px 32px 40px;
}

.login-content {
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  padding: 34px clamp(20px, 5vw, 56px) 40px;
}

.welcome-copy {
  padding-top: 28px;
}

.eyebrow {
  color: var(--accent-strong);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.eyebrow.small {
  margin-bottom: 8px;
}

h1 {
  max-width: 12ch;
  margin-bottom: 18px;
  font-size: clamp(2.8rem, 5.8vw, 5.2rem);
  line-height: 0.93;
  letter-spacing: -0.05em;
}

.lede {
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.feature-card,
.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(31, 34, 42, 0.98), rgba(21, 24, 31, 0.98));
  box-shadow: var(--shadow);
}

.feature-card {
  min-height: 152px;
  padding: 18px;
}

.feature-card p,
.panel-copy,
.session-user {
  color: var(--muted);
  line-height: 1.55;
}

.welcome-stack {
  display: grid;
  align-self: center;
  justify-self: center;
  width: min(100% - 48px, 420px);
  gap: 14px;
}

.index-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px clamp(20px, 5vw, 56px) 24px;
  color: var(--muted);
  font-size: 0.76rem;
}

.auth-panel,
.dock-panel {
  padding: 24px;
}

.auth-panel {
  border-color: var(--panel-border-soft);
}

.auth-head {
  margin-bottom: 22px;
}

.auth-head h2 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.auth-head .eyebrow {
  margin-bottom: 9px;
}

.panel-title,
.dashboard-head,
.panel-head,
.terminal-head,
.keyboard-overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 12px 13px;
  background: #101319;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(168, 216, 184, 0.62);
  background: #11161b;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  cursor: pointer;
}

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

.toolbar-button,
form button {
  height: 29px;
  padding: 0 11px;
  border: 1px solid #49556d;
  border-radius: 4px;
  color: var(--text);
  background: linear-gradient(180deg, #212b3f, #192334);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.toolbar-button:hover,
form button:hover {
  background: #2b3650;
}

.toolbar-button:active,
form button:active {
  transform: translateY(1px);
}

form button {
  height: 44px;
  margin-top: 2px;
  border-color: rgba(168, 216, 184, 0.5);
  color: #08100b;
  font-weight: 700;
  background: linear-gradient(180deg, #b8e4c6, #8fc89f);
  box-shadow: 0 10px 28px rgba(45, 78, 55, 0.28);
}

form button:hover {
  border-color: rgba(187, 235, 202, 0.75);
  background: linear-gradient(180deg, #c8efd3, #9bd2aa);
}

.toolbar-button.subtle {
  border-color: #445168;
  background: linear-gradient(180deg, #1c2536, #151d2c);
}

.toolbar-button.active {
  border-color: #6280ff;
  background: linear-gradient(180deg, #5777f1, #3c5fe0);
}

.small-button {
  padding: 0 10px;
  font-size: 0.82rem;
}

.status {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 0.82rem;
}

.device-info {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: #101319;
  color: var(--muted);
  line-height: 1.55;
}

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

.device-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  text-align: left;
  background: #151922;
  box-shadow: none;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.device-option:hover:not(:disabled) {
  border-color: rgba(168, 216, 184, 0.44);
  background: #191f25;
}

.device-option.selected {
  border-color: rgba(168, 216, 184, 0.74);
  background: rgba(143, 191, 159, 0.12);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.device-option:disabled {
  opacity: 0.52;
}

.device-option-name,
.device-option-meta {
  display: block;
}

.device-option-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.device-option-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.device-selected-details {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.session-view {
  min-height: 100vh;
}

.session-view > .brand-bar {
  min-height: 32px;
  padding: 2px 10px;
  gap: 8px;
}

.session-view .brand-logo {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  font-size: 0.72rem;
}

.session-view .brand-mark {
  gap: 7px;
}

.session-view .brand-mark strong {
  font-size: 0.78rem;
}

.session-view .brand-mark p,
.session-view .status-card:not(.live),
.session-view .status-label,
.session-view .status-meta {
  display: none;
}

.session-view .status-card.live {
  min-width: 0;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-height: 34px;
  padding: 2px 10px;
  border-bottom: 1px solid var(--panel-border-soft);
  background: #111a2c;
  overflow-x: auto;
}

.tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: nowrap;
}

.toolbar-segment {
  display: inline-flex;
  gap: 4px;
}

.session-view .toolbar-button {
  height: 25px;
  padding: 0 8px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.session-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 9px;
  padding: 7px 9px 10px;
  align-items: start;
}

.viewer-column {
  min-width: 0;
}

.viewer-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background:
    radial-gradient(circle at 0 0, rgba(68, 102, 232, 0.22) 1px, transparent 1px),
    radial-gradient(circle at 12px 12px, rgba(68, 102, 232, 0.14) 1px, transparent 1px),
    linear-gradient(180deg, rgba(28, 39, 61, 0.7), rgba(14, 22, 36, 0.86));
  background-size: 24px 24px, 24px 24px, auto;
}

.viewer-stage {
  position: relative;
  min-height: max(420px, calc(100vh - 112px));
  overflow: hidden;
  background: rgba(2, 4, 10, 0.8);
}

.viewer-stage.mode-mouse,
.viewer-stage.mode-mouse video {
  cursor: default;
}

.viewer-stage.mode-mouse.show-local-cursor,
.viewer-stage.mode-mouse.show-local-cursor video {
  cursor: none;
}

.viewer-stage.mode-touch,
.viewer-stage.mode-touch video {
  cursor: pointer;
}

.viewer-stage.app-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
}

.viewer-stage.app-fullscreen video {
  min-height: 100vh;
}

body.viewer-fullscreen-active {
  overflow: hidden;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: max(420px, calc(100vh - 112px));
  object-fit: contain;
  background: #000;
  touch-action: none;
}

.overlay {
  display: none !important;
}

.capture-warning {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 4;
  padding: 12px 14px;
  border: 1px solid rgba(244, 198, 86, 0.38);
  border-radius: 10px;
  background: rgba(16, 22, 32, 0.9);
  color: #f5d98a;
  font-size: 0.92rem;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.local-cursor,
.remote-cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
}

.local-cursor {
  width: 18px;
  height: 18px;
  border: 2px solid #7ad9ff;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(8, 16, 30, 0.5);
  transform: translate(-50%, -50%);
}

.local-cursor::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 999px;
  background: #7ad9ff;
}

.remote-cursor {
  width: 18px;
  height: 24px;
  background: rgba(255, 255, 255, 0.98);
  clip-path: polygon(0 0, 0 100%, 28% 72%, 44% 100%, 58% 92%, 42% 65%, 100% 65%);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
  transform: translate(-10%, -10%);
}

.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding: 6px 8px;
  border: 1px solid var(--panel-border-soft);
  border-top: 0;
  background: #0d1423;
  color: var(--muted);
  font-size: 0.78rem;
}

.footer-keys,
.footer-locks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.lock-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lock-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4b5363;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.lock-state.enabled {
  color: #b8f5c8;
}

.lock-state.enabled::before {
  background: #45d66f;
  box-shadow: 0 0 7px rgba(69, 214, 111, 0.72);
}

.footer-label {
  color: #dce4f1;
  font-weight: 600;
}

.control-dock {
  display: grid;
  gap: 8px;
}

.control-dock .dock-panel {
  padding: 11px;
}

.control-dock .panel-head h3 {
  margin-bottom: 7px;
  font-size: 0.9rem;
}

.control-dock .panel-copy {
  margin-bottom: 8px;
  font-size: 0.76rem;
}

.display-switcher {
  display: grid;
  gap: 8px;
}

.quality-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.quality-button {
  min-width: 0;
  height: 26px;
  padding: 0 5px;
  border: 1px solid #3d485d;
  border-radius: 4px;
  background: #151d2c;
  color: var(--muted);
  font-size: 0.68rem;
}

.quality-button.active {
  border-color: #6280ff;
  background: linear-gradient(180deg, #5777f1, #3c5fe0);
  color: #fff;
}

.display-button {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #323d52;
  border-radius: 6px;
  text-align: left;
  color: var(--text);
  background: #162136;
}

.display-button.active {
  border-color: #5d79f0;
  background: linear-gradient(180deg, rgba(85, 117, 241, 0.27), rgba(33, 46, 73, 0.9));
}

.display-label,
.display-meta {
  display: block;
}

.display-label {
  margin-bottom: 4px;
  font-weight: 700;
}

.display-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.inline-status {
  margin-bottom: 0;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 9px;
  font-size: 0.72rem;
}

.telemetry-grid dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.telemetry-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.empty-note {
  margin-bottom: 0;
  color: var(--muted);
}

.keyboard-overlay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  width: min(760px, calc(100% - 24px));
  border: 1px solid #465067;
  border-radius: 7px;
  background: rgba(241, 246, 255, 0.52);
  color: #1a2231;
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.keyboard-overlay.dragging {
  opacity: 0.94;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.52);
}

.keyboard-overlay-head {
  align-items: center;
  padding: 4px 6px;
  background: #1d2639;
  color: #fff;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.keyboard-title strong,
.keyboard-title span {
  display: block;
}

.keyboard-title span {
  display: none;
}

.keyboard-title strong {
  font-size: 0.72rem;
}

.keyboard-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.keyboard-head-button {
  height: 23px;
  padding: 0 7px;
  border: 1px solid #49556d;
  border-radius: 4px;
  color: #fff;
  background: linear-gradient(180deg, #212b3f, #192334);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  font-size: 0.68rem;
}

.keyboard-head-button:hover {
  background: #2b3650;
}

.modifier-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 20px;
  padding: 4px 0 2px;
}

.modifier-chip {
  padding: 3px 7px;
  border: 1px solid rgba(69, 84, 110, 0.26);
  border-radius: 999px;
  background: rgba(29, 38, 57, 0.08);
  color: #31415c;
  font-size: 0.64rem;
}

.keyboard-scale-viewport {
  padding: 0 8px 8px;
  overflow: hidden;
}

.keyboard-scale-shell {
  --keyboard-scale: 1;
  --keyboard-shell-height: auto;
  width: 1120px;
  height: var(--keyboard-shell-height);
  transform: scale(var(--keyboard-scale));
  transform-origin: left top;
}

.keyboard-root {
  display: grid;
  gap: 3px;
  padding: 0;
  overflow: visible;
}

.keyboard-row {
  display: flex;
  gap: 3px;
  min-width: 0;
}

.key-button {
  flex: 1;
  min-width: 27px;
  min-height: 29px;
  padding: 3px;
  border: 1px solid #b8c0ce;
  border-radius: 4px;
  color: #1a2231;
  background: #fff;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.18);
  font-size: 0.68rem;
  transition: transform 70ms ease, background 70ms ease, box-shadow 70ms ease;
}

.key-button.active {
  border-color: #6f83aa;
  background: linear-gradient(180deg, #dbe6ff, #cfdcf8);
}

.key-button.pressed,
.key-button.pulse {
  border-color: #6179aa;
  background: linear-gradient(180deg, #bed0f7, #9fb6e8);
  box-shadow: inset 0 2px 4px rgba(30, 48, 84, 0.3);
  transform: translateY(1px) scale(0.985);
}

.key-gap {
  flex: 0 0 16px;
  min-height: 29px;
}

.key-wide {
  flex: 2;
}

.key-extra-wide {
  flex: 2.6;
}

.key-ultra-wide {
  flex: 3.1;
}

.key-space {
  flex: 7;
}

.key-numpad-enter {
  flex: 2.2;
}

.key-macro {
  flex: 2.5;
}

.key-compact {
  flex: 0.9;
}

.terminal-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
}

.terminal-card {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #10182b;
  overflow: hidden;
}

.terminal-head {
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border-soft);
  background: #141d30;
}

.terminal-body {
  min-height: 96px;
  padding: 12px;
  background: #09101b;
  color: #7f8ca2;
}

@media (max-width: 1180px) {
  .welcome-content {
    grid-template-columns: 1fr;
  }

  .brand-bar,
  .toolbar {
    padding-right: 18px;
    padding-left: 18px;
  }

  .welcome-content {
    padding-right: 18px;
    padding-left: 18px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .brand-bar {
    min-height: 64px;
  }

  .welcome-stack {
    width: min(100% - 56px, 460px);
  }

  .auth-panel {
    padding: 28px;
  }

  .auth-head h2 {
    font-size: 1.7rem;
  }

  input,
  select,
  textarea,
  form button {
    min-height: 48px;
  }
}

@media (max-width: 900px) {
  .brand-status {
    display: none;
  }

  .toolbar {
    padding: 2px 8px;
  }

  .tools.right {
    justify-content: flex-end;
  }

  .session-layout {
    grid-template-columns: 1fr;
  }

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

  .telemetry-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .brand-bar {
    min-height: 58px;
    padding-right: 20px;
    padding-left: 20px;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
  }

  .brand-mark h1 {
    font-size: 0.95rem;
  }

  .welcome-view {
    min-height: 100svh;
  }

  .welcome-stack {
    width: calc(100% - 32px);
  }

  .auth-panel {
    padding: 22px;
  }

  .auth-head {
    margin-bottom: 20px;
  }

  .auth-head h2 {
    font-size: 1.45rem;
  }

  .welcome-content {
    gap: 18px;
  }

  h1 {
    font-size: clamp(2.2rem, 9vw, 3.2rem);
  }

  .keyboard-overlay-head,
  .dashboard-head {
    flex-direction: column;
    align-items: stretch;
  }

  .keyboard-overlay .keyboard-overlay-head {
    flex-direction: row;
    align-items: center;
  }

  .keyboard-actions {
    justify-content: flex-end;
  }

  .viewer-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .index-footer {
    gap: 8px;
    padding: 14px 20px 18px;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .brand-bar {
    min-height: 54px;
  }

  .welcome-stack {
    align-self: start;
    margin-top: 42px;
  }

  .auth-panel {
    padding: 18px;
  }

  form {
    gap: 14px;
  }

  input,
  select,
  textarea,
  form button {
    min-height: 46px;
  }

  .index-footer {
    flex-direction: column;
  }
}
