/* Reset & base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0b0e14;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #1e2430; }
::-webkit-scrollbar-thumb { background: #3b4455; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #5b6a80; }

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: #141a24;
  border-bottom: 1px solid #2a3344;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  background: #2d8cf0;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  letter-spacing: -0.5px;
}
.brand-title {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.3px;
  color: #f0f4fc;
}
.badge {
  background: #2a3344;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #9bb1d0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #8899bb;
  margin-left: 8px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f97316;
  transition: background 0.2s;
}
.dot.ready { background: #4ade80; }
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.example-select {
  background: #1e2430;
  border: 1px solid #2f3a4e;
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  border: none;
  background: #2a3344;
  color: #cdd9f0;
  cursor: pointer;
  transition: 0.15s;
  font-family: 'Inter', sans-serif;
}
.btn-primary {
  background: #2d8cf0;
  color: white;
}
.btn-primary:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn-primary:hover { background: #3d9cff; }
.btn-secondary:hover { background: #364153; }
.btn svg { display: block; }

/* Main panels */
.main-container {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  padding: 0;
  background: #0f141e;
}
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #202834;
  background: #131b26;
  min-width: 0;
}
.panel:last-child { border-right: none; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #181f2b;
  border-bottom: 1px solid #283040;
  flex-shrink: 0;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 14px;
  color: #b6c8e5;
}
.badge-char {
  font-size: 12px;
  color: #6a7f9f;
  background: #202a38;
  padding: 2px 10px;
  border-radius: 30px;
}

/* CodeMirror - One Dark theme overrides */
.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0f141e;
}
.editor-wrapper .CodeMirror {
  height: 100% !important;
  font-family: 'Fira Code', 'Fira Mono', 'JetBrains Mono', monospace;
  font-size: 14px;
  background: #0f141e;
  color: #e2e8f0;
  line-height: 1.6;
}
.editor-wrapper .CodeMirror-gutters {
  background: #0f141e;
  border-right: 1px solid #263040;
}
.editor-wrapper .CodeMirror-linenumber {
  color: #4a5b78;
  padding: 0 8px;
}
.editor-wrapper .CodeMirror-cursor {
  border-left: 2px solid #9bb1d0;
}
.editor-wrapper .cm-s-material .CodeMirror-activeline-background { background: #1f293b; }

/* Custom Tender highlighting colors (One Dark inspired) */
.cm-tender-keyword { color: #c678dd; font-weight: 600; }
.cm-tender-type { color: #56b6c2; font-weight: 500; }
.cm-tender-builtin { color: #98c379; }
.cm-tender-string { color: #98c379; }
.cm-tender-comment { color: #5c6370; font-style: italic; }
.cm-tender-number { color: #d19a66; }
.cm-tender-operator { color: #c678dd; }
.cm-tender-operator-def { color: #d19a66; font-weight: 600; }
.cm-tender-variable { color: #e6e6e6; }
.cm-tender-function { color: #61afef; }
.cm-tender-constant { color: #d19a66; }
.cm-tender-arrow { color: #d19a66; }

/* Tabs & Output */
.tab-buttons {
  display: flex;
  gap: 4px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: #7a8aa8;
  padding: 4px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 30px;
  transition: 0.15s;
  font-family: 'Inter', sans-serif;
}
.tab-btn.active {
  background: #2d8cf0;
  color: #fff;
}
.tab-btn:hover { color: #d0def5; }

.tab-content {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: #0f141e;
}
.tab-content.active { display: block; }

.console-output, .json-ast {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  color: #d4e0f5;
  margin: 0;
  min-height: 100px;
  display: flex;
  flex-direction: column;
}
.output-error { color: #e06c75; }
.output-log { color: #abb2bf; }
.output-meta { 
    display: flex;
    flex-direction: column;
    color: #56b6c2; 
    margin-top: 6px; 
}

/* Collapsible scope variables */
.scope-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #56b6c2;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.scope-toggle:hover {
  background: rgba(86, 182, 194, 0.1);
}
.scope-toggle .arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 12px;
}
.scope-toggle .arrow.collapsed {
  transform: rotate(-90deg);
}
.scope-variables {
    margin-left: 8px;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
    max-height: 5000px;
    opacity: 1;
    display: flex;
    flex-direction: column;
}
.scope-variables.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
  margin: 0;
  border-left: none;
}
.scope-var-line {
  padding: 2px 0;
  color: #abb2bf;
}
.scope-var-line .var-name {
  color: #61afef;
}
.scope-var-line .var-value {
  color: #98c379;
}

.modules-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.module-card {
  background: #1a2332;
  padding: 10px 16px;
  border-radius: 12px;
  border-left: 3px solid #2d8cf0;
}
.module-name {
  font-weight: 600;
  color: #b8cef0;
}
.module-desc {
  font-size: 12px;
  color: #6b84aa;
}

footer {
  background: #10171f;
  border-top: 1px solid #1f2a38;
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #5d7397;
  flex-shrink: 0;
}
footer kbd {
  background: #1e2636;
  padding: 2px 8px;
  border-radius: 4px;
  color: #b6cef0;
  font-family: 'Fira Code', monospace;
}
code { font-family: 'Fira Code', monospace; }

@media (max-width: 800px) {
  .main-container { flex-direction: column; }
  .panel { border-right: none; border-bottom: 1px solid #202834; }
}

/* Keywords: italic + bold + different color */
.cm-tender-keyword {
  font-style: italic !important;
  font-weight: normal !important;
  color: #c678dd !important; /* purple like in many themes */
}

/* Built-ins: italic + lighter */
.cm-tender-builtin {
  font-style: italic !important;
  color: #61afef !important; /* blue */
}