.btn {
  background-color: #16a34a;
  border-bottom-color: #15803d;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
  border-bottom-width: 1px;
  border-left-color: #15803d;
  border-left-width: 1px;
  border-right-color: #15803d;
  border-top-color: #15803d;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  border-top-style: solid;
  border-top-width: 1px;
  box-sizing: border-box;
  color: rgb(255, 255, 255);
  cursor: pointer;
  display: inline-block;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 12px;
  font-weight: normal;
  height: 22px;
  line-height: 18px;
  margin-bottom: 0px;
  margin-right: 8px;
  outline-color: rgb(255, 255, 255);
  outline-style: none;
  outline-width: 0px;
  padding-bottom: 1px;
  padding-left: 5px;
  padding-right: 5px;
  padding-top: 1px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  width: 24px;
}

/* Theme */
:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e7eaf0;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.06);
  --shadow-sm: 0 2px 10px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --accent: #2563eb;
  --accent-2: #10b981;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#main {
  width: min(92%, 1400px);
  margin-left: auto;
  margin-right: auto;
  max-width: 1400px;
  background: var(--panel);
  border: 1px solid #eee;
  border-top: none;
  box-shadow: var(--shadow);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.code {
  padding: 0;
  border-left: none;
  border-right: none;
}

h1, h2, h3, h4 {
  font-family: 'Raleway',  sans-serif;
}

.hero {
  padding: 18px 18px 0;
}

.hero-site {
  color: var(--text);
  letter-spacing: -0.02em;
}

.hefo-tagline {
  color: var(--muted);
}

.hero .code {
  border-radius: 12px;
  overflow: hidden;
}

.btn-collapse-all{
  color: white;
  border-radius: 4px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  background: #0ea5e9;
}

.goast-layout{
  display: flex;
  flex-direction: row;
  align-items: stretch;
  /* avoid wrapping on wide screens; we’ll wrap on small screens below */
  flex-wrap: nowrap;
  gap: 16px;
  padding: 12px 12px 18px;
}

.goast-layout .source,
.goast-layout .ast{
  /* make both columns share the row evenly */
  flex: 1 1 0;
  /* allow inner content (like long pre/textareas) to shrink instead of forcing wrap */
  min-width: 0;
}

@media (max-width: 900px) {
  .goast-layout{
    flex-wrap: wrap;
  }
  .goast-layout .source,
  .goast-layout .ast{
    flex-basis: 100%;
  }
}

.goast-layout legend {
  display: block;
  padding: 0 0 10px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.source {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.ast {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);

  /* Make AST scroll within its own panel */
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* Keep scroll working (for programmatic scrollIntoView), but hide scrollbar unless hovered */
.ast {
  scrollbar-width: none; /* Firefox */
}
.ast:hover {
  scrollbar-width: thin; /* Firefox */
}
.ast::-webkit-scrollbar {
  width: 0px;
  height: 0px;
}
.ast:hover::-webkit-scrollbar {
  width: 10px;
}

#tree-root {
  margin-top: 10px
}

.source .pure-control-group:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.source input[type="file"] {
  flex: 1 1 auto;
  max-width: 100%;
  font-size: 13px;
}

.source .pure-button,
.ast .pure-button {
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.04);
  transition: transform 120ms ease, filter 120ms ease;
}

.source .pure-button:hover,
.ast .pure-button:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

#code {
  width:100%;
  /* Make the source editor taller by default (independent of parent height) */
  height: clamp(360px, 60vh, 900px);
  resize: vertical;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  box-sizing: border-box;
}

#code:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* CodeMirror editor styling (syntax highlight) */
body.goast-has-codemirror #code {
  display: none;
}

.CodeMirror {
  height: clamp(360px, 60vh, 900px);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.55;
}

.CodeMirror-focused {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* Flash highlight for "jump to code" (3 times)
   Use selection flashing (continuous across spaces) instead of markText spans. */
@keyframes goast-selection-flash {
  0% { background-color: rgba(251, 191, 36, 0.00); }
  50% { background-color: rgba(251, 191, 36, 0.32); }
  100% { background-color: rgba(251, 191, 36, 0.00); }
}

.CodeMirror.goast-flash-selection .CodeMirror-selected {
  border-radius: 4px;
  animation: goast-selection-flash 900ms ease-in-out 0s 3;
}

.btn-expand-all{
  color: white;
  border-radius: 4px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  background: #22c55e;
}

.tree-node {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 10px 10px;
    border-radius: 10px;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.tree-node-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tree-node-content .node-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node:hover {
    color: #0f172a;
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Flash highlight for AST node in tree (3 times) */
@keyframes goast-tree-flash {
  0% { background: rgba(251, 191, 36, 0.00); }
  50% { background: rgba(251, 191, 36, 0.22); }
  100% { background: rgba(251, 191, 36, 0.00); }
}

.tree-node-content.goast-tree-flash {
  border-radius: 10px;
  animation: goast-tree-flash 900ms ease-in-out 0s 3;
}

.hidden {
  display: none!important;
  visibility: hidden!important;
}

.dump {
  font-size: 11px;
  line-height: 1.45;
  overflow: auto;
  padding: 10px 12px;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  max-height: 38vh;
}

/* Subtle scrollbar (WebKit) */
.ast:hover::-webkit-scrollbar,
.dump::-webkit-scrollbar {
  width: 10px;
}
.ast:hover::-webkit-scrollbar-track,
.dump::-webkit-scrollbar-track {
  background: transparent;
}
.ast:hover::-webkit-scrollbar-thumb,
.dump::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
