/* =========================
   Everforest for CodeMirror (CM5)
   ========================= */

:root {
  --ef-fg: var(--tblr-gray-400);
  --ef-bg: #2d353b;
  --ef-gutter-bg: #2a3136;
  --ef-gutter-fg: #56635f;
  --ef-cursor: var(--tblr-gray-400);
  --ef-cursorline-bg: #343f44;
  --ef-selection: #4b565c80;

  --ef-kw: #e67e80;    /* keywords, commands */
  --ef-fn: #a7c080;    /* functions/defs */
  --ef-str: #a7c080;   /* strings */
  --ef-num: #d699b6;   /* numbers */
  --ef-var: #7fbbb3;   /* variables/properties */
  --ef-dlm: #d3c6aa;   /* punctuation/delimiters */
  --ef-comment: #859289;
}

.CodeMirror {
  transition: height 0.2s ease;
}

.CodeMirror {
  min-height: 25px;
  height: auto;
}

/* --- BASICS --- */
.cm-s-everforest.CodeMirror {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  height: 50vh;                 /* adjust as you like */
  color: var(--ef-fg);
  background: var(--ef-bg);
  direction: ltr;
}

/* --- PADDING --- */
.cm-s-everforest .CodeMirror-lines { padding: 12px 0; }
.cm-s-everforest .CodeMirror pre.CodeMirror-line,
.cm-s-everforest .CodeMirror pre.CodeMirror-line-like { padding: 0 16px; }

/* The little square between scrollbars */
.cm-s-everforest .CodeMirror-scrollbar-filler,
.cm-s-everforest .CodeMirror-gutter-filler { background-color: var(--ef-bg); }

/* --- GUTTER --- */
.cm-s-everforest .CodeMirror-gutters {
  min-width: 25px;          /* overall gutter min width */
  border-right: 1px solid rgba(255,255,255,.06);
  background-color: var(--ef-gutter-bg);
  white-space: nowrap;
  color: var(--ef-gutter-fg);
}
.cm-s-everforest .CodeMirror-linenumber {
  padding: 0 3px;           /* horizontal padding inside each number */
  min-width: 25px;          /* match to keep alignment */
  /*padding: 0 6px 0 8px;*/
  /*min-width: 2.25rem;*/
  text-align: right;
  color: var(--ef-gutter-fg);
}
.cm-s-everforest .CodeMirror-guttermarker { color: var(--ef-fg); }
.cm-s-everforest .CodeMirror-guttermarker-subtle { color: var(--ef-gutter-fg); }

/* --- CURSOR --- */
.cm-s-everforest .CodeMirror-cursor {
  border-left: 2px solid var(--ef-cursor);
  border-right: none;
  width: 0;
}
.cm-s-everforest.cm-fat-cursor .CodeMirror-cursor {
  width: auto; border: 0 !important; background: #7e7;
}
.cm-s-everforest.cm-fat-cursor { caret-color: transparent; }

/* --- SELECTION & ACTIVE LINE --- */
.cm-s-everforest .CodeMirror-selected { background: var(--ef-selection); }
.cm-s-everforest.CodeMirror-focused .CodeMirror-selected { background: var(--ef-selection); }
.cm-s-everforest .CodeMirror-line::selection,
.cm-s-everforest .CodeMirror-line > span::selection,
.cm-s-everforest .CodeMirror-line > span > span::selection { background: var(--ef-selection); }
.cm-s-everforest .CodeMirror-line::-moz-selection,
.cm-s-everforest .CodeMirror-line > span::-moz-selection,
.cm-s-everforest .CodeMirror-line > span > span::-moz-selection { background: var(--ef-selection); }

.cm-s-everforest .CodeMirror-activeline-background { background: var(--ef-cursorline-bg); }
.cm-s-everforest .CodeMirror-activeline .CodeMirror-linenumber {
  color: var(--ef-comment);
  background: var(--ef-cursorline-bg);
}

/* --- MATCHING --- */
.cm-s-everforest div.CodeMirror span.CodeMirror-matchingbracket {
  color: var(--ef-kw);
  font-weight: 600;
}
.cm-s-everforest div.CodeMirror span.CodeMirror-nonmatchingbracket { color: #e67e80; }
.cm-s-everforest .CodeMirror-matchingtag { background: rgba(219,188,127,.25); }

/* --- TOKENS (Default Theme Mappings) --- */
.cm-s-everforest .cm-comment        { color: var(--ef-comment); font-style: italic; }
.cm-s-everforest .cm-keyword        { color: var(--ef-kw); }
.cm-s-everforest .cm-atom           { color: var(--ef-num); }
.cm-s-everforest .cm-number         { color: var(--ef-num); }
.cm-s-everforest .cm-def            { color: var(--ef-fn); }          /* function/def names */
.cm-s-everforest .cm-variable       { color: var(--ef-var); }
.cm-s-everforest .cm-variable-2     { color: var(--ef-var); }
.cm-s-everforest .cm-variable-3,
.cm-s-everforest .cm-type           { color: var(--ef-fn); }
.cm-s-everforest .cm-property       { color: var(--ef-var); }
.cm-s-everforest .cm-operator       { color: var(--ef-kw); }
.cm-s-everforest .cm-punctuation    { color: var(--ef-dlm); }
.cm-s-everforest .cm-string         { color: var(--ef-str); }
.cm-s-everforest .cm-string-2       { color: var(--ef-str); }
.cm-s-everforest .cm-meta,
.cm-s-everforest .cm-qualifier      { color: var(--ef-comment); }
.cm-s-everforest .cm-builtin        { color: var(--ef-fn); }
.cm-s-everforest .cm-bracket        { color: var(--ef-dlm); }
.cm-s-everforest .cm-tag            { color: var(--ef-kw); }
.cm-s-everforest .cm-attribute      { color: var(--ef-var); }
.cm-s-everforest .cm-hr             { color: var(--ef-comment); }
.cm-s-everforest .cm-link           { color: var(--ef-var); text-decoration: underline; }

.cm-s-everforest .cm-error          { color: #ff6b6b; }
.cm-s-everforest .cm-invalidchar    { color: #ff6b6b; }

/* --- MECHANICS we keep safe defaults for --- */
.cm-s-everforest.CodeMirror {
  position: relative; overflow: hidden;
}
.cm-s-everforest .CodeMirror-scroll {
  overflow: scroll !important;
  margin-bottom: -50px; margin-right: -50px;
  padding-bottom: 50px;
  height: 100%;
  outline: none;
  position: relative; z-index: 0;
}
.cm-s-everforest .CodeMirror-sizer { position: relative; border-right: 50px solid transparent; }
.cm-s-everforest .CodeMirror-gutters {
  position: absolute; left: 0; top: 0; min-height: 100%; z-index: 3;
}
.cm-s-everforest .CodeMirror-lines { cursor: text; min-height: 1px; }
.cm-s-everforest .CodeMirror pre.CodeMirror-line,
.cm-s-everforest .CodeMirror pre.CodeMirror-line-like {
  border: 0; background: transparent;
  font-family: inherit; font-size: inherit; margin: 0;
  white-space: pre; word-wrap: normal; line-height: inherit; color: inherit;
  position: relative; overflow: visible;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-variant-ligatures: contextual; font-variant-ligatures: contextual;
}
.cm-s-everforest .CodeMirror-selectedtext { background: none; }

/* Optional: make sure pointer events are allowed inside the editor card */
.cm-s-everforest .CodeMirror,
.cm-s-everforest .CodeMirror-scroll,
.cm-s-everforest .CodeMirror-lines { pointer-events: auto; }
