:root {
  --bg: #111;
  --bg-elev: #151515;
  --bg-sub: #0d0d0d;
  --line: #222;
  --text: #d5d5d5;
  --muted: #8c8c8c;
  --accent: #2f5fff;
  --accent-subtle: #1a2440;
  --danger: #d16a6a;
  --terminal-height: 30vh;
  --font-stack: "IBM Plex Mono", "Consolas", "Menlo", monospace;
  --right-rail-width: 38px;
  --devtools-width: 330px;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-stack);
}

body {
  overflow: hidden;
}

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

.app-layout {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr var(--terminal-height) 20px;
  width: 100%;
  height: 100vh;
  padding-right: var(--right-rail-width);
}

.app-layout[data-devtools-open="true"] {
  padding-right: calc(var(--right-rail-width) + var(--devtools-width));
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.topbar-left {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 100%;
  min-width: 0;
}

.topbar-tabs {
  display: flex;
  align-items: stretch;
  min-width: 0;
  height: 100%;
}

.topbar-tab {
  min-width: 56px;
  padding: 0 14px;
  cursor: pointer;
  border-right: 1px solid var(--line);
  color: var(--text);
}

.topbar-tab:hover,
.topbar-tab[data-open="true"] {
  background: var(--bg-sub);
}

.topbar-menu {
  position: absolute;
  top: 41px;
  min-width: 180px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  display: none;
  z-index: 20;
  max-height: min(72vh, 560px);
  overflow-y: auto;
  overflow-x: visible;
}

.topbar-menu[data-open="true"] {
  display: block;
}

.topbar-menu.has-categories {
  min-width: 210px;
  max-height: none;
  overflow: visible;
}

.menu-heading {
  padding: 7px 12px 6px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: var(--bg-sub);
}

.menu-separator {
  height: 1px;
  background: var(--line);
}

.menu-categories {
  display: flex;
  flex-direction: column;
}

.menu-category {
  position: relative;
}

.menu-category-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px 8px 12px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.menu-category:hover > .menu-category-button,
.menu-category:focus-within > .menu-category-button {
  background: var(--bg-sub);
}

.menu-category-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-category-chevron {
  color: var(--muted);
  margin-left: 10px;
}

.menu-category-panel {
  position: absolute;
  top: -1px;
  left: calc(100% - 1px);
  min-width: 230px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  display: none;
  z-index: 21;
  max-height: min(72vh, 560px);
  overflow-y: auto;
}

.menu-category:hover > .menu-category-panel,
.menu-category:focus-within > .menu-category-panel {
  display: block;
}

.menu-sub-item {
  border-bottom: 1px solid var(--line);
}

.current-file-display {
  max-width: 64vw;
  padding: 0 12px;
  justify-self: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.status-display {
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--muted);
  max-width: 34vw;
}

.status-display[data-level="error"] {
  color: var(--danger);
}

.topbar-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-right: 10px;
}

.settings-root {
  position: relative;
}

.settings-button {
  height: 26px;
  padding: 0 10px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-sub);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.settings-button:hover {
  background: #1b1b1b;
}

.settings-menu {
  position: absolute;
  top: 32px;
  right: 0;
  width: 280px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  display: none;
  z-index: 40;
}

.settings-menu[data-open="true"] {
  display: block;
}

.settings-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.settings-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.settings-preset {
  flex: 1 1 auto;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #101010;
  cursor: pointer;
  font-size: 11px;
}

.settings-preset:hover {
  background: #1a1a1a;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.settings-row input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #0f0f0f;
  color: var(--text);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.settings-action {
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: var(--bg-sub);
  cursor: pointer;
  font-size: 12px;
}

.settings-action:hover {
  background: #1b1b1b;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  min-height: 0;
}

.left-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-sub);
}

.panel-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.explorer-tree {
  padding: 8px 0;
  overflow: auto;
}

.tree-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
}

.tree-list {
  margin: 0;
  padding-left: 14px;
  list-style: none;
}

.tree-list.root {
  padding-left: 10px;
}

details > summary {
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

.tree-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
}

.tree-summary:hover {
  background: #171717;
}

.tree-summary.is-drop-target {
  background: #1a2338;
}

.tree-arrow {
  width: 12px;
  min-width: 12px;
  color: var(--muted);
  transform-origin: 45% 55%;
  transition: transform 120ms ease;
}

details[open] > .tree-summary .tree-arrow {
  transform: rotate(90deg);
}

.tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 8px;
  cursor: pointer;
  text-align: left;
  border-left: 2px solid transparent;
}

.file-icon {
  width: 14px;
  height: 14px;
  min-width: 14px;
  object-fit: contain;
  opacity: 0.95;
}

.file-button:hover {
  background: #171717;
}

.file-button.is-drop-target {
  background: #1a2338;
}

.file-button.is-active {
  border-left-color: var(--accent);
  background: var(--accent-subtle);
}

.explorer-tree.is-drop-target-root {
  box-shadow: inset 0 0 0 1px #2c3f66;
  background: #101524;
}

.center-panel {
  display: grid;
  grid-template-rows: 34px 1fr;
  min-width: 0;
  min-height: 0;
}

.editor-tabs {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.editor-tab {
  display: flex;
  align-items: center;
  height: 100%;
  border-right: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.editor-tab:hover {
  color: var(--text);
  background: var(--bg-sub);
}

.editor-tab.is-active {
  color: var(--text);
  background: var(--bg);
}

.editor-tab.is-dirty .editor-tab-main::after {
  content: " *";
}

.editor-tab-main {
  height: 100%;
  padding: 0 10px 0 12px;
  cursor: pointer;
  color: inherit;
  background: transparent;
  border: none;
  white-space: nowrap;
}

.editor-tab-close {
  width: 24px;
  height: 100%;
  cursor: pointer;
  color: var(--muted);
  border-left: 1px solid var(--line);
}

.editor-tab-close:hover {
  color: var(--text);
  background: #1f1f1f;
}

.editor-host {
  min-height: 0;
}

.terminal-panel {
  display: grid;
  grid-template-rows: auto 8px 1fr;
  min-height: 130px;
  border-top: 1px solid var(--line);
  background: #101010;
}

.vm-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #121212;
  font-size: 12px;
  color: var(--muted);
  max-height: 40px;
  opacity: 1;
  transform: scaleY(1);
  transform-origin: top;
  overflow: hidden;
  transition:
    max-height 160ms ease,
    padding 160ms ease,
    opacity 120ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}

.vm-progress.is-collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-color: transparent;
  opacity: 0;
  transform: scaleY(0);
  pointer-events: none;
}

.vm-progress-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vm-progress-track {
  position: relative;
  width: 100%;
  height: 6px;
  border: 1px solid var(--line);
  background: #0f0f0f;
  overflow: hidden;
}

.vm-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 160ms linear;
}

.vm-progress-fill.is-indeterminate {
  width: 32%;
  animation: vm-progress-indeterminate 1s linear infinite;
}

.terminal-resize-handle {
  cursor: row-resize;
  border-bottom: 1px solid var(--line);
  background: #131313;
}

.terminal-resize-handle:hover,
.terminal-resize-handle.is-dragging {
  background: #1a1a1a;
}

.terminal-host {
  display: flex;
  align-items: stretch;
  position: relative;
  height: 100%;
  min-height: 0;
  padding: 6px 8px 8px;
  overflow: hidden;
}

.vm-screen {
  display: none;
}

.bottom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 8px;
  border-top: 1px solid var(--line);
  background: #101010;
  font-size: 10px;
  color: var(--muted);
}

.bottom-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-mount {
  display: none;
  align-items: center;
  gap: 6px;
  flex: 0 1 360px;
  min-width: 180px;
}

.bottom-mount[data-open="true"] {
  display: inline-flex;
}

.bottom-mount-text {
  min-width: 116px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-mount-track {
  flex: 1 1 auto;
  height: 6px;
  border: 1px solid var(--line);
  background: #0f0f0f;
}

.bottom-mount-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}

#bottom-vm {
  max-width: 34%;
}

#bottom-folder {
  max-width: 26%;
}

#bottom-tabs {
  flex: 1 1 auto;
  min-width: 0;
}

#bottom-terminal {
  margin-left: auto;
}

.right-sidebar {
  position: absolute;
  right: 0;
  top: 42px;
  bottom: 20px;
  width: var(--right-rail-width);
  border-left: 1px solid var(--line);
  background: #0f0f0f;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  z-index: 45;
}

.right-icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: #171717;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

.right-icon-button:hover {
  background: #202020;
}

.devtools-panel {
  position: absolute;
  right: var(--right-rail-width);
  top: 42px;
  bottom: 20px;
  width: var(--devtools-width);
  border-left: 1px solid var(--line);
  background: #0f0f0f;
  display: none;
  grid-template-rows: auto 1fr;
  z-index: 44;
}

.devtools-panel[data-open="true"] {
  display: grid;
}

.devtools-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #131313;
}

.devtools-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.devtools-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.devtools-command-log {
  overflow: auto;
  font-size: 11px;
  line-height: 1.35;
  padding: 6px 8px 8px;
  color: #cfcfcf;
  white-space: pre-wrap;
  word-break: break-word;
}

.devtools-log-empty {
  color: var(--muted);
}

.devtools-log-entry {
  margin-bottom: 6px;
  border-bottom: 1px solid #1a1a1a;
  padding-bottom: 5px;
}

.devtools-log-meta {
  color: #8ea0c8;
  margin-bottom: 2px;
}

.devtools-log-command {
  color: #d7d7d7;
}

.context-menu {
  position: fixed;
  min-width: 160px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  display: none;
  z-index: 120;
}

.context-menu.is-open {
  display: block;
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.context-menu-item:last-child {
  border-bottom: none;
}

.context-menu-item:hover:not(:disabled) {
  background: var(--bg-sub);
}

.context-menu-item:disabled {
  color: #666;
  cursor: default;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 140;
}

.dialog-modal {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--line);
  background: var(--bg-elev);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  padding: 14px;
}

.dialog-title {
  margin: 0;
  font-size: 15px;
}

.dialog-message {
  margin-top: 10px;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.dialog-input {
  width: 100%;
  margin-top: 10px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  background: var(--bg-sub);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.dialog-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog-button {
  min-width: 80px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: var(--bg-sub);
  color: var(--text);
  cursor: pointer;
}

.dialog-button.is-primary {
  border-color: #5874ff;
  background: #243c8f;
}

.xterm {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

@keyframes vm-progress-indeterminate {
  0% {
    transform: translateX(-45%);
  }
  100% {
    transform: translateX(260%);
  }
}

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: minmax(160px, 220px) 1fr;
  }

  .current-file-display {
    max-width: 52vw;
  }
}

@media (max-width: 700px) {
  .app-layout {
    grid-template-rows: auto minmax(240px, 1fr) var(--terminal-height) 20px;
    padding-right: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 200px 1fr;
  }

  .left-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .current-file-display {
    justify-self: start;
    max-width: 100%;
    padding-left: 12px;
  }

  .status-display {
    display: none;
  }

  .topbar-right {
    justify-self: start;
    padding-left: 12px;
    padding-right: 0;
    margin-top: 2px;
  }

  #bottom-vm,
  #bottom-folder {
    display: none;
  }

  .right-sidebar {
    top: auto;
    bottom: 20px;
    left: 0;
    right: 0;
    width: auto;
    height: 34px;
    border-left: none;
    border-top: 1px solid var(--line);
    flex-direction: row;
    justify-content: flex-end;
    padding: 3px 6px 0 0;
    background: rgba(12, 12, 12, 0.94);
  }

  .devtools-panel {
    right: 0;
    top: 62px;
    bottom: 54px;
    width: min(92vw, 360px);
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }
}
