:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090d14;
  color: #eef4ff;
  --surface: #101722;
  --line: #263244;
  --text: #eef4ff;
  --muted: #8fa0b7;
  --soft: #c8d5e8;
  --accent: #28c7d9;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(40, 199, 217, 0.16), transparent 34%),
    linear-gradient(135deg, #090d14 0%, #101827 52%, #0b111a 100%);
}

button,
input {
  font: inherit;
}

.shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  overflow: hidden;
}

.topbar,
.setup,
.panel,
.screen-column {
  border: 1px solid rgba(200, 213, 232, 0.12);
  background: rgba(16, 23, 34, 0.84);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  border-radius: 14px;
}

.brand,
.top-actions,
.screen-pills {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #021016;
  background: linear-gradient(135deg, var(--accent), #6ee7b7);
  font-weight: 900;
  letter-spacing: 0;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.metric {
  display: grid;
  gap: 2px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 13, 20, 0.54);
}

.metric span,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric strong {
  color: var(--soft);
  font-size: 13px;
}

.status {
  min-width: 152px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 107, 0.28);
  border-radius: 10px;
  color: #ffd6d6;
  background: rgba(255, 107, 107, 0.08);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.setup {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 260px) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

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

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #304057;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #0b111a;
  padding: 9px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: rgba(40, 199, 217, 0.75);
  box-shadow: 0 0 0 3px rgba(40, 199, 217, 0.15);
  background: #0d1420;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  color: #021016;
  background: linear-gradient(135deg, var(--accent), #80e6c2);
  padding: 10px 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(40, 199, 217, 0.18);
}

button:hover {
  filter: brightness(1.06);
}

.ghost {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(143, 160, 183, 0.2);
  color: var(--soft);
  background: rgba(9, 13, 20, 0.52);
  box-shadow: none;
  font-size: 12px;
}

.workspace {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
}

.screen-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: 16px;
  overflow: hidden;
}

.screen-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(21, 31, 45, 0.62);
}

.screen-toolbar strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.screen-pills {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.screen-pills span {
  padding: 7px 9px;
  border: 1px solid rgba(143, 160, 183, 0.2);
  border-radius: 999px;
  color: var(--soft);
  background: rgba(9, 13, 20, 0.52);
  font-size: 12px;
  font-weight: 800;
}

.screen-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #05080d;
  background-size: 36px 36px;
}

#screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.screen-wrap[data-fit="cover"] #screen {
  object-fit: cover;
}

.screen-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background-color: #000;
}

.screen-meta,
.device-meta {
  position: absolute;
  z-index: 4;
  padding: 7px 10px;
  border-radius: 8px;
  color: #67e8f9;
  background: rgba(0, 0, 0, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

.screen-meta {
  top: 12px;
  right: 12px;
}

.device-meta {
  right: 12px;
  bottom: 12px;
}

#screen:not([src]),
#screen[src=""] {
  display: none;
}

#empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  z-index: 1;
}

#empty strong {
  color: var(--text);
  font-size: 18px;
}

#empty span {
  max-width: 380px;
  line-height: 1.5;
}

.empty-icon {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(40, 199, 217, 0.28);
  border-radius: 16px;
  color: var(--accent);
  background: rgba(40, 199, 217, 0.08);
  font-size: 30px;
}

.panel {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-rows: auto auto auto minmax(220px, 1fr);
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  scrollbar-width: thin;
  scrollbar-color: #36506d transparent;
}

.panel::-webkit-scrollbar,
pre::-webkit-scrollbar {
  width: 8px;
}

.panel::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #36506d;
}

.grow {
  min-height: 0;
}

.panel-section {
  display: grid;
  gap: 10px;
}

.wide {
  width: 100%;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.switch {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 13, 20, 0.48);
  color: var(--soft);
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch span {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #263244;
  transition: background 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #9baac0;
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + span {
  background: rgba(40, 199, 217, 0.34);
}

.switch input:checked + span::after {
  transform: translateX(16px);
  background: var(--accent);
}

.switch b {
  font-size: 14px;
}

pre {
  min-height: 0;
  height: clamp(220px, 34vh, 460px);
  max-height: 100%;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #9bdcff;
  background: #070b12;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1020px) {
  html,
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .screen-wrap {
    height: min(60vh, 560px);
    min-height: 300px;
  }

  .panel {
    grid-template-rows: auto;
    max-height: none;
  }

  pre {
    height: 260px;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  .screen-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .top-actions,
  .screen-pills {
    justify-content: space-between;
  }

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

  .screen-wrap {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 10;
  }
}

/* Keep the remote display as the primary view; controls live in a drawer. */
html,
body {
  overflow: hidden;
}

.shell {
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.topbar {
  min-height: 62px;
  padding: 10px 14px;
}

.brand p {
  margin-top: 2px;
}

.top-actions {
  flex-shrink: 0;
}

.status {
  min-width: 0;
  padding: 9px 12px;
}

.workspace {
  position: relative;
  display: block;
  min-height: 0;
  overflow: hidden;
}

.screen-column {
  display: block;
  width: 100%;
  height: 100%;
}

.screen-wrap,
.screen-wrap:fullscreen {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

.screen-actions {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(5, 8, 13, 0.7);
  backdrop-filter: blur(8px);
}

.screen-actions .ghost {
  min-height: 36px;
}

.panel {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100%);
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-radius: 16px;
  background: #111a27;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.52);
}

.panel[hidden] {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading strong {
  font-size: 18px;
}

.panel-heading button {
  min-width: 36px;
  padding: 6px;
}

.panel .setup {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.panel pre {
  height: 160px;
  max-height: none;
}

@media (max-width: 760px) {
  .shell {
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    min-height: 58px;
    padding: 8px;
    flex-direction: row;
    align-items: center;
  }

  .mark {
    width: 36px;
    height: 36px;
  }

  .brand {
    min-width: 0;
  }

  .brand h1 {
    font-size: 14px;
  }

  .brand p {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .status {
    display: none;
  }

  .screen-actions {
    top: 8px;
    right: 8px;
  }

  .screen-actions .ghost {
    font-size: 11px;
  }
}
