:root {
  color-scheme: dark;
  --bg: #06080b;
  --stage: #03060a;
  --ink: #e7eef4;
  --soft: #c2ccd6;
  --muted: #979b9e;
  --faint: #5f676d;
  --line: rgba(244, 240, 231, 0.12);
  --line-strong: rgba(244, 240, 231, 0.23);
  --panel: rgba(15, 17, 20, 0.72);
  --panel-strong: rgba(22, 25, 29, 0.92);
  --card: rgba(15, 17, 20, 0.64);
  --acid: #35e0ff;
  --acid-soft: #7ef0ff;
  --cyan: #7ef0ff;
  --shadow: rgba(0, 0, 0, 0.38);
  --display: "Space Grotesk", "Pretendard Variable", Pretendard, "Segoe UI", sans-serif;
  --sans: "Pretendard Variable", Pretendard, "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --green: #91d66f;
  --blue: #7fb8ff;
  --purple: #a77cff;
}

* {
  box-sizing: border-box;
}

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

html {
  background: var(--bg);
}

body {
  position: relative;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
  background:
    linear-gradient(135deg, rgba(53, 224, 255, 0.05), transparent 520px),
    linear-gradient(215deg, rgba(243, 212, 180, 0.02), transparent 560px),
    #07080a;
}



button, input {
  font: inherit;
}

button {
  cursor: pointer;
  outline: none;
}

.hidden {
  display: none !important;
}

/* Login View */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 10;
}

.loginBox {
  position: relative;
  width: min(420px, calc(100vw - 34px));
  display: grid;
  gap: 16px;
  padding: 36px 32px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(135deg, rgba(53, 224, 255, 0.09), transparent 38%),
    linear-gradient(180deg, rgba(244, 240, 231, 0.045), transparent 44%),
    var(--panel);
  box-shadow: 0 28px 90px var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
  border-radius: 2px;
}

.loginBox::before {
  content: "";
  position: absolute;
  inset: 14px;
  pointer-events: none;
  border: 1px solid rgba(244, 240, 231, 0.055);
}

.mark {
  width: max-content;
  padding: 5px 8px;
  border: 1px solid rgba(53, 224, 255, 0.3);
  color: var(--acid-soft);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(53, 224, 255, 0.06);
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.loginBox h1 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.0;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 8px 32px rgba(53, 224, 255, 0.14);
}

.loginBox p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.loginBox input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(7, 8, 10, 0.64);
  color: var(--ink);
  padding: 11px 14px;
  font-family: var(--sans);
  border-radius: 2px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.loginBox input:focus {
  outline: none;
  border-color: rgba(53, 224, 255, 0.5);
  box-shadow: 0 0 8px rgba(53, 224, 255, 0.15);
}

.loginBox button {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(53, 224, 255, 0.48);
  background: linear-gradient(135deg, #35e0ff, #7ef0ff);
  color: #1b0d03;
  font-weight: 700;
  font-family: var(--sans);
  border-radius: 2px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.loginBox button:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 16px rgba(53, 224, 255, 0.25);
  transform: translateY(-1px);
}

#loginError {
  min-height: 18px;
  color: #ff8f9a;
  font-size: 12px;
  margin: 0;
  text-align: center;
}

/* Remote Control Screen View */
.remote {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  position: relative;
  z-index: 10;
}

#uacImage {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  z-index: 3; object-fit: contain; cursor: default;
}
#uacControls {
  position: absolute; left: 12px; top: 12px; z-index: 5;
  padding: 8px; background: rgba(6,8,11,.88); color: #e7eef4; font-size: 12px;
}
#uacImage[hidden], #uacControls[hidden], #uacArm[hidden] { display: none; }
.remote.uacMode #screen, .remote.uacMode #h264Video { visibility: hidden; }

/* Video Stage */
.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--stage);
}

.stageMeta {
  position: absolute;
  left: 28px;
  top: 24px;
  z-index: 4;
  display: flex;
  gap: 14px;
  align-items: center;
  color: rgba(244, 240, 231, 0.6);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  pointer-events: none;
}

.stageMeta span:first-child {
  color: var(--acid-soft);
  font-weight: 700;
}

#screen {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  outline: none;
  z-index: 2;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

#h264Video {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  background: #000;
  pointer-events: none;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.remote.h264Mode #h264Video {
  display: block;
}

.remote.h264Mode #screen {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  box-shadow: none;
}


.hud[hidden] { display: none; }
.hud {
  white-space: pre-line;
  line-height: 1.55;
  max-height: 65vh;
  overflow-y: auto;
  position: absolute;
  left: 22px;
  bottom: 18px;
  z-index: 6;
  max-width: calc(100% - 44px);
  padding: 8px 12px;
  border: 1px solid rgba(244, 240, 231, 0.1);
  background: rgba(7, 8, 10, 0.85);
  color: var(--soft);
  font-size: 11px;
  font-family: var(--mono);
  pointer-events: none;
  word-wrap: break-word;
  border-radius: 2px;
}

/* Control Panel */
.panel {
  position: relative;
  height: 100vh;
  overflow-y: auto;
  padding: 16px;
  border-left: 1px solid var(--line-strong);
  background:
    linear-gradient(135deg, rgba(53, 224, 255, 0.06), transparent 36%),
    linear-gradient(180deg, rgba(244, 240, 231, 0.035), transparent 38%),
    rgba(10, 12, 14, 0.94);
}

/* Sleek scrollbars for panel */
.panel::-webkit-scrollbar {
  width: 5px;
}

.panel::-webkit-scrollbar-track {
  background: transparent;
}

.panel::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.panel::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
}

.panel::before {
  content: "";
  position: sticky;
  display: block;
  top: 0;
  height: 1px;
  margin: -16px -16px 14px;
  background: linear-gradient(90deg, transparent, rgba(53, 224, 255, 0.3), transparent);
  z-index: 10;
}

.panelHero,
.panelBlock,
.infoBlock {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card);
  overflow: hidden;
  border-radius: 2px;
}

.panelHero {
  min-height: 72px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: rgba(7, 8, 10, 0.58);
}

.panelHero::before {
  content: "01";
  position: absolute;
  right: 6px;
  bottom: -8px;
  color: rgba(53, 224, 255, 0.14);
  font-family: var(--display);
  font-size: 54px;
  font-weight: 700;
  line-height: .8;
}

.panelHero strong {
  display: block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 32px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panelHero em {
  display: block;
  margin-top: 6px;
  color: var(--acid-soft);
  font: 600 11px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panelKicker {
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
  font-family: var(--mono);
}

.panelBlock {
  padding: 12px;
  margin-bottom: 12px;
}

.panelBlock h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.panelBlock h2 span {
  width: 3px;
  height: 13px;
  background: var(--acid);
  box-shadow: 0 0 12px rgba(53, 224, 255, .45);
}

/* Controls Grid */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  margin-bottom: 8px;
  border: 1px solid rgba(244, 240, 231, 0.08);
  background: rgba(7, 8, 10, 0.52);
  border-radius: 2px;
}

.segmented button,
.twoGrid button,
.sendRow button,
.imageSend {
  min-height: 34px;
  border: 1px solid rgba(244, 240, 231, 0.10);
  background: rgba(244, 240, 231, 0.04);
  color: var(--soft);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  border-radius: 2px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.segmented button:hover,
.twoGrid button:hover,
.sendRow button:hover,
.imageSend:hover {
  background: rgba(244, 240, 231, 0.08);
  border-color: rgba(244, 240, 231, 0.22);
  color: var(--ink);
}

.segmented button.active {
  border-color: rgba(53, 224, 255, 0.42);
  background: linear-gradient(135deg, rgba(53, 224, 255, 0.95), rgba(126, 240, 255, 0.86));
  color: #1b0d03;
  font-weight: 650;
}

.twoGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#pointerLock.locked,
#inputGuard.locked {
  border-color: rgba(53, 224, 255, 0.52);
  background: var(--acid);
  color: #1b0d03;
  font-weight: 600;
}

#receiverToggle {
  grid-column: 1 / -1;
  border-color: rgba(255, 96, 96, 0.38);
}

#receiverToggle.stopped {
  border-color: rgba(94, 220, 150, 0.52);
  background: rgba(94, 220, 150, 0.14);
  color: #baffd8;
}

#receiverToggle.starting {
  border-color: rgba(255, 184, 77, 0.60);
  background: rgba(255, 184, 77, 0.14);
  color: #ffe0a3;
}

#receiverToggle.receiving {
  border-color: rgba(94, 220, 150, 0.52);
  background: rgba(94, 220, 150, 0.10);
}

/* Status Telemetry Card */
.streamCard {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 10px;
  border: 1px solid rgba(244, 240, 231, 0.1);
  background:
    linear-gradient(135deg, rgba(53, 224, 255, 0.08), transparent 60%),
    rgba(7, 8, 10, 0.42);
  border-radius: 2px;
}

.streamCard div {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--soft);
  font-size: 11px;
}

.streamCard b {
  font-family: var(--mono);
  font-weight: 600;
}

.streamCard p {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(244, 240, 231, 0.06);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.dot,
.blueDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.dot {
  background: var(--green);
  box-shadow: 0 0 10px rgba(145, 214, 111, 0.45);
}

.blueDot {
  background: var(--acid);
  box-shadow: 0 0 12px rgba(53, 224, 255, 0.6);
}

.blue {
  color: var(--blue);
}

.orange {
  color: var(--acid-soft);
}

/* Telemetry Resource Progress Rows */
.resourceRows {
  display: grid;
  gap: 10px;
}

.resourceRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--sans);
}

.resourceRow b {
  color: var(--soft);
  font-family: var(--mono);
  font-weight: 500;
}

.resourceRow i {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  background: rgba(244, 240, 231, 0.08);
  border-radius: 2px;
}

.resourceRow em {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#cpuBar {
  background: linear-gradient(90deg, #7fb8ff, #a77cff);
}

#memBar {
  background: linear-gradient(90deg, #a77cff, #35e0ff);
}

#gpuBar {
  background: linear-gradient(90deg, #35e0ff, #7ef0ff);
}

/* Input sliders */
.sliderBox {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(244, 240, 231, 0.1);
  background: rgba(7, 8, 10, 0.42);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  border-radius: 2px;
}

.sliderBox input {
  accent-color: var(--acid);
}

.sliderBox b {
  min-width: 38px;
  color: var(--acid-soft);
  font-family: var(--mono);
  font-weight: 600;
  text-align: right;
}

/* Utility Input Rows */
.sendRow {
  display: grid;
  grid-template-columns: 1fr 54px;
  gap: 6px;
}

.sendRow input {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(7, 8, 10, 0.58);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--sans);
  border-radius: 2px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sendRow input:focus {
  outline: none;
  border-color: rgba(53, 224, 255, 0.5);
  box-shadow: 0 0 8px rgba(53, 224, 255, 0.15);
}

.sendRow button {
  border-color: rgba(53, 224, 255, 0.48);
  background: var(--acid);
  color: #1b0d03;
  font-weight: 600;
}

.imageSend {
  display: grid;
  place-items: center;
  margin-top: 8px;
}

.imageSend input {
  display: none;
}

/* Info Details Row */
.infoBlock {
  display: grid;
  gap: 6px;
  padding: 12px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--sans);
  border-radius: 2px;
}

.infoBlock div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.infoBlock b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--soft);
  font-family: var(--mono);
  font-weight: 500;
  text-align: right;
}

/* ==========================================================================
   Fullscreen Floating Settings Panel & Drag-Move Gear Button
   ========================================================================== */

/* 1. Fullscreen Active Layout Modification */
.remote.fullscreen-active {
  grid-template-columns: minmax(0, 1fr) !important;
}

.remote.fullscreen-active .panel {
  display: none !important;
}

/* 2. Floating Panel Overlay during Fullscreen */
.remote.fullscreen-active .panel.floating-show {
  display: block !important;
  position: fixed;
  right: 0;
  top: 0;
  width: 344px;
  height: 100vh;
  z-index: 1000;
  background: var(--panel-strong) !important;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.72);
  border-left: 1px solid var(--line-strong);
  backdrop-filter: blur(20px);
}

/* 3. Floating Draggable Gear Button */
.floatingGear {
  position: fixed;
  z-index: 999;
  cursor: move;
  width: 44px;
  height: 44px;
  background: rgba(53, 224, 255, 0.85);
  color: #07080a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.floatingGear:hover {
  background: rgba(53, 224, 255, 1.0);
  color: #000;
  border-color: rgba(255, 255, 255, 0.4);
}

.floatingGear svg {
  pointer-events: none;
  animation: gear-spin 20s linear infinite;
}

.floatingGear.panel-open {
  background: #3a3f45;
  color: var(--soft);
  border-color: rgba(244, 240, 231, 0.2);
}

.floatingGear.panel-open svg {
  animation-play-state: paused;
}

@keyframes gear-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
