/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1b1f27;
  --border: #21262d;
  --border-light: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #c9d1d9;
  --text-muted: #8b949e;
  --text-faint: #6e7681;
  --text-dim: #484f58;
  --accent: #58a6ff;
  --accent-bg: rgba(88, 166, 255, 0.1);
  --green: #3fb950;
  --red: #f85149;
  --yellow: #ffd43b;
  --pink: #f97583;
  --blue: #79c0ff;
  --purple: #bc8cff;
  --orange: #f0883e;
  --swift-red: #f05138;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, sans-serif;
  --hint-bg: #1c2128;
  --hint-border: #30363d;
  --hint-active-bg: rgba(88, 166, 255, 0.15);
  --hint-active-color: #58a6ff;
  --hint-text: #c9d1d9;
  --hint-icon-tag: #f97583;
  --hint-icon-attr: #79c0ff;
  --hint-icon-prop: #bc8cff;
  --hint-icon-val: #3fb950;
  --hint-icon-kw: #f0883e;
  --modal-bg: #1c2128;
  --modal-border: #30363d;
}

/* ===== Light Theme ===== */
body.light-theme {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eef1f5;
  --border: #d8dee4;
  --border-light: #d0d7de;
  --text-primary: #1f2328;
  --text-secondary: #353b43;
  --text-muted: #656d76;
  --text-faint: #818b98;
  --text-dim: #a3acb6;
  --accent: #0969da;
  --accent-bg: rgba(9, 105, 218, 0.08);
  --green: #1a7f37;
  --red: #cf222e;
  --yellow: #9a6700;
  --pink: #cf222e;
  --blue: #0550ae;
  --purple: #8250df;
  --orange: #bc4c00;
  --swift-red: #d4310e;
  --hint-bg: #ffffff;
  --hint-border: #d0d7de;
  --hint-active-bg: rgba(9, 105, 218, 0.1);
  --hint-active-color: #0969da;
  --hint-text: #1f2328;
  --hint-icon-tag: #cf222e;
  --hint-icon-attr: #0550ae;
  --hint-icon-prop: #8250df;
  --hint-icon-val: #1a7f37;
  --hint-icon-kw: #bc4c00;
  --modal-bg: #ffffff;
  --modal-border: #d0d7de;
}

html,
body {
  height: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-sans);
}

.main {
  display: flex;
  height: calc(100vh - 48px - 60px);
  min-height: 0;
}

.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
}
.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.footer-links a {
  font-size: 12px;
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-links a:hover {
  color: var(--text-primary);
}

.footer-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.3px;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

.title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Page navigation links in editor header */
.header-page-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.page-nav-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 5px;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.page-nav-link:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

@media (max-width: 900px) {
  .header-page-nav { display: none; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Run Button (in header) */
.run-btn {
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  background: #238636;
  color: #fff;
  cursor: pointer;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}

.run-btn:hover {
  background: #2ea043;
}

.run-btn:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: default;
}

.run-icon {
  font-size: 10px;
}

/* Save Button */
.save-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}

.save-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: rgba(63, 185, 80, 0.1);
}

/* Save Dropdown */
.save-dropdown {
  position: fixed;
  background: #1c2128;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 250;
  min-width: 170px;
  display: none;
}

.save-dropdown.visible {
  display: block;
}

.save-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

.save-dropdown-item:hover {
  background: rgba(88, 166, 255, 0.1);
}

/* Layout Toggle */
.layout-toggle {
  display: flex;
  gap: 2px;
}

.layout-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: all 0.15s;
  white-space: nowrap;
}

.layout-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.layout-btn:hover:not(.active) {
  color: var(--text-muted);
  border-color: var(--text-dim);
}

/* ===== Editor Panel ===== */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-width: 0;
  min-height: 0;
  border-right: 2px solid var(--border);
}

/* Tabs */
.editor-tabs {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 160px;
}

.tab:hover {
  color: var(--text-muted);
}

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

.tab[data-tab="html"].active {
  border-bottom-color: var(--pink);
}

.tab[data-tab="css"].active {
  border-bottom-color: var(--blue);
}

.tab[data-tab="python"].active {
  border-bottom-color: var(--yellow);
}

.tab[data-tab="swift"].active {
  border-bottom-color: var(--swift-red);
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Dynamic tab name truncation */
.tab .tab-name {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* File Label */
.editor-file-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid #2d333b;
  flex-shrink: 0;
}

.file-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

#fileName {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.8px;
}

/* Editor */
.editor-wrapper {
  flex: 1;
  position: relative;
  min-height: 0;
}

/* Emmet Popup */
.emmet-popup {
  display: none;
  position: absolute;
  top: 40px;
  left: 16px;
  background: #1c2128;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  min-width: 250px;
}

.emmet-popup.visible {
  display: block;
}

.emmet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--accent-bg);
  cursor: pointer;
}

.emmet-item:hover {
  background: rgba(88, 166, 255, 0.15);
}

.emmet-trigger {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(88, 166, 255, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
}

.emmet-desc {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}

.emmet-hint {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: var(--border);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ===== Resize Handle ===== */
.resize-handle {
  width: 4px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
}

.resize-handle:hover,
.resize-handle.active {
  background: var(--accent);
}

/* ===== Right Panel ===== */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.preview-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 2px solid var(--border);
}

.preview-section.hidden {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.green-dot {
  background: var(--green);
  box-shadow: 0 0 6px rgba(63, 185, 80, 0.3);
}

.yellow-dot {
  background: var(--yellow);
  box-shadow: 0 0 6px rgba(255, 212, 59, 0.3);
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
}

/* Browser Chrome Bar */
.browser-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #1e2430;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.browser-dots {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.bdot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.bdot.red {
  background: #ff5f57;
}

.bdot.yellow {
  background: #febc2e;
}

.bdot.green {
  background: #28c840;
}

.browser-tab {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  padding: 3px 12px;
  max-width: 160px;
  flex-shrink: 0;
}

.browser-tab-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browser-url {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  min-width: 0;
}

.lock-icon {
  color: var(--green);
  flex-shrink: 0;
}

.browser-url-text {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-content {
  flex: 1;
  min-height: 0;
}

#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #e8e8e8;
}

/* Terminal */
.terminal-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.terminal-section.hidden {
  display: none;
}

.clear-btn {
  margin-left: auto;
  padding: 2px 10px;
  font-size: 11px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--font-sans);
}

.clear-btn:hover {
  color: var(--text-secondary);
  border-color: var(--text-faint);
}

.terminal-content {
  flex: 1;
  background: var(--bg-primary);
  padding: 16px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
  min-height: 0;
}

.console-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.console-line.out {
  color: var(--text-secondary);
}

.console-line.out::before {
  content: "> ";
  color: var(--green);
}

.console-line.error {
  color: var(--red);
}

.console-line.error::before {
  content: "x ";
}

.console-line.info {
  color: var(--text-faint);
  font-style: italic;
}

.console-line.placeholder {
  color: var(--text-dim);
}

.console-line.placeholder .green {
  color: var(--green);
  font-weight: 600;
}

/* Layout States */
.main.layout-code .right-panel,
.main.layout-code .resize-handle {
  display: none;
}

.main.layout-preview .editor-panel,
.main.layout-preview .resize-handle {
  display: none;
}

.main.layout-code .editor-panel {
  border-right: none;
}

/* CodeMirror */
.cm-wrap {
  position: absolute;
  inset: 0;
  display: none;
}

.cm-wrap.active {
  display: block;
}

.cm-wrap .CodeMirror {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  padding: 0;
  font-variant-ligatures: none;
  -webkit-font-variant-ligatures: none;
}

.cm-wrap .CodeMirror pre,
.cm-wrap .CodeMirror-code,
.cm-wrap .CodeMirror-line,
.cm-wrap .CodeMirror-line span,
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line * {
  font-variant-ligatures: none !important;
  -webkit-font-variant-ligatures: none !important;
  font-feature-settings: "liga" 0, "calt" 0 !important;
}

.cm-wrap .CodeMirror-gutters {
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
}

.cm-wrap .CodeMirror-linenumber {
  color: var(--text-dim);
}

.cm-wrap .CodeMirror-cursor {
  border-left-color: var(--accent);
}

.cm-wrap .CodeMirror-selected {
  background: rgba(88, 166, 255, 0.15);
}

.cm-wrap .CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.03);
}

/* VS Code Dark+ Theme */
.cm-s-playground .cm-comment {
  color: #6a9955;
  font-style: italic;
}

/* Template edit hint highlights */
.cm-s-playground .cm-customize-hint {
  background: rgba(250, 204, 21, 0.22);
  color: #a38b10;
  font-style: italic;
  border-radius: 3px;
  padding: 1px 0;
}

/* Customize guide header lines */
.cm-customize-guide {
  background: rgba(59, 130, 246, 0.08) !important;
}

/* Color picker popup */
.color-picker-popup {
  background: #1c2128;
  border: 1px solid #444c56;
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-family: 'JetBrains Mono', monospace;
  animation: cpFadeIn 0.12s ease;
}
@keyframes cpFadeIn { from { opacity:0; transform:translateY(-2px); } to { opacity:1; transform:translateY(0); } }
.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.2);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.color-swatch:hover { transform: scale(1.15); border-color: #3b82f6; }
.color-picker-popup .color-picker-label {
  font-size: 12px;
  color: #8b949e;
}
/* Color palette grid */
.cp-palette {
  border-top: 1px solid #30363d;
  margin-top: 6px;
  padding-top: 6px;
}
.cp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.cp-color {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.cp-color:hover { transform: scale(1.2); border-color: #fff; }

/* Inline code explanation widgets */
.cm-line-widget {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 11.5px;
  color: #64748b;
  padding: 1px 0 1px 24px;
  border-left: 2px solid #3b82f6;
  margin-left: 4px;
  line-height: 1.4;
  background: rgba(59, 130, 246, 0.04);
  pointer-events: none;
  user-select: none;
}

/* Clickable guide lines (click to jump to section) */
.cm-guide-clickable {
  cursor: pointer !important;
  position: relative;
}
.cm-guide-clickable .CodeMirror-line {
  text-decoration: underline !important;
  text-decoration-color: #3b82f6 !important;
  text-underline-offset: 3px;
}
.cm-guide-clickable .CodeMirror-line span {
  color: #60a5fa !important;
}
.cm-guide-clickable:hover {
  background: rgba(59, 130, 246, 0.12) !important;
}
.cm-guide-clickable:hover .CodeMirror-line span {
  color: #93c5fd !important;
}

/* Insertable code idea widget */
.cm-idea-insert {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 11.5px;
  color: #22c55e;
  padding: 2px 0 2px 24px;
  margin-left: 4px;
  line-height: 1.4;
  user-select: none;
}
.cm-idea-toggle {
  cursor: pointer;
  transition: color 0.15s;
}
.cm-idea-toggle:hover {
  color: #4ade80;
}
.cm-idea-preview {
  margin: 6px 0 4px;
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: 8px;
  padding: 12px;
  max-width: 500px;
}
.cm-idea-preview pre {
  margin: 0 0 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.cm-idea-insert-btn {
  background: #22c55e;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.cm-idea-insert-btn:hover {
  background: #16a34a;
}

/* Preview-to-code sync highlight */
.cm-preview-highlight {
  background: rgba(59, 130, 246, 0.25) !important;
  border-left: 3px solid #3b82f6 !important;
  animation: highlightPulse 1.5s ease;
}
@keyframes highlightPulse {
  0% { background: rgba(59, 130, 246, 0.5) !important; }
  100% { background: rgba(59, 130, 246, 0.25) !important; }
}
.cm-preview-highlight .CodeMirror-linenumber {
  color: #3b82f6 !important;
  font-weight: 700;
}
.cm-value-highlight {
  background: rgba(59, 130, 246, 0.25);
  outline: 1.5px solid #3b82f6;
  border-radius: 3px;
  padding: 1px 0;
}
.cm-color-highlight {
  outline: 1.5px dashed #3b82f6;
  border-radius: 2px;
}

/* Hints toggle button */
.hints-toggle {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  color: #8b949e;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.hints-toggle:hover { border-color: #3b82f6; color: #c9d1d9; }
.hints-toggle.active { background: rgba(59,130,246,0.12); border-color: #3b82f6; color: #3b82f6; }
.hints-toggle .toggle-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #484f58; transition: background 0.15s;
}
.hints-toggle.active .toggle-dot { background: #3b82f6; }

.cm-s-playground .cm-tag {
  color: #808080;
}

.cm-s-playground .cm-tag.cm-bracket {
  color: #808080;
}

.cm-s-playground .cm-attribute {
  color: #9cdcfe;
}

.cm-s-playground .cm-string {
  color: #ce9178;
}

.cm-s-playground .cm-string-2 {
  color: #ce9178;
}

.cm-s-playground .cm-meta {
  color: #808080;
}

.cm-s-playground .cm-qualifier {
  color: #d7ba7d;
}

.cm-s-playground .cm-property {
  color: #9cdcfe;
}

.cm-s-playground .cm-number {
  color: #b5cea8;
}

.cm-s-playground .cm-unit {
  color: #b5cea8;
}

.cm-s-playground .cm-atom {
  color: #ce9178;
}

.cm-s-playground .cm-keyword {
  color: #c586c0;
}

.cm-s-playground .cm-variable {
  color: #9cdcfe;
}

.cm-s-playground .cm-variable-2 {
  color: #9cdcfe;
}

.cm-s-playground .cm-variable-3 {
  color: #4ec9b0;
}

.cm-s-playground .cm-def {
  color: #dcdcaa;
}

.cm-s-playground .cm-type {
  color: #4ec9b0;
}

.cm-s-playground .cm-operator {
  color: #d4d4d4;
}

.cm-s-playground .cm-builtin {
  color: #dcdcaa;
}

/* Xcode Dark for Swift */
.cm-wrap#swiftEditor .CodeMirror {
  color: #d0d0d0;
}

.cm-wrap#swiftEditor .cm-keyword {
  color: #fc5fa3;
}

.cm-wrap#swiftEditor .cm-type,
.cm-wrap#swiftEditor .cm-variable-3 {
  color: #5dd8ff;
}

.cm-wrap#swiftEditor .cm-def {
  color: #41a1c0;
}

.cm-wrap#swiftEditor .cm-variable {
  color: #d0d0d0;
}

.cm-wrap#swiftEditor .cm-variable-2 {
  color: #d0d0d0;
}

.cm-wrap#swiftEditor .cm-string {
  color: #fc6a5d;
}

.cm-wrap#swiftEditor .cm-string-2 {
  color: #fc6a5d;
}

.cm-wrap#swiftEditor .cm-number {
  color: #d0bf69;
}

.cm-wrap#swiftEditor .cm-comment {
  color: #6c7986;
  font-style: italic;
}

.cm-wrap#swiftEditor .cm-property {
  color: #5dd8ff;
}

.cm-wrap#swiftEditor .cm-attribute {
  color: #cc7ec9;
}

.cm-wrap#swiftEditor .cm-operator {
  color: #d0d0d0;
}

.cm-wrap#swiftEditor .cm-builtin {
  color: #b281eb;
}

.cm-wrap#swiftEditor .cm-atom {
  color: #fc5fa3;
}

.cm-wrap#swiftEditor .cm-meta {
  color: #fc5fa3;
}

/* File Explorer Sidebar */
.file-sidebar {
  width: 180px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  overflow-y: auto;
  user-select: none;
  position: relative;
}

.sidebar-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  font-family: var(--font-sans);
}

.sidebar-section {
  padding: 0;
}

.sidebar-folder {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-family: var(--font-sans);
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
}

.folder-arrow {
  font-size: 8px;
  color: var(--text-faint);
}

.sidebar-files {
  padding: 2px 0;
}

.sidebar-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 14px 3px 28px;
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.1s;
}

.sidebar-file i {
  font-size: 16px;
  width: 16px;
  flex-shrink: 0;
}

.sidebar-file:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-file.active {
  background: rgba(88, 166, 255, 0.08);
  color: var(--text-primary);
}

/* Editor Area */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Sidebar uploads */
.sidebar-uploads {
  padding: 2px 0;
}

.sidebar-file .img-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-add-btn {
  margin-left: auto;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
  font-family: var(--font-sans);
  opacity: 0;
  transition: opacity 0.15s;
}

.file-sidebar:hover .sidebar-add-btn {
  opacity: 1;
}

.sidebar-add-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: #1c2128;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 200;
  min-width: 160px;
  display: none;
}

.context-menu.visible {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: rgba(88, 166, 255, 0.1);
}

.context-menu-item.danger:hover {
  background: rgba(248, 81, 73, 0.12);
  color: var(--red);
}

.context-menu-item .ctx-icon {
  width: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.context-menu-item.danger .ctx-icon {
  color: var(--red);
}

.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* Add File Dropdown */
.add-dropdown {
  position: absolute;
  background: #1c2128;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 150;
  min-width: 150px;
  display: none;
}

.add-dropdown.visible {
  display: block;
}

.add-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

.add-dropdown-item:hover {
  background: rgba(88, 166, 255, 0.1);
}

.add-dropdown-item .add-icon {
  font-size: 18px;
  color: var(--text-muted);
  width: 18px;
  text-align: center;
}

/* Drag & Drop Overlay */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(88, 166, 255, 0.08);
  border: 2px dashed var(--accent);
  border-radius: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
}

.drag-overlay.visible {
  display: flex;
}

.drag-overlay-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-sans);
  background: rgba(88, 166, 255, 0.15);
  padding: 6px 14px;
  border-radius: 6px;
}

/* Image Preview Tab */
.image-preview-wrap {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg-primary);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.image-preview-wrap.active {
  display: flex;
}

.image-preview-wrap.doc-mode img,
.image-preview-wrap.doc-mode .image-preview-actions {
  display: none !important;
}

.image-preview-wrap.doc-mode {
  background: #f5f5f5;
  justify-content: flex-start;
  padding: 0;
}

/* Doc/Excel/PDF preview — light overrides only inside doc-mode */
.doc-mode .doc-preview-loading { color: #666; }
.doc-mode .doc-preview-toolbar { background: #e8e8e8; border-bottom-color: #d0d0d0; }
.doc-mode .doc-nav-btn { background: #fff; border-color: #ccc; color: #333; }
.doc-mode .doc-nav-btn:hover:not(:disabled) { background: #e3f2fd; color: #1565c0; border-color: #1565c0; }
.doc-mode .doc-page-info { color: #555; }
.doc-mode .docx-preview-content { color: #333; }
.doc-mode .docx-preview-content h1, .doc-mode .docx-preview-content h2 { color: #111; }
.doc-mode .docx-preview-content h3 { color: #222; }
.doc-mode .docx-preview-content th { background: #e8e8e8; color: #333; }
.doc-mode .docx-preview-content th, .doc-mode .docx-preview-content td { border-color: #d0d0d0; }
.doc-mode .docx-preview-content a { color: #1565c0; }
.doc-mode .excel-toolbar { background: #e8e8e8; border-bottom-color: #d0d0d0; }
.doc-mode .excel-file-name { color: #666; }
.doc-mode .excel-table th, .doc-mode .excel-table td { border-color: #d0d0d0; color: #333; }
.doc-mode .excel-table thead th { background: #e8e8e8; color: #555; }
.doc-mode .excel-row-num { background: #e8e8e8 !important; color: #888 !important; }
.doc-mode .excel-table tbody td { background: #fff; }
.doc-mode .excel-table tbody tr:hover td { background: #e3f2fd; }

.image-preview-wrap img {
  max-width: 100%;
  max-height: 80%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.image-preview-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

.img-action-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}

.img-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.img-action-btn.primary {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.img-action-btn.primary:hover {
  background: #2ea043;
}

/* Rename Input */
.sidebar-file .rename-input {
  background: var(--bg-primary);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 1px 4px;
  width: 100%;
  outline: none;
}

/* Dynamic Tab Close */
.tab .tab-close {
  font-size: 14px;
  line-height: 1;
  color: var(--text-dim);
  margin-left: 4px;
  border-radius: 3px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  opacity: 0;
  flex-shrink: 0;
}

.tab:hover .tab-close {
  opacity: 1;
}

.tab.active .tab-close {
  opacity: 1;
}

.tab .tab-close:hover {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red);
}

.tab[data-upload-tab].active {
  border-bottom-color: #4ec9b0;
}

/* Responsive — see comprehensive mobile styles at bottom of file */

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== CodeMirror Search Dialog ===== */
.CodeMirror-dialog {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.CodeMirror-dialog input {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 3px 8px;
  outline: none;
  margin: 0 4px;
}

.CodeMirror-dialog input:focus {
  border-color: var(--accent);
}

.CodeMirror-dialog button {
  background: var(--border-light);
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  margin: 0 2px;
}

.CodeMirror-dialog button:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.cm-searching {
  background: rgba(255, 212, 59, 0.3);
}

/* ===== Header Search Bar ===== */
.search-bar {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-muted);
}

.search-bar.visible {
  display: flex;
}

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  width: 160px;
}

.search-bar input::placeholder {
  color: var(--text-dim);
}

.search-count {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 40px;
  text-align: center;
}

.search-nav {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}

.search-nav:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.search-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.search-close:hover {
  color: var(--red);
}

.header-text-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
  white-space: nowrap;
}

.header-text-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}


.header-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ===== Tab Bar Overflow ===== */
.editor-tabs {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
}

.editor-tabs::-webkit-scrollbar {
  display: none;
}

.editor-tabs-wrap {
  position: relative;
}

.tab-scroll-left,
.tab-scroll-right {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to right, var(--bg-secondary), transparent);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  z-index: 10;
  font-size: 12px;
}

.tab-scroll-left {
  left: 0;
}

.tab-scroll-right {
  right: 0;
  background: linear-gradient(to left, var(--bg-secondary), transparent);
}

.tab-scroll-left.visible,
.tab-scroll-right.visible {
  display: flex;
}

/* ===== Console Panel ===== */
.console-panel {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 200px;
  flex-shrink: 0;
}

.console-panel.collapsed .console-output {
  display: none;
}

.console-panel.collapsed {
  max-height: none;
}

.console-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
}

.console-badge {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--red);
  border-radius: 8px;
  padding: 0 5px;
  min-width: 16px;
  text-align: center;
  display: none;
}

.console-badge.visible {
  display: inline-block;
}

.console-toggle-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 4px;
}

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  background: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  max-height: 150px;
}

.console-line-entry {
  padding: 1px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.console-line-entry.log {
  color: var(--text-secondary);
}

.console-line-entry.warn {
  color: var(--yellow);
}

.console-line-entry.error {
  color: var(--red);
}

.console-line-entry.info {
  color: var(--accent);
}

.console-line-entry::before {
  margin-right: 6px;
  font-size: 10px;
}

.console-line-entry.log::before {
  content: "›";
  color: var(--text-dim);
}

.console-line-entry.warn::before {
  content: "⚠";
}

.console-line-entry.error::before {
  content: "✕";
}

.console-line-entry.info::before {
  content: "ℹ";
}

/* ===== Stdin Input ===== */
.stdin-bar {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stdin-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}

.stdin-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 8px;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

.stdin-input:focus {
  border-color: var(--accent);
}

/* ===== Interactive Terminal Input ===== */
.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.terminal-prompt {
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  caret-color: var(--accent);
}
.cm-trailingspace {
  background: rgba(255, 0, 0, 0.15);
  border-bottom: 1px dashed rgba(255, 0, 0, 0.3);
}

/* ===== Terminal Inline Input ===== */
.terminal-prompt-line {
  display: flex;
  align-items: center;
  padding: 2px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
}

.terminal-prompt-text {
  color: var(--green);
  white-space: pre;
  flex-shrink: 0;
}

.terminal-inline-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  caret-color: var(--accent);
  padding: 0;
  margin: 0;
  line-height: 1.8;
}

.terminal-inline-input::placeholder {
  color: var(--text-dim);
}

.terminal-input-value {
  color: var(--text-secondary);
}

.terminal-input-controls {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}

.terminal-input-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}

.terminal-input-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.terminal-input-btn.primary {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.terminal-input-btn.primary:hover {
  background: #2ea043;
}

/* ===== Sidebar Folders ===== */
.sidebar-user-folder {
  user-select: none;
}

.sidebar-user-folder-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 14px 3px 20px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 0.1s;
}

.sidebar-user-folder-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-user-folder-header .folder-arrow {
  font-size: 8px;
  color: var(--text-faint);
  transition: transform 0.15s;
}

.sidebar-user-folder.collapsed .folder-arrow {
  transform: rotate(-90deg);
}

.sidebar-user-folder.collapsed .sidebar-folder-files {
  display: none;
}

.sidebar-folder-files .sidebar-file {
  padding-left: 40px;
}

.sidebar-user-folder-header .folder-add-btn {
  margin-left: auto;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-sans);
  opacity: 0;
  transition: opacity 0.15s;
}

.sidebar-user-folder:hover .folder-add-btn {
  opacity: 1;
}

.folder-add-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.sidebar-user-folder-header .folder-icon {
  font-size: 13px;
  flex-shrink: 0;
}

/* ===== Matching HTML Tags ===== */
.CodeMirror-matchingtag {
  background: rgba(88, 166, 255, 0.15);
  border-bottom: 1px solid var(--accent);
}

/* ===== Code Folding ===== */
.CodeMirror-foldgutter {
  width: 14px;
}

.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.7;
  padding: 0 2px;
}

.CodeMirror-foldgutter-open::after {
  content: "▾";
}

.CodeMirror-foldgutter-folded::after {
  content: "▸";
}

.CodeMirror-foldmarker {
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-mono);
}

/* Error gutter */
.CodeMirror-lint-markers {
  width: 16px;
}

/* ===== Indent Guides ===== */
.cm-wrap .CodeMirror .CodeMirror-line {
  background-image:
    repeating-linear-gradient(to right,
      transparent,
      transparent calc(2ch - 1px),
      rgba(255, 255, 255, 0.05) calc(2ch - 1px),
      rgba(255, 255, 255, 0.05) 2ch);
  background-size: 2ch 100%;
  background-position: left top;
}

/* Hide indent guides on the active line to keep it clean */
.cm-wrap .CodeMirror .CodeMirror-activeline .CodeMirror-line {
  background-image: none;
}

/* ===== CSS Color Swatches ===== */
.cm-color-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  margin-right: 3px;
  vertical-align: middle;
  pointer-events: none;
}

/* Stop Button */
.stop-btn {
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  background: #da3633;
  color: #fff;
  cursor: pointer;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}

.stop-btn:hover {
  background: #f85149;
}

.stop-icon {
  font-size: 10px;
}

/* Matplotlib plot in terminal */
.terminal-plot {
  max-width: 100%;
  border-radius: 6px;
  margin: 8px 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  display: block;
  background: #0d1117;
  padding: 8px;
}

/* Pandas table in terminal */
.terminal-html {
  margin: 8px 0;
  overflow-x: auto;
}

.terminal-html table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e6edf3;
  background: #161b22;
  border-radius: 6px;
  overflow: hidden;
}

.terminal-html th {
  background: #1c2128;
  color: #79c0ff;
  padding: 6px 12px;
  text-align: left;
  border-bottom: 1px solid #30363d;
  font-weight: 600;
  white-space: nowrap;
}

.terminal-html td {
  padding: 4px 12px;
  border-bottom: 1px solid #21262d;
  white-space: nowrap;
}

.terminal-html tr:hover td {
  background: rgba(88, 166, 255, 0.06);
}

/* Excel Preview */
.excel-preview-table {
  max-width: 100%;
  max-height: 80%;
  overflow: auto;
  border-radius: 6px;
  background: #161b22;
}

.excel-sheet-name {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #3fb950;
  font-family: var(--font-mono);
  background: #1c2128;
  border-bottom: 1px solid #30363d;
}

.excel-preview-table table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e6edf3;
  width: 100%;
}

.excel-preview-table th {
  background: #1c2128;
  color: #79c0ff;
  padding: 6px 12px;
  text-align: left;
  border: 1px solid #30363d;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.excel-preview-table td {
  padding: 4px 12px;
  border: 1px solid #21262d;
  white-space: nowrap;
}

.excel-preview-table tr:hover td {
  background: rgba(88, 166, 255, 0.06);
}

/* ===== Excel Spreadsheet Preview ===== */
.excel-preview-table {
  width: 100%;
  max-height: 80%;
  overflow: auto;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
}

.excel-sheet-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  flex-shrink: 0;
  overflow-x: auto;
}

.excel-sheet-tab {
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.excel-sheet-tab:hover {
  color: var(--text-secondary);
}

.excel-sheet-tab.active {
  color: #217346;
  border-bottom-color: #217346;
}

.excel-sheet-grid {
  display: none;
  overflow: auto;
  max-height: calc(80vh - 120px);
}

.excel-sheet-grid.active {
  display: block;
}

.excel-grid {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 100%;
}

.excel-grid th,
.excel-grid td {
  border: 1px solid var(--border);
  padding: 4px 10px;
  text-align: left;
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.excel-grid .excel-col-header {
  position: sticky;
  top: 0;
  background: #1a2332;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-align: center;
  padding: 5px 10px;
  border-bottom: 2px solid var(--border-light);
  z-index: 2;
}

.excel-grid .excel-row-header {
  position: sticky;
  left: 0;
  background: #1a2332;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-align: center;
  padding: 4px 8px;
  min-width: 40px;
  border-right: 2px solid var(--border-light);
  z-index: 1;
}

.excel-grid thead .excel-row-header {
  z-index: 3;
  background: #1a2332;
}

.excel-grid tbody tr:hover td:not(.excel-row-header) {
  background: rgba(33, 115, 70, 0.08);
}

.excel-grid td:not(.excel-row-header) {
  color: var(--text-secondary);
}

.excel-grid td.excel-num {
  text-align: right;
  color: var(--blue);
}

/* ===== Excel Preview ===== */
.excel-preview-table {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.excel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: #1c2128;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.excel-sheet-tab {
  font-size: 11px;
  font-weight: 600;
  color: #217346;
  background: rgba(33, 115, 70, 0.12);
  padding: 3px 10px;
  border-radius: 4px;
  font-family: var(--font-sans);
}

.excel-file-name {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--font-mono);
  table-layout: auto;
}

.excel-preview-table {
  overflow: auto;
}

.excel-table th,
.excel-table td {
  border: 1px solid var(--border);
  padding: 4px 10px;
  text-align: left;
  white-space: nowrap;
  color: var(--text-secondary);
}

.excel-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1c2128;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  font-size: 11px;
}

.excel-col-header {
  min-width: 80px;
}

.excel-row-num {
  background: #1c2128 !important;
  color: var(--text-dim) !important;
  text-align: center !important;
  font-size: 11px;
  min-width: 40px;
  width: 40px;
  position: sticky;
  left: 0;
  z-index: 1;
}

thead .excel-row-num {
  z-index: 3 !important;
}

.excel-table tbody tr:hover td {
  background: rgba(88, 166, 255, 0.06);
}

.excel-table tbody td {
  background: var(--bg-primary);
}

/* ===== Keyboard Shortcuts Modal ===== */
.shortcuts-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.shortcuts-overlay.visible {
  display: flex;
}

.shortcuts-modal {
  background: #1c2128;
  border: 1px solid #30363d;
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  font-family: var(--font-sans);
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #30363d;
}

.shortcuts-title {
  font-size: 14px;
  font-weight: 600;
  color: #e6edf3;
}

.shortcuts-close {
  background: none;
  border: none;
  color: #8b949e;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.shortcuts-close:hover {
  color: #e6edf3;
}

.shortcuts-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 60vh;
}

.shortcut-group {
  margin-bottom: 16px;
}

.shortcut-group-title {
  font-size: 11px;
  font-weight: 600;
  color: #58a6ff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
}

.shortcut-desc {
  font-size: 13px;
  color: #c9d1d9;
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #8b949e;
}

.shortcut-keys kbd {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #c9d1d9;
  min-width: 20px;
  text-align: center;
}

.shortcut-hint {
  font-size: 12px;
  color: #6e7681;
  padding-top: 8px;
  border-top: 1px solid #21262d;
}

.shortcut-hint kbd {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #c9d1d9;
}

/* ===== Markdown Preview ===== */
.markdown-preview {
  padding: 24px 32px;
  overflow-y: auto;
  color: #c9d1d9;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  height: 100%;
}

.markdown-preview h1 { font-size: 28px; font-weight: 700; color: #e6edf3; border-bottom: 1px solid #30363d; padding-bottom: 8px; margin: 24px 0 16px; }
.markdown-preview h2 { font-size: 22px; font-weight: 600; color: #e6edf3; border-bottom: 1px solid #21262d; padding-bottom: 6px; margin: 20px 0 12px; }
.markdown-preview h3 { font-size: 18px; font-weight: 600; color: #e6edf3; margin: 16px 0 8px; }
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 { font-size: 15px; font-weight: 600; color: #c9d1d9; margin: 12px 0 6px; }
.markdown-preview p { margin: 0 0 12px; }
.markdown-preview a { color: #58a6ff; text-decoration: none; }
.markdown-preview a:hover { text-decoration: underline; }
.markdown-preview code { background: #161b22; padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 13px; color: #e6edf3; }
.markdown-preview pre { background: #161b22; border: 1px solid #30363d; border-radius: 6px; padding: 14px 16px; overflow-x: auto; margin: 0 0 16px; }
.markdown-preview pre code { background: none; padding: 0; font-size: 13px; line-height: 1.5; }
.markdown-preview blockquote { border-left: 3px solid #3fb950; padding: 4px 16px; margin: 0 0 12px; color: #8b949e; }
.markdown-preview ul, .markdown-preview ol { padding-left: 24px; margin: 0 0 12px; }
.markdown-preview li { margin: 4px 0; }
.markdown-preview table { border-collapse: collapse; width: 100%; margin: 0 0 16px; }
.markdown-preview th { background: #161b22; color: #58a6ff; padding: 8px 12px; text-align: left; border: 1px solid #30363d; font-weight: 600; font-size: 13px; }
.markdown-preview td { padding: 6px 12px; border: 1px solid #21262d; font-size: 13px; }
.markdown-preview img { max-width: 100%; border-radius: 6px; }
.markdown-preview hr { border: none; border-top: 1px solid #30363d; margin: 20px 0; }

/* ===== PDF & DOCX Preview ===== */
.doc-preview-wrap {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: transparent;
}

.doc-preview-loading {
  padding: 40px;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 13px;
}

.doc-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.doc-nav-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--font-sans);
}

.doc-nav-btn:hover:not(:disabled) {
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent);
  border-color: var(--accent);
}

.doc-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.doc-page-info {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  min-width: 100px;
  text-align: center;
}

#pdfCanvas {
  display: block;
  margin: 0 auto;
  width: 100%;
}

.docx-preview-content {
  padding: 24px 32px;
  color: #c9d1d9;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.7;
}

.docx-preview-content h1 { font-size: 26px; font-weight: 700; color: #e6edf3; margin: 20px 0 12px; }
.docx-preview-content h2 { font-size: 21px; font-weight: 600; color: #e6edf3; margin: 16px 0 10px; }
.docx-preview-content h3 { font-size: 17px; font-weight: 600; color: #e6edf3; margin: 12px 0 8px; }
.docx-preview-content p { margin: 0 0 10px; }
.docx-preview-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.docx-preview-content th, .docx-preview-content td { padding: 6px 10px; border: 1px solid #30363d; font-size: 13px; }
.docx-preview-content th { background: #161b22; color: #58a6ff; font-weight: 600; }
.docx-preview-content ul, .docx-preview-content ol { padding-left: 24px; margin: 0 0 10px; }
.docx-preview-content img { max-width: 100%; border-radius: 4px; }
.docx-preview-content a { color: #58a6ff; }

/* ===== Device Preview Toggle ===== */
.device-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  padding-right: 4px;
}

.device-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #6e7681;
  cursor: pointer;
  padding: 3px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-btn:hover {
  color: #c9d1d9;
  background: rgba(255, 255, 255, 0.06);
}

.device-btn.active {
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.1);
  border-color: rgba(88, 166, 255, 0.2);
}

/* ===== Color Picker ===== */
.cm-color-swatch {
  cursor: pointer;
}

.color-picker-hidden {
  position: absolute;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* ===== Drag Between Folders ===== */
.sidebar-file[draggable="true"] {
  cursor: grab;
}

.sidebar-file.dragging {
  opacity: 0.3;
}

.drag-target {
  background: rgba(88, 166, 255, 0.12) !important;
  border-radius: 4px;
  outline: 1px dashed #58a6ff;
  outline-offset: -1px;
}

.sidebar-user-folder-header.drag-target {
  background: rgba(88, 166, 255, 0.15) !important;
}

/* ===== Autocomplete Hints (main styles at bottom of file) ===== */

/* ===== Confirm Modal ===== */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 600;
  align-items: center;
  justify-content: center;
}

.confirm-overlay.visible {
  display: flex;
}

.confirm-modal {
  background: #1c2128;
  border: 1px solid #30363d;
  border-radius: 14px;
  width: 360px;
  max-width: 88vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  font-family: var(--font-sans);
  text-align: center;
  overflow: hidden;
  animation: confirmPop 0.18s ease-out;
}

@keyframes confirmPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.confirm-icon {
  margin: 28px auto 12px;
  width: 64px;
  height: 64px;
  position: relative;
}

.confirm-icon svg { width: 64px; height: 64px; }

.confirm-message {
  font-size: 15px;
  font-weight: 600;
  color: #e6edf3;
  padding: 0 28px;
  line-height: 1.5;
}

.confirm-sub {
  font-size: 13px;
  color: #8b949e;
  margin-top: 8px;
  padding: 0 28px 24px;
}

.confirm-buttons {
  display: flex;
  border-top: 1px solid #30363d;
}

.confirm-buttons button {
  flex: 1;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
  transition: background 0.15s;
}

.confirm-btn-cancel {
  background: #2d333b;
  color: #c9d1d9;
  border-right: 1px solid #30363d !important;
  border-radius: 0 0 0 14px;
}

.confirm-btn-cancel:hover {
  background: #373e47;
}

.confirm-btn-action {
  background: #1f6feb;
  color: #ffffff;
  border-radius: 0 0 14px 0;
}

.confirm-btn-action:hover {
  background: #388bfd;
}

/* ===== Font Size Controls ===== */
.font-size-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

.font-size-btn {
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #8b949e;
  font-size: 13px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-mono);
  padding: 0;
  line-height: 1;
}

.font-size-btn:hover {
  background: rgba(88, 166, 255, 0.1);
  color: #e6edf3;
  border-color: #58a6ff;
}

.font-size-label {
  font-size: 10px;
  color: #6e7681;
  font-family: var(--font-mono);
  min-width: 28px;
  text-align: center;
} 


.sidebar-file i[class*="devicon-javascript"],
.sidebar-file i[class*="devicon-python"] {
  filter: saturate(0.7) brightness(0.9);
}

/* ===== Theme Toggle Button ===== */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

body.light-theme .theme-icon-dark { display: none !important; }
body.light-theme .theme-icon-light { display: block !important; }
body:not(.light-theme) .theme-icon-dark { display: block; }
body:not(.light-theme) .theme-icon-light { display: none !important; }

/* ===== Light Theme — CodeMirror overrides ===== */
body.light-theme .cm-wrap .CodeMirror {
  background: #ffffff;
  color: #1f2328;
}

body.light-theme .cm-wrap .CodeMirror-gutters {
  background: #f6f8fa;
  border-right: 1px solid #d8dee4;
}

body.light-theme .cm-wrap .CodeMirror-linenumber { color: #a3acb6; }
body.light-theme .cm-wrap .CodeMirror-cursor { border-left-color: #0969da; }
body.light-theme .cm-wrap .CodeMirror-selected { background: rgba(9, 105, 218, 0.12); }
body.light-theme .cm-wrap .CodeMirror-activeline-background { background: rgba(0, 0, 0, 0.025); }

/* Light theme — VS Code Light+ syntax tokens */
body.light-theme .cm-s-playground .cm-comment { color: #6a737d; }
body.light-theme .cm-s-playground .cm-tag { color: #22863a; }
body.light-theme .cm-s-playground .cm-tag.cm-bracket { color: #22863a; }
body.light-theme .cm-s-playground .cm-attribute { color: #6f42c1; }
body.light-theme .cm-s-playground .cm-string { color: #032f62; }
body.light-theme .cm-s-playground .cm-string-2 { color: #032f62; }
body.light-theme .cm-s-playground .cm-meta { color: #6a737d; }
body.light-theme .cm-s-playground .cm-qualifier { color: #e36209; }
body.light-theme .cm-s-playground .cm-property { color: #005cc5; }
body.light-theme .cm-s-playground .cm-number { color: #005cc5; }
body.light-theme .cm-s-playground .cm-unit { color: #005cc5; }
body.light-theme .cm-s-playground .cm-atom { color: #005cc5; }
body.light-theme .cm-s-playground .cm-keyword { color: #d73a49; }
body.light-theme .cm-s-playground .cm-variable { color: #24292e; }
body.light-theme .cm-s-playground .cm-variable-2 { color: #e36209; }
body.light-theme .cm-s-playground .cm-variable-3 { color: #22863a; }
body.light-theme .cm-s-playground .cm-def { color: #6f42c1; }
body.light-theme .cm-s-playground .cm-type { color: #22863a; }
body.light-theme .cm-s-playground .cm-operator { color: #24292e; }
body.light-theme .cm-s-playground .cm-builtin { color: #6f42c1; }

/* Light theme — Swift syntax */
body.light-theme .cm-wrap#swiftEditor .CodeMirror { color: #1f2328; }
body.light-theme .cm-wrap#swiftEditor .cm-keyword { color: #ad3da4; }
body.light-theme .cm-wrap#swiftEditor .cm-type,
body.light-theme .cm-wrap#swiftEditor .cm-variable-3 { color: #0b4f79; }
body.light-theme .cm-wrap#swiftEditor .cm-def { color: #326d74; }
body.light-theme .cm-wrap#swiftEditor .cm-variable { color: #1f2328; }
body.light-theme .cm-wrap#swiftEditor .cm-variable-2 { color: #1f2328; }
body.light-theme .cm-wrap#swiftEditor .cm-string { color: #c41a16; }
body.light-theme .cm-wrap#swiftEditor .cm-string-2 { color: #c41a16; }
body.light-theme .cm-wrap#swiftEditor .cm-number { color: #1c00cf; }
body.light-theme .cm-wrap#swiftEditor .cm-comment { color: #5d6c79; }
body.light-theme .cm-wrap#swiftEditor .cm-property { color: #326d74; }
body.light-theme .cm-wrap#swiftEditor .cm-attribute { color: #ad3da4; }
body.light-theme .cm-wrap#swiftEditor .cm-operator { color: #1f2328; }
body.light-theme .cm-wrap#swiftEditor .cm-builtin { color: #6f42c1; }
body.light-theme .cm-wrap#swiftEditor .cm-atom { color: #ad3da4; }
body.light-theme .cm-wrap#swiftEditor .cm-meta { color: #ad3da4; }

/* Light theme — indent guides */
body.light-theme .cm-wrap .CodeMirror .CodeMirror-line {
  background-image:
    repeating-linear-gradient(to right,
      transparent,
      transparent calc(2ch - 1px),
      rgba(0, 0, 0, 0.06) calc(2ch - 1px),
      rgba(0, 0, 0, 0.06) 2ch);
}

/* Light theme — preview iframe bg */
body.light-theme #previewFrame { background: #fff; }

/* Light theme — misc hardcoded overrides */
body.light-theme .save-dropdown,
body.light-theme .emmet-popup,
body.light-theme .context-menu,
body.light-theme .add-dropdown { background: #fff; border-color: #d0d7de; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

body.light-theme .shortcuts-modal { background: #fff; border-color: #d0d7de; }
body.light-theme .shortcuts-header { border-bottom-color: #d0d7de; }
body.light-theme .shortcuts-title { color: #1f2328; }
body.light-theme .shortcut-desc { color: #353b43; }
body.light-theme .shortcut-keys kbd { background: #f6f8fa; border-color: #d0d7de; color: #1f2328; }
body.light-theme .shortcut-hint { color: #656d76; border-top-color: #d8dee4; }
body.light-theme .shortcut-hint kbd { background: #f6f8fa; border-color: #d0d7de; color: #1f2328; }

body.light-theme .confirm-modal { background: #fff; border-color: #d0d7de; }
body.light-theme .confirm-message { color: #1f2328; }
body.light-theme .confirm-sub { color: #656d76; }
body.light-theme .confirm-buttons { border-top-color: #d0d7de; }
body.light-theme .confirm-btn-cancel { background: #f6f8fa; color: #353b43; border-right-color: #d0d7de !important; }
body.light-theme .confirm-btn-cancel:hover { background: #eef1f5; }

body.light-theme .browser-bar { background: #f0f2f5; border-bottom-color: #d8dee4; }
body.light-theme .browser-tab { background: #fff; border-color: #d8dee4; }
body.light-theme .browser-url { background: #fff; border-color: #d8dee4; }

body.light-theme .sidebar-file:hover { background: rgba(0, 0, 0, 0.04); }
body.light-theme .sidebar-file.active { background: rgba(9, 105, 218, 0.08); }

body.light-theme .cm-searching { background: rgba(255, 212, 59, 0.45); }

body.light-theme .terminal-html table { background: #f6f8fa; color: #1f2328; }
body.light-theme .terminal-html th { background: #eef1f5; color: #0550ae; border-bottom-color: #d0d7de; }
body.light-theme .terminal-html td { border-bottom-color: #d8dee4; }

body.light-theme .CodeMirror-dialog { background: #f6f8fa; border-bottom-color: #d0d7de; color: #353b43; }
body.light-theme .CodeMirror-dialog input { background: #fff; border-color: #d0d7de; color: #1f2328; }
body.light-theme .CodeMirror-dialog button { background: #eef1f5; color: #353b43; }

body.light-theme .font-size-btn { border-color: #d0d7de; color: #656d76; }
body.light-theme .font-size-btn:hover { background: rgba(9,105,218,0.08); color: #1f2328; border-color: #0969da; }

body.light-theme .CodeMirror-matchingtag { background: rgba(9, 105, 218, 0.12); border-bottom-color: #0969da; }
body.light-theme .CodeMirror-foldgutter-open,
body.light-theme .CodeMirror-foldgutter-folded { color: #a3acb6; }
body.light-theme .CodeMirror-foldmarker { color: #0969da; background: rgba(9, 105, 218, 0.1); }

/* ===== Improved Autocomplete Hints ===== */
.CodeMirror-hints {
  background: var(--hint-bg);
  border: 1px solid var(--hint-border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 1px rgba(0,0,0,0.05);
  font-family: var(--font-mono);
  font-size: 13px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.CodeMirror-hints::-webkit-scrollbar { width: 5px; }
.CodeMirror-hints::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.CodeMirror-hints::-webkit-scrollbar-track { background: transparent; }

.CodeMirror-hint {
  padding: 5px 10px 5px 8px;
  color: var(--hint-text);
  cursor: pointer;
  white-space: nowrap;
  border-radius: 5px;
  margin: 1px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.08s;
  line-height: 1.4;
}

.CodeMirror-hint-active {
  background: var(--hint-active-bg);
  color: var(--hint-active-color);
}

/* ===== Error Line Highlighting ===== */
.cm-error-line {
  background: rgba(248, 81, 73, 0.08) !important;
}

.cm-error-gutter {
  color: var(--red);
  font-size: 13px;
  width: 14px;
  text-align: center;
  cursor: pointer;
  line-height: 1.7;
}

body.light-theme .cm-error-line {
  background: rgba(207, 34, 46, 0.06) !important;
}

.cm-error-message {
  position: absolute;
  right: 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--red);
  opacity: 0.8;
  pointer-events: none;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.7;
  top: 0;
}

.cm-error-widget {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--red);
  opacity: 0.75;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ===== Responsive Layout — Mobile-first ===== */
@media (max-width: 900px) {
  .header-right .header-text-btn span:not(.run-icon):not(.stop-icon) {
    display: none;
  }

  .layout-btn span:last-child {
    display: none;
  }

  .layout-btn {
    padding: 5px 8px;
  }

  .save-btn span:last-child {
    display: none;
  }

  .file-sidebar {
    width: 140px;
  }
}

@media (max-width: 768px) {
  .title {
    display: none;
  }

  .header {
    padding: 0 8px;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .header::-webkit-scrollbar { display: none; }

  .header-right {
    gap: 4px;
    flex-shrink: 0;
  }

  /* Stack editor and preview vertically */
  .main {
    flex-direction: column;
    height: calc(100vh - 48px - 28px);
  }

  .main.layout-split {
    flex-direction: column;
  }

  .editor-panel {
    flex: 1 1 50%;
    border-right: none;
    border-bottom: 2px solid var(--border);
    min-height: 180px;
  }

  .right-panel {
    flex: 1 1 50%;
    min-height: 180px;
  }

  .resize-handle {
    width: 100%;
    height: 6px;
    cursor: row-resize;
    flex-shrink: 0;
  }

  /* Hide sidebar on mobile by default */
  .file-sidebar {
    position: fixed;
    left: -180px;
    top: 48px;
    bottom: 28px;
    z-index: 400;
    width: 180px;
    transition: left 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
  }

  .file-sidebar.mobile-open {
    left: 0;
  }

  /* Compact tabs */
  .tab {
    padding: 8px 10px;
    font-size: 11px;
  }

  .tab .tab-name {
    max-width: 60px;
  }

  /* Hide text labels on buttons */
  .header-text-btn {
    padding: 5px 8px;
    gap: 0;
  }

  .save-btn {
    padding: 5px 8px;
  }

  .font-size-controls {
    display: none;
  }

  .layout-toggle {
    gap: 1px;
  }

  /* Reduce footer */
  .footer {
    padding: 3px 10px;
    font-size: 10px;
    height: 28px;
    min-height: 28px;
  }

  .footer-status {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .header-left {
    gap: 6px;
  }

  .logo {
    width: 24px;
    height: 24px;
    font-size: 10px;
    border-radius: 6px;
  }

  /* Show only code or preview, not split */
  .main.layout-split .right-panel {
    display: none;
  }

  .main.layout-split .resize-handle {
    display: none;
  }

  .main.layout-split .editor-panel {
    flex: 1;
    border-bottom: none;
  }

  /* Mobile quick toggle button */
  .mobile-panel-toggle {
    display: flex !important;
  }

  .layout-toggle {
    display: none;
  }

  .shortcuts-modal {
    width: 95vw;
    max-height: 85vh;
  }

  .search-bar input {
    width: 100px;
  }
}

/* Mobile panel toggle (hidden on desktop) */
.mobile-panel-toggle {
  display: none;
  align-items: center;
  gap: 2px;
}

.mobile-panel-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}

.mobile-panel-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* Mobile sidebar toggle button */
.mobile-sidebar-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.mobile-sidebar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

@media (max-width: 768px) {
  .mobile-sidebar-btn {
    display: flex;
  }
}

/* Mobile sidebar overlay */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 48px;
  background: rgba(0,0,0,0.4);
  z-index: 399;
}

.mobile-sidebar-overlay.visible {
  display: block;
}

@media (max-width: 1400px) {

  .header-text-btn span,
  .layout-btn span {
    display: none;
  }

  .header-text-btn,
  .layout-btn {
    padding: 6px 8px;
  }
}