/*
 * GitLite Sandbox Cloud IDE
 * VM workspace theme: Hyper-Violet Engineered Nexus
 *
 * This stylesheet is self-contained for vm.php.
 */
:root {
  --bg-app: #0a0914;
  --bg-nav: #100f1d;
  --bg-sidebar: #0e0d19;
  --bg-editor: #121122;
  --bg-console: #07070f;
  --bg-active-tab: #18162b;
  --bg-input: #090912;
  --border-subtle: rgba(139, 92, 246, 0.15);
  --border-card: rgba(139, 92, 246, 0.25);
  --border-active: #8b5cf6;
  --border-focus: rgba(139, 92, 246, 0.6);
  --primary: #8b5cf6;
  --primary-light: #c084fc;
  --primary-glow: rgba(139, 92, 246, 0.35);
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-code: #e2e8f0;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --header-height: 48px;
  --explorer-width: 310px;
  --console-height: 420px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body.lab-vm-page {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.is-hidden {
  display: none !important;
}

/* ========================================================================== 
   1. Overall workspace shell
   ========================================================================== */
.workspace-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-app);
}

/* ========================================================================== 
   2. Header
   ========================================================================== */
.ws-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 40;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-icon-box {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
  transition: all 0.2s ease;
}

.brand-group:hover .brand-icon-box {
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-glow);
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.workspace-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.workspace-status b {
  color: var(--accent-green);
  font-weight: 600;
}

.status-dot,
.sidebar-ready {
  position: relative;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.btn-header,
.toolbar-btn,
.btn-icon-tool,
.btn-run,
.btn-shell-send,
.custom-modal-btn {
  border: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn-header-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.btn-header-ghost:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.btn-header-link {
  background: rgba(139, 92, 246, 0.12);
  color: var(--primary-light);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.btn-header-link:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px var(--primary-glow);
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.lang-switch a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.lang-switch a.active,
.lang-switch a:hover {
  color: var(--primary-light);
}

/* ========================================================================== 
   3. Body layout and explorer
   ========================================================================== */
.ws-body {
  display: flex;
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.ws-sidebar {
  width: var(--explorer-width);
  min-width: var(--explorer-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-heading {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.sidebar-path {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--primary-light);
  font-family: var(--font-mono);
  font-size: 11px;
}

.sidebar-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-icon-tool {
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 7px;
  border-radius: 4px;
}

.btn-icon-tool:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.explorer-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.breadcrumb-icon {
  color: var(--primary-light);
}

.file-tree-container,
.tree-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 6px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.tree-empty,
.empty-tree {
  padding: 14px 10px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

/* Existing JS-rendered file tree classes */
.ft-row,
.tree-node {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 8px 5px calc(8px + (var(--tree-depth, 0) * 18px));
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.ft-row:hover,
.tree-node:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.ft-row.selected,
.ft-row.active,
.tree-node.active {
  background: rgba(139, 92, 246, 0.15);
  color: var(--primary-light);
  border-left: 2px solid var(--primary);
  padding-left: calc(6px + (var(--tree-depth, 0) * 18px));
}

.ft-caret {
  width: 14px;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.15s ease;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ft-caret.open {
  transform: rotate(90deg);
  color: var(--primary-light);
}

.ft-icon,
.tree-icon {
  width: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.ft-icon.dir::before { content: '📁'; }
.ft-row.selected .ft-icon.dir::before { content: '📂'; }
.ft-icon.file::before { content: '📄'; }
.ft-icon.file.runnable::before { content: '⚡'; color: var(--accent-amber); }

.ft-row .ft-name { line-height: 1.35; }
.ft-row .ft-icon.dir { opacity: 1; }
.ft-row:has(.ft-icon.dir) .ft-name { font-weight: 600; color: var(--text-main); }

.ft-name,
.tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ft-actions {
  display: none;
  gap: 3px;
  flex-shrink: 0;
}

.ft-row:hover .ft-actions {
  display: flex;
}

.ft-actions button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 3px;
}

.ft-actions button:hover {
  color: #fff;
}

.ft-children {
  display: none;
  margin: 0;
  padding: 0;
}

.ft-children.open {
  display: block;
}

.ft-children .ft-row::before {
  content: '';
  position: absolute;
  left: calc(17px + ((var(--tree-depth, 0) - 1) * 18px));
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(139, 92, 246, 0.10);
  pointer-events: none;
}

.ft-name-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--primary);
  border-radius: 4px;
  padding: 3px 5px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
}

.sidebar-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-ready {
  color: var(--accent-green);
  letter-spacing: 0.06em;
}

/* ========================================================================== 
   4. Main editor area
   ========================================================================== */
.ws-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-editor);
  overflow: hidden;
}

.editor-shell {
  min-height: 0;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.editor-topbar {
  min-height: 38px;
  height: 38px;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  flex-shrink: 0;
}

.editor-tabs {
  display: flex;
  align-items: center;
  height: 100%;
  min-width: 0;
}

.editor-tab {
  height: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
}

.editor-tab.active {
  background: var(--bg-active-tab);
  color: var(--primary-light);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-type {
  color: var(--accent-cyan);
  font-size: 10px;
  letter-spacing: 0.05em;
}

.tab-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mode-toggle {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--bg-input);
}

.mode-toggle button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
}

.mode-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.toolbar-open-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.toolbar-btn {
  min-height: 25px;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.toolbar-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.btn-run {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
  white-space: nowrap;
}

.btn-run:hover {
  opacity: 0.92;
}

.btn-run:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Actual JS editor target */
.editor-pane,
.editor-body {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: var(--bg-editor);
}

.editor-content-wrap {
  height: 100%;
  width: 100%;
  padding: 0;
}

.code-area,
#codeArea {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 240px;
  resize: none;
  outline: none;
  border: 0;
  border-radius: 0;
  padding: 14px 18px;
  background: var(--bg-editor);
  color: var(--text-code);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.65;
  tab-size: 4;
  white-space: pre;
}

.code-area::placeholder {
  color: var(--text-dim);
}

.code-area:focus {
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.12);
}

/* ========================================================================== 
   5. AI panel
   ========================================================================== */
.ai-panel {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-editor);
  overflow: hidden;
}

.ai-panel.is-hidden {
  display: none !important;
}

.editor-body.ai-mode .editor-content-wrap {
  display: none;
}

.ai-toolbar {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) minmax(160px, 1fr) minmax(180px, 1.4fr) auto;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.ai-toolbar select,
.ai-toolbar input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  outline: none;
}

.ai-toolbar select:focus,
.ai-toolbar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.ai-free-mode {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid rgba(16, 185, 129, 0.22);
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-green);
  font-size: 9px;
  white-space: nowrap;
}

.ai-free-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 7px rgba(16, 185, 129, 0.6);
}

.ai-free-state {
  color: var(--text-dim);
}

.ai-key-hint {
  flex-shrink: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim);
  font-size: 9.5px;
  line-height: 1.4;
}

.ai-key-hint strong {
  color: var(--primary-light);
}

.ai-key-hint span {
  display: block;
  margin-top: 3px;
  color: var(--accent-amber);
}

.ai-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 11px;
  background: #0d0d0d;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.ai-msg-user { color: var(--accent-amber); }
.ai-msg-assistant { color: var(--text-code); }
.ai-msg-err { color: #e06060; }
.ai-msg-pending { color: var(--text-dim); }

.ai-input-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ai-input-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  color: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 11px;
  outline: none;
}

.ai-input-row input:focus {
  border-color: var(--primary);
}

/* ========================================================================== 
   6. Dropzone
   ========================================================================== */
.dropzone-hint {
  position: absolute;
  inset: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--primary);
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.07);
  color: var(--primary-light);
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
}

.editor-body.dragover .dropzone-hint {
  display: flex;
}

/* ========================================================================== 
   7. Console and shell
   ========================================================================== */
.console-section {
  height: var(--console-height);
  min-height: 160px;
  flex: 0 0 var(--console-height);
  background: var(--bg-console);
  border-top: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  transition: height 0.2s ease, flex-basis 0.2s ease;
  overflow: hidden;
}

.console-header {
  height: 32px;
  min-height: 32px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 12px;
}

.console-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 10px;
}

.window-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.console-title {
  color: var(--text-muted);
  font-weight: 600;
}

.console-status {
  color: var(--text-dim);
  font-size: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-body {
  flex: 1;
  min-height: 0;
  padding: 10px 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}

.empty-console {
  color: var(--text-dim);
}

.term-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.term-prompt,
.cmd-prompt {
  color: #818cf8;
}

.term-cmd,
.cmd-line {
  color: #38bdf8;
  margin-bottom: 4px;
}

.term-output,
.output-dim {
  color: var(--text-dim);
}

.term-output.error,
.output-error {
  color: #f87171;
}

.output-success {
  color: var(--accent-green);
}

.term-status {
  color: var(--text-dim);
}

.term-input-row,
.shell-input-bar {
  padding: 8px 12px 10px;
  background: rgba(7, 7, 15, 0.98);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.shell-prefix,
.term-prompt {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-light);
  white-space: nowrap;
}

.shell-input,
#termInput {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.shell-input:focus,
#termInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.btn-shell-send {
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-shell-send:hover {
  background: #7c3aed;
}

/* ==========================================================================
   8. Modal
   ========================================================================== */
.custom-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  touch-action: none;
  overscroll-behavior: contain;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.custom-modal {
  width: min(420px, calc(100vw - 32px));
  background: #11101e;
  color: var(--text-main);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 10px;
  padding: 46px 18px 18px;
  position: relative;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 24px rgba(139, 92, 246, 0.12);
  font-family: var(--font-mono);
}

.custom-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.custom-modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.custom-modal-close:focus-visible {
  outline: 1px solid var(--primary);
  outline-offset: 1px;
}

.custom-modal-content {
  min-height: 22px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.custom-modal-input {
  width: 100%;
  padding: 8px 10px;
  margin-top: 12px;
  background: #090912;
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: var(--text-main);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}

.custom-modal-input:focus {
  border-color: var(--primary);
}

.custom-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 16px;
}

.custom-modal-btn {
  padding: 7px 14px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
}

.custom-modal-btn.primary {
  background: var(--primary);
  color: #fff;
}

.custom-modal-btn.primary:hover {
  background: #7c3aed;
}

.custom-modal-btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.custom-modal-btn.secondary:hover {
  color: #fff;
}

/* ========================================================================== 
   9. Scrollbars
   ========================================================================== */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-thumb {
  background: #27213d;
  border-radius: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   Desktop editor / console balance
   ========================================================================== */
@media (min-width: 769px) {
  .editor-shell {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  .editor-pane.editor-body {
    min-height: 0;
    flex: 1 1 auto;
  }

  .console-section {
    height: 420px;
    min-height: 420px;
    flex: 0 0 420px;
  }
}

/* ==========================================================================
   Fullscreen workspace panes
   ========================================================================== */
.ws-main.console-maximized .editor-shell {
  display: none !important;
}

.ws-main.console-maximized .console-section {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0;
}

.ws-body.explorer-maximized .ws-sidebar {
  width: 100%;
  min-width: 0;
  flex: 1 1 100%;
  border-right: 0;
}

.ws-body.explorer-maximized .ws-main {
  display: none !important;
}

.explorer-maximize-btn {
  line-height: 1;
}

/* Consistent square icon buttons for workspace controls */
.btn-icon-tool.icon-only {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.btn-icon-tool .tool-svg {
  width: 16px;
  height: 16px;
  display: block;
  stroke: currentColor;
}

.btn-new-workspace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.workspace-new-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 18px;
  line-height: 1;
}

.workspace-new-label {
  white-space: nowrap;
}

/* ========================================================================== 
   10. Mobile
   - Fixed viewport: page itself never scrolls vertically.
   - Larger file tree.
   - Code editor hidden; files open in a modal code window.
   - Console occupies the remaining lower area.
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --header-height: 44px;
    --console-height: auto;
  }

  html,
  body,
  body.lab-vm-page {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .workspace-layout {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .ws-header {
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 6px 9px;
    gap: 7px;
    flex-wrap: nowrap;
  }

  .brand-icon-box {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }

  .brand-title {
    font-size: 13px;
  }

  .brand-badge {
    display: none;
  }

  .header-actions {
    margin-left: auto;
    width: auto;
    justify-content: flex-end;
    gap: 5px;
  }

  .workspace-status {
    display: none;
  }

  .btn-header {
    min-height: 28px;
    padding: 5px 7px;
    font-size: 10px;
  }

  .btn-header.btn-new-workspace {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 7px;
    font-size: 0;
  }

  .btn-header.btn-new-workspace .workspace-new-icon {
    width: 20px;
    height: 20px;
    font-size: 20px;
  }

  .btn-header.btn-new-workspace .workspace-new-label {
    display: none;
  }

  .sidebar-tools .btn-icon-tool.icon-only,
  #btnToggleMaximize {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    font-size: 17px;
    border-radius: 7px;
  }

  #btnToggleMaximize .tool-svg,
  .sidebar-tools .btn-icon-tool.icon-only .tool-svg {
    width: 17px;
    height: 17px;
  }

  .btn-header-ghost {
    padding-inline: 7px;
  }

  .lang-switch {
    padding: 4px 6px;
    font-size: 10px;
  }

  .ws-body {
    height: calc(100% - var(--header-height));
    min-height: 0;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
  }

  .ws-sidebar {
    width: 100%;
    min-width: 0;
    height: 340px;
    min-height: 340px;
    flex: 0 0 340px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .sidebar-header {
    min-height: 46px;
    padding: 8px 10px;
  }

  .sidebar-title {
    font-size: 13px;
  }

  .sidebar-path {
    max-width: 42vw;
    font-size: 10px;
  }

  .sidebar-tools .btn-icon-tool {
    font-size: 10px;
    padding: 5px 6px;
  }

  .explorer-breadcrumb {
    min-height: 34px;
    font-size: 11px;
    padding: 0 10px;
  }

  .file-tree-container,
  .tree-scroll {
    padding: 6px 5px;
    font-size: 13px;
  }

  .ft-row,
  .tree-node {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 12px;
    gap: 7px;
  }

  .ft-row .ft-name {
    font-size: 11.5px;
  }

  .ft-icon,
  .tree-icon {
    width: 18px;
    font-size: 14px;
  }

  .ft-caret {
    font-size: 11px;
  }

  .sidebar-footer {
    padding: 8px 10px;
    font-size: 10px;
  }

  .ws-body.explorer-maximized .ws-sidebar {
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    border-bottom: 0;
  }

  .ws-body.explorer-maximized .file-tree-container,
  .ws-body.explorer-maximized .tree-scroll {
    flex: 1 1 auto;
    min-height: 0;
  }

  .ws-main {
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .editor-shell {
    min-height: 0;
    height: 0;
    flex: 0 0 0;
    overflow: hidden;
  }

  .editor-topbar {
    height: 0;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
  }

  .editor-pane,
  .editor-body,
  .editor-content-wrap,
  #codeArea {
    display: none !important;
  }

  .ai-panel {
    display: none !important;
  }

  .editor-actions,
  .editor-tabs {
    display: none !important;
  }

  .console-section {
    height: auto;
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    border-top: 1px solid var(--border-card);
  }

  .ws-main {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  .console-header {
    height: 36px;
    min-height: 36px;
    padding: 0 9px;
  }

  .console-title-group {
    font-size: 11px;
    gap: 6px;
  }

  .console-status {
    font-size: 9px;
  }

  .console-body {
    min-height: 0;
    padding: 8px 10px;
    font-size: 11.5px;
    line-height: 1.5;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .term-input-row,
  .shell-input-bar {
    margin: 0 8px 8px;
    padding: 7px 8px;
    gap: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: 7px;
    background: rgba(7, 7, 15, 0.98);
    flex-shrink: 0;
  }

  .shell-prefix,
  .term-prompt {
    font-size: 11px;
  }

  #termInput,
  .shell-input {
    padding: 7px 8px;
    font-size: 11px;
  }

  .btn-shell-send {
    padding: 7px 10px;
    font-size: 11px;
  }

  .custom-modal {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 28px);
    overflow: auto;
    padding: 15px;
  }

  .custom-modal-content {
    font-size: 13px;
  }

}

@media (max-width: 420px) {
  .btn-header-link {
    display: none;
  }

  .ws-sidebar {
    height: 310px;
    min-height: 310px;
    flex-basis: 310px;
  }

  .sidebar-header {
    min-height: 44px;
  }

  .ft-row,
  .tree-node {
    min-height: 29px;
    font-size: 11.5px;
  }

  .ft-row .ft-name {
    font-size: 11px;
  }

  .console-title {
    font-size: 10px;
  }

  .console-body {
    font-size: 11px;
  }
}


/* ========================================================================== 
   11. Mobile code viewer modal
   ========================================================================== */
.mobile-code-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  touch-action: none;
  overscroll-behavior: contain;
}

.mobile-code-window {
  width: min(900px, 100%);
  height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-editor);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 28px rgba(139, 92, 246, 0.15);
}

.mobile-code-header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px 0 13px;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-code-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--primary-light);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.mobile-code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-code-actions .mobile-code-close-btn {
  min-width: 34px;
  padding-inline: 8px;
  font-size: 16px;
  line-height: 1;
}

.mobile-code-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  padding: 14px;
  background: var(--bg-editor);
  color: var(--text-code);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}

.mobile-code-area:focus {
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.12);
}

@media (max-width: 768px) {
  .mobile-code-overlay {
    padding: 8px;
  }

  .mobile-code-window {
    width: 100%;
    height: calc(100vh - 16px);
    border-radius: 8px;
  }

  .mobile-code-header {
    min-height: 44px;
  }

  .mobile-code-title {
    font-size: 11px;
  }

  .mobile-code-area {
    font-size: 12px;
    padding: 11px;
  }
}

/* Embed mode: hide navigation chrome when requested by boot query. */
body.embed-mode .brand-badge,
body.embed-mode .header-actions .lang-switch,
body.embed-mode .header-actions .btn-header-link,
body.embed-mode .header-actions .btn-header-ghost {
  display: none;
}

/* ========================================================================== 
   Robust console maximize / restore
   ========================================================================== */
.ws-main {
  position: relative;
}

.ws-main.has-console-maximized .editor-shell {
  display: none !important;
}

.ws-main .console-section.console-maximized {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  flex: none !important;
  z-index: 20;
  border-top: 0;
}

.ws-main .console-section.console-maximized .console-body {
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 768px) {
  .ws-main .console-section.console-maximized {
    top: var(--header-height) !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    height: auto !important;
    max-height: none !important;
    z-index: 30 !important;
  }

  .ft-row {
    touch-action: manipulation;
  }
}

/* ===========================================================================
   Final console fullscreen: escape the workspace frame and cover the viewport
   =========================================================================== */
.ws-main .console-section.console-maximized {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  flex: none !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  z-index: 10000 !important;
}

.ws-main .console-section.console-maximized .console-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: auto !important;
}

.ws-main .console-section.console-maximized .shell-input-bar {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .ws-main .console-section.console-maximized {
    top: var(--header-height) !important;
    bottom: 0 !important;
    height: auto !important;
    max-height: none !important;
    z-index: 30 !important;
  }
}
