:root {
  color-scheme: dark;
  --bg: #10151c;
  --panel: #19222d;
  --panel-2: #121a24;
  --field: #0f1720;
  --line: #344559;
  --text: #edf2f7;
  --muted: #9aa8b8;
  --accent: #7fc7c0;
  --accent-2: #e9c46a;
  --danger: #e07878;
  --ok: #7ed39f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 18% -10%, #1b2f39 0, transparent 34rem), var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111a24;
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
}

button:hover,
button:focus-visible,
.file-button:hover,
.file-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

button.active,
.tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #12252a;
}

button.danger {
  color: var(--danger);
}

a {
  color: var(--accent);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto;
  display: grid;
  gap: 16px;
}

.intro-panel,
.toolbar-panel,
.workspace,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, black);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.22);
}

.intro-panel,
.toolbar-panel,
.panel {
  padding: 16px;
}

.intro-panel {
  display: grid;
  gap: 12px;
}

.builder-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 8px;
  background: linear-gradient(180deg, #12252a, #101923);
  padding: 12px;
}

.repo-cta {
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #d9fffb;
  background: #123139;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.repo-cta:hover,
.repo-cta:focus-visible {
  background: #163f49;
  outline: none;
}

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

.brand-mark {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 9px;
  object-fit: contain;
  filter: drop-shadow(0 0 0.35rem rgb(127 199 192 / 0.18));
}

.brand-lockup strong,
.brand-lockup span:last-child {
  display: block;
}

.brand-lockup strong {
  color: #f4fbff;
  font-size: 20px;
  letter-spacing: 0;
}

.brand-lockup span:last-child {
  color: #a7d8d4;
  font-size: 13px;
}

.intro-panel p {
  max-width: 88ch;
  margin: 0;
  color: var(--muted);
}

.toolbar-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.workspace {
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #111923;
  overflow-x: auto;
}

.tab {
  white-space: nowrap;
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.builder-grid,
.assets-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(360px, 1fr);
  gap: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(520px, 680px) minmax(360px, 1fr);
  gap: 16px;
}

.snippets-panel {
  margin-top: 16px;
}

.snippet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field.compact {
  margin-bottom: 0;
}

.field label,
.checkline {
  color: var(--muted);
  font-size: 12px;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  padding: 8px 9px;
}

textarea {
  min-height: 130px;
  resize: vertical;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input[type="file"] {
  display: none;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.item-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, #151f2a, #101720);
  padding: 10px;
  text-align: left;
}

.item-row.selected {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.item-row strong,
.preview-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--accent-2);
  font-size: 11px;
  white-space: nowrap;
}

.editor-form {
  display: grid;
  gap: 2px;
}

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

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

.asset-list {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
}

.asset-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, #151f2a, #101720);
  padding: 10px;
}

.asset-preview,
.preview-icon {
  display: grid;
  place-items: center;
  color: #96a6b6;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.asset-preview {
  width: 36px;
  height: 36px;
}

.asset-preview::before,
.preview-icon::before {
  content: "";
  width: 62%;
  height: 62%;
  background: currentColor;
  -webkit-mask: var(--asset-url, none) center / contain no-repeat;
  mask: var(--asset-url, none) center / contain no-repeat;
}

.target-summary {
  display: grid;
  gap: 12px;
}

.target-summary section {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111923;
  padding: 12px;
}

.target-summary ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.status-widget-editor {
  display: grid;
  gap: 12px;
}

.status-widget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.status-widget-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111923;
  padding: 12px;
}

.status-widget-card.disabled {
  opacity: 0.68;
}

.status-widget-card.disabled input:not([type="checkbox"]) {
  cursor: not-allowed;
}

.preview-shell {
  min-height: 500px;
}

.preview-workspace {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px;
}

.preview-display-stack {
  display: grid;
  gap: 8px;
  min-width: min(100%, 320px);
  max-width: 100%;
  overflow: auto;
}

.preview-display-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.preview-display-toolbar button {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
}

.preview-display-toolbar button::before,
.preview-display-toolbar button::after {
  content: "";
  grid-area: 1 / 1;
  width: 12px;
  height: 2px;
  background: currentColor;
}

#preview-zoom-in::after {
  transform: rotate(90deg);
}

#preview-zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.preview-frame {
  width: 100%;
}

.preview-frame.graphical-frame {
  width: calc(var(--preview-width, 320px) * var(--preview-zoom, 1));
  height: calc(var(--preview-height, 240px) * var(--preview-zoom, 1));
  overflow: auto;
}

.preview-menu {
  display: grid;
  gap: 8px;
  padding-right: 8px;
  position: relative;
}

.preview-menu.rover-skin {
  align-content: start;
  border: 1px solid #263443;
  border-radius: 8px;
  background: linear-gradient(180deg, #111923, #0c1118);
  padding: 8px 18px 8px 8px;
  min-height: 294px;
}

.preview-menu.graphical-viewport {
  position: relative;
  width: var(--preview-width, 320px);
  height: var(--preview-height, 240px);
  aspect-ratio: var(--preview-aspect, 320 / 240);
  min-height: 0;
  overflow: hidden;
  transform: scale(var(--preview-zoom, 1));
  transform-origin: top left;
}

.preview-menu.rover-skin.graphical-viewport {
  display: block;
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: 0 0 0 1px #263443;
}

.preview-menu.text-stream-preview {
  display: block;
  padding: 0;
}

.stream-output {
  min-height: 248px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #071017;
  color: #dfe8f2;
  padding: 14px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.serial-stream-preview .stream-output {
  color: #cdd8df;
}

.stdio-screen-preview .stream-output {
  color: #e5edf3;
}

.preview-menu.ansi-terminal-preview {
  display: grid;
  gap: 8px;
  justify-content: start;
  padding: 0;
}

.preview-menu.monochrome-viewport {
  position: relative;
  width: var(--preview-width, 128px);
  height: var(--preview-height, 64px);
  aspect-ratio: var(--preview-aspect, 128 / 64);
  min-height: 0;
  overflow: hidden;
  transform: scale(var(--preview-zoom, 1));
  transform-origin: top left;
  border: 0;
  border-radius: 0;
  background: #f7fbff;
  box-shadow: 0 0 0 1px #263443;
  color: #061015;
  font: 7px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mono-line {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--mono-top, 0);
  height: var(--mono-height, 10px);
  padding: 1px 3px 0;
  white-space: nowrap;
  overflow: hidden;
}

.mono-line.title {
  border-bottom: 1px solid #061015;
  font-weight: 700;
}

.mono-line.selected,
.mono-line.editing {
  background: #061015;
  color: #f7fbff;
}

.mono-line.disabled {
  color: #7b8794;
}

.mono-status {
  position: absolute;
  top: 1px;
  right: 3px;
  max-width: 52px;
  overflow: hidden;
  background: #f7fbff;
  color: #061015;
  text-align: right;
  white-space: nowrap;
}

.preview-menu.character-lcd-preview {
  display: block;
  width: fit-content;
  padding: 0;
  transform: scale(var(--preview-zoom, 1));
  transform-origin: top left;
}

.lcd-window {
  display: grid;
  grid-template-rows: repeat(var(--lcd-rows, 2), 1.35em);
  width: fit-content;
  border: 1px solid #273747;
  border-radius: 8px;
  background: #10231b;
  color: #b7ffca;
  padding: 12px;
  box-shadow: inset 0 0 0 3px #07110d;
  font: 18px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0;
}

.lcd-line {
  width: calc(var(--lcd-cols, 16) * 0.62em);
  white-space: pre;
  overflow: hidden;
  text-shadow: 0 0 0.45rem rgb(126 211 159 / 0.45);
}

.terminal-region-label {
  color: var(--muted);
  font-size: 12px;
}

.ansi-terminal {
  display: grid;
  grid-auto-rows: 1.45em;
  width: fit-content;
  min-width: min(100%, calc(var(--terminal-cols, 48) * 0.68em + 28px));
  min-height: calc(var(--terminal-lines, 8) * 1.45em + 28px);
  overflow: auto;
  border: 1px solid #273747;
  border-radius: 7px;
  background: #050b10;
  color: #dfe8f2;
  padding: 14px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ansi-line {
  white-space: pre;
}

.ansi-line.title {
  color: #5fe0c4;
  font-weight: 700;
}

.ansi-line.selected {
  color: #061015;
  background: #5fd5d0;
  font-weight: 700;
}

.ansi-line.editing {
  color: #0d1218;
  background: #e8c36d;
  font-weight: 700;
}

.ansi-line.disabled {
  color: #6f7f8e;
}

.ansi-line.selected.disabled {
  color: #6f7f8e;
  background: transparent;
}

.preview-header,
.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, #17202b, #101720);
  padding: 9px 10px;
  min-height: 42px;
}

.preview-header {
  color: var(--accent);
  font-weight: 700;
  background: linear-gradient(180deg, #1c2634, #121923);
}

.rover-skin .preview-header {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 34px;
  padding: 7px 10px;
}

.rover-skin.graphical-viewport .preview-header {
  position: absolute;
  left: 8px;
  top: 6px;
  width: 304px;
  height: 32px;
  min-height: 0;
  padding: 5px 8px;
  border-radius: 8px;
}

.breadcrumb {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
}

.state-chip span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.state-chip.ready {
  color: #7ed39f;
  background: #12342b;
}

.state-chip.armed {
  color: #e9c46a;
  background: #392a12;
}

.battery-meter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.battery-case {
  display: block;
  width: 24px;
  height: 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 2px;
}

.battery-fill {
  display: block;
  height: 100%;
  background: currentColor;
}

.battery-meter.good {
  color: #7ed39f;
}

.battery-meter.warn {
  color: #e9c46a;
}

.battery-meter.low {
  color: var(--danger);
}

.rover-skin .preview-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 42px;
}

.rover-skin.graphical-viewport .preview-row {
  position: absolute;
  left: 8px;
  top: var(--row-top, 44px);
  width: 294px;
  height: 32px;
  min-height: 0;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  border-radius: 7px;
}

.preview-icon {
  width: 24px;
  height: 24px;
}

.graphical-viewport .preview-icon {
  width: 22px;
  height: 22px;
  margin-left: 7px;
}

.preview-row.selected .preview-icon {
  color: var(--accent);
}

.preview-row.disabled .preview-icon {
  color: #677386;
}

.preview-row.disabled .preview-icon::before,
.preview-icon.empty::before {
  opacity: 0.55;
}

.row-main {
  min-width: 0;
}

.graphical-viewport .row-main strong {
  font-size: 14px;
  line-height: 1;
}

.graphical-viewport .row-main {
  align-self: center;
}

.preview-row.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, #11373c, #0c2329);
  box-shadow: inset 4px 0 0 var(--accent);
}

.preview-row.disabled {
  color: #718091;
}

.preview-row .value {
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.graphical-viewport .preview-row .value {
  align-self: center;
  padding-right: 8px;
  font-size: 14px;
}

.preview-row.choice .value {
  color: var(--accent-2);
}

.value-icon {
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.edit-controls {
  display: inline-grid;
  grid-template-columns: 22px auto 22px;
  align-items: center;
  gap: 7px;
  color: var(--accent);
}

.edit-button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 5px;
}

.edit-button::before,
.edit-button.plus::after {
  content: "";
  width: 10px;
  height: 2px;
  background: currentColor;
  grid-area: 1 / 1;
}

.edit-button.plus::after {
  transform: rotate(90deg);
}

.edit-value {
  min-width: 48px;
  color: var(--accent);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.preview-scrollbar {
  position: absolute;
  top: 52px;
  right: 7px;
  bottom: 9px;
  width: 4px;
  border-radius: 2px;
  background: #223041;
}

.graphical-viewport .preview-scrollbar {
  top: 44px;
  right: auto;
  left: 307px;
  bottom: auto;
  height: 176px;
}

.preview-remote {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 8px;
  align-self: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101720;
}

.remote-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #edf2f7;
  border-radius: 8px;
  background: #141f2a;
}

.remote-button::before,
.remote-button::after {
  content: "";
  grid-area: 1 / 1;
}

.remote-up {
  grid-column: 2;
  grid-row: 1;
}

.remote-left {
  grid-column: 1;
  grid-row: 2;
}

.remote-select {
  grid-column: 2;
  grid-row: 2;
  border-color: var(--accent);
}

.remote-right {
  grid-column: 3;
  grid-row: 2;
}

.remote-down {
  grid-column: 2;
  grid-row: 3;
}

.remote-back {
  grid-column: 3;
  grid-row: 3;
}

.remote-up::before,
.remote-down::before,
.remote-left::before,
.remote-right::before {
  width: 0;
  height: 0;
  border-style: solid;
}

.remote-up::before {
  border-width: 0 8px 11px;
  border-color: transparent transparent currentColor;
}

.remote-down::before {
  border-width: 11px 8px 0;
  border-color: currentColor transparent transparent;
}

.remote-left::before {
  border-width: 8px 11px 8px 0;
  border-color: transparent currentColor transparent transparent;
}

.remote-right::before {
  border-width: 8px 0 8px 11px;
  border-color: transparent transparent transparent currentColor;
}

.remote-select::before {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.remote-back::before {
  width: 17px;
  height: 13px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateX(3px) rotate(45deg);
}

.remote-back::after {
  width: 16px;
  height: 2px;
  background: currentColor;
  transform: translateX(3px);
}

.preview-scrollbar span {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 2px;
  background: #3a968c;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.facts div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111923;
  padding: 10px;
}

.facts span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.facts strong {
  display: block;
  margin-top: 4px;
}

.code-output {
  min-height: 520px;
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b1118;
  color: #dfe8f2;
  padding: 14px;
  font: 12px/1.48 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

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

.instructions {
  display: grid;
  gap: 12px;
}

.instructions section {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111923;
  padding: 12px;
}

.instructions h3 {
  margin-bottom: 8px;
}

.instructions ol,
.instructions ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .toolbar-panel,
  .builder-grid,
  .preview-grid,
  .snippet-grid,
  .assets-grid,
  .status-widget-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    margin: 10px auto;
  }

  .tab-panel,
  .intro-panel,
  .toolbar-panel,
  .panel {
    padding: 12px;
  }

  .builder-brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .form-grid,
  .decorator-grid,
  .facts {
    grid-template-columns: 1fr;
  }
}
