:root {
  --bg: #07090d;
  --panel: #0c1118;
  --panel2: #10161f;
  --line: #1c2634;
  --txt: #c9d6e3;
  --dim: #5b6b7d;
  --accent: #00e5ff;
  --accent2: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --mono: 'Cascadia Code', 'JetBrains Mono', Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--mono);
  overflow: hidden;
}

.crt {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 3px);
}

/* ---------- top bar ---------- */
#topbar {
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0077ff);
  color: #000; font-weight: 700; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px rgba(0, 229, 255, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: 2px; color: #fff; }
.brand-sub { font-size: 10px; color: var(--dim); letter-spacing: 1px; }
.top-status { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 1px; color: var(--accent2); }
.led {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
  animation: blink 2s infinite;
}
.led.err { background: var(--err); box-shadow: 0 0 8px var(--err); animation: none; }
.led.busy { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: blink .5s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- layout ---------- */
#layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 12px;
  padding: 12px;
  height: calc(100% - 52px);
}
@media (max-width: 860px) {
  #layout { grid-template-columns: 1fr; }
  #monitor { display: none; }
}

/* ---------- monitor ---------- */
#monitor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
}
#monitor h2 { font-size: 11px; letter-spacing: 3px; color: var(--dim); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.mon-block { display: flex; flex-direction: column; gap: 6px; }
.mon-label { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 1px; color: var(--dim); }
.mon-val { color: var(--accent); }
.bar { height: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #0077ff, var(--accent));
  transition: width .3s ease;
}
.mon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mon-cell {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; text-align: center;
}
.mon-num { font-size: 20px; font-weight: 700; color: #fff; }
.mon-label2 { font-size: 9px; letter-spacing: 2px; color: var(--dim); margin-top: 2px; }
.mon-log { flex: 1; min-height: 80px; }
#m-syslog { font-size: 10px; color: var(--accent2); line-height: 1.6; overflow: hidden; }
#m-syslog div::before { content: '▸ '; color: var(--dim); }

/* ---------- stage ---------- */
#stage {
  display: grid;
  grid-template-rows: 24px 1fr 24px 190px;
  gap: 8px;
  min-height: 0;
}
.stage-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: 2px; color: var(--dim);
}
#screen-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, .03) 1px, transparent 1px);
  background-size: 24px 24px;
}
#screen { position: absolute; inset: 0; }
#screen-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 12px; letter-spacing: 2px;
}
#screen-empty.hidden, .hidden { display: none !important; }

#console {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.7;
  min-height: 0;
}
#console .line { white-space: pre-wrap; word-break: break-word; }
#console .line::before { content: '❯ '; color: var(--dim); }
#console .warn { color: var(--warn); }
#console .err { color: var(--err); }
#console .sys { color: var(--accent); }
#console .stamp { color: var(--dim); margin-right: 6px; }

.mini-btn {
  background: var(--panel2); color: var(--dim);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  padding: 3px 8px; cursor: pointer;
}
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- editor launcher ---------- */
#editor-launch {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 58px; height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #10161f, #0c1118);
  color: var(--accent);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
#editor-launch:hover {
  transform: translateY(-2px) scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(0, 229, 255, .3);
}
#editor-launch.open { color: var(--warn); border-color: var(--warn); }

/* ---------- floating editor ---------- */
#editor-win {
  position: fixed; right: 26px; bottom: 92px; z-index: 50;
  width: min(560px, calc(100vw - 40px));
  height: min(480px, calc(100vh - 160px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  overflow: hidden;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.95) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.editor-titlebar {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  cursor: grab; user-select: none;
}
.editor-titlebar:active { cursor: grabbing; }
.editor-dots { display: flex; gap: 5px; }
.editor-dots i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.editor-dots i:nth-child(1) { background: #ff5f57; }
.editor-dots i:nth-child(2) { background: #febc2e; }
.editor-dots i:nth-child(3) { background: #28c840; }
.editor-title { flex: 1; font-size: 11px; color: var(--dim); letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-toolbar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
#examples {
  flex: 1;
  background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--mono); font-size: 11px; padding: 5px 8px;
  outline: none;
}
.btn-run {
  background: linear-gradient(135deg, #0077ff, var(--accent));
  color: #001; border: none; border-radius: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 6px 12px; cursor: pointer;
}
.btn-run:hover { filter: brightness(1.15); }
.kbd {
  background: rgba(0,0,0,.25); border-radius: 4px; padding: 1px 5px;
  font-size: 9px; font-weight: 400;
}
#code {
  flex: 1;
  background: #0a0e14; color: #d5e3f0;
  border: none; outline: none; resize: none;
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  padding: 12px 14px;
  tab-size: 4;
  caret-color: var(--accent);
}
.editor-statusbar {
  display: flex; justify-content: space-between;
  padding: 5px 12px;
  border-top: 1px solid var(--line);
  font-size: 10px; color: var(--dim); letter-spacing: 1px;
}
#editor-status.ok { color: var(--accent2); }
#editor-status.err { color: var(--err); }

/* ---------- rendered roblox UI defaults ---------- */
.rbx-text {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; white-space: pre-wrap; word-break: break-word;
  user-select: none;
}
.rbx-click { cursor: pointer; }
.rbx-click:active { filter: brightness(.85); }
.rbx-part {
  background: linear-gradient(145deg, #b9b9b9, #8a8a8a);
  border: 2px solid #6f6f6f;
  box-shadow: inset -6px -8px 14px rgba(0,0,0,.28), inset 5px 6px 10px rgba(255,255,255,.28);
}
