/* MPL language support styles (from mpl-codemirror package) */
@import "@axiomhq/mpl-codemirror/styles/tokens.css";

@font-face {
  font-family: "Ioskeley Mono";
  src: url("/fonts/IoskeleyMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-color: #ffffff;
  --text-color: #333;
  --border-color: #ddd;
  --header-bg: #ffffff;
  --toggle-bg: #f0f0f0;
  --toggle-active-bg: #ffffff;
  --toggle-text: #666;
  --toggle-active-text: #333;
  --editor-border: #ddd;
  --editor-border-focus: #4a90e2;
  --label-bg: rgba(255, 255, 255, 0.9);
  --label-text: #666;
  --scrollbar-track: #f0f0f0;
  --scrollbar-thumb: #c0c0c0;
  --scrollbar-thumb-hover: #a0a0a0;
}

.dark-theme {
  --bg-color: #1e1e1e;
  --text-color: #e0e0e0;
  --border-color: #404040;
  --header-bg: #1e1e1e;
  --toggle-bg: #2d2d2d;
  --toggle-active-bg: #404040;
  --toggle-text: #a0a0a0;
  --toggle-active-text: #e0e0e0;
  --editor-border: #404040;
  --editor-border-focus: #4a90e2;
  --label-bg: rgba(30, 30, 30, 0.9);
  --label-text: #a0a0a0;
  --scrollbar-track: #2d2d2d;
  --scrollbar-thumb: #505050;
  --scrollbar-thumb-hover: #606060;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

*,
*::before,
*::after {
  font-family: inherit;
}

body {
  font-family: "Ioskeley Mono", ui-monospace, monospace;
  background: var(--bg-color);
  color: var(--text-color);
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  display: flex;
  flex-direction: column;
}

body > div {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Scrollbar styles */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 6px;
  border: 2px solid var(--scrollbar-track);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

#header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

#example-select {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--toggle-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 180px;
}

#example-select:hover {
  background: var(--toggle-active-bg);
}

#example-select:focus {
  outline: none;
  border-color: var(--editor-border-focus);
}

.header-spacer {
  flex: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-color);
  cursor: pointer;
  transition:
    background 0.15s ease,
    opacity 0.15s ease;
  opacity: 0.6;
}

.icon-btn:hover {
  background: var(--toggle-bg);
  opacity: 1;
}

.label-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--toggle-text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.label-btn:hover {
  color: var(--toggle-active-text);
}

.label-btn.active {
  color: var(--toggle-active-text);
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--toggle-text);
  cursor: pointer;
}

.toggle {
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--toggle-bg);
  border: 1px solid var(--border-color);
  position: relative;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
  box-sizing: border-box;
}

.toggle.on {
  background: var(--toggle-text);
  border-color: var(--toggle-text);
}

.toggle-knob {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-color);
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition:
    left 0.2s ease,
    background 0.2s ease;
}

.toggle.on .toggle-knob {
  left: calc(100% - 12px);
  background: var(--bg-color);
}

#panel-toolbars {
  display: flex;
  padding: 2px 20px;
  /* 4px divider gap to match #container's divider */
  gap: 4px;
}

.panel-toolbar {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

#container {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0 20px 20px 20px;
}

.editor-wrapper {
  flex: 1;
  border: 2px solid var(--editor-border);
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.2s ease;
  position: relative;
}

.editor-wrapper:has(.cm-editor.cm-focused) {
  border-color: var(--editor-border-focus);
  box-shadow: 0 0 0 1px var(--editor-border-focus);
}

.editor-container {
  height: 100%;
}

.cm-editor {
  height: 100%;
}

.cm-editor,
.cm-editor .cm-content,
.cm-editor .cm-gutters,
.cm-editor .cm-lineNumbers {
  font-family: "Ioskeley Mono", ui-monospace, monospace;
  font-size: 0.75rem;
}

.editor-vim-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
  opacity: 0.3;
  color: var(--text-color);
}

/* Draggable divider */
#divider {
  width: 4px;
  cursor: col-resize;
  background: var(--border-color);
  flex-shrink: 0;
  transition: background 0.15s;
}

#divider:hover,
#divider.dragging {
  background: var(--editor-border-focus);
}

/* Charts panel */
#charts-panel {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-label {
  font-family: "Ioskeley Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 16px;
  color: var(--label-text);
  padding: 2px 4px;
  white-space: pre-wrap;
  flex-shrink: 0;
}

.chart-widget {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: visible;
}

.chart-widget > .uplot {
  border-radius: 4px;
}

.chart-error {
  padding: 6px 12px;
  color: #dc2626;
  font-family: "Ioskeley Mono", ui-monospace, monospace;
  font-size: 11px;
  border: 1px dashed #dc2626;
  border-radius: 4px;
  background: rgba(220, 38, 38, 0.05);
  white-space: pre-wrap;
  word-break: break-word;
}

.chart-empty {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--label-text);
  font-size: 12px;
  font-style: italic;
  border: 1px dashed var(--border-color);
  border-radius: 4px;
}

/* Tooltip */
.step-tooltip {
  position: fixed;
  z-index: 10000;
  background: var(--label-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: "Ioskeley Mono", ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
  color: var(--text-color);
  backdrop-filter: blur(4px);
}

/* Responsive: stack editor above charts on small screens */
@media (max-width: 768px) {
  #header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  #header h1 {
    font-size: 15px;
  }

  #example-select {
    min-width: 0;
    flex: 1;
  }

  #panel-toolbars {
    flex-direction: column;
    padding: 2px 8px;
    gap: 0;
  }

  #container {
    flex-direction: column;
    padding: 0 8px 8px 8px;
  }

  .editor-wrapper {
    flex: none;
    height: 40vh;
  }

  #divider {
    width: auto;
    height: 4px;
    cursor: row-resize;
  }

  #charts-panel {
    flex: 1;
    min-height: 0;
  }
}
