:root {
  --bg: #0e1116;
  --panel: #151a21;
  --line: #262d37;
  --fg: #d6dde6;
  --dim: #8b95a3;
  --accent: #6cb6ff;
  --ok: #57d18b;
  font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg); }
body { display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: 16px; padding: 8px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.nav { color: var(--dim); font-size: 12px; text-decoration: none; }
.nav:hover { color: var(--accent); }
.nav.github { display: inline-flex; align-items: center; gap: 4px; }
.nav.github .ci { font-size: 14px; width: 14px; }
.tag { font-size: 11px; color: var(--dim); border: 1px solid var(--line); padding: 1px 6px; border-radius: 10px; }
.templates { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.templates label { color: var(--dim); }
select, button, input {
  background: var(--bg); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.status { min-width: 180px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.status.ok { color: var(--ok); }
main {
  flex: 1; min-height: 0; display: grid; gap: 1px; background: var(--line);
  grid-template-columns: 244px minmax(300px, 1fr) minmax(320px, 1.1fr);
  grid-template-rows: minmax(200px, 1.4fr) minmax(180px, 1fr);
  grid-template-areas: 'files editor preview' 'terminal terminal preview';
}
section { background: var(--panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.files { grid-area: files; }
.editor { grid-area: editor; }
.preview { grid-area: preview; }
.terminal { grid-area: terminal; }
.pane-title {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line);
  color: var(--dim); font-size: 12px; text-transform: none; white-space: nowrap;
}
.pane-title .hint { margin-left: auto; font-size: 11px; }
.pane-title button, .pane-title a { padding: 0 6px; color: var(--dim); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; }
#url { flex: 1; min-width: 0; font-size: 12px; color: var(--dim); }
#url:focus { color: var(--fg); border-color: var(--accent); outline: 0; }

/* Codicon glyphs (the font is bundled with Monaco, see demo.css). */
.ci { font: normal 16px/1 codicon; display: inline-block; width: 16px; text-align: center; flex-shrink: 0; user-select: none; }

/* Files pane */
.files-bar { padding: 3px 6px 3px 10px; gap: 4px; }
.files-bar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.toolbar { display: flex; margin-left: auto; }
.toolbar button, .pane-title .toolbar button {
  border: 0; background: transparent; color: var(--dim); padding: 2px; border-radius: 4px; line-height: 0;
}
.toolbar button:hover:not(:disabled) { color: var(--fg); background: #232b36; }
.toolbar button:disabled { opacity: .35; cursor: default; }
.toolbar button[aria-pressed="true"] { color: var(--accent); }
#tree {
  flex: 1; list-style: none; margin: 0; padding: 4px 0 24px; overflow: auto; outline: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
#tree.drop-target { box-shadow: inset 0 0 0 1px var(--accent); background: #131c27; }
#tree li.row {
  display: flex; align-items: center; gap: 3px; height: 22px; padding: 0 4px 0 calc(6px + var(--depth, 0) * 12px);
  cursor: pointer; white-space: nowrap; position: relative;
}
#tree li.row:hover { background: #1d2430; }
#tree li.row.selected { background: #1a222d; }
#tree li.row.active { background: #1f3147; color: #fff; }
#tree li.row.drop-target { background: #1f3147; box-shadow: inset 0 0 0 1px var(--accent); }
#tree:focus-visible li.row.selected { box-shadow: inset 0 0 0 1px #3a4553; }
#tree .twisty { color: var(--dim); }
#tree .kind { color: #7d8896; font-size: 14px; }
#tree li.dir .kind { color: #c9a75f; }
/* Text badges (JS, TS, V…) for file types codicons have no glyph for. */
.ci.badge, #tree .kind.badge {
  font: 700 7px/16px ui-sans-serif, system-ui, sans-serif; letter-spacing: -.3px; text-align: center; overflow: hidden;
}
.ci.badge[data-len="1"], #tree .kind.badge[data-len="1"] { font-size: 11px; }
.ci.badge[data-len="2"], #tree .kind.badge[data-len="2"] { font-size: 9px; }
#filename { display: flex; align-items: center; gap: 5px; }
#filename .ci:not(.badge) { font-size: 14px; }
#tree .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#tree li.dirty .name::after { content: " ●"; color: var(--accent); }
#tree .more { display: none; border: 0; background: transparent; color: var(--dim); padding: 1px 2px; line-height: 0; border-radius: 4px; }
#tree li.row:hover .more, #tree .more:focus-visible { display: block; }
#tree .more:hover { color: var(--fg); background: #2a323d; }
#tree li.editing input { flex: 1; min-width: 0; padding: 1px 4px; border-radius: 3px; border-color: var(--accent); font: inherit; outline: 0; }
#tree li.empty { padding: 10px 12px; color: var(--dim); font-family: ui-sans-serif, system-ui, sans-serif; white-space: normal; }

/* Editor pane */
#filename { overflow: hidden; text-overflow: ellipsis; color: var(--fg); min-width: 0; }
#filename.dirty::after { content: " ●"; color: var(--accent); }
#editor-wrap { flex: 1; min-height: 0; position: relative; background: var(--bg); }
#editor { position: absolute; inset: 0; }
#editor[hidden] { display: block; visibility: hidden; }
#editor-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--dim); padding: 16px; text-align: center;
}
#editor-empty[hidden] { display: none; }
#editor-empty img {
  max-width: 90%; max-height: 70%; object-fit: contain; image-rendering: auto;
  background: repeating-conic-gradient(#1d2430 0 25%, #151a21 0 50%) 0 0 / 16px 16px;
}

/* Context menu and dialogs */
.menu {
  position: fixed; z-index: 100; min-width: 170px; padding: 4px; background: var(--panel); border: 1px solid #333c48;
  border-radius: 8px; box-shadow: 0 8px 24px #0009; display: flex; flex-direction: column;
}
.menu button {
  display: flex; align-items: center; gap: 8px; border: 0; border-radius: 5px; padding: 4px 10px 4px 6px;
  background: transparent; text-align: left; color: var(--fg); outline: 0;
}
.menu button:hover:not(:disabled), .menu button:focus-visible { background: #1f3147; }
.menu button.danger { color: #ff7b72; }
.menu button:disabled { opacity: .4; cursor: default; }
.menu .ci { color: var(--dim); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }
dialog.chooser {
  background: var(--panel); color: var(--fg); border: 1px solid #333c48; border-radius: 10px; padding: 16px 18px;
  max-width: 440px; box-shadow: 0 16px 48px #000a;
}
dialog.chooser::backdrop { background: #0008; }
dialog.chooser h3 { margin: 0 0 8px; font-size: 14px; }
dialog.chooser p { margin: 0 0 16px; color: var(--dim); }
.chooser-buttons { display: flex; gap: 8px; justify-content: flex-end; }
button.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.preview-body { flex: 1; min-height: 0; position: relative; display: flex; }
/* color-scheme: light makes the browser give pages with a dark scheme (e.g. Chrome's JSON viewer in
   dark mode: light text, transparent canvas) their own opaque canvas instead of our white. */
#preview { flex: 1; border: 0; background: #fff; color-scheme: light; }
.preview-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; background: var(--bg); color: var(--dim);
}
.preview-placeholder[hidden] { display: none; }
.preview-placeholder p { margin: 0; max-width: 360px; }
.preview-placeholder .preview-note { font-size: 11px; margin-top: 12px; }
.preview-placeholder a { color: var(--accent); }
.preview-placeholder .spinner {
  display: none; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.preview-placeholder.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .preview-placeholder .spinner { animation-duration: 2.4s; } }
#term { flex: 1; min-height: 0; position: relative; background: #0b0e12; }
#term .term-view { position: absolute; inset: 4px 6px; display: none; }
#term .term-view.active { display: block; }
.term-bar { padding-top: 3px; padding-bottom: 3px; }
.tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer; color: var(--dim); background: var(--bg); user-select: none; flex-shrink: 0;
}
.tab:hover { border-color: #3a4553; }
.tab.active { color: var(--fg); border-color: var(--accent); }
.tab.exited .tab-label { text-decoration: line-through; }
.tab .tab-close { border: 0; padding: 0 5px; background: transparent; color: var(--dim); line-height: 1.3; border-radius: 4px; }
.tab .tab-close:hover { color: var(--fg); background: #2a323d; }
#new-tab { padding: 0 8px; font-size: 14px; line-height: 1.4; }
code { color: var(--accent); }
.status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

/* Smaller screens: files + editor on top, then terminal, then preview. */
@media (max-width: 1100px) {
  main {
    grid-template-columns: 236px minmax(0, 1fr);
    grid-template-rows: minmax(260px, 1.3fr) minmax(180px, 1fr) minmax(220px, 1fr);
    grid-template-areas: "files editor" "terminal terminal" "preview preview";
  }
}
@media (max-width: 700px) {
  header { flex-wrap: wrap; gap: 8px; }
  .templates { margin-left: 0; }
  .status { min-width: 0; max-width: none; }
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(160px, .8fr) minmax(260px, 1.3fr) minmax(180px, 1fr) minmax(220px, 1fr);
    grid-template-areas: "files" "editor" "terminal" "preview";
  }
  body { height: auto; min-height: 100%; }
  main { min-height: 900px; }
}
