@font-face {
  font-family: "Workbench FiraCode Nerd Mono Medium";
  src: local("FiraCode Nerd Font Mono Medium"), local("FiraCodeNerdFontMono-Medium");
}

:root {
  color-scheme: light;
  font-family: Inter, "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-synthesis: none;
  background: #f4f6fa;
  color: #182236;
  --muted: #566378;
  --line: #dce3ee;
  --line-soft: #e8edf4;
  --accent: #254fc5;
  --accent-hover: #1d3fa0;
  --accent-surface: #edf2ff;
  --mono: "IBM Plex Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button { color: inherit; font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.shell { width: calc(100% - 2 * clamp(16px, 2.2vw, 40px)); margin-inline: auto; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 66px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.workbench-window-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 14px; }
.workbench-window-actions .button { font-size: 12px; }
.keyboard-fullscreen-status { margin-block: 0; padding-bottom: 9px; text-align: end; font-size: 12px; color: var(--muted); }
.keyboard-fullscreen-status:empty { display: none; }
.brand { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 16px; font-weight: 750; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #1b2b49;
  color: #fff;
  font: 700 24px/1 var(--mono);
}
.brand-mark span { font-size: 14px; transform: translateY(3px); }
.engine { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a640d; }
.engine[data-state="ready"] .status-dot { background: #167346; }
.engine[data-state="running"] .status-dot { background: var(--accent); }
.engine[data-state="error"] .status-dot { background: #b03446; }
.engine[data-state="stopped"] .status-dot { background: #637389; }

.workbench {
  display: grid;
  grid-template-columns: clamp(213px, 14vw, 300px) minmax(0, 1.04fr) minmax(0, 1fr);
  gap: clamp(12px, 1vw, 22px);
  margin-block: clamp(12px, 2dvh, 20px) clamp(12px, 2dvh, 24px);
}
.sidebar, .panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 2px 5px #1b2b4905;
}
.sidebar { display: flex; flex-direction: column; align-self: start; }
.workspace-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin: 12px 13px 0;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #f4f6fa;
}
.workspace-modes button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.workspace-modes button[aria-pressed="true"] {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px #1b2b4908;
}
.workspace-modes button:not(:disabled):hover { color: var(--accent); }
.sidebar-pane { min-width: 0; }
.sidebar-section { padding: 17px 13px; }
.sidebar-section + .sidebar-section { border-top: 1px solid var(--line-soft); }
.sidebar h2 { margin: 0 0 9px 4px; font-size: 13px; letter-spacing: -0.025em; }
.examples { display: grid; gap: 3px; }
.example {
  width: 100%;
  min-height: 57px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 7px;
  text-align: left;
}
.example:hover { background: #f5f7fb; }
.example[aria-pressed="true"] { color: #203f9a; border-color: #dce5ff; background: var(--accent-surface); }
.example-icon {
  display: grid;
  flex: 0 0 31px;
  height: 31px;
  place-items: center;
  border-radius: 7px;
  background: #eef1f6;
  font: 700 14px var(--mono);
}
.example[aria-pressed="true"] .example-icon { background: #dce6ff; }
.example strong, .example small { display: block; }
.example strong { font-size: 13px; margin-bottom: 3px; }
.example small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.example-filters { display: grid; gap: 6px; margin-bottom: 9px; }
.example-filters input, .example-filters select {
  min-width: 0;
  width: 100%;
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfe;
  color: #263a58;
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
}
.example-filters input::placeholder { color: var(--muted); }
.example-filters input:focus-visible, .example-filters select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.example-list {
  max-height: clamp(174px, 33vh, 296px);
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-block: 1px solid var(--line-soft);
}
.example-list:focus-visible { outline-offset: -2px; }
.example-group { padding: 6px 0; }
.example-group + .example-group { border-top: 1px solid var(--line-soft); }
.example-group h3 { margin: 3px 7px 4px; color: var(--muted); font-size: 11px; font-weight: 650; }
.catalog-example { min-height: 33px; padding: 5px 7px; }
.catalog-example strong { font-size: 12px; margin-bottom: 0; overflow-wrap: anywhere; }
.catalog-example small { margin-top: 2px; overflow-wrap: anywhere; }
.example-feedback { margin: 8px 4px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.example-feedback[data-error="true"] { color: #963246; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 3px 9px 0; }
.section-title h2 { margin-bottom: 0; }
.file-count {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 8px;
  background: #edf0f6;
  color: var(--muted);
  font: 600 11px/1.4 var(--mono);
  text-align: center;
}
.sidebar .files { padding-block: 10px; }
.attachment-header { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.sidebar .attachment-header h2 { min-width: 0; margin: 0; }
.attachment-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  width: 100%;
  padding: 2px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  font-size: 12px;
}
.attachment-toggle .file-count { margin-inline-start: auto; }
.attachment-toggle:hover { background: #f4f6fa; }
.attachment-chevron {
  width: 6px;
  height: 6px;
  margin: 0 2px 0 0;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
}
.attachment-toggle[aria-expanded="true"] .attachment-chevron { transform: rotate(45deg); }
.attachment-add.button { gap: 4px; padding-inline: 7px; }
.attachment-add span:first-child { font-size: 15px; line-height: 1; }
#example-attachment-list:not([hidden]) { margin-top: 7px; }
.files-empty, .file-feedback { color: var(--muted); font-size: 11px; line-height: 1.55; margin: 8px 4px 12px; }
.file-feedback { margin-bottom: 0; overflow-wrap: anywhere; }
.file-feedback[data-error="true"] { color: #963246; }
.file-list { list-style: none; padding: 0; margin: 0; max-height: 230px; overflow: auto; }
.file-list:not(:empty) { margin-bottom: 9px; }
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  margin-block: 3px;
  padding: 3px 4px 3px 7px;
  border-radius: 6px;
  background: #f5f7fb;
}
.file-row code { overflow-wrap: anywhere; font: 12px var(--mono); }
.file-description { min-width: 0; }
.file-origin { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.remove-file {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
}
.remove-file:hover { background: #fbe6ea; color: #963246; }
.add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 34px;
  border: 1px dashed #bfcadd;
  border-radius: 7px;
  background: #fafbfe;
  color: #435775;
  font-size: 12px;
  font-weight: 700;
}
.add-button:hover { border-color: #869cd0; color: var(--accent); }
.add-button span { font-size: 18px; line-height: 1; }
.project-form { display: flex; gap: 5px; }
.project-form input, .project-entry-field select {
  min-width: 0;
  width: 100%;
  min-height: 36px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfe;
  color: #263a58;
  font-family: inherit;
  font-size: 12px;
}
.project-form input.mono, .project-entry-field select { font-family: var(--mono); }
.project-form input::placeholder { color: var(--muted); }
.project-form input:focus-visible, .project-entry-field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.project-form .button { flex: none; padding-inline: 7px; }
.project-list { display: grid; gap: 3px; list-style: none; margin: 8px 0 0; padding: 0; max-height: 188px; overflow: auto; }
.project-list:empty { margin: 0; }
.project-select {
  min-width: 0;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f5f7fb;
  text-align: left;
  font-size: 12px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.project-select:not(:disabled):hover { background: #eef2f8; }
.project-select[aria-pressed="true"] { border-color: #dce5ff; color: #203f9a; background: var(--accent-surface); }
.project-select:focus-visible { outline-offset: -2px; }
.project-file-row { display: flex; align-items: center; gap: 3px; }
.rename-file {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
}
.rename-file:hover { color: var(--accent); background: var(--accent-surface); }
.project-inline-rename { min-width: 0; width: 100%; padding: 2px; }
.project-inline-rename input { min-height: 32px; background: #fff; }
.project-inline-rename input:focus-visible { outline-offset: -2px; }
.project-inline-rename input[aria-invalid="true"] { border-color: #963246; }
.project-inline-rename p {
  margin: 4px 5px 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.project-inline-rename #rename-file-error { color: #963246; }
.project-delete.button { margin-top: 8px; color: #963246; }
#import-project-files { margin-top: 7px; }
.project-note, .project-feedback { color: var(--muted); font-size: 11px; line-height: 1.6; }
.project-note { margin: 8px 0 0; }
.project-feedback { margin: 0; padding: 0 13px 12px; overflow-wrap: anywhere; }
.project-feedback[data-error="true"] { color: #963246; }
.project-entry-field { display: grid; gap: 5px; margin-top: 12px; }
.project-entry-field label { font-size: 12px; font-weight: 700; }
.delete-dialog {
  width: min(370px, calc(100% - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  box-shadow: 0 12px 50px #1b2b492e;
}
.delete-dialog::backdrop { background: #18223666; }
.delete-dialog h2 { margin: 0; font-size: 16px; }
.delete-dialog p { margin: 10px 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; }
.editor-settings {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  box-shadow: 0 12px 50px #1b2b492e;
}
.editor-settings::backdrop { background: #18223666; }
.editor-settings h2 { margin: 0 0 15px; font-size: 17px; }
.editor-settings h3 { margin: 0 0 8px; font-size: 13px; }
.editor-settings-fields { display: grid; gap: 6px; }
.editor-settings-fields label { font-size: 13px; font-weight: 700; }
.editor-settings-fields p:not(:last-child) { margin-bottom: 7px; }
.editor-settings select {
  width: 100%;
  min-height: 36px;
  padding-inline: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 13px;
}
.editor-settings p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.editor-settings-section { margin-top: 15px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.editor-settings-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.editor-settings-section p:not(:empty) { margin-block: 6px; }
.editor-settings [data-error="true"], .editor-settings [data-state="error"] { color: #963246; }
.editor-settings .editor-cursors-help { margin-block: 14px 10px; }
.confirm-delete.button { border-color: #9e3146; background: #9e3146; color: #fff; }
.confirm-delete.button:hover { border-color: #802436; background: #802436; }
.sidebar-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  border-top: 1px solid var(--line-soft);
  padding: 12px 17px;
  color: var(--muted);
  font-size: 10px;
}
.sidebar-footer span:first-child { font-family: var(--mono); }
.sidebar-footer a { margin-inline-start: auto; color: var(--muted); text-underline-offset: 2px; }
.sidebar-footer a:hover { color: var(--accent); }

.compatibility { max-width: 52rem; margin: 2rem auto; padding: clamp(1rem, 4vw, 2.6rem); background: #fff; }
.compatibility h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.compatibility h2 { margin: 2rem 0 0.6rem; font-size: 1.25rem; }
.compatibility p, .compatibility dd { line-height: 1.65; }
.compatibility a, .diagnostic-help { color: var(--accent); text-underline-offset: 0.16em; }
.compatibility dt { font-weight: 700; }
.compatibility dd { margin: 0.25rem 0 1rem; }
.compatibility code { font-family: var(--mono); overflow-wrap: anywhere; }
.diagnostic-help { display: inline-block; margin-top: 0.5rem; font-size: 12px; }

.panel { display: flex; flex-direction: column; min-height: 0; }
.panel-header { display: flex; min-height: 60px; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 15px; border-bottom: 1px solid var(--line-soft); }
.panel-title { display: flex; min-width: 0; align-items: baseline; flex-wrap: wrap; gap: 3px 10px; }
.panel-title h2 { margin: 0; font-size: 15px; letter-spacing: -0.025em; white-space: nowrap; }
.panel-subtitle { color: var(--muted); font-size: 11px; white-space: nowrap; }
#editor-file-name, #editor-entry { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#editor-entry { flex-basis: 100%; }
#editor-entry-name { font-family: var(--mono); }
.mono { font-family: var(--mono); }
.editor-panel > .panel-header { flex-wrap: wrap; }
.editor-panel .panel-title { flex: 1 1 6.5rem; }
.editor-actions { display: flex; max-width: 100%; flex-wrap: wrap; justify-content: flex-end; gap: 7px; margin-inline-start: auto; }
#editor-theme {
  min-height: 34px;
  max-width: 100%;
  padding-inline: 6px 1px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #26324b;
  font: inherit;
  font-size: 12px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.button:disabled { opacity: 0.54; }
.button:not(:disabled):hover { background: #eef2f8; }
.run-button { padding-inline: 14px; border-color: var(--accent); background: var(--accent); color: #fff; }
.run-button:not(:disabled):hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.play-icon { width: 0; height: 0; border-block: 5px solid transparent; border-left: 7px solid currentColor; }
.stop-icon { width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 1px; }
.clear-button { color: var(--muted); }
.result-actions, .animation-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.result-actions { justify-content: flex-end; }
#animation-mode { max-width: 100%; min-height: 34px; padding-inline: 4px; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--muted); font: inherit; font-size: 12px; }
.animation-tools { flex: none; min-width: 0; padding: 6px 12px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.animation-tools .button { min-height: 28px; }
#animation-status { margin-right: auto; font-variant-numeric: tabular-nums; }
#animation-export-status { flex-basis: 100%; font-variant-numeric: tabular-nums; }
.animation-export-canvas { position: fixed; left: -20000px; top: 0; visibility: hidden; pointer-events: none; }
#run-summary { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }

.editor-tab-strip {
  display: flex;
  flex: none;
  min-width: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #f2f5fa;
}
.editor-tabs {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 8px;
  scrollbar-width: thin;
}
.editor-tab-scroll {
  display: flex;
  flex: none;
  align-items: center;
  padding-inline: 2px;
  border-left: 1px solid var(--line-soft);
}
.editor-tab-scroll button {
  width: 28px;
  height: 33px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #455570;
  font-size: 20px;
}
.editor-tab-scroll button[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.editor-tab-scroll button[aria-disabled="false"]:hover { background: #e7edf9; }
.editor-tab-scroll button:focus-visible { outline-offset: -2px; }
.editor-tab {
  display: flex;
  flex: 0 0 auto;
  align-items: stretch;
  max-width: min(215px, 100%);
  border: 1px solid transparent;
  border-radius: 6px;
  color: #455570;
}
.editor-tab[data-selected="true"] {
  border-color: #cad8f8;
  background: #fff;
  color: #203f9a;
}
.editor-tab-select, .editor-tab-close {
  min-width: 0;
  min-height: 33px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
}
.editor-tab-select {
  overflow: hidden;
  padding: 0 8px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-tab-close { flex: none; width: 33px; font-size: 17px; }
.editor-tab-select:hover, .editor-tab-close:hover { background: #e7edf9; }
.editor-tab-select:focus-visible, .editor-tab-close:focus-visible { outline-offset: -2px; }
.editor-surface {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #fcfdff;
  --editor-code-size: 14px;
}
#editor-host { position: absolute; inset: 0; }
#editor-host .cm-content:focus-visible { outline: 0; }
.editor-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #fcfdff;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.editor-drop-target {
  position: absolute;
  inset: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-surface);
  color: #203f9a;
  font-weight: 700;
  pointer-events: none;
}
.editor-drop-status { overflow-wrap: anywhere; }
.editor-drop-status:empty { position: absolute; }
.editor-drop-status[data-error="true"] { color: #963246; }
.editor-footer-state { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 5px 10px; }
#project-save-status[data-state="error"] { color: #963246; }
#project-save-status[data-state="saved"] { color: #167346; }
.editor-footer-state .button { min-height: 28px; padding-inline: 6px; font-size: 11px; }
.panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 39px;
  padding: 7px 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
}
kbd { padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; background: #f6f8fc; font: 10px var(--mono); }

.results { flex: 1; min-height: 0; padding: 12px; overflow: auto; border-radius: 0 0 13px 13px; background: #f8fafe; }
.result {
  min-width: 0;
  margin: 0 0 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.result:last-child { margin-bottom: 0; }
.result-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.result-title h3 { margin: 0; color: #22334f; font: 700 12px/1.3 var(--mono); overflow-wrap: anywhere; }
.result-meta { color: var(--muted); font: 11px/1.4 var(--mono); white-space: nowrap; }
.scalar { margin: 0; color: #263a64; font: 600 15px/1.4 var(--mono); overflow-wrap: anywhere; }
.result-text { margin: 0; color: #263a64; font: 13px/1.5 var(--mono); overflow-wrap: anywhere; white-space: pre-wrap; }
.matrix-scroll { overflow: auto; max-height: 245px; }
.matrix-scroll:focus-visible { outline-offset: -2px; }
.matrix { min-width: 135px; border-collapse: collapse; color: #263a64; font: 13px/1.3 var(--mono); }
.matrix td, .matrix th { padding: 4px 10px; white-space: nowrap; text-align: right; }
.matrix th { color: var(--muted); font-size: 10px; font-weight: 400; }
.matrix thead { background: #edf2fa; border-bottom: 1px solid #dae3f0; }
.matrix tbody tr:nth-child(odd) { background: #f8faff; }
.matrix .row-number { border-right: 1px solid #dae3f0; }
.empty-matrix, .matrix-limit { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.matrix-limit { margin-top: 7px; }
.plot { display: block; width: 100%; height: clamp(200px, 52vw, 300px); }
.scientific-plot { height: clamp(235px, 62vw, 360px); }
.plot-rotatable { cursor: grab; touch-action: none; }
.plot-rotatable:active { cursor: grabbing; }
.figure-key, .figure-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 7px 0 0;
  padding: 7px 0 0;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font: 11px/1.4 var(--mono);
}
.figure-key { overflow-x: auto; list-style: none; }
.figure-key li { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; padding: 3px 5px; }
.figure-swatch { width: 12px; height: 7px; border-radius: 2px; }
.result:is([data-event="plot"], [data-event="figure"]) { container-type: inline-size; }
.figure-stage { position: relative; min-width: 0; }
.figure-legend {
  position: absolute;
  inset-block-start: 24px;
  inset-inline-end: 25px;
  z-index: 1;
  display: grid;
  gap: 2px;
  max-inline-size: min(55%, 290px);
  max-block-size: min(50%, 140px);
  overflow: auto;
  margin: 0;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fffffff0;
  color: #2d405d;
  font-size: 11px;
  list-style: none;
}
.figure-legend li { display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.figure-legend-swatch { width: 34px; height: 15px; flex: 0 0 auto; }
.figure-stage:is([data-legend-location="northwest"], [data-legend-location="west"], [data-legend-location="southwest"]) .figure-legend {
  inset-inline: 50px auto;
}
.figure-stage:is([data-legend-location="north"], [data-legend-location="south"]) .figure-legend {
  inset-inline: 50% auto;
  transform: translateX(-50%);
}
.figure-stage:is([data-legend-location="west"], [data-legend-location="east"]) .figure-legend {
  inset-block-start: 45%;
  transform: translateY(-50%);
}
.figure-stage:is([data-legend-location="southwest"], [data-legend-location="southeast"], [data-legend-location="south"]) .figure-legend {
  inset-block: auto 40px;
}
.figure-stage[data-legend-location$="outside"] {
  display: grid;
  justify-items: end;
  gap: 4px;
}
.figure-stage[data-legend-location$="outside"] .figure-legend {
  position: static;
  max-inline-size: 100%;
  max-block-size: 130px;
}
.figure-stage[data-legend-location^="north"][data-legend-location$="outside"] .figure-legend { grid-row: 1; }
.figure-stage:is([data-legend-location="northwestoutside"], [data-legend-location="southwestoutside"], [data-legend-location="westoutside"]) {
  justify-items: start;
}
.figure-stage:is([data-legend-location="northoutside"], [data-legend-location="southoutside"]) { justify-items: center; }
@container (min-width: 360px) {
  .figure-stage:is([data-legend-location="northwestoutside"], [data-legend-location="westoutside"], [data-legend-location="southwestoutside"]) {
    grid-template-columns: fit-content(125px) minmax(0, 1fr);
  }
  .figure-stage:is([data-legend-location="northeastoutside"], [data-legend-location="eastoutside"], [data-legend-location="southeastoutside"]) {
    grid-template-columns: minmax(0, 1fr) fit-content(125px);
  }
  .figure-stage:is([data-legend-location="northwestoutside"], [data-legend-location="westoutside"], [data-legend-location="southwestoutside"]) .plot {
    grid-row: 1;
    grid-column: 2;
  }
  .figure-stage:is([data-legend-location="northeastoutside"], [data-legend-location="eastoutside"], [data-legend-location="southeastoutside"]) .plot {
    grid-row: 1;
    grid-column: 1;
  }
  .figure-stage:is([data-legend-location="northwestoutside"], [data-legend-location="westoutside"], [data-legend-location="southwestoutside"]) .figure-legend {
    grid-row: 1;
    grid-column: 1;
    max-inline-size: 125px;
  }
  .figure-stage:is([data-legend-location="northeastoutside"], [data-legend-location="eastoutside"], [data-legend-location="southeastoutside"]) .figure-legend {
    grid-row: 1;
    grid-column: 2;
    max-inline-size: 125px;
  }
  .figure-stage:is([data-legend-location="northeastoutside"], [data-legend-location="northwestoutside"]) .figure-legend { align-self: start; }
  .figure-stage:is([data-legend-location="eastoutside"], [data-legend-location="westoutside"]) .figure-legend { align-self: center; }
  .figure-stage:is([data-legend-location="southeastoutside"], [data-legend-location="southwestoutside"]) .figure-legend { align-self: end; }
}
.figure-controls { flex-wrap: wrap; }
.figure-controls button {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #2d405d;
  background: #f6f8fc;
  font: inherit;
}
.figure-controls button:hover { background: #eaf0fb; }
.figure-view { margin: 0 0 0 auto; padding: 4px 0; }
.plot-zoomable { touch-action: pan-x pan-y; }
.plot-zoomable:focus-visible { outline-offset: -2px; }
.figure-controls-2d button { min-inline-size: 30px; min-block-size: 30px; }
.figure-controls-2d .figure-view { min-inline-size: 5ch; text-align: end; }
.figure-controls-3d {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: center;
}
.figure-view-buttons {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1;
  gap: 5px;
}
.figure-view-buttons button { min-inline-size: 30px; min-block-size: 30px; }
.figure-controls-3d .figure-view { grid-column: 1; margin: 0; }
.figure-controls-3d button[aria-pressed="true"] { border-color: #6b83b1; background: #e4ecfb; }
.figure-origin-status { grid-column: 1 / -1; margin: 2px 0 0; }
.figure-orientation {
  grid-column: 2;
  grid-row: 1 / span 2;
  inline-size: 104px;
  block-size: 78px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #fbfcff;
}
.figure-script-title {
  margin: 0 0 6px;
  color: #2d405d;
  font-size: 13px;
  text-align: center;
  overflow-wrap: anywhere;
}
.figure-axis-labels, .figure-warning {
  margin: 5px 0 0;
  padding: 0;
  color: #455a79;
  font-size: 11px;
  line-height: 1.4;
  list-style: none;
  overflow-wrap: anywhere;
}
.figure-warning { color: #832336; }
.diagnostic { border-color: #f0c9d0; background: #fff7f8; color: #832336; }
.diagnostic h3 { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.diagnostic p { margin: 6px 0 0; color: #6d3441; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.error-line {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.placeholder { display: grid; justify-items: center; align-content: center; height: 100%; min-height: 160px; color: var(--muted); text-align: center; }
.placeholder p { margin: 9px 5px 0; font-size: 13px; line-height: 1.5; }
.placeholder-icon { width: 43px; height: 43px; border-radius: 9px; background: #eaf0fb; color: #4e6b9c; font: 700 17px/43px var(--mono); }

@media (min-width: 741px) {
  .results { container-type: size; }
  .matrix-scroll { max-height: max(245px, 60cqb); }
  .plot { height: max(200px, min(53cqi, 46cqb)); }
  .scientific-plot { height: max(235px, min(62cqi, 53cqb)); }
  /* Reserve space below a standalone plot for labels and view controls. */
  .result:only-child .plot, .animation-figure .plot { height: max(220px, min(100cqi, 100cqb - 156px)); }
}

@media (min-width: 1141px) {
  .workbench-page { display: flex; flex-direction: column; height: 100dvh; }
  .workbench-page > main { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  .workbench { flex: 1; grid-template-rows: minmax(0, 1fr); min-height: 350px; }
  .sidebar { align-self: stretch; min-height: 0; }
  .workspace-modes, .sidebar-footer { flex: none; }
  .sidebar-pane { flex: 1; min-height: 0; overflow-y: auto; }
  #examples-pane:not([hidden]) { display: flex; flex-direction: column; }
  #examples-pane > .sidebar-section:first-child {
    display: flex;
    flex: 1 0 250px;
    flex-direction: column;
    min-height: 0;
  }
  #examples-pane > .files { flex: none; }
  .example-list { flex: 1; min-height: 0; max-height: none; }
}

@media (max-width: 1140px) {
  .shell { width: calc(100% - 40px); }
  .workbench { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sidebar { grid-column: 1 / -1; }
  .workspace-modes { align-self: start; min-width: 180px; }
  .sidebar-pane { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .sidebar-section + .sidebar-section { border-top: 0; border-left: 1px solid var(--line-soft); }
  .examples { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .example-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr); }
  .example-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .example-list { max-height: 192px; }
  .project-feedback { grid-column: 1 / -1; }
  .sidebar-footer { padding: 7px 16px; }
  .file-list { max-height: 105px; }
  .panel { height: max(400px, 72dvh); }
}

@media (max-width: 740px) {
  .shell { width: calc(100% - 28px); }
  .topbar-inner { min-height: 56px; }
  .brand { font-size: 13px; gap: 8px; }
  .brand-mark { width: 29px; height: 29px; }
  .engine { font-size: 10px; gap: 5px; }
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-block: 12px 24px; }
  .workspace-modes { align-self: stretch; margin-inline: 11px; }
  .sidebar-pane { display: block; }
  .sidebar-section { padding: 11px; }
  .sidebar-section + .sidebar-section { border-left: 0; border-top: 1px solid var(--line-soft); }
  .examples { gap: 4px; }
  .example { min-height: 38px; gap: 4px; padding: 3px; }
  .example-icon { flex-basis: 20px; height: 23px; font-size: 10px; }
  .example strong { font-size: 11px; margin: 0; }
  .example small { display: none; }
  .example-list { max-height: 158px; }
  .sidebar-footer { padding-inline: 12px; }
  .files-empty { margin-block: 3px 7px; }
  .project-list { max-height: 120px; }
  .editor-panel { height: clamp(360px, 55dvh, 640px); }
  .editor-surface { --editor-code-size: 16px; }
  .results-panel { height: auto; min-height: 290px; }
  .results { min-height: 231px; }
}
