html, body {
  margin: 0;
  height: 100%;
  background: #181818;
  color: #d8d8d8;
}

body {
  display: flex;
  flex-direction: column;
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  font-size: 14px;
}

#statusbar {
  display: flex;
  align-items: center;
  gap: 1em;
  padding: 4px 10px;
  background: #242424;
  border-bottom: 1px solid #333;
  flex: none;
}

#title {
  font-weight: bold;
}

#status {
  color: #888;
  flex: 1;
}

#status.connected { color: #6c6; }

#connectbtn {
  margin: 0;
  font-size: 13px;
  padding: 2px 14px;
  width: auto;
}

#output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.35;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}

#output::-webkit-scrollbar { width: 10px; }
#output::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 5px; }
#output::-webkit-scrollbar-track { background: transparent; }

#main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#splitter {
  flex: none;
  width: 5px;
  cursor: col-resize;
  background: #242424;
  touch-action: none;
}

#splitter:hover, #splitter.dragging { background: #4a6a8a; }

#editorpane {
  flex: none;
  width: 45%;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background: #1b1b1b;
}

#editorpane.collapsed {
  width: 28px;
  min-width: 28px;
}

#editorpane.collapsed #editortabs,
#editorpane.collapsed #editorhost,
#editorpane.collapsed #editorbar {
  display: none;
}

#editorexpand {
  flex: 1;
  width: 100%;
  margin: 0;
  background: #242424;
  color: #888;
  border: none;
  border-radius: 0;
  font: inherit;
  cursor: pointer;
  writing-mode: vertical-rl;
  padding: 8px 0;
}

#editorexpand:hover { background: #333; color: #ccc; }

#editortabs {
  flex: none;
  display: flex;
  overflow-x: auto;
  background: #242424;
  border-bottom: 1px solid #333;
}

.editortab {
  margin: 0;
  background: transparent;
  color: #aaa;
  border: none;
  border-right: 1px solid #333;
  border-radius: 0;
  font: inherit;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  width: auto;
}

.editortab:hover { background: #333; }
.editortab.active { background: #1b1b1b; color: #eee; }
.editortab.dirty { color: #cc5; }

#editorhost {
  flex: 1;
  min-height: 0;
  position: relative;
}

.editorbody {
  position: absolute;
  inset: 0;
}

.editorbody .cm-editor {
  height: 100%;
  font-size: 13px;
}

/* Soft-wrap indication: continuation rows hang-indent, so a wrapped logical
   line is visually distinct from a real newline (which restarts at the
   gutter with a fresh line number). */
.editorbody .cm-line {
  padding-left: 3ch;
  text-indent: -3ch;
}

.editorbody .cm-scroller {
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  overflow-x: hidden;
}

.editorfallback {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  margin: 0;
  background: #1b1b1b;
  color: #e8e8e8;
  border: none;
  outline: none;
  box-shadow: none;
  resize: none;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
}

#editorbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: #242424;
  border-top: 1px solid #333;
}

#editorinfo {
  flex: 1;
  color: #888;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editorsave, #editorclose, #editorcollapse {
  margin: 0;
  font-size: 12px;
  padding: 1px 10px;
  width: auto;
}

#inputline {
  flex: none;
  display: flex;
  border-top: 1px solid #333;
  background: #202020;
}

#input {
  flex: 1;
  margin: 0;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  color: #eee;
  font: inherit;
  padding: 8px 10px;
}

.sys { color: #777; font-style: italic; }
.echoinput { color: #9a9a9a; }

.bold { font-weight: bold; }
.italic { font-style: italic; }
.underline { text-decoration: underline; }

.fg-black   { color: #555; }
.fg-red     { color: #d65f5f; }
.fg-green   { color: #6c6; }
.fg-yellow  { color: #cc5; }
.fg-blue    { color: #6a6ad6; }
.fg-magenta { color: #c6c; }
.fg-cyan    { color: #6cc; }
.fg-white   { color: #e8e8e8; }

.fg-bright-black   { color: #888; }
.fg-bright-red     { color: #f77; }
.fg-bright-green   { color: #7e7; }
.fg-bright-yellow  { color: #ee7; }
.fg-bright-blue    { color: #88f; }
.fg-bright-magenta { color: #e7e; }
.fg-bright-cyan    { color: #7ee; }
.fg-bright-white   { color: #fff; }

.bg-black   { background-color: #000; }
.bg-red     { background-color: #a00; }
.bg-green   { background-color: #0a0; }
.bg-yellow  { background-color: #a50; }
.bg-blue    { background-color: #00a; }
.bg-magenta { background-color: #a0a; }
.bg-cyan    { background-color: #0aa; }
.bg-white   { background-color: #aaa; }

.bg-bright-black   { background-color: #555; }
.bg-bright-red     { background-color: #f55; }
.bg-bright-green   { background-color: #5f5; }
.bg-bright-yellow  { background-color: #ff5; }
.bg-bright-blue    { background-color: #55f; }
.bg-bright-magenta { background-color: #f5f; }
.bg-bright-cyan    { background-color: #5ff; }
.bg-bright-white   { background-color: #fff; }
