:root {
  color-scheme: dark;
  --bg: #080a09;
  --panel: #0e1110;
  --panel-2: #121614;
  --panel-3: #0b0e0c;
  --line: #252b28;
  --line-soft: #1a1f1c;
  --text: #eef3ef;
  --muted: #78847d;
  --muted-2: #4d5751;
  --lime: #b8ff4f;
  --cyan: #74ecff;
  --amber: #ffcf6b;
  --red: #ff6f67;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 1180px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

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

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: -2px;
}

button:disabled {
  cursor: default;
}

::selection {
  background: rgba(116, 236, 255, 0.22);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: #303732;
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 50;
  border: 1px solid var(--lime);
  background: #101510;
  padding: 10px 14px;
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
}

.skip-link:focus {
  top: 8px;
}

.desktop-notice {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 146px 28px;
  width: 100vw;
  height: 100vh;
  min-height: 760px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #0b0e0c;
  padding: 0 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  width: max-content;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark,
.notice-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid #546057;
  border-radius: 50%;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark i,
.notice-mark::before,
.notice-mark::after {
  content: "";
  position: absolute;
  width: 1px;
  height: 17px;
  background: var(--lime);
  transform: rotate(45deg);
  box-shadow: 0 0 9px rgba(184, 255, 79, 0.45);
}

.brand-mark::after,
.notice-mark::after {
  transform: rotate(-45deg);
}

.brand-mark i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #fff;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.runbar,
.top-actions,
.card-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.top-actions {
  justify-self: end;
}

.button,
.text-button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #141816;
  padding: 0 14px;
  color: #bac2bd;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
}

.button:hover:not(:disabled),
.text-button:hover {
  border-color: #465149;
  color: #fff;
}

.button:disabled {
  color: #4f5752;
}

.button-primary {
  border-color: var(--lime);
  background: var(--lime);
  color: #0b0d0b;
  font-weight: 700;
}

.button-primary:hover:not(:disabled) {
  color: #0b0d0b;
  background: #cbff7c;
}

.button-primary kbd {
  margin-left: 9px;
  border-left: 1px solid rgba(0, 0, 0, 0.2);
  padding-left: 8px;
  color: rgba(0, 0, 0, 0.55);
  font: inherit;
  font-size: 8px;
}

.button-icon {
  width: 34px;
  padding: 0;
  font-size: 16px;
}

.play-icon {
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 7px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
}

.stop-icon {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  background: currentColor;
}

.text-button {
  border-color: transparent;
  background: transparent;
  padding: 0 7px;
}

.local-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 7px;
  color: #8f9b94;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.local-pill i,
.statusbar i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px rgba(184, 255, 79, 0.8);
}

.workbench {
  display: grid;
  grid-template-columns: 222px minmax(500px, 1fr) 440px;
  min-height: 0;
}

.panel {
  min-width: 0;
  background: var(--panel);
}

.files-panel,
.editor-panel {
  border-right: 1px solid var(--line);
}

.files-panel {
  position: relative;
  display: grid;
  grid-template-rows: 39px minmax(0, 1fr);
  min-height: 0;
}

.panel-heading,
.preview-heading,
.editor-tabs {
  height: 39px;
  border-bottom: 1px solid var(--line);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.panel-heading div {
  display: flex;
  gap: 2px;
}

.panel-heading button,
.preview-card header button,
.console header button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.panel-heading button {
  width: 24px;
  height: 25px;
  padding: 0;
  font-size: 13px;
}

.panel-heading button:hover,
.preview-card header button:hover,
.console header button:hover {
  color: var(--text);
}

.side-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 84px;
}

.project-name {
  display: flex;
  align-items: center;
  height: 32px;
  gap: 5px;
  padding: 0 10px;
  color: #acb5af;
  font-family: var(--mono);
  font-size: 10px;
}

.project-name strong {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row {
  position: relative;
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr) 20px;
  align-items: center;
  width: 100%;
  height: 31px;
  gap: 5px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  padding: 0 7px 0 19px;
  color: #8e9992;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  text-align: left;
}

.file-row:hover,
.file-row.active {
  background: #151a17;
  color: #e7ece8;
}

.file-row.active {
  border-left-color: var(--lime);
}

.file-row .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .delete-file {
  display: none;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
}

.file-row:hover .delete-file,
.file-row:focus-within .delete-file {
  display: block;
}

.file-row .delete-file:hover {
  color: var(--red);
}

.lua-badge {
  color: #8ed9ff;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: -0.04em;
}

.files-footer {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 2;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  background: rgba(11, 14, 12, 0.95);
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.6;
  backdrop-filter: blur(8px);
}

.files-footer strong {
  display: block;
  color: #728078;
  font-weight: 400;
}

.simulator-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding: 0 12px 14px;
}

.section-label {
  margin: 13px 0 14px 2px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.control-group {
  margin-bottom: 15px;
}

.control-group > label,
.ble-form > label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #78847d;
  font-family: var(--mono);
  font-size: 8px;
  text-transform: uppercase;
}

.control-group output {
  color: #aab5ae;
  font: inherit;
}

.event-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.event-buttons button {
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #121613;
  color: #8c9690;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
}

.event-buttons button:hover {
  border-color: #536057;
  color: var(--lime);
}

.range-group input {
  width: 100%;
  height: 12px;
  margin: 0;
  appearance: none;
  background: transparent;
}

.range-group input::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, #6c923a, #273029);
}

.range-group input::-webkit-slider-thumb {
  width: 9px;
  height: 9px;
  margin-top: -3px;
  border: 1px solid #d3f3a3;
  border-radius: 50%;
  background: var(--lime);
  appearance: none;
  cursor: ew-resize;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch-row > label {
  margin: 0;
}

.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 0;
  color: #667169;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
}

.switch span {
  position: relative;
  width: 25px;
  height: 14px;
  border: 1px solid #384039;
  border-radius: 8px;
  background: #181c19;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #636e66;
  transition: transform 140ms ease, background 140ms ease;
}

.switch i {
  min-width: 54px;
  font-style: normal;
}

.switch.active {
  color: #9bac9f;
}

.switch.active span {
  border-color: #72973d;
}

.switch.active span::after {
  background: var(--lime);
  transform: translateX(11px);
}

.ble-form div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 27px;
}

.ble-form input,
.ble-form button {
  height: 27px;
  border: 1px solid var(--line);
  background: #0a0d0b;
  color: #aeb7b1;
  font-family: var(--mono);
  font-size: 9px;
}

.ble-form input {
  min-width: 0;
  border-radius: 3px 0 0 3px;
  padding: 0 7px;
}

.ble-form button {
  border-left: 0;
  border-radius: 0 3px 3px 0;
  color: var(--lime);
  cursor: pointer;
}

.editor-panel {
  display: grid;
  grid-template-rows: 39px minmax(0, 1fr) 24px;
  min-height: 0;
  background: #0b0e0c;
}

.editor-tabs {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
}

.editor-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 148px;
  max-width: 240px;
  border: 0;
  border-right: 1px solid var(--line);
  border-top: 2px solid var(--lime);
  background: #0b0e0c;
  padding: 0 12px;
  color: #d7ded9;
  font-family: var(--mono);
  font-size: 10px;
}

.editor-tab > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-tab i {
  width: 5px;
  height: 5px;
  margin-left: auto;
  border-radius: 50%;
  background: transparent;
}

.editor-tab i.dirty {
  background: var(--amber);
}

.editor-status {
  align-self: center;
  margin-right: 13px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
}

.editor-shell {
  display: grid;
  grid-template-columns: 47px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 14%, rgba(36, 53, 42, 0.13), transparent 31%),
    #0b0e0c;
}

.line-numbers,
.highlight-layer,
#editor {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-ligatures: none;
  line-height: 1.68;
  tab-size: 2;
}

.line-numbers {
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid #151916;
  padding: 15px 12px 40px 0;
  color: #38403b;
  text-align: right;
  user-select: none;
}

.code-layer {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.highlight-layer,
#editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 15px 20px 80px;
  white-space: pre;
}

.highlight-layer {
  overflow: hidden;
  color: #cbd3ce;
  pointer-events: none;
}

#editor {
  z-index: 1;
  resize: none;
  overflow: auto;
  outline: none;
  background: transparent;
  caret-color: #f4fff6;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

#editor::selection {
  background: rgba(116, 236, 255, 0.24);
}

.token-comment { color: #59645d; }
.token-keyword { color: #cf92ff; }
.token-api { color: #8ed9ff; }
.token-function { color: #a8dbff; }
.token-string { color: #d8ef9b; }
.token-number { color: #ffb67c; }

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  border-top: 1px solid var(--line-soft);
  padding: 0 11px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
}

.preview-panel {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 13px;
  background: #101310;
}

.preview-heading {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(16, 19, 16, 0.96);
  backdrop-filter: blur(9px);
}

.preview-heading div {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.preview-heading span,
.fps {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.preview-heading strong {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
}

.preview-heading strong[data-state="running"],
.preview-heading strong[data-state="ready"] {
  color: var(--lime);
}

.preview-heading strong[data-state="error"] {
  color: var(--red);
}

.fps {
  letter-spacing: 0;
}

.preview-card {
  margin: 12px 12px 0;
  border: 1px solid var(--line);
  background: #0b0e0c;
}

.preview-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  border-bottom: 1px solid var(--line-soft);
  padding: 0 8px 0 12px;
}

.preview-card header > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.preview-card header strong {
  font-size: 11px;
  font-weight: 550;
}

.preview-card header span {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 8px;
}

.preview-card header button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
}

.raw-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: 260px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    #090b0a;
  background-size: 16px 16px;
}

.halo-display-bezel {
  position: relative;
  width: 230px;
  height: 230px;
  border: 1px solid #282f2a;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 8px #0d100e, 0 0 0 9px #202520, 0 17px 40px #000;
  overflow: hidden;
}

#rawCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #000;
  image-rendering: pixelated;
}

.display-sheen {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0.045), transparent 32%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.pixel-coordinate {
  position: absolute;
  right: 8px;
  bottom: 6px;
  color: #3f4742;
  font-family: var(--mono);
  font-size: 8px;
}

.world-stage {
  position: relative;
  height: 230px;
  overflow: hidden;
  cursor: grab;
  background: #111915;
  touch-action: none;
}

.world-stage.dragging {
  cursor: grabbing;
}

#worldCanvas,
#worldOverlay,
.world-vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#worldCanvas {
  display: block;
}

#worldOverlay {
  z-index: 2;
  pointer-events: none;
}

#worldVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.world-vignette {
  z-index: 3;
  background:
    radial-gradient(ellipse at center, transparent 43%, rgba(3, 7, 5, 0.22) 70%, rgba(2, 5, 3, 0.82) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.5), transparent 17%, transparent 83%, rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.drag-hint,
.video-credit {
  position: absolute;
  bottom: 8px;
  z-index: 4;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--mono);
  font-size: 7px;
  text-shadow: 0 1px 4px #000;
}

.drag-hint {
  left: 9px;
  pointer-events: none;
}

.drag-hint i {
  margin-right: 4px;
  color: var(--lime);
  font-style: normal;
}

.video-credit {
  right: 9px;
  max-width: 175px;
  overflow: hidden;
  text-align: right;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-credit:hover {
  color: #fff;
}

.raw-stage:fullscreen,
.world-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  background-color: #050706;
}

.raw-stage:fullscreen .halo-display-bezel {
  width: min(72vh, 72vw);
  height: min(72vh, 72vw);
}

.world-stage:fullscreen .drag-hint,
.world-stage:fullscreen .video-credit {
  bottom: 18px;
  font-size: 10px;
}

.console {
  min-height: 0;
  border-top: 1px solid var(--line);
  background: #0b0e0c;
}

.console header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  border-bottom: 1px solid var(--line-soft);
  padding: 0 12px 0 6px;
}

.console-tabs,
.console-actions {
  display: flex;
  height: 100%;
}

.console header button {
  position: relative;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.console header button.active {
  color: #c8d0cb;
}

.console header button.active::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 1px;
  background: var(--lime);
}

.console header i {
  display: inline-grid;
  place-items: center;
  min-width: 14px;
  height: 14px;
  margin-left: 3px;
  border-radius: 7px;
  background: #202521;
  color: #7a837d;
  font-style: normal;
  letter-spacing: 0;
}

.console-output {
  height: calc(100% - 34px);
  overflow: auto;
  padding: 8px 16px 20px;
  color: #89948d;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.7;
}

.console-line {
  display: grid;
  grid-template-columns: 68px 48px minmax(0, 1fr);
}

.console-line time {
  color: #444d47;
}

.console-line em {
  color: #67726b;
  font-style: normal;
  text-transform: uppercase;
}

.console-line[data-kind="ready"] em,
.console-line[data-kind="system"] em {
  color: var(--lime);
}

.console-line[data-kind="error"] {
  color: #ff9a94;
}

.console-line[data-kind="error"] em {
  color: var(--red);
}

.console-line[data-kind="ble"] em {
  color: var(--cyan);
}

.console-empty {
  color: #465049;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 28px;
  border-top: 1px solid #293129;
  background: #151b16;
  padding: 0 12px;
  color: #78847c;
  font-family: var(--mono);
  font-size: 8px;
}

.statusbar span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #aab5ae;
}

.statusbar span:first-child.error i {
  background: var(--red);
  box-shadow: 0 0 8px rgba(255, 111, 103, 0.8);
}

.statusbar span:first-child.stopped i {
  background: #626d65;
  box-shadow: none;
}

.statusbar a {
  margin-left: auto;
  color: #8e9992;
  text-decoration: none;
}

.statusbar a:hover {
  color: var(--lime);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 42px;
  z-index: 20;
  max-width: 360px;
  border: 1px solid #455047;
  border-left: 2px solid var(--lime);
  background: rgba(12, 16, 13, 0.96);
  padding: 10px 13px;
  color: #c9d2cc;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 130ms ease, transform 130ms ease;
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: var(--red);
}

@media (max-width: 1280px) {
  .workbench {
    grid-template-columns: 210px minmax(470px, 1fr) 410px;
  }

  .button-primary kbd {
    display: none;
  }
}

@media (max-width: 1179px), (max-height: 759px) {
  html,
  body {
    min-width: 0;
  }

  body {
    display: grid;
    place-items: center;
    overflow: auto;
    background:
      radial-gradient(circle at 50% 40%, rgba(83, 117, 54, 0.14), transparent 32%),
      #080a09;
  }

  .desktop-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 390px;
    border: 1px solid var(--line);
    padding: 28px;
    color: #b8c2bc;
    font-family: var(--mono);
    text-align: center;
  }

  .desktop-notice strong {
    margin-top: 15px;
    color: #eef5ef;
    font-size: 13px;
  }

  .desktop-notice p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.7;
  }

  .app-shell,
  .skip-link {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
