:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  --background: #0d111b;
  --panel: #131a28;
  --deep: #101623;
  --raised: #182132;
  --line: #283347;
  --ink: #edf2fa;
  --muted: #9baac1;
  --mint: #74efc7;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, textarea { font: inherit; }
button:focus-visible, .console:focus-visible, #stdin:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.topbar { border-bottom: 1px solid var(--line); background: #111725; }
.topbar-inner {
  margin: auto;
  max-width: 1512px;
  min-height: 68px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-actions { display: flex; gap: 8px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.09rem; font-weight: 730; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  color: var(--mint);
  background: #163735;
  border: 1px solid #285049;
  border-radius: 9px;
  font: 700 15px var(--mono);
}

main { max-width: 1512px; margin: auto; padding: 30px 32px 32px; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { margin: 0; font-size: clamp(1.7rem, 4.5vw, 2.25rem); letter-spacing: -.045em; line-height: 1.15; }
.subtitle { margin: 8px 0 0; color: var(--muted); font-size: 0.96rem; }
.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.connection::before { content: ""; width: 7px; height: 7px; background: #f1bc72; border-radius: 50%; }
.connection[data-state="live"] { color: var(--mint); border-color: #285049; background: #102520; }
.connection[data-state="live"]::before { background: var(--mint); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(350px, 1fr);
  gap: 16px;
  height: max(600px, calc(100dvh - 211px));
}
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.panel-bar {
  min-height: 53px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-bar h2 { margin: 0; font-size: 0.92rem; font-weight: 680; }
.source-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.source-bar { padding: 0 16px 0 0; background: var(--raised); }
.file-tab {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 19px;
  border-top: 2px solid var(--mint);
  border-right: 1px solid var(--line);
  background: var(--deep);
  font: 0.87rem var(--mono);
}
.file-icon { color: var(--mint); font-weight: 800; }
.language { color: #bfcde3; font-size: 0.83rem; white-space: nowrap; }
.editor { position: relative; display: grid; grid-template-columns: 4.1rem minmax(0, 1fr); background: var(--deep); }
.editor-area { position: relative; min-width: 0; }
.editor:focus-within { box-shadow: inset 0 0 0 1px #466389; }
.gutter { overflow: hidden; position: relative; border-right: 1px solid #202b3e; }
.gutter pre {
  margin: 0;
  padding: 15px 13px 15px 0;
  position: absolute;
  inset: 0;
  text-align: right;
  color: #8293ae;
}
.gutter pre, #highlight, #code {
  font: 0.93rem/1.65 var(--mono);
  tab-size: 2;
  font-variant-ligatures: none;
}
#highlight, #code {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 15px 17px;
  border: 0;
  border-radius: 0;
  white-space: pre;
  overflow: auto;
  scrollbar-width: none;
}
#highlight { pointer-events: none; }
#code { background: transparent; color: transparent; caret-color: var(--ink); outline: 0; resize: none; }
#code::selection { background: #5980b753; color: transparent; }
.syntax-keyword { color: #b9a5ff; }
.syntax-builtin { color: #90caff; }
.syntax-string { color: #a9dfab; }
.syntax-comment { color: #95a6be; }
.syntax-directive { color: #ebba87; }
.syntax-number { color: #ffc58f; }
.syntax-operator { color: #a7bce1; }
.editor-footer, .console-footer {
  border-top: 1px solid var(--line);
  padding: 8px 14px;
  color: var(--muted);
  font: 0.8rem/1.5 var(--mono);
}
.editor-footer { display: flex; justify-content: space-between; gap: 12px; }
.sidebar { min-width: 0; display: grid; gap: 14px; grid-template-rows: auto 150px minmax(210px, 1fr); }
.muted { color: var(--muted); font-size: 0.85rem; }
.room-content { padding: 12px 14px 14px; }
.room-status { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.room-status strong { font-size: 0.92rem; }
.room-status p { margin: 4px 0 0; }
.requests { padding: 0; margin: 12px 0 0; list-style: none; max-height: 200px; overflow: auto; }
.requests li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.request-actions { display: flex; gap: 6px; }
.input-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); }
#stdin {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 11px 14px;
  border: 0;
  border-radius: 0;
  resize: none;
  background: var(--deep);
  color: var(--ink);
  font: 0.9rem/1.55 var(--mono);
}
#stdin:focus-visible { outline-offset: -2px; }
#stdin::placeholder { color: #92a2bd; }
.output-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.console { background: var(--deep); min-height: 0; overflow: auto; padding: 13px 14px; }
.console:focus-visible { outline-offset: -2px; }
.console pre { margin: 8px 0 0; font: 0.9rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.console pre:empty { display: none; }
.run-status { font: 0.84rem/1.5 var(--mono); }
.run-status[data-result="success"] { color: var(--mint); }
.run-status[data-result]:not([data-result=""]):not([data-result="success"]), .diagnostics { color: #ffaaaa; }
kbd { color: #d1def2; }
.button {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 665;
  cursor: pointer;
}
.button:disabled { opacity: 0.55; cursor: default; }
.secondary { background: var(--raised); color: #e0e9f8; border-color: #354259; }
.secondary:not(:disabled):hover { background: #24324a; }
.compact { min-height: 32px; padding: 4px 9px; }
.approval { background: #214741; color: var(--mint); border-color: #39685b; }
.approval:not(:disabled):hover { background: #2b584f; }
.primary { display: inline-flex; align-items: center; gap: 8px; background: var(--mint); color: #0a2620; }
.primary:not(:disabled):hover { background: #a3ffdf; }
.play { width: 0; height: 0; border-block: 5px solid transparent; border-left: 8px solid currentColor; }
.notice {
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid #405574;
  border-radius: 8px;
  background: #18273e;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

@media (max-width: 840px) {
  .topbar-inner, main { padding-inline: 18px; }
  .workspace { grid-template-columns: minmax(0, 1fr); height: auto; }
  .source-panel { min-height: 450px; }
  .sidebar { grid-template-rows: auto 140px minmax(235px, auto); }
  .console { max-height: 380px; }
}

@media (max-width: 480px) {
  .topbar-inner { min-height: 64px; }
  .topbar-inner, main { padding-inline: 12px; }
  .brand-mark { display: none; }
  .button { padding-inline: 8px; }
  .heading { align-items: start; flex-direction: column; gap: 10px; }
  .editor { grid-template-columns: 3rem minmax(0, 1fr); }
  #highlight, #code { padding-inline: 10px; }
}

@media (forced-colors: active) {
  #highlight { visibility: hidden; }
  #code { color: CanvasText; background: Canvas; }
  #code::selection { color: HighlightText; background: Highlight; }
}
