:root {
  --ink: #263033;
  --muted: #6f7a7d;
  --soft: #e5e7e6;
  --soft-2: #f3f5f4;
  --soft-3: #c8cecc;
  --panel: rgba(232, 235, 234, 0.78);
  --panel-2: rgba(242, 244, 243, 0.86);
  --line: rgba(76, 91, 94, 0.2);
  --cyan: #168f9f;
  --cyan-2: #0b7180;
  --cyan-soft: rgba(22, 143, 159, 0.18);
  --amber: #d59b2e;
  --red: #c5514f;
  --black: #111718;
  --shadow-dark: rgba(71, 80, 82, 0.34);
  --shadow-light: rgba(255, 255, 255, 0.82);
  --topbar-height: 66px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: #171a17;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

.site-jump-nav {
  position: fixed;
  top: 12px;
  left: 32px;
  right: 32px;
  z-index: 13;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

.site-nav-left,
.site-nav-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.site-nav-left {
  flex: 0 0 auto;
  justify-content: flex-start;
}

.site-nav-right {
  flex: 0 1 auto;
  justify-content: flex-end;
  margin-left: auto;
}

.site-home-logo {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 25px;
  flex: 0 0 auto;
  margin-right: 10px;
  color: rgba(255, 255, 255, 0.84);
  border-color: transparent;
  background: transparent;
  font-size: 15px;
  font-weight: 720;
  text-transform: none;
}

.site-home-logo img {
  display: block;
  width: auto;
  height: 22px;
  max-width: 165px;
}

.site-jump-nav a {
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
}

.site-jump-icon,
.site-jump-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.site-jump-icon {
  width: 32px;
  border-color: transparent;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.site-social-start {
  margin-left: auto !important;
}

.site-nav-right .site-social-start {
  margin-left: 0 !important;
}

.site-jump-btn {
  padding: 0 11px;
  font-size: 12px;
  font-weight: 560;
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-jump-icon svg {
  width: 19px;
  height: 19px;
}

.site-jump-nav a:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.16);
}

.site-jump-nav .site-home-logo:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.16);
}

.site-jump-btn.site-jump-current {
  color: #ffffff;
  border-color: rgba(92, 219, 225, 0.72);
  background: linear-gradient(180deg, rgba(104, 216, 224, 0.96), rgba(34, 159, 172, 0.92));
}

.site-jump-icon:hover {
  border-color: transparent;
  background: transparent;
}

#viewport {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar {
  position: fixed;
  top: 49px;
  left: 14px;
  right: 14px;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 9px 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(213, 218, 216, 0.72)),
    rgba(229, 231, 230, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 18px;
  z-index: 10;
  box-shadow:
    8px 10px 26px rgba(0, 0, 0, 0.22),
    inset 1px 1px 0 rgba(255, 255, 255, 0.85),
    inset -1px -1px 0 rgba(99, 111, 114, 0.16);
  backdrop-filter: blur(10px);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow:
    4px 5px 12px rgba(22, 143, 159, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

.brand-copy {
  min-width: 0;
}

.brand strong {
  display: block;
  color: var(--cyan-2);
  font-size: 17px;
  font-weight: 760;
}

.brand-copy > span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-key-accent {
  color: var(--cyan-2);
  font-weight: 820;
  display: inline;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
}

.camera-buttons {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex: 1 1 360px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(223, 236, 235, 0.5), rgba(184, 205, 205, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 3px 3px 8px rgba(87, 98, 101, 0.13),
    inset -3px -3px 8px rgba(255, 255, 255, 0.58);
}

.panel {
  position: fixed;
  right: 14px;
  top: calc(var(--topbar-height) + 62px);
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - var(--topbar-height) - 40px);
  overflow: auto;
  padding: 16px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(248, 250, 249, 0.78), rgba(215, 220, 218, 0.68)),
    rgba(232, 235, 234, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  z-index: 11;
  box-shadow:
    12px 16px 40px rgba(0, 0, 0, 0.26),
    inset 1px 1px 0 var(--shadow-light),
    inset -1px -1px 0 rgba(92, 104, 106, 0.12);
  backdrop-filter: blur(12px);
}

.panel.options-panel {
  width: min(420px, calc(100vw - 28px));
}

.panel.help-panel {
  top: calc(var(--topbar-height) + 390px);
  right: 14px;
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - var(--topbar-height) - 410px);
  color: rgba(245, 255, 255, 0.92);
  background:
    linear-gradient(180deg, rgba(43, 59, 63, 0.42), rgba(18, 30, 34, 0.34)),
    rgba(5, 17, 22, 0.16);
  border-color: rgba(255, 255, 255, 0.26);
}

.panel-close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.panel-close-button::before,
.panel-close-button::after {
  position: absolute;
  left: 14px;
  top: 5px;
  width: 2px;
  height: 20px;
  content: "";
  background: rgba(245, 255, 255, 0.86);
}

.panel-close-button::before {
  transform: rotate(45deg);
}

.panel-close-button::after {
  transform: rotate(-45deg);
}

.panel:not(.help-panel) .panel-close-button::before,
.panel:not(.help-panel) .panel-close-button::after {
  background: #747474;
}

.panel-close-button:hover {
  background: transparent;
  box-shadow: none;
}

.panel > .section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.help-panel .section {
  border-top: 0;
  padding-top: 0;
}

.help-panel .section h2 {
  color: rgba(133, 238, 246, 0.95);
}

.help-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.52;
  word-break: keep-all;
}

.panel.is-hidden {
  display: none;
}

.section {
  padding: 13px 0;
  border-top: 1px solid rgba(95, 108, 111, 0.17);
}

.section:first-child {
  padding-top: 0;
  border-top: 0;
}

.section h2 {
  margin: 0 0 10px;
  color: var(--cyan-2);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 830;
}

.collapse-section {
  display: block;
}

.collapse-section summary {
  cursor: pointer;
  list-style: none;
  color: var(--cyan-2);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 830;
  user-select: none;
}

.collapse-section summary::-webkit-details-marker {
  display: none;
}

.collapse-section summary::after {
  content: "+";
  float: right;
  color: var(--cyan);
  font-weight: 900;
}

.collapse-section[open] summary::after {
  content: "-";
}

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

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

small {
  color: var(--cyan-2);
  font-size: 11px;
  font-weight: 720;
}

select,
button,
input[type="range"] {
  font: inherit;
}

select,
button,
input[type="color"],
input[type="file"],
input[type="number"] {
  min-height: 36px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(247, 249, 248, 0.92), rgba(211, 217, 215, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 11px;
  outline: none;
  box-shadow:
    4px 5px 10px rgba(79, 90, 92, 0.25),
    -3px -3px 8px rgba(255, 255, 255, 0.78),
    inset 1px 1px 0 rgba(255, 255, 255, 0.65);
}

select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  color: var(--cyan-2);
  font-weight: 760;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  min-height: 30px;
  padding: 0 9px;
  color: var(--cyan-2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 780;
  transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

button:hover {
  color: var(--cyan);
  box-shadow:
    3px 4px 9px rgba(22, 143, 159, 0.22),
    -3px -3px 8px rgba(255, 255, 255, 0.85),
    inset 1px 1px 0 rgba(255, 255, 255, 0.75);
}

button:active {
  transform: translateY(1px);
  box-shadow:
    inset 4px 4px 9px rgba(82, 91, 93, 0.22),
    inset -3px -3px 8px rgba(255, 255, 255, 0.78);
}

button.primary {
  color: #f4ffff;
  border-color: rgba(22, 143, 159, 0.62);
  background:
    linear-gradient(180deg, #1aa6b8, #087381);
  box-shadow:
    5px 7px 16px rgba(7, 113, 128, 0.28),
    inset 1px 1px 0 rgba(255, 255, 255, 0.34);
}

#runBtn {
  min-height: 42px;
  height: 42px;
  font-size: 16px;
  font-weight: 560;
}

button.warn {
  color: #fff7df;
  border-color: rgba(213, 155, 46, 0.55);
  background: linear-gradient(180deg, #e1aa42, #b9841e);
}

button.danger {
  color: #fff4f3;
  border-color: rgba(197, 81, 79, 0.55);
  background: linear-gradient(180deg, #db706c, #ad3f3e);
}

button.neutral-action {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
  background: linear-gradient(180deg, rgba(180, 185, 184, 0.92), rgba(128, 135, 136, 0.88));
  box-shadow:
    4px 5px 11px rgba(58, 66, 68, 0.25),
    -3px -3px 8px rgba(255, 255, 255, 0.62),
    inset 1px 1px 0 rgba(255, 255, 255, 0.42);
}

button.neutral-action:hover {
  color: #ffffff;
  background: linear-gradient(180deg, rgba(192, 197, 196, 0.94), rgba(142, 149, 150, 0.9));
}

button.is-toggle-active,
button.neutral-action.is-toggle-active,
button.neutral-action.is-toggle-active:hover {
  color: #ffffff;
  border-color: rgba(92, 219, 225, 0.72);
  background: linear-gradient(180deg, rgba(104, 216, 224, 0.96), rgba(34, 159, 172, 0.92));
  box-shadow:
    0 0 14px rgba(37, 184, 197, 0.34),
    4px 5px 11px rgba(38, 132, 144, 0.22),
    inset 1px 1px 0 rgba(255, 255, 255, 0.46);
}

#cancelBtn.neutral-action:disabled {
  opacity: 1;
  color: #ffffff;
  background: linear-gradient(180deg, rgba(180, 185, 184, 0.92), rgba(128, 135, 136, 0.88));
}

button.camera-button {
  flex: 1 1 0;
  height: 28px;
  min-height: 28px;
  padding: 0 8px;
  color: rgba(37, 54, 57, 0.78);
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

button.camera-button:hover {
  color: var(--cyan-2);
  background: rgba(255, 255, 255, 0.4);
  box-shadow: none;
}

button.camera-button.is-active {
  color: var(--cyan-2);
  background: rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 2px 2px 5px rgba(93, 106, 108, 0.14),
    inset -2px -2px 5px rgba(255, 255, 255, 0.72);
}

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

.wide {
  width: 100%;
}

.stack {
  display: grid;
  gap: 9px;
}

.section-gap {
  margin-top: 10px;
}

.section-gap-sm {
  margin-top: 8px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.meter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.meter strong {
  color: var(--cyan-2);
}

input[type="range"] {
  width: 100%;
  height: 8px;
  accent-color: var(--cyan);
}

input[type="color"],
input[type="file"],
input[type="number"] {
  width: 100%;
  padding: 6px 9px;
  font: inherit;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 7px 10px;
  padding: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 13px;
  box-shadow:
    inset 3px 3px 9px rgba(115, 125, 127, 0.12),
    inset -3px -3px 9px rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.status strong {
  color: var(--ink);
  font-weight: 740;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log {
  min-height: 44px;
  max-height: 92px;
  overflow: auto;
  padding: 10px 11px;
  color: #394648;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 13px;
  box-shadow:
    inset 3px 3px 9px rgba(115, 125, 127, 0.14),
    inset -3px -3px 9px rgba(255, 255, 255, 0.7);
  font-size: 12px;
  line-height: 1.45;
}

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(220, 224, 223, 0.76);
  z-index: 20;
}

.idle-auto-banner {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 14;
  transform: translate(-50%, -50%);
  padding: 16px 24px;
  color: #f4ffff;
  background: linear-gradient(180deg, rgba(22, 143, 159, 0.94), rgba(8, 115, 129, 0.92));
  border: 1px solid rgba(158, 239, 245, 0.56);
  border-radius: 18px;
  box-shadow:
    10px 14px 30px rgba(0, 0, 0, 0.28),
    inset 1px 1px 0 rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
  font-size: 18px;
  font-weight: 820;
  pointer-events: none;
}

.idle-auto-banner.is-hidden {
  display: none;
}

.site-joystick {
  position: fixed;
  left: 22px;
  bottom: 24px;
  z-index: 11;
  width: 148px;
  height: 166px;
  pointer-events: auto;
  touch-action: none;
}

.site-joystick.is-hidden {
  display: none;
}

.joystick-label {
  height: 18px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.38);
}

.joystick-ring {
  position: relative;
  width: 100%;
  height: 148px;
  border-radius: 50%;
  background: rgba(28, 55, 64, 0.24);
  border: 1px solid rgba(0, 232, 255, 0.45);
  backdrop-filter: blur(4px);
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 232, 255, 0.56);
  border: 2px solid rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  touch-action: none;
}

.loading-box {
  width: min(420px, calc(100vw - 40px));
  padding: 20px;
  background: linear-gradient(180deg, rgba(246, 248, 247, 0.86), rgba(215, 220, 218, 0.76));
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 18px;
  box-shadow:
    10px 14px 32px rgba(0, 0, 0, 0.22),
    inset 1px 1px 0 rgba(255, 255, 255, 0.8);
}

.bar {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  background: #d8dddb;
  border-radius: 999px;
  box-shadow:
    inset 4px 4px 8px rgba(91, 101, 103, 0.18),
    inset -3px -3px 8px rgba(255, 255, 255, 0.85);
}

.bar span {
  display: block;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-2), var(--cyan), #edbd4a);
  border-radius: inherit;
  animation: load 1.1s ease-in-out infinite alternate;
}

@keyframes load {
  from { transform: translateX(-20%); }
  to { transform: translateX(250%); }
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  color: #f4ffff;
  background: linear-gradient(180deg, var(--cyan), var(--cyan-2));
  border-radius: 999px;
  font-size: 12px;
  font-weight: 840;
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 132px;
  }

  .site-jump-nav {
    left: 4px;
    right: 4px;
    top: 8px;
    gap: 1px;
    flex-wrap: nowrap;
    overflow: hidden;
    scrollbar-width: none;
  }

  .site-nav-left {
    flex: 0 0 auto;
    gap: 2px;
  }

  .site-nav-right {
    flex: 0 1 auto;
    gap: 1px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .site-nav-right::-webkit-scrollbar {
    display: none;
  }

  .site-jump-nav::-webkit-scrollbar {
    display: none;
  }

  .site-home-logo {
    flex: 0 0 auto;
    margin-right: 0;
    min-height: 26px;
    justify-content: flex-start;
  }

  .site-home-logo img {
    height: 15px;
    max-width: 92px;
  }

  .site-mobile-hide {
    display: none !important;
  }

  .site-social-start {
    margin-left: 0 !important;
  }

  .site-jump-icon {
    flex: 0 0 auto;
    width: 22px;
    min-height: 26px;
  }

  .site-jump-btn {
    flex: 0 0 auto;
    min-height: 26px;
    padding: 0 2px;
    font-size: 8.4px;
  }

  .topbar {
    top: 38px;
    grid-template-columns: 1fr;
    left: 10px;
    right: 10px;
    gap: 8px;
    padding: 8px 10px;
    overflow: hidden;
  }

  .brand-copy > span {
    white-space: nowrap;
    line-height: 1.25;
    font-size: 10.5px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 5px;
    max-width: 100%;
  }

  .toolbar > * {
    min-width: 0;
  }

  .toolbar > button {
    width: 100%;
  }

  .toolbar > .camera-buttons {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .toolbar button {
    padding: 0 6px;
    font-size: 9.5px;
  }

  .camera-buttons {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
    gap: 2px;
    padding: 0 4px;
  }

  button.camera-button {
    min-width: 0;
    padding: 0 3px;
    font-size: 9.5px;
  }

  .site-joystick {
    left: 10px;
    bottom: 12px;
    width: 104px;
    height: 120px;
  }

  .joystick-ring {
    height: 104px;
  }

  .joystick-knob {
    width: 34px;
    height: 34px;
  }

  .joystick-label {
    font-size: 10px;
  }

  .panel {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(38vh + 20px);
    width: auto;
    max-height: 34vh;
  }

  .panel.options-panel {
    left: 10px;
    right: 10px;
    width: auto;
  }

  .panel.help-panel {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    max-height: 38vh;
  }
}
