/* ===============================================================================
   MODERN COMPILER PAGE STYLES
   =============================================================================== */

:root {
  --compiler-bg: #0f172a;
  --compiler-surface: #1a2847;
  --compiler-surface-alt: #16213e;
  --compiler-border: rgba(56, 189, 248, 0.15);
  --compiler-text: #e2e8f0;
  --compiler-text-muted: #a0aec0;
  --compiler-accent: #38a169;
  --compiler-accent-hover: #2f855a;
  --compiler-blue: #63b3ed;
  --compiler-blue-light: rgba(99, 179, 237, 0.1);
}

/* ===============================================================================
   MAIN LAYOUT
   =============================================================================== */

.compiler-page {
  background: var(--compiler-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===============================================================================
   TOP BAR
   =============================================================================== */

.compiler-topbar {
  background: linear-gradient(135deg, var(--compiler-surface) 0%, var(--compiler-surface-alt) 100%);
  border-bottom: 1px solid var(--compiler-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  min-width: 0;
}

.compiler-topbar h1 {
  font-size: 1.1rem;
  color: var(--compiler-text);
  margin: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.compiler-topbar h1 i {
  color: var(--compiler-blue);
}

/* ===============================================================================
   LANGUAGE TABS
   =============================================================================== */

.lang-tabs-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(74, 85, 104, 0.5) transparent;
}

.lang-tabs-wrapper::-webkit-scrollbar {
  height: 4px;
}

.lang-tabs-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.lang-tabs-wrapper::-webkit-scrollbar-thumb {
  background: rgba(74, 85, 104, 0.5);
  border-radius: 2px;
}

.lang-tabs-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(74, 85, 104, 0.8);
}

.scroll-arrow {
  background: var(--compiler-blue-light);
  border: 1px solid var(--compiler-border);
  color: var(--compiler-blue);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-size: 0.8rem;
}

.scroll-arrow.show {
  display: flex;
}

.scroll-arrow:hover:not(.disabled) {
  background: rgba(99, 179, 237, 0.2);
  border-color: var(--compiler-border);
  color: var(--compiler-text);
}

.scroll-arrow:active:not(.disabled) {
  transform: scale(0.95);
}

.scroll-arrow.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.lang-tabs {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}

.lang-tabs::-webkit-scrollbar {
  display: none;
}

.lang-tab {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--compiler-border);
  background: rgba(45, 55, 72, 0.5);
  color: var(--compiler-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.lang-tab:hover {
  background: rgba(99, 179, 237, 0.15);
  border-color: var(--compiler-border);
  color: var(--compiler-text);
  text-decoration: none;
}

.lang-tab.active {
  color: var(--compiler-text);
  border-color: var(--compiler-blue);
  background: var(--compiler-blue-light);
}

/* ===============================================================================
   MAIN BODY
   =============================================================================== */

.compiler-body {
  display: flex;
  flex: 1;
  gap: 0;
  min-height: 0;
}

.compiler-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px;
  background: #111827;
  border-top: 1px solid var(--compiler-border);
  flex-shrink: 0;
}

.compiler-insight-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: rgba(26, 40, 71, 0.72);
  border: 1px solid var(--compiler-border);
  border-radius: 8px;
}

.compiler-insight-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  border-radius: 8px;
  background: var(--compiler-blue-light);
  color: var(--compiler-blue);
}

.compiler-insight-card strong {
  display: block;
  color: var(--compiler-text);
  font-size: 0.85rem;
  line-height: 1.25;
}

.compiler-insight-card span:not(.compiler-insight-icon) {
  display: block;
  margin-top: 3px;
  color: var(--compiler-text-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

/* ===============================================================================
   EDITOR PANEL (LEFT)
   =============================================================================== */

.compiler-file-explorer {
  width: 230px;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  background: #0b1220;
  border-right: 1px solid var(--compiler-border);
  flex-shrink: 0;
}

.compiler-explorer-backdrop,
.compiler-explorer-toggle,
.compiler-explorer-close {
  display: none;
}

.compiler-explorer-toggle {
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid rgba(74, 85, 104, 0.72);
  background: rgba(74, 85, 104, 0.45);
  color: var(--compiler-blue);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.compiler-explorer-toggle:hover {
  background: var(--compiler-blue-light);
  border-color: var(--compiler-blue);
  color: var(--compiler-blue);
}

.compiler-explorer-toggle i {
  color: inherit;
}

body.compiler-explorer-collapsed .compiler-file-explorer {
  display: none;
}

body.compiler-explorer-collapsed .compiler-resizer {
  display: none;
}

body.compiler-explorer-collapsed .compiler-explorer-toggle {
  display: inline-flex;
}

.file-explorer-header {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(22, 33, 62, 0.92);
  border-bottom: 1px solid var(--compiler-border);
  color: var(--compiler-text);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.file-explorer-header span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.file-explorer-header i {
  color: var(--compiler-blue);
}

.file-explorer-header button {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(74, 85, 104, 0.72);
  background: rgba(45, 55, 72, 0.75);
  color: var(--compiler-text-muted);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.file-explorer-header button:hover {
  background: var(--compiler-blue-light);
  border-color: var(--compiler-blue);
  color: var(--compiler-blue);
}

.file-explorer-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.file-explorer-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--compiler-text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.file-explorer-item:hover {
  background: rgba(99, 179, 237, 0.08);
  color: var(--compiler-text);
}

.file-explorer-item.active {
  background: rgba(99, 179, 237, 0.14);
  border-color: rgba(99, 179, 237, 0.32);
  color: var(--compiler-text);
}

.file-explorer-item > i {
  width: 16px;
  color: var(--compiler-blue);
  flex-shrink: 0;
  text-align: center;
}

.file-explorer-item > span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-explorer-actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.file-explorer-item:hover .file-explorer-actions,
.file-explorer-item.active .file-explorer-actions {
  display: flex;
}

.file-explorer-actions button {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--compiler-text-muted);
  cursor: pointer;
}

.file-explorer-actions button:hover {
  background: rgba(99, 179, 237, 0.14);
  color: var(--compiler-blue);
}

.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.compiler-resizer {
  width: 8px;
  flex: 0 0 8px;
  cursor: col-resize;
  background: #0b1220;
  border-left: 1px solid var(--compiler-border);
  border-right: 1px solid var(--compiler-border);
  position: relative;
  z-index: 4;
}

.compiler-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 46px;
  border-radius: 99px;
  background: rgba(99, 179, 237, 0.36);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.compiler-resizer:hover::before,
body.compiler-resizing .compiler-resizer::before {
  opacity: 1;
  background: rgba(99, 179, 237, 0.9);
}

body.compiler-resizing {
  cursor: col-resize;
  user-select: none;
}

.editor-toolbar {
  background: var(--compiler-surface-alt);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--compiler-border);
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.editor-toolbar .file-label {
  color: var(--compiler-text-muted);
  font-size: 0.8rem;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

#activeFileName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-toolbar .file-label i {
  color: var(--compiler-blue);
}

/* Buttons */
.btn-run {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-toolbar-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid rgba(74, 85, 104, 0.72);
  background: rgba(74, 85, 104, 0.45);
  color: var(--compiler-text-muted);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-toolbar-icon:hover {
  background: var(--compiler-blue-light);
  color: var(--compiler-blue);
  border-color: var(--compiler-blue);
}

.compiler-tools-dropdown {
  position: relative;
  flex-shrink: 0;
}

.btn-tools-menu {
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid rgba(74, 85, 104, 0.72);
  background: rgba(45, 55, 72, 0.75);
  color: var(--compiler-text);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-tools-menu:hover,
.btn-tools-menu[aria-expanded="true"] {
  background: var(--compiler-blue-light);
  color: var(--compiler-blue);
  border-color: var(--compiler-blue);
}

.btn-tools-menu.compact {
  padding: 0 12px;
}

.compiler-tools-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 250px;
  display: none;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--compiler-border);
  background: #101827;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.36);
  z-index: 50;
}

.compiler-tools-menu.align-right {
  right: 0;
  left: auto;
}

.compiler-tools-menu.open {
  display: grid;
  gap: 6px;
}

.compiler-enhanced-actions {
  display: grid;
  gap: 6px;
}

.compiler-enhanced-actions:not(:empty) {
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(74, 85, 104, 0.45);
}

.compiler-menu-label {
  color: var(--compiler-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  padding: 4px 4px 0;
}

.compiler-menu-item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--compiler-text);
  text-align: left;
  font-size: 0.84rem;
  cursor: pointer;
}

.compiler-menu-item i {
  width: 18px;
  color: var(--compiler-blue);
  text-align: center;
}

.compiler-menu-item:hover {
  background: rgba(99, 179, 237, 0.12);
  border-color: rgba(99, 179, 237, 0.22);
}

.compiler-menu-item.danger i {
  color: #fc8181;
}

.compiler-menu-item.danger:hover {
  background: rgba(245, 101, 101, 0.12);
  border-color: rgba(245, 101, 101, 0.28);
}

.compiler-select {
  height: 36px;
  width: 100%;
  padding: 0 34px 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(74, 85, 104, 0.72);
  background: #111827;
  color: var(--compiler-text);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

.compiler-select:focus {
  border-color: var(--compiler-blue);
  box-shadow: 0 0 0 3px var(--compiler-blue-light);
}

.btn-run {
  background: linear-gradient(135deg, var(--compiler-accent) 0%, var(--compiler-accent-hover) 100%);
  color: #fff;
  border: none;
  padding: 0 18px;
  font-weight: 600;
}

.btn-run:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 169, 105, 0.3);
}

.btn-run:active:not(:disabled) {
  transform: translateY(0);
}

.btn-run:disabled {
  background: rgba(74, 85, 104, 0.5);
  cursor: not-allowed;
  opacity: 0.6;
}

.compiler-metrics-output {
  border-top-color: rgba(56, 189, 248, 0.12);
}

.compiler-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10000;
  max-width: min(320px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--compiler-surface);
  border: 1px solid var(--compiler-border);
  color: var(--compiler-text);
  font-size: 0.85rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.compiler-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.compiler-toast.success {
  border-color: rgba(56, 161, 105, 0.55);
  color: #c6f6d5;
}

.compiler-toast.error {
  border-color: rgba(245, 101, 101, 0.55);
  color: #fed7d7;
}

/* CodeMirror */
.CodeMirror {
  flex: 1;
  height: 100%;
  font-size: 14px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  line-height: 1.6;
}

.CodeMirror-scroll {
  height: 100%;
}

.editor-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.compiler-metrics {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 14px;
  background: rgba(15, 23, 42, 0.92);
  border-top: 1px solid var(--compiler-border);
  color: var(--compiler-text-muted);
  font-size: 0.74rem;
  flex-shrink: 0;
}

.compiler-metrics span {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(45, 55, 72, 0.52);
  border: 1px solid rgba(74, 85, 104, 0.45);
}

/* Stdin Panel */
.stdin-panel {
  background: var(--compiler-surface-alt);
  border-top: 1px solid var(--compiler-border);
  padding: 10px 14px;
  flex-shrink: 0;
}

.stdin-panel label {
  color: var(--compiler-text-muted);
  font-size: 0.75rem;
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stdin-panel label i {
  color: var(--compiler-blue);
}

.stdin-panel textarea {
  width: 100%;
  background: rgba(26, 32, 44, 0.8);
  color: var(--compiler-text);
  border: 1px solid var(--compiler-border);
  border-radius: 4px;
  padding: 8px;
  font-size: 0.8rem;
  font-family: monospace;
  resize: vertical;
  min-height: 50px;
  max-height: 100px;
  transition: all 0.2s ease;
}

.stdin-panel textarea:focus {
  outline: none;
  border-color: var(--compiler-blue);
  background: rgba(26, 32, 44, 1);
  box-shadow: 0 0 0 3px var(--compiler-blue-light);
}

/* ===============================================================================
   OUTPUT PANEL (RIGHT)
   =============================================================================== */

.output-panel {
  width: 45%;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: #0d1117;
  border-left: 1px solid var(--compiler-border);
}

.output-toolbar {
  background: var(--compiler-surface-alt);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--compiler-border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.output-toolbar span {
  color: var(--compiler-text-muted);
  font-size: 0.8rem;
  flex: 1;
  min-width: 100px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.output-toolbar span i {
  color: var(--compiler-blue);
}

/* Output Tabs */
.output-tabs {
  display: flex;
  background: var(--compiler-surface-alt);
  border-bottom: 1px solid var(--compiler-border);
  gap: 0;
  flex-shrink: 0;
}

.output-tab {
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--compiler-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.output-tab:hover {
  color: var(--compiler-text);
}

.output-tab.active {
  color: var(--compiler-blue);
  border-bottom-color: var(--compiler-blue);
}

.output-tab i {
  font-size: 0.9rem;
}

/* Output Content */
.output-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.output-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 14px;
  display: none;
}

.output-pane.active {
  display: block;
}

#output-console {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--compiler-text);
  white-space: pre-wrap;
  word-break: break-all;
}

#output-console .out-line {
  color: var(--compiler-text);
}

#output-console .err-line {
  color: #fc8181;
}

#output-console .info-line {
  color: #68d391;
}

#output-console .meta-line {
  color: var(--compiler-text-muted);
  font-size: 0.75rem;
}

#output-preview {
  padding: 0;
}

#output-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ===============================================================================
   UTILITIES
   =============================================================================== */

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 179, 237, 0.3);
  border-top-color: var(--compiler-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status-badge {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 10px;
  font-weight: 600;
  display: none;
  flex-shrink: 0;
}

.status-badge.ok {
  background: rgba(39, 103, 73, 0.8);
  color: #9ae6b4;
  display: inline-block;
}

.status-badge.err {
  background: rgba(116, 42, 42, 0.8);
  color: #feb2b2;
  display: inline-block;
}

#fsBtn {
  background: var(--compiler-blue-light);
  border: 1px solid var(--compiler-border);
  color: var(--compiler-blue);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

#fsBtn:hover {
  background: rgba(99, 179, 237, 0.2);
  border-color: var(--compiler-border);
  color: var(--compiler-text);
}

#fsBtn:active {
  transform: scale(0.95);
}

/* ===============================================================================
   RESPONSIVE DESIGN
   =============================================================================== */

@media (max-width: 1024px) {
  .compiler-insights {
    grid-template-columns: 1fr;
  }

  .compiler-file-explorer {
    width: 190px;
    min-width: 180px;
  }

  .output-panel {
    width: 40%;
  }
}

@media (max-width: 768px) {
  .compiler-topbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 10px;
  }

  .compiler-topbar h1 {
    width: auto;
    min-width: 28px;
    font-size: 1rem;
  }

  .lang-tabs-wrapper {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    gap: 5px;
    overflow: hidden;
  }

  .lang-tabs {
    min-width: 0;
    gap: 5px;
  }

  .lang-tab {
    padding: 5px 9px;
    gap: 4px;
    font-size: 0.72rem;
  }

  .scroll-arrow {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    font-size: 0.72rem;
  }

  #fsBtn {
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    border-radius: 5px;
  }

  .compiler-body {
    flex-direction: column;
    height: auto;
  }

  .compiler-resizer {
    display: none;
  }

  body.compiler-explorer-open {
    overflow: hidden;
  }

  .compiler-file-explorer {
    position: fixed;
    top: 68px;
    left: 0;
    width: 280px;
    max-width: 85vw;
    min-width: 0;
    height: calc(100vh - 68px);
    max-height: none;
    z-index: 1050;
    border-right: 1px solid var(--compiler-border);
    border-bottom: none;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.34);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  .compiler-file-explorer.open {
    transform: translateX(0);
  }

  .compiler-explorer-backdrop {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, 0.42);
  }

  body.compiler-explorer-open .compiler-explorer-backdrop {
    display: block;
  }

  .compiler-explorer-toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: #38bdf8;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
  }

  .compiler-explorer-toggle:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
  }

  .compiler-explorer-close {
    display: inline-flex;
  }

  .file-explorer-list {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .file-explorer-item {
    min-width: 0;
  }

  .output-panel {
    width: 100%;
    min-width: 0;
    height: 350px;
    border-left: none;
    border-top: 1px solid var(--compiler-border);
  }

  .editor-panel {
    height: auto;
    border-right: none;
  }

  .editor-wrap {
    flex: 0 0 350px;
    min-height: 350px;
  }

  .compiler-title-text {
    display: none;
  }

  .editor-toolbar,
  .output-toolbar {
    flex-wrap: wrap;
  }

  .editor-toolbar {
    flex-wrap: nowrap;
  }

  .editor-toolbar .file-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }

  #activeFileName {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .editor-toolbar .compiler-tools-dropdown {
    width: auto;
  }

  .editor-toolbar .btn-tools-menu {
    width: auto;
    padding: 0 10px;
    white-space: nowrap;
  }

  .editor-toolbar .btn-toolbar-icon {
    width: 34px;
    height: 34px;
  }

  .compiler-select {
    max-width: none;
  }
}

@media (max-width: 576px) {
  .compiler-topbar {
    padding: 7px 8px;
    gap: 6px;
  }

  .compiler-topbar h1 {
    font-size: 0.95rem;
    min-width: 24px;
  }

  .lang-tabs-wrapper {
    gap: 4px;
  }

  .lang-tab {
    padding: 4px 7px;
    font-size: 0.66rem;
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .scroll-arrow {
    width: 26px;
    height: 26px;
  }

  #fsBtn {
    width: 28px !important;
    height: 28px !important;
  }

  .editor-toolbar,
  .output-toolbar {
    padding: 8px 10px;
    gap: 8px;
  }

  .compiler-insights {
    padding: 10px;
  }

  .compiler-insight-card {
    padding: 10px;
  }

  .output-toolbar .compiler-tools-dropdown,
  .output-toolbar .btn-tools-menu {
    width: 100%;
  }

  .editor-toolbar .compiler-tools-dropdown,
  .editor-toolbar .btn-tools-menu {
    width: auto;
  }

  .editor-toolbar .btn-tools-menu {
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .editor-toolbar .btn-toolbar-icon {
    width: 32px;
    height: 32px;
  }

  .compiler-tools-menu,
  .compiler-tools-menu.align-right {
    left: 0;
    right: auto;
    width: min(280px, calc(100vw - 24px));
  }

  .btn-run {
    padding: 6px 14px;
    font-size: 0.8rem;
  }

  .output-panel {
    height: 300px;
  }

  .editor-panel {
    height: auto;
  }

  .editor-wrap {
    flex-basis: 300px;
    min-height: 300px;
  }
}

/* ===============================================================================
   FULLSCREEN MODE
   =============================================================================== */

.compiler-page:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

.compiler-page:-moz-full-screen {
  width: 100vw;
  height: 100vh;
}

.compiler-page:fullscreen {
  width: 100vw;
  height: 100vh;
}

.compiler-page:fullscreen .compiler-body,
.compiler-page:-webkit-full-screen .compiler-body,
.compiler-page:-moz-full-screen .compiler-body {
  height: calc(100vh - 70px);
}

/* ===============================================================================
   DARK MODE SUPPORT
   =============================================================================== */

@media (prefers-color-scheme: dark) {
  .compiler-page {
    background: var(--compiler-bg);
  }

  .CodeMirror {
    background: var(--compiler-surface);
    color: var(--compiler-text);
  }

  .CodeMirror-gutters {
    background: var(--compiler-surface-alt);
    border-right: 1px solid var(--compiler-border);
  }

  .CodeMirror-linenumber {
    color: var(--compiler-text-muted);
  }

  .CodeMirror-cursor {
    border-left-color: var(--compiler-blue);
  }
}

/* ===============================================================================
   LIGHT MODE SUPPORT
   =============================================================================== */

html:not([data-theme="dark"]) .compiler-page {
  --compiler-bg: #f6f8fc;
  --compiler-surface: #ffffff;
  --compiler-surface-alt: #edf3fb;
  --compiler-border: rgba(37, 99, 235, 0.16);
  --compiler-text: #172033;
  --compiler-text-muted: #5b677a;
  --compiler-blue: #0f75bc;
  --compiler-blue-light: rgba(14, 116, 144, 0.09);
  background: var(--compiler-bg);
}

html:not([data-theme="dark"]) .compiler-topbar,
html:not([data-theme="dark"]) .editor-toolbar,
html:not([data-theme="dark"]) .output-toolbar,
html:not([data-theme="dark"]) .output-tabs,
html:not([data-theme="dark"]) .stdin-panel,
html:not([data-theme="dark"]) .file-explorer-header {
  background: var(--compiler-surface);
}

html:not([data-theme="dark"]) .compiler-body,
html:not([data-theme="dark"]) .compiler-file-explorer,
html:not([data-theme="dark"]) .output-panel,
html:not([data-theme="dark"]) .output-content,
html:not([data-theme="dark"]) .output-pane,
html:not([data-theme="dark"]) .compiler-resizer {
  background: #f8fafc;
}

html:not([data-theme="dark"]) .compiler-insights,
html:not([data-theme="dark"]) .compiler-metrics {
  background: #eef5ff;
}

html:not([data-theme="dark"]) .compiler-insight-card,
html:not([data-theme="dark"]) .file-explorer-item.active {
  background: #ffffff;
  border-color: rgba(14, 116, 144, 0.24);
}

html:not([data-theme="dark"]) .lang-tab,
html:not([data-theme="dark"]) .btn-toolbar-icon,
html:not([data-theme="dark"]) .btn-tools-menu,
html:not([data-theme="dark"]) .file-explorer-header button,
html:not([data-theme="dark"]) .compiler-explorer-toggle,
html:not([data-theme="dark"]) #fsBtn {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.14);
  color: var(--compiler-text-muted);
}

html:not([data-theme="dark"]) .lang-tab:hover,
html:not([data-theme="dark"]) .btn-toolbar-icon:hover,
html:not([data-theme="dark"]) .btn-tools-menu:hover,
html:not([data-theme="dark"]) .btn-tools-menu[aria-expanded="true"],
html:not([data-theme="dark"]) .file-explorer-header button:hover,
html:not([data-theme="dark"]) .compiler-explorer-toggle:hover,
html:not([data-theme="dark"]) #fsBtn:hover {
  background: var(--compiler-blue-light);
  border-color: rgba(14, 116, 144, 0.32);
  color: var(--compiler-blue);
}

html:not([data-theme="dark"]) #fsBtn {
  background: #ffffff !important;
  border-color: rgba(15, 23, 42, 0.14) !important;
  color: var(--compiler-text-muted) !important;
}

html:not([data-theme="dark"]) #fsBtn:hover {
  background: var(--compiler-blue-light) !important;
  border-color: rgba(14, 116, 144, 0.32) !important;
  color: var(--compiler-blue) !important;
}

html:not([data-theme="dark"]) .compiler-tools-menu,
html:not([data-theme="dark"]) .compiler-modal-content,
html:not([data-theme="dark"]) .compiler-notification,
html:not([data-theme="dark"]) .compiler-toast {
  background: #ffffff;
  color: var(--compiler-text);
  border-color: var(--compiler-border);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
}

html:not([data-theme="dark"]) .compiler-select,
html:not([data-theme="dark"]) .stdin-panel textarea {
  background: #ffffff;
  color: var(--compiler-text);
  border-color: rgba(15, 23, 42, 0.14);
}

html:not([data-theme="dark"]) .compiler-metrics span {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.12);
}

html:not([data-theme="dark"]) .CodeMirror {
  background: #ffffff;
  color: #172033;
}

html:not([data-theme="dark"]) .CodeMirror-gutters {
  background: #f1f5f9;
  border-right: 1px solid rgba(15, 23, 42, 0.12);
}

html:not([data-theme="dark"]) .CodeMirror-linenumber {
  color: #64748b;
}

html:not([data-theme="dark"]) .CodeMirror-cursor {
  border-left-color: #0f75bc;
}

html:not([data-theme="dark"]) .CodeMirror-selected {
  background: rgba(14, 116, 144, 0.16);
}

html:not([data-theme="dark"]) .output-console,
html:not([data-theme="dark"]) #output-console {
  background: #ffffff;
  color: #172033;
}

html:not([data-theme="dark"]) .output-pane .info-line,
html:not([data-theme="dark"]) .info-line {
  color: #047857;
}

html:not([data-theme="dark"]) .out-line {
  color: #172033;
}

html:not([data-theme="dark"]) .meta-line {
  color: #7c3aed;
}

html:not([data-theme="dark"]) .err-line {
  color: #dc2626;
}

/* ===============================================================================
   DYNAMIC BUTTONS (Templates, Recent, Share)
   =============================================================================== */

.btn-templates,
.btn-recent,
.btn-share {
  height: 36px;
  background: rgba(74, 85, 104, 0.5);
  color: var(--compiler-text-muted);
  border: 1px solid rgba(74, 85, 104, 0.7);
  padding: 0 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-templates:hover,
.btn-recent:hover,
.btn-share:hover {
  background: rgba(113, 128, 150, 0.7);
  color: var(--compiler-text);
  border-color: rgba(113, 128, 150, 0.9);
}

.btn-templates i,
.btn-recent i,
.btn-share i {
  font-size: 0.85rem;
}

.compiler-tools-menu .btn-templates,
.compiler-tools-menu .btn-recent,
.compiler-tools-menu .btn-share {
  width: 100%;
  height: auto;
  min-height: 38px;
  justify-content: flex-start;
  padding: 8px 10px;
  background: transparent;
  color: var(--compiler-text);
  border-color: transparent;
}

.compiler-tools-menu .btn-templates:hover,
.compiler-tools-menu .btn-recent:hover,
.compiler-tools-menu .btn-share:hover {
  background: rgba(99, 179, 237, 0.12);
  border-color: rgba(99, 179, 237, 0.22);
}

/* ===============================================================================
   MODALS
   =============================================================================== */

.compiler-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.compiler-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.compiler-modal-content {
  position: relative;
  background: var(--compiler-surface);
  border: 1px solid var(--compiler-border);
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.compiler-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--compiler-border);
  flex-shrink: 0;
}

.compiler-modal-header h3 {
  margin: 0;
  color: var(--compiler-text);
  font-size: 1rem;
  font-weight: 600;
}

.compiler-modal-header button {
  background: transparent;
  border: none;
  color: var(--compiler-text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.compiler-modal-header button:hover {
  color: var(--compiler-text);
  background: rgba(99, 179, 237, 0.1);
  border-radius: 4px;
}

.compiler-modal-body {
  overflow-y: auto;
  padding: 16px;
  flex: 1;
}

.template-item {
  padding: 12px;
  margin-bottom: 8px;
  background: rgba(99, 179, 237, 0.05);
  border: 1px solid var(--compiler-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.template-item:hover {
  background: rgba(99, 179, 237, 0.15);
  border-color: var(--compiler-blue);
}

.template-item i {
  color: var(--compiler-blue);
  font-size: 1rem;
  flex-shrink: 0;
}

.template-item span {
  color: var(--compiler-text);
  font-size: 0.9rem;
  flex: 1;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: rgba(99, 179, 237, 0.05);
  border-radius: 4px;
}

.shortcut-item kbd {
  background: var(--compiler-surface-alt);
  border: 1px solid var(--compiler-border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--compiler-blue);
  white-space: nowrap;
  flex-shrink: 0;
}

.shortcut-item span {
  color: var(--compiler-text-muted);
  font-size: 0.85rem;
}

/* ===============================================================================
   NOTIFICATIONS
   =============================================================================== */

.compiler-notification {
  position: fixed;
  top: auto !important;
  left: auto !important;
  bottom: 18px !important;
  right: 18px !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: min(320px, calc(100vw - 32px)) !important;
  max-height: none !important;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--compiler-surface);
  color: var(--compiler-text);
  padding: 10px 14px !important;
  border-radius: 8px;
  border: 1px solid var(--compiler-border);
  font-size: 0.85rem;
  line-height: 1.35;
  z-index: 9999;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.compiler-notification.show {
  opacity: 1;
  transform: translateY(0);
}

.compiler-notification.success {
  border-color: rgba(39, 103, 73, 0.8);
  background: rgba(39, 103, 73, 0.2);
  color: #9ae6b4;
}

.compiler-notification.error {
  border-color: rgba(116, 42, 42, 0.8);
  background: rgba(116, 42, 42, 0.2);
  color: #feb2b2;
}

.compiler-notification.info {
  border-color: var(--compiler-border);
  background: var(--compiler-surface);
  color: var(--compiler-text);
}

/* ===============================================================================
   KEYBOARD SHORTCUTS HINT
   =============================================================================== */

.keyboard-shortcuts-hint {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
}

.keyboard-shortcuts-hint button {
  background: var(--compiler-blue-light);
  border: 1px solid var(--compiler-border);
  color: var(--compiler-blue);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.keyboard-shortcuts-hint button:hover {
  background: rgba(99, 179, 237, 0.2);
  border-color: var(--compiler-blue);
  color: var(--compiler-text);
  transform: scale(1.1);
}

.keyboard-shortcuts-hint button:active {
  transform: scale(0.95);
}

/* ===============================================================================
   PRINT STYLES
   =============================================================================== */

@media print {
  .compiler-topbar,
  .editor-toolbar,
  .output-toolbar,
  .output-tabs {
    display: none;
  }

  .compiler-body {
    height: auto;
  }

  .editor-panel,
  .output-panel {
    width: 100%;
    height: auto;
    border: none;
  }
}
