:root {
  --bg: #071019;
  --panel: #101d29;
  --panel-2: #142534;
  --line: #294155;
  --muted: #91a7b7;
  --text: #edf8ff;
  --cyan: #30d5e8;
  --green: #48e09a;
  --yellow: #ffc857;
  --red: #ff626f;
  --blue: #4f91ff;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #02070c;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, textarea { font: inherit; }
button { color: inherit; }

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(27, 71, 92, .3), transparent 48%),
    #03090f;
}

#app {
  position: absolute;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  display: grid;
  grid-template-rows: 104px 1fr 116px;
  gap: 14px;
  padding: 20px 24px;
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(145deg, #07111b, #0b1823 60%, #071019);
  background-size: 32px 32px, 32px 32px, auto;
}

.topbar, .controls, .panel {
  border: 1px solid var(--line);
  background: rgba(13, 27, 39, .94);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .25);
}

.topbar {
  border-radius: 14px;
  display: grid;
  grid-template-columns: 430px 1fr auto;
  align-items: center;
  gap: 28px;
  padding: 16px 22px;
}

.eyebrow, .mission-label {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 { margin: 2px 0 0; font-size: 29px; line-height: 1.1; }
.mission { padding-left: 25px; border-left: 1px solid var(--line); }
.mission strong { display: block; margin-top: 5px; font-size: 18px; }
.header-actions { display: flex; align-items: center; gap: 14px; }

.status {
  min-width: 150px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a1720;
  font-weight: 800;
  text-align: center;
}

.status span {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px currentColor;
}

.status.running span { background: var(--yellow); }
.status.failed span { background: var(--red); }
.status.success span { background: var(--green); }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 615px; gap: 14px; }
.panel { min-height: 0; border-radius: 14px; overflow: hidden; }
.factory-panel { display: grid; grid-template-rows: 54px minmax(0, 1fr) 46px; }

.panel-title, .editor-title, .factory-footer, .console-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #112230;
}

.panel-title { padding: 0 18px; font-weight: 800; }
.indicator { display: inline-block; width: 9px; height: 9px; margin-right: 9px; border-radius: 50%; background: var(--cyan); }
.telemetry { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; font-weight: 600; }

#factory { display: block; width: 100%; height: 100%; background: #0a151f; }

.factory-footer { border-top: 1px solid var(--line); border-bottom: 0; padding: 0 16px; color: var(--muted); font-size: 13px; }
kbd { padding: 3px 7px; margin-right: 5px; border: 1px solid #456176; border-radius: 5px; background: #1a3040; color: #dffaff; font-family: inherit; }

.code-panel { display: grid; grid-template-rows: 50px minmax(120px, 1fr) auto 170px; }
.editor-title { padding: 0 15px; color: var(--muted); font-size: 13px; }
.file-tab { align-self: stretch; display: flex; align-items: center; padding: 0 15px; border-bottom: 3px solid var(--cyan); color: var(--text); font-weight: 750; }
.python-icon { margin-right: 9px; padding: 3px 5px; border-radius: 4px; background: #2769a8; color: #ffe061; font-size: 11px; }

.editor-wrap { min-height: 0; display: grid; grid-template-columns: 48px 1fr; background: #07111a; }
#line-numbers {
  margin: 0;
  padding: 17px 10px;
  overflow: hidden;
  border-right: 1px solid #1e3445;
  color: #4f6d82;
  text-align: right;
  font: 17px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  user-select: none;
}

#code {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 17px 18px;
  background: transparent;
  color: #deedfa;
  caret-color: var(--cyan);
  font: 17px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 4;
}

.reference { padding: 12px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #10202c; }
.reference-heading { margin-bottom: 8px; color: var(--cyan); font-size: 12px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.command-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.command-grid code { color: #d8e9f6; font-size: 12px; }
.reference p { margin: 9px 0 0; color: var(--muted); font-size: 12px; }

.console { min-height: 0; display: grid; grid-template-rows: 36px 1fr; background: #061018; }
.console-heading { padding: 0 14px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.console-heading button { border: 0; background: none; color: var(--muted); cursor: pointer; text-transform: none; }
#output { margin: 0; padding: 13px 16px; overflow: auto; white-space: pre-wrap; color: #bcd0dd; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

.controls { border-radius: 14px; display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; }
.control-group { display: flex; gap: 12px; }
.button {
  min-height: 49px;
  padding: 0 20px;
  border: 1px solid #426176;
  border-radius: 9px;
  background: #1a3040;
  font-weight: 800;
  cursor: pointer;
  transition: transform .1s, filter .1s;
}
.button:hover:not(:disabled) { filter: brightness(1.16); transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button.run { min-width: 190px; border-color: #31b979; background: #168453; }
.button.danger { border-color: #a94451; background: #58232b; }
.button.secondary { background: #132633; }

.scoreboard { display: flex; height: 72px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #09151e; }
.scoreboard div { min-width: 145px; padding: 11px 20px; border-left: 1px solid var(--line); }
.scoreboard div:first-child { border-left: 0; }
.scoreboard span { display: block; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.scoreboard strong { display: block; margin-top: 4px; font-size: 20px; }

@media (max-aspect-ratio: 4/3) {
  /* The app retains its 16:9 working area and letterboxes rather than rearranging controls. */
}
