@font-face {
  font-family: "tabler";
  src: url("/static/vendor/tabler-icons.ttf") format("truetype");
  font-display: block;
}

:root {
  color-scheme: dark;
  --bg: #101114;
  --pane: #17191e;
  --gutter: #25282c;
  --line: #2a2d34;
  --text: #e7e5e0;
  --muted: #9a968c;
  --select: #2c333d;
  --accent: #d7a15a;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button, input {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
}

button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.35; }

#app {
  display: grid;
  position: fixed;
  left: var(--vv-x, 0px);
  top: var(--vv-y, 0px);
  width: var(--vv-w, 100%);
  height: var(--vv-h, 100%);
  grid-template-columns: var(--rail-width, 260px) minmax(0, 1fr);
  overflow: hidden;
}
#app.is-rail-hidden { grid-template-columns: minmax(0, 1fr); }
#app.is-rail-hidden #rail { display: none; }

#rail, #workspace {
  min-height: 0;
  min-width: 0;
}

#rail {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--pane);
}

#rail-head, #rail-tools, #term-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 8px;
}

#term-status {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#term-status[hidden] { display: none; }
#term-clear { margin-left: auto; }
#term-clear[hidden] { display: none; }
#rail-head { border-bottom: 1px solid var(--line); }
#rail-tools { border-bottom: 1px solid var(--line); }

#project-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 600;
  padding: 6px 4px;
}

#rail-body, #tabs, #stage, #term, #preview, .ace_editor {
  scrollbar-width: thin;
  scrollbar-color: #5c5852 transparent;
}

#rail-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px 0 16px;
}

.row, .tab, .project-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 3px 8px;
  border-radius: 4px;
}

.row { padding-right: 4px; }
.row.is-selected { background: var(--select); }
.row.is-dragging { background: #3f3424; }
.row.is-drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.row.is-drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.row.is-drop-before.is-drop-after { box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); }
.row.is-drop-into { outline: 1px solid var(--accent); outline-offset: -1px; }
.row.is-open .name { color: #fff; font-weight: 600; }
.row.is-deleted .name { color: var(--muted); font-style: italic; }
.row .name, .project-row .name, .tab .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .ti-pencil,
.row .ti-trash,
.project-row .ti-trash {
  display: none;
  flex: none;
}

.row.is-selected:hover .ti-trash,
.project-row:hover .ti-trash {
  display: inline-flex;
}

.row.is-only:hover .ti-pencil {
  display: inline-flex;
}

#rename-project { visibility: hidden; }
#rail-head:hover #rename-project { visibility: visible; }

.saved-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px 12px;
  color: var(--muted);
  font-size: 12px;
}

.lock-note {
  margin: 0;
  padding: 2px 12px 8px;
  color: var(--muted);
  font-size: 12px;
}

.project-row.is-locked { cursor: default; }
.project-row.is-locked .name,
.project-row.is-locked .kind,
.project-row.is-locked .when { color: var(--muted); }
.project-row.is-locked:hover .ti-trash { display: none; }

.saved-actions { display: flex; align-items: center; }
.saved-actions .ti { flex: none; color: var(--text); }

#rail.is-projects #rail-tools { display: none; }

#rail-body::-webkit-scrollbar,
#tabs::-webkit-scrollbar,
#preview::-webkit-scrollbar,
.ace_scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#rail-body::-webkit-scrollbar-thumb,
#tabs::-webkit-scrollbar-thumb,
#preview::-webkit-scrollbar-thumb {
  background: #5c5852;
}

.ace_scrollbar {
  scrollbar-color: #9a9488 transparent;
}
.ace_scrollbar::-webkit-scrollbar-thumb {
  background: #9a9488;
}
.ace_scrollbar-inner {
  background: transparent;
}

.row, .project-row { cursor: pointer; }
.project-row { padding: 6px 8px; }
.project-row .kind { flex: none; }
.project-row .kind:hover { background: none; }
.project-row .ahead { flex: none; }
.project-row .update {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  padding: 0 4px;
  border-radius: 4px;
  color: var(--text);
}
.project-row .update:hover { background: #2a2d34; }
.project-row .update .ti { width: 16px; height: 16px; }
.project-row .update .ti::before { font-size: 16px; }
.project-row .update .ti:hover { background: none; }
.project-row .update .count { font-size: 12px; }
.row.is-conflict .name,
.tab.is-conflict .name { color: #e15d5d; }
.project-row .when {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.project-row.is-current .name { font-weight: 600; }

#workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

#tabbar {
  display: flex;
  align-items: flex-end;
  position: relative;
  min-width: 0;
  min-height: 0;
  gap: 2px;
  padding: 0 4px 0 2px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
#app.is-rail-hidden #tabbar { padding-left: 0; }
#rail-show {
  display: flex;
  align-items: center;
  align-self: stretch;
  flex: none;
  gap: 6px;
  max-width: 220px;
  margin: 0 4px 0 0;
  padding: 0 8px 0 10px;
  border-top: 1px solid #6a707b;
  border-right: 1px solid #6a707b;
  border-radius: 0;
  background: var(--pane);
}
#rail-show[hidden] { display: none; }
#rail-show:hover { background: var(--select); }
#rail-show .name {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#rail-show .ti { width: 16px; height: 16px; flex: none; }
#rail-show .ti::before { font-size: 16px; }
#rail-show .ti:hover { background: none; }
#tabs {
  display: flex;
  flex: 1;
  align-items: flex-end;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 4px;
  padding: 4px 3px 0;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar {
  display: none;
  height: 0;
  width: 0;
}
#tab-scroll {
  position: absolute;
  bottom: 0;
  height: 3px;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}
#tabbar:hover #tab-scroll { opacity: 1; }
#tab-scroll[hidden] { display: none; }
#tab-scroll i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: rgba(210, 206, 198, 0.55);
}

.tab {
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: auto;
  max-width: none;
  flex: none;
  gap: 4px;
  border-top: 1px solid #6a707b;
  border-left: 1px solid #6a707b;
  border-right: 1px solid #6a707b;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  margin: 0 0 -1px;
  padding: 3px 8px 3px;
  background: #17191e;
}
.tab .name { flex: none; }
.tab .ti {
  width: 16px;
  height: 16px;
}
.tab .ti::before { font-size: 16px; }
.tab.is-active { background: var(--gutter); }
.tab.is-dragging { background: #3f3424; }
.tab.is-drop-before { box-shadow: inset 2px 0 0 var(--accent); }
.tab.is-drop-after { box-shadow: inset -2px 0 0 var(--accent); }
.tab.is-drop-before.is-drop-after { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
.tab.is-deleted { color: var(--muted); }
.tab .ti-download, .tab .ti-x { display: none; flex: none; }
.tab.is-active .ti-download,
.tab.is-active .ti-x { display: inline-flex; }

#run-controls { display: flex; gap: 2px; }

#stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
#ace, #preview { position: absolute; z-index: 1; inset: 0; overflow: hidden; }
#ace.ace-tomorrow-night { background-color: var(--pane); }
#ace .ace_gutter { background: var(--gutter); }
#ace.ace-tomorrow-night.ace_multiselect .ace_selection.ace_start { box-shadow: 0 0 3px 0 var(--pane); }
#readme-toggle {
  position: absolute;
  z-index: 4;
  top: 8px;
  right: 12px;
  background: #17191e;
  border: 1px solid var(--line);
}
#readme-toggle[hidden] { display: none; }
#preview {
  overflow: auto;
  padding: 16px;
  color: var(--muted);
}
#preview img { max-width: 100%; }
#preview.is-readme {
  padding: 28px 52px 32px 28px;
  color: var(--text);
  line-height: 1.55;
}
#preview.is-readme h1,
#preview.is-readme h2,
#preview.is-readme h3,
#preview.is-readme h4,
#preview.is-readme h5,
#preview.is-readme h6 {
  margin: 1.1em 0 0.4em;
  font-weight: 600;
  line-height: 1.25;
}
#preview.is-readme h1 { margin-top: 0; font-size: 28px; }
#preview.is-readme h2 { font-size: 22px; }
#preview.is-readme h3 { font-size: 18px; }
#preview.is-readme p { margin: 0.6em 0; }
#preview.is-readme ul,
#preview.is-readme ol { margin: 0.4em 0; padding-left: 1.4em; }
#preview.is-readme li { margin: 0.2em 0; }
#preview.is-readme a { color: var(--accent); }
#preview.is-readme code {
  font-family: Consolas, monospace;
  font-size: 0.92em;
  background: #101114;
  border-radius: 4px;
  padding: 0 4px;
}
#preview.is-readme pre {
  margin: 0.8em 0;
  padding: 10px 12px;
  background: #101114;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
}
#preview.is-readme pre code { padding: 0; background: none; }
#preview.is-readme blockquote {
  margin: 0.8em 0;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}
#preview.is-readme hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
#preview.is-readme table { border-collapse: collapse; margin: 0.8em 0; }
#preview.is-readme th,
#preview.is-readme td { border: 1px solid var(--line); padding: 4px 8px; }
#preview.is-readme .diagram-svg { margin: 0.8em 0; overflow: auto; }
#preview.is-readme .diagram-svg svg { max-width: 100%; height: auto; }
#preview.is-readme .diagram-svg p {
  margin: 0;
  padding: 0;
  line-height: 1.5;
}
#preview.is-readme .diagram-svg .edgeLabel,
#preview.is-readme .diagram-svg .edgeLabel p,
#preview.is-readme .diagram-svg .edgeLabel div,
#preview.is-readme .diagram-svg .labelBkg {
  background: var(--bg);
  background-color: var(--bg);
}
#preview.is-readme .diagram-svg .edgeLabel rect {
  fill: var(--bg);
  opacity: 1;
}
#preview.is-readme .diagram-error { color: var(--accent); }
#preview pre {
  color: var(--text);
  font-family: Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

#term-pane {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  height: 220px;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: #14120f;
}
#term-pane.is-collapsed {
  height: auto;
  flex-shrink: 0;
}
#term-pane.is-collapsed #term { display: none; }
#term-pane.is-collapsed #term-bar {
  min-height: 0;
  align-items: flex-start;
  padding: 2px 8px 6px;
}
#term-body { flex: 1; min-height: 0; min-width: 0; display: flex; }
#term { position: relative; flex: 1; min-height: 0; min-width: 0; overflow: hidden; padding: 4px 8px 8px; }
#lander-panel {
  width: 132px;
  flex-shrink: 0;
  box-sizing: border-box;
  padding: 8px 10px;
  border-left: 1px solid var(--line);
  background: #101114;
  color: var(--text);
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
}
#lander-panel[hidden] { display: none; }
#lander-panel p { margin: 0 0 6px; }
#lander-controls { white-space: nowrap; }
#lander-package { white-space: pre-line; }
#lander-panel sub { font-size: 0.72em; }
#lander-panel.is-low { color: #e15a4a; }
#lander {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--pane);
}
#lander[hidden] { display: none; }

.split {
  position: absolute;
  z-index: 4;
  background: transparent;
}
.split:hover,
.split.is-dragging { background: rgba(231, 229, 224, 0.12); }
#split-rail {
  top: 0;
  right: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
}
#split-term {
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  cursor: row-resize;
}
body.is-splitting-x, body.is-splitting-x * { cursor: col-resize !important; }
body.is-splitting-y, body.is-splitting-y * { cursor: row-resize !important; }
body.is-splitting-x, body.is-splitting-y { user-select: none; }
.xterm { height: 100%; }

.ti {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
}
.ti:hover { background: #2a2d34; }
.ti::before {
  font-family: "tabler";
  font-size: 18px;
  line-height: 1;
}
.ti-file-plus::before { content: "\eaa0"; }
.ti-folder-plus::before { content: "\eaab"; }
.ti-upload::before { content: "\eb47"; }
.ti-download::before { content: "\ea96"; }
.ti-play::before { content: "\ed46"; }
.ti-stop::before { content: "\ed4a"; }
.ti-pencil::before { content: "\eb04"; }
.ti-trash::before { content: "\eb41"; }
.ti-x::before { content: "\eb55"; }
.ti-share::before { content: "\eb21"; }
.ti-plus::before { content: "\eb0b"; }
.ti-device-laptop::before { content: "\eb64"; }
.ti-brand-github::before { content: "\ec1c"; }
.ti-lock::before { content: "\eae2"; }
.ti-git-pull-request::before { content: "\eab6"; }
#github-pr[hidden] { display: none; }
#github-update[hidden] { display: none; }
.ti-refresh::before { content: "\eb13"; }
.ti-copy::before { content: "\ea7a"; }
.ti-alert-triangle::before { content: "\ea06"; }
.ti-chevrons-left::before { content: "\ea64"; }
.ti-chevrons-right::before { content: "\ea65"; }
.ti-chevron-down::before { content: "\ea5f"; }
.ti-chevron-right::before { content: "\ea61"; }
.ti-chevron-up::before { content: "\ea62"; }
.ti-folder::before { content: "\eaad"; }
.ti-python::before { content: "\ed01"; }
.ti-java::before { content: "\ef0e"; }
.ti-text::before { content: "\eaa2"; }
.ti-photo::before { content: "\eb0a"; }
.ti-zip::before { content: "\ed4e"; }
.ti-unknown::before { content: "\f042"; }
.ti-code::before { content: "\ea77"; }
.ti-brand-cpp::before { content: "\f5fe"; }
.ti-eye::before { content: "\ea9a"; }

.row .ti, .project-row .ti { width: 22px; height: 22px; }
.row .ti::before, .project-row .ti::before { font-size: 16px; }
.tab .ti { width: 16px; height: 16px; }
.tab .ti::before { font-size: 16px; }
.row .twist { width: 16px; height: 16px; flex: none; }
.row .twist::before { font-size: 14px; }

.rename {
  flex: 1;
  min-width: 0;
  background: #0e1014;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
}

#rail-body > .rename {
  display: block;
  width: calc(100% - 16px);
  margin: 4px 8px;
}

.modal {
  position: fixed;
  z-index: 30;
  left: var(--vv-x, 0px);
  top: var(--vv-y, 0px);
  width: var(--vv-w, 100%);
  height: var(--vv-h, 100%);
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(420px, calc(100% - 32px));
  background: #1d2026;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}
.modal-card h2 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0 0 14px; color: var(--muted); }
#modal-body { display: flex; gap: 8px; align-items: flex-start; }
#modal-body[hidden] { display: none; }
#modal-body-text { min-width: 0; }
#modal-warn { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--accent); }
#modal-warn::before { font-size: 18px; }
#modal-warn:hover { background: none; }
#modal-warn[hidden] { display: none; }
.modal-card.has-link { width: min(560px, calc(100% - 32px)); }
#modal-link { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; }
#modal-link[hidden] { display: none; }
#modal-link input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  background: #0e1014;
  border: 1px solid var(--line);
  border-radius: 4px;
}
#modal-field { display: block; margin-bottom: 14px; }
#modal-field[hidden] { display: none; }
#modal-field span { display: block; margin-bottom: 6px; color: var(--muted); }
#modal-field span:empty { display: none; }
#modal-field input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  background: #0e1014;
  border: 1px solid var(--line);
  border-radius: 4px;
}
#modal-check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
#modal-check[hidden] { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button {
  background: #2a2d34;
  border-radius: 6px;
  padding: 6px 12px;
}
#modal-ok { background: var(--accent); color: #1a1208; }
