:root {
  /* Base colors */
  --cm-bg: #ffffff;
  --cm-fg: #2a2a2a;
  --cm-border: #ddd;
  --cm-gutter-bg: #f7f7f7;
  --cm-gutter-border: #e1e4e8;
  --cm-line-number: #999;
  --cm-cursor: #4a89dc;

  /* Selection */
  --cm-selection-bg: #d9d9d9;
  --cm-selection-focused-bg: #d7d4f0;

  /* Search */
  --cm-search-bg: rgba(255, 255, 0, 0.4);

  /* Syntax highlighting */
  --cm-keyword: #9333ea;
  --cm-atom: #0891b2;
  --cm-number: #0d9488;
  --cm-def: #2563eb;
  --cm-variable: #334155;
  --cm-variable-2: #3b82f6;
  --cm-variable-3: #0d9488;
  --cm-type: #0d9488;
  --cm-comment: #64748b;
  --cm-string: #333333;
  --cm-string-2: #15803d;
  --cm-meta: #6b7280;
  --cm-builtin: #7c3aed;
  --cm-tag: #ea580c;
  --cm-attribute: #0284c7;
  --cm-error: #dc2626;
  --cm-header: blue;
  --cm-quote: #090;
  --cm-negative: #d44;
  --cm-positive: #292;
  --cm-link: #00c;
  --cm-bracket: #997;

  /* UI Elements */
  --cm-matching-bracket: #0b0;
  --cm-nonmatching-bracket: #a22;
  --cm-matching-tag-bg: rgba(255, 150, 0, 0.3);
  --cm-active-line-bg: #e8f2ff;
  --cm-fat-cursor-bg: #7e7;
  --cm-fat-cursor-mark: rgba(20, 255, 20, 0.5);
}

[data-theme="dark"] {
  /* Base colors */
  --cm-bg: #1a1a1a;
  --cm-fg: #d4d4d4;
  --cm-border: #404040;
  --cm-gutter-bg: #2a2a2a;
  --cm-gutter-border: #404040;
  --cm-line-number: #888;
  --cm-cursor: #6ba4ee;

  /* Selection */
  --cm-selection-bg: #264f78;
  --cm-selection-focused-bg: #2c5380;

  /* Search */
  --cm-search-bg: rgba(255, 255, 0, 0.2);

  /* Syntax highlighting */
  --cm-keyword: #c792ea;
  --cm-atom: #56c8d8;
  --cm-number: #4ec9b0;
  --cm-def: #569cd6;
  --cm-variable: #9cdcfe;
  --cm-variable-2: #4fc1ff;
  --cm-variable-3: #4ec9b0;
  --cm-type: #4ec9b0;
  --cm-comment: #608b4e;
  --cm-string: rgb(205, 214, 209);
  --cm-string-2: #4ec9b0;
  --cm-meta: #888888;
  --cm-builtin: #c586c0;
  --cm-tag: #f29668;
  --cm-attribute: #4ec9b0;
  --cm-error: #f44747;
  --cm-header: #569cd6;
  --cm-quote: #608b4e;
  --cm-negative: #f44747;
  --cm-positive: #4ec9b0;
  --cm-link: #569cd6;
  --cm-bracket: #888888;

  /* UI Elements */
  --cm-matching-bracket: #4ec9b0;
  --cm-nonmatching-bracket: #f44747;
  --cm-matching-tag-bg: rgba(255, 150, 0, 0.15);
  --cm-active-line-bg: #2c2c2c;
  --cm-fat-cursor-bg: #4ec9b0;
  --cm-fat-cursor-mark: rgba(20, 255, 20, 0.25);
}

/* BASICS */

.CodeMirror {
  font-family: "JetBrains Mono", "Fira Code", "IBM Plex Mono", "Source Code Pro", Consolas, monospace;
  height: 300px;
  color: var(--cm-fg);
  background: var(--cm-bg);
  direction: ltr;
}

/* PADDING */

.CodeMirror-lines {
  padding: 4px 0;
}
.CodeMirror pre {
  padding: 0 4px;
}

.CodeMirror-scrollbar-filler,
.CodeMirror-gutter-filler {
  background-color: var(--cm-bg);
}

/* GUTTER */

.CodeMirror-gutters {
  border-right: 1px solid var(--cm-gutter-border);
  background-color: var(--cm-gutter-bg);
  white-space: nowrap;
}

.CodeMirror-linenumber {
  padding: 0 3px 0 5px;
  min-width: 20px;
  text-align: right;
  color: var(--cm-line-number);
  white-space: nowrap;
}

/* CURSOR */

.CodeMirror-cursor {
  border-left: 2px solid var(--cm-cursor);
  border-right: none;
  width: 0;
}

.CodeMirror div.CodeMirror-secondarycursor {
  border-left: 1px solid silver;
}

.cm-fat-cursor .CodeMirror-cursor {
  width: auto;
  border: 0 !important;
  background: var(--cm-fat-cursor-bg);
}

.cm-fat-cursor div.CodeMirror-cursors {
  z-index: 1;
}

.cm-fat-cursor-mark {
  background-color: var(--cm-fat-cursor-mark);
  -webkit-animation: blink 1.06s steps(1) infinite;
  -moz-animation: blink 1.06s steps(1) infinite;
  animation: blink 1.06s steps(1) infinite;
}

.cm-animate-fat-cursor {
  width: auto;
  border: 0;
  -webkit-animation: blink 1.06s steps(1) infinite;
  -moz-animation: blink 1.06s steps(1) infinite;
  animation: blink 1.06s steps(1) infinite;
  background-color: var(--cm-fat-cursor-bg);
}

/* DEFAULT THEME */

.cm-s-default .cm-header {
  color: var(--cm-header);
}
.cm-s-default .cm-quote {
  color: var(--cm-quote);
}
.cm-negative {
  color: var(--cm-negative);
}
.cm-positive {
  color: var(--cm-positive);
}
.cm-header,
.cm-strong {
  font-weight: bold;
}
.cm-em {
  font-style: italic;
}
.cm-link {
  text-decoration: underline;
  color: var(--cm-link);
}
.cm-strikethrough {
  text-decoration: line-through;
}

.cm-s-default .cm-keyword {
  color: var(--cm-keyword);
}
.cm-s-default .cm-atom {
  color: var(--cm-atom);
}
.cm-s-default .cm-number {
  color: var(--cm-number);
}
.cm-s-default .cm-def {
  color: var(--cm-def);
}
.cm-s-default .cm-variable {
  color: var(--cm-variable);
}
.cm-s-default .cm-variable-2 {
  color: var(--cm-variable-2);
}
.cm-s-default .cm-variable-3,
.cm-s-default .cm-type {
  color: var(--cm-type);
}
.cm-s-default .cm-comment {
  color: var(--cm-comment);
  font-style: italic;
}
.cm-s-default .cm-string {
  color: var(--cm-string);
}
.cm-s-default .cm-string-2 {
  color: var(--cm-string-2);
}
.cm-s-default .cm-meta {
  color: var(--cm-meta);
}
.cm-s-default .cm-qualifier {
  color: var(--cm-meta);
}
.cm-s-default .cm-builtin {
  color: var(--cm-builtin);
}
.cm-s-default .cm-bracket {
  color: var(--cm-bracket);
}
.cm-s-default .cm-tag {
  color: var(--cm-tag);
}
.cm-s-default .cm-attribute {
  color: var(--cm-attribute);
}
.cm-s-default .cm-error {
  color: var(--cm-error);
  text-decoration: underline wavy var(--cm-error);
}

/* Selection */
.CodeMirror-selected {
  background: var(--cm-selection-bg);
}
.CodeMirror-focused .CodeMirror-selected {
  background: var(--cm-selection-focused-bg);
}

/* Matching */
div.CodeMirror span.CodeMirror-matchingbracket {
  color: var(--cm-matching-bracket);
}
div.CodeMirror span.CodeMirror-nonmatchingbracket {
  color: var(--cm-nonmatching-bracket);
}
.CodeMirror-matchingtag {
  background: var(--cm-matching-tag-bg);
}

/* Active line */
.CodeMirror-activeline-background {
  background: var(--cm-active-line-bg);
}

/* Search highlighting */
.cm-searching {
  background-color: var(--cm-search-bg);
}

/* Rest of mechanical CSS */

.CodeMirror {
  position: relative;
  overflow: hidden;
}

.CodeMirror-scroll {
  overflow: scroll !important;
  margin-bottom: -30px;
  margin-right: -30px;
  padding-bottom: 30px;
  height: 100%;
  outline: none;
  position: relative;
}

.CodeMirror-sizer {
  position: relative;
  border-right: 30px solid transparent;
}

.CodeMirror-vscrollbar,
.CodeMirror-hscrollbar,
.CodeMirror-scrollbar-filler,
.CodeMirror-gutter-filler {
  position: absolute;
  z-index: 6;
  display: none;
}

.CodeMirror-vscrollbar {
  right: 0;
  top: 0;
  overflow-x: hidden;
  overflow-y: scroll;
}

.CodeMirror-hscrollbar {
  bottom: 0;
  left: 0;
  overflow-y: hidden;
  overflow-x: scroll;
}

.CodeMirror-scrollbar-filler {
  right: 0;
  bottom: 0;
}

.CodeMirror-gutter-filler {
  left: 0;
  bottom: 0;
}

.CodeMirror-gutters {
  position: absolute;
  left: 0;
  top: 0;
  min-height: 100%;
  z-index: 3;
}

.CodeMirror-gutter {
  white-space: normal;
  height: 100%;
  display: inline-block;
  vertical-align: top;
  margin-bottom: -30px;
}

.CodeMirror-gutter-wrapper {
  position: absolute;
  z-index: 4;
  background: none !important;
  border: none !important;
}

.CodeMirror-gutter-background {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 4;
}

.CodeMirror-gutter-elt {
  position: absolute;
  cursor: default;
  z-index: 4;
}

.CodeMirror-gutter-wrapper ::selection {
  background-color: transparent;
}

.CodeMirror-gutter-wrapper ::-moz-selection {
  background-color: transparent;
}

.CodeMirror-lines {
  cursor: text;
  min-height: 1px;
}

.CodeMirror pre {
  -moz-border-radius: 0;
  -webkit-border-radius: 0;
  border-radius: 0;
  border-width: 0;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  margin: 0;
  white-space: pre;
  word-wrap: normal;
  line-height: inherit;
  color: inherit;
  z-index: 2;
  position: relative;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-variant-ligatures: contextual;
  font-variant-ligatures: contextual;
}

.CodeMirror-wrap pre {
  word-wrap: break-word;
  white-space: pre-wrap;
  word-break: normal;
}

.CodeMirror-wrap pre .cm-atom,
.CodeMirror-wrap pre .cm-keyword,
.CodeMirror-wrap pre .cm-def {
  word-break: break-all;
}

.CodeMirror-linebackground {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 0;
}

.CodeMirror-linewidget {
  position: relative;
  z-index: 2;
  padding: 0.1px;
}

.CodeMirror-rtl pre {
  direction: rtl;
}

.CodeMirror-code {
  outline: none;
}

.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
}

.CodeMirror-measure {
  position: absolute;
  width: 100%;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.CodeMirror-cursor {
  position: absolute;
  pointer-events: none;
}

.CodeMirror-measure pre {
  position: static;
}

div.CodeMirror-cursors {
  visibility: hidden;
  position: relative;
  z-index: 3;
}

div.CodeMirror-dragcursors {
  visibility: visible;
}

.CodeMirror-focused div.CodeMirror-cursors {
  visibility: visible;
}

.CodeMirror-crosshair {
  cursor: crosshair;
}

.CodeMirror-line::selection,
.CodeMirror-line > span::selection,
.CodeMirror-line > span > span::selection {
  background: var(--cm-selection-focused-bg);
}

.CodeMirror-line::-moz-selection,
.CodeMirror-line > span::-moz-selection,
.CodeMirror-line > span > span::-moz-selection {
  background: var(--cm-selection-focused-bg);
}

/* Used to force a border model for a node */
.cm-force-border {
  padding-right: 0.1px;
}

@media print {
  /* Hide the cursor when printing */
  .CodeMirror div.CodeMirror-cursors {
    visibility: hidden;
  }
}

/* See issue #2901 */
.cm-tab-wrap-hack:after {
  content: "";
}

/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext {
  background: none;
}

/* Hints */
.CodeMirror-hints {
  position: absolute;
  z-index: 10;
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 2px;
  -webkit-box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.2);
  box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  border: 1px solid var(--cm-border);
  background: var(--cm-bg);
  font-size: 90%;
  font-family: monospace;
  max-height: 20em;
  overflow-y: auto;
}

.CodeMirror-hint {
  margin: 0;
  padding: 0 4px;
  border-radius: 2px;
  white-space: pre;
  color: var(--cm-fg);
  cursor: pointer;
}

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

/* Animation keyframes */
@-moz-keyframes blink {
  0% {
  }
  50% {
    background-color: transparent;
  }
  100% {
  }
}

@-webkit-keyframes blink {
  0% {
  }
  50% {
    background-color: transparent;
  }
  100% {
  }
}

@keyframes blink {
  0% {
  }
  50% {
    background-color: transparent;
  }
  100% {
  }
}
