:root {
  color-scheme: light dark;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', emoji, sans-serif;
  --font-mono: 'Fira Code', 'Menlo', 'SFMono-Regular', 'JetBrains Mono', Consolas, 'Liberation Mono', emoji, monospace;
  --font-symbols: 'Lucide', var(--font-sans);
  --sidepane-collapse-duration: 0.24s;
}

@font-face {
  font-family: 'Fira Code';
  src: url('assets/fonts/FiraCode-Regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Lucide';
  src: url('assets/fonts/lucide.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  /* Lucide maps a-z/0-9/- to blank ligature components; keep it off real text. */
  unicode-range: U+E000-F8FF;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  background: var(--body-gradient), var(--bg);
  color: var(--fg);
  color-scheme: dark;
  overflow: hidden;

  --bg: #121417;
  --fg: #f0f3f9;
  --muted: #9aa4b1;
  --muted-ghost: rgba(154, 164, 177, 0.22);
  --accent: #4bc0c8;
  --accent-strong: #2d99a7;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-subtle: color-mix(in srgb, var(--border-strong) 55%, transparent);
  --surface-raised: rgba(255, 255, 255, 0.04);
  --surface-glass: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.12);
  --text-code-bg: rgba(255, 255, 255, 0.08);
  --sidepane-shell-bg: rgba(12, 15, 20, 0.85);
  --gutter-bg: rgba(255, 255, 255, 0.04);
  --selection-bg: rgba(75, 192, 200, 0.25);
  --plot-area-bg: rgba(5, 7, 12, 0.82);
  --plot-actions-bg: rgba(5, 7, 12, 0.82);
  --log-panel-bg: rgba(10, 12, 16, 0.9);
  --log-entry-bg: rgba(255, 255, 255, 0.04);
  --log-entry-border: rgba(255, 255, 255, 0.08);
  --button-shadow: rgba(75, 192, 200, 0.18);
  --chip-border: rgba(255, 255, 255, 0.08);
  --body-gradient: radial-gradient(circle at top, rgba(43, 56, 80, 0.6), transparent 60%);
  --app-header-bg: linear-gradient(180deg, rgba(34, 41, 52, 0.92), rgba(22, 26, 33, 0.92));
  --sidepane-bg: linear-gradient(180deg, rgba(18, 20, 23, 0.95), rgba(18, 20, 23, 0.8));
  --pane-plot-bg: linear-gradient(180deg, rgba(14, 16, 20, 0.95), rgba(14, 16, 20, 0.8));
  --danger: #ff6b6b;
  --warning: #e8b04f;
  --danger-soft: rgba(255, 107, 107, 0.45);

  --button-bg: var(--surface-glass);
  --button-border: var(--border);
  --button-hover-bg: var(--surface-hover);
  --button-disabled-opacity: 0.6;
  --toolbar-btn-bg: rgba(0, 0, 0, 0.08);
  --toolbar-btn-color: var(--muted);
  --toolbar-btn-border: var(--border);
  --toolbar-btn-active-bg: rgba(38, 139, 210, 0.22);
  --mode-switch-bg: transparent;
  --mode-switch-border: var(--border);
  --mode-option-color: var(--muted);
  --mode-option-active-color: var(--fg);
  --mode-option-hover-bg: rgba(255, 255, 255, 0.06);
  --accent-button-disabled-opacity: 0.82;
  --sidepane-setting-group-bg: rgba(255, 255, 255, 0.03);
}

body[data-theme="light"] {
  --bg: white;
  --fg: #073642;
  --muted: #90a3aa;
  --muted-ghost: rgba(144, 163, 170, 0.26);
  --accent: #268bd2;
  --accent-strong: #1d6fa5;
  --border: rgba(7, 54, 66, 0.12);
  --border-strong: rgba(7, 54, 66, 0.18);
  --border-subtle: color-mix(in srgb, var(--border-strong) 55%, transparent);
  --surface-raised: rgba(255, 255, 255, 0.95);
  --surface-glass: rgba(255, 255, 255, 0.9);
  --surface-hover: rgba(38, 139, 210, 0.18);
  --text-code-bg: rgba(7, 54, 66, 0.1);
  --sidepane-shell-bg: white;
  --gutter-bg: rgba(7, 54, 66, 0.12);
  --selection-bg: rgba(38, 139, 210, 0.28);
  --plot-area-bg: rgba(255, 255, 255, 0.98);
  --plot-actions-bg: rgba(255, 255, 255, 0.78);
  --log-panel-bg: rgba(255, 255, 255, 0.98);
  --log-entry-bg: rgba(7, 54, 66, 0.08);
  --log-entry-border: rgba(7, 54, 66, 0.18);
  --button-shadow: rgba(38, 139, 210, 0.22);
  --chip-border: rgba(7, 54, 66, 0.16);
  --body-gradient: radial-gradient(circle at top, rgba(255, 255, 255, 0.78), transparent 55%);
  --app-header-bg: white;
  --sidepane-bg: white;
  --pane-plot-bg: white;
  --danger: #d14343;
  --warning: #ad6d00;
  --danger-soft: rgba(209, 67, 67, 0.4);

  --button-bg: var(--surface-glass);
  --button-border: var(--border);
  --button-hover-bg: var(--surface-hover);
  --toolbar-btn-bg: rgba(255, 255, 255, 0.7);
  --toolbar-btn-color: rgba(7, 54, 66, 0.58);
  --toolbar-btn-border: rgba(7, 54, 66, 0.18);
  --toolbar-btn-active-bg: rgba(38, 139, 210, 0.22);
  --mode-switch-bg: rgba(255, 255, 255, 0.92);
  --mode-switch-border: rgba(7, 54, 66, 0.18);
  --mode-option-color: rgba(7, 54, 66, 0.58);
  --mode-option-active-color: var(--fg);
  --mode-option-hover-bg: rgba(7, 54, 66, 0.12);
  --accent-button-disabled-opacity: 0.88;
  --sidepane-setting-group-bg: rgba(7, 54, 66, 0.08);

  color-scheme: light;
}

body[data-theme="light"] .cm-activeLine,
body[data-theme="light"] .cm-activeLineGutter {
  background-color: rgba(61, 57, 45, 0.03);
}

* {
  box-sizing: border-box;
}

#app-header {
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
  gap: 1.25rem;
  height: 3.1rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--app-header-bg);
  backdrop-filter: blur(8px);
}

/* Both rails keep their natural width; the centre block is the one that truncates. */
#title-group {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: max-content;
}

#header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  min-width: max-content;
}

#data-source-group {
  display: inline-flex;
  align-items: stretch;
  height: 2rem;
  border: 1px solid var(--mode-switch-border);
  border-radius: 0.5rem;
  background: var(--mode-switch-bg);
  overflow: hidden;
}

.data-source-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  color: var(--mode-option-color);
  transition: color 0.14s ease, background 0.14s ease;
}

.data-source-btn + .data-source-btn {
  border-left: 1px solid color-mix(in srgb, var(--mode-switch-border) 65%, transparent);
}

#data-source-group .data-source-btn:hover:not(:disabled) {
  background: var(--mode-option-hover-bg);
  color: var(--mode-option-active-color);
}

#data-source-group .data-source-btn[data-active="true"] {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

#header-icons {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-subtle);
}

#header-actions .icon-button {
  width: 2rem;
  height: 2rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
}

#header-actions .icon-button:hover:not(:disabled) {
  background: var(--mode-option-hover-bg);
  color: var(--fg);
}

#share-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#share-repair-btn {
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--danger-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 2rem;
  padding: 0 0.35rem;
  white-space: nowrap;
}

#share-repair-btn:hover {
  background: var(--mode-option-hover-bg);
  color: var(--fg);
}

/* Outranks the #header-actions .icon-button:hover colour so it stays red while hovered. */
#header-actions #share-btn[data-share-dirty="true"] {
  color: var(--danger);
}

#share-btn[data-share-saving="true"] {
  cursor: wait;
  font-size: 0;
}

#share-btn[data-share-saving="true"]::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border: 0.14rem solid color-mix(in srgb, var(--muted) 45%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: share-button-spin 0.8s linear infinite;
}

@keyframes share-button-spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-button {
  width: 2.2rem;
  height: 2.2rem;
  min-width: unset;
  padding: 0;
  border-radius: 0.4rem;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.emoji-icon {
  display: inline-block;
  line-height: 1;
}

#toggle-log {
  transition: transform 0.2s ease;
}

#toggle-log[data-expanded="true"] {
  transform: rotate(90deg);
}

#share-toast {
  position: absolute;
  right: calc(100% + 0.5rem);
  top: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.35rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(-50%) translateX(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 50;
}

#share-toast[data-active="true"] {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

#app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#app-version {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.title-accent {
  color: var(--accent);
}

.short-name {
  color: var(--muted);
  font-weight: 400;
}

#app-status {
  color: var(--fg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

#plot-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.05rem 0.4rem;
  border-radius: 0.35rem;
  cursor: default;
}

#plot-title:empty {
  display: none;
}

#plot-title:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
}

#plot-title[data-editing="true"] {
  width: min(100%, 32rem);
  padding: 0;
  background: none;
}

#plot-title-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  background: var(--surface-glass);
  color: var(--fg);
  font: inherit;
  line-height: inherit;
  padding: 0.1rem 0.35rem;
  outline: none;
}

#app-status-line {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.74rem;
}

#app-status-detail::before {
  content: '·';
  margin-right: 0.45rem;
  opacity: 0.6;
}

#app-status-line > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#app-status.error {
  color: var(--danger);
}

#app-status[data-state="warn"] {
  color: var(--accent);
}

#app-status #app-status-detail {
  color: var(--muted);
}

#app-status #app-status-detail:empty {
  display: none;
}

#app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

#split-shell {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
  position: relative;
  height: 100%;
  overflow: hidden;
  --plot-flex: 1.4;
  --sidepane-flex: 0.6;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

#plot-pane {
  flex: var(--plot-flex);
  background: var(--pane-plot-bg);
  border-right: 1px solid var(--border);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#plot-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  --plot-area-flex: 0.74;
  --brettli-flex: 0.26;
}

#plot-stack[data-brettli-collapsed="1"] {
  --plot-area-flex: 1;
  --brettli-flex: 0;
}

#plot-stack[data-brettli-collapsed="1"] #plot-table-resizer {
  pointer-events: none;
  opacity: 0.35;
}

#plot-stack[data-brettli-transitioning="1"] #plot-table-resizer {
  pointer-events: none;
  opacity: 0.35;
}

#sidepane {
  --sidepane-collapsed-width: 2rem;
  --sidepane-open-min-width: 355px;
  flex: var(--sidepane-flex);
  background: var(--sidepane-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: var(--sidepane-open-min-width);
}

#pane-resizer {
  flex: 0 0 6px;
  cursor: col-resize;
  background: var(--border);
  position: relative;
  transition: background 0.12s ease;
}

#pane-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 32px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

#pane-resizer:hover,
#pane-resizer:focus-visible,
#pane-resizer.dragging {
  background: var(--accent);
}

button {
  appearance: none;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--fg);
  font: inherit;
  padding: 0.45rem 0.9rem;
  border-radius: 0.45rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border 0.12s ease;
}

button:hover:not(:disabled):not(.sidepane-mode-option) {
  background: var(--button-hover-bg);
}

button:disabled {
  opacity: var(--button-disabled-opacity);
  cursor: not-allowed;
}

.data-source-btn[data-active="true"] {
  color: var(--accent);
}

#remote-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

#remote-status-dots {
  --remote-dot-size: 0.32rem;
  --remote-dot-gap: 0.16rem;
  display: grid;
  gap: var(--remote-dot-gap);
  align-items: center;
  justify-items: center;
}

#remote-status-dots[data-active="0"] {
  display: none;
}

.remote-status-dot {
  width: var(--remote-dot-size);
  height: var(--remote-dot-size);
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 1px var(--border-strong);
}

.remote-status-dot[data-state="up"] {
  background: var(--accent);
}


.sidepane-topbar-btn {
  display: inline-flex;
  height: 1.7rem;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.7rem 0.3rem 0.7rem;
  margin: 0.35rem;
  font-size: 0.78rem;
  border-radius: 0.45rem;
  border: 1px solid var(--toolbar-btn-border);
  background: var(--toolbar-btn-bg);
  color: var(--toolbar-btn-color);
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease,
    background 0.12s ease,
    color 0.12s ease,
    border-radius var(--sidepane-collapse-duration) ease;
}

.sidepane-topbar-btn:hover {
  color: var(--fg);
}

.sidepane-topbar-btn[data-pressed="true"] {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--toolbar-btn-active-bg);
}

#run-btn {
  border-color: var(--accent-strong);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #ffffff;
}
#run-btn .emoji-icon {
  margin-left: 0.25em;
}

#run-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

#run-btn:disabled {
  opacity: var(--accent-button-disabled-opacity);
  filter: none;
}

#sidepane-mode-switch {
  --mode-index: 0;
  --mode-count: 3;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--mode-count), minmax(0, 1fr));
  align-items: stretch;
  flex: 0 0 auto;
  min-width: 0;
  border-radius: 0.65rem 0.65rem 0 0;
  border: 1px solid var(--mode-switch-border);
  margin-top: 0.7rem;
  background: var(--mode-switch-bg);
  overflow: visible;
}

#plot-type-mode {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  z-index: 1;
}

.sidepane-mode-option {
  position: relative;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  line-height: 1;
  padding: 0.32rem 0;
  color: var(--mode-option-color);
  cursor: pointer;
  z-index: 1;
  transition: color 0.14s ease, background 0.14s ease;
  user-select: none;
}

.sidepane-mode-option:not([data-pressed="true"]):hover {
  background: var(--mode-option-hover-bg);
  color: var(--mode-option-active-color);
  border-radius: 0;
}

.sidepane-mode-option[data-pressed="true"] {
  color: var(--mode-option-active-color);
}

.sidepane-mode-option:focus-visible {
  outline: none;
  color: var(--mode-option-active-color);
}

#sidepane-mode-highlight {
  position: absolute;
  top: 0;
  left: calc(var(--mode-index) * (100% / var(--mode-count)));
  width: calc(100% / var(--mode-count));
  height: 100%;
  border-radius: 0;
  background: var(--mode-option-hover-bg);
  transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.22s ease;
  z-index: 0;
  pointer-events: none;
}

#plot-type-mode .sidepane-mode-option {
  min-width: 0;
}

#plot-type-menu-btn {
  position: relative;
  z-index: 1;
  border: 0;
  border-left: 1px solid color-mix(in srgb, var(--mode-switch-border) 65%, transparent);
  border-radius: 0;
  background: transparent;
  color: var(--mode-option-color);
  padding: 0 0.45rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.7rem;
  line-height: 1;
}

#plot-type-menu-btn:hover,
#plot-type-menu-btn[data-open="true"] {
  background: var(--mode-option-hover-bg);
  color: var(--mode-option-active-color);
}

#plot-type-menu-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#plot-type-menu {
  position: absolute;
  top: calc(100% + 0.2rem);
  left: 0.2rem;
  right: 0.2rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  box-shadow: 0 0.4rem 1.2rem color-mix(in srgb, black 20%, transparent);
}

#plot-type-menu[hidden] {
  display: none;
}

.plot-type-menu-option {
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.plot-type-menu-option:hover,
.plot-type-menu-option[data-active="true"] {
  background: var(--mode-option-hover-bg);
  color: var(--mode-option-active-color);
}

#sidepane-toggle-label {
  display: inline-block;
  transform-origin: center;
  letter-spacing: 0;
  transition: transform var(--sidepane-collapse-duration) ease,
    letter-spacing var(--sidepane-collapse-duration) ease,
    opacity 0.12s ease;
}

.editor-shortcut code {
  background: var(--text-code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

#sidepane-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  padding: 0;
}

#sidepane-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  transition: transform var(--sidepane-collapse-duration) ease,
    opacity var(--sidepane-collapse-duration) ease;
}

body[data-sidepane-slide="closing"] #sidepane-body,
body[data-sidepane-slide="opening"] #sidepane-body {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

body[data-sidepane-animating="1"] #sidepane-topbar .sidepane-topbar-btn:not(#sidepane-toggle) {
  transition: transform var(--sidepane-collapse-duration) ease,
    opacity var(--sidepane-collapse-duration) ease,
    background 0.12s ease,
    color 0.12s ease,
    border-radius var(--sidepane-collapse-duration) ease;
}

body[data-sidepane-slide="closing"] #sidepane-topbar .sidepane-topbar-btn:not(#sidepane-toggle),
body[data-sidepane-slide="opening"] #sidepane-topbar .sidepane-topbar-btn:not(#sidepane-toggle) {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

#sidepane-tabs {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
  padding: 0 0.35rem;
  background: transparent;
}

#sidepane-global-augment {
  display: flex;
  flex-direction: column;
  padding: 0 0.35rem 0.4rem;
}

#sidepane-global-augment .setup-editor {
  height: 8.5rem;
  flex: 0 0 auto;
}

#tab-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tab-item {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.4rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.45rem;
  background: var(--sidepane-shell-bg);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
  touch-action: none;
}

.tab-item.is-dragging {
  border-color: var(--accent);
  box-shadow: 0 0.4rem 0.9rem rgba(0, 0, 0, 0.28);
  cursor: grabbing;
}

.tab-placeholder {
  border-style: dashed;
  border-color: var(--accent);
  background: transparent;
  pointer-events: none;
}

#tab-list.is-dragging {
  cursor: grabbing;
}

.tab-item:hover {
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border-strong));
}

.tab-item[data-active="true"] {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong));
  background: var(--sidepane-shell-bg);
  z-index: 2;
}

.tab-item[data-dirty="true"] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border-strong));
}

.tab-item[data-preview-outdated="true"] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border-strong));
}

.tab-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.78rem;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tab-rename-input {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.15;
  padding: 0.2rem 0.35rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
}

.tab-rename-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.2rem;
  cursor: pointer;
}

.tab-rename-btn:hover {
  color: var(--fg);
}

.tab-dirty {
  color: var(--accent);
  font-size: 1rem;
  line-height: 0;
}

.tab-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
}

.tab-action {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.2rem;
  cursor: pointer;
  line-height: 1;
}

.tab-action:hover:not([data-disabled="true"]) {
  color: var(--fg);
}

.tab-action[data-disabled="true"] {
  opacity: var(--button-disabled-opacity);
  cursor: not-allowed;
}

.tab-action-delete {
  color: var(--muted);
}

.tab-action-delete:hover:not([data-disabled="true"]) {
  color: var(--danger);
}

.tab-item[data-editing="true"] .tab-actions {
  display: none;
}

.tab-item[data-editing="true"] .tab-title,
.tab-item[data-editing="true"] .tab-rename-btn,
.tab-item[data-editing="true"] .tab-dirty {
  display: none;
}

.tab-item[data-editing="true"] .tab-rename-input {
  display: block;
}

#sidepane-edit {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  margin: 0 0 0.4rem;
  padding: 0rem 0.5rem 0.5rem;
  background: var(--sidepane-shell-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--border-strong));
  border-top: none;
  border-radius: 0 0 0.55rem 0.55rem;
}

#sidepane-edit[hidden] {
  display: none;
}

#sidepane-edit #sidepane-mode-switch {
  margin-top: 1px;
  margin-bottom: -1px;
}

body[data-tab-edit="0"] #sidepane-edit {
  display: none;
}

body[data-tab-edit="0"] #sidepane-global-augment {
  display: none;
}

body[data-tab-edit="1"] .tab-item[data-open="true"] {
  margin-top: 0.4rem;
  border-bottom: none;
  border-radius: 0.55rem 0.55rem 0 0;
  margin-bottom: 0px;
  padding: 0 0.45rem;
}

body[data-tab-edit="0"] .tab-action-duplicate,
body[data-tab-edit="0"] .tab-action-delete {
  display: none;
}

body[data-sidepane-collapsed="1"]:not([data-sidepane-animating="1"]) #sidepane-topbar .sidepane-topbar-btn {
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

body[data-sidepane-collapsed="1"]:not([data-sidepane-animating="1"]) #sidepane-body,
body[data-sidepane-collapsed="1"]:not([data-sidepane-animating="1"]) #sidepane-topbar .sidepane-topbar-btn:not(#sidepane-toggle) {
  display: none;
}

body[data-sidepane-collapsed="1"] #sidepane-toggle,
body[data-sidepane-slide="opening"] #sidepane-toggle {
  align-self: stretch;
  justify-content: center;
  padding: 0;
  min-height: 8.4rem;
  width: 100%;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

body[data-sidepane-collapsed="1"] #sidepane-toggle #sidepane-toggle-label,
body[data-sidepane-slide="opening"] #sidepane-toggle #sidepane-toggle-label {
  letter-spacing: 0.08rem;
}

body[data-sidepane-collapsed="1"] #pane-resizer {
  display: none;
}

body[data-sidepane-collapsed="1"] #sidepane {
  background: transparent;
  flex: 0 0 var(--sidepane-collapsed-width);
  min-width: 0;
}

body[data-sidepane-collapsed="1"] #plot-pane {
  flex: 1 1 auto;
}

body[data-sidepane-animating="1"] #sidepane {
  flex: 0 0 var(--sidepane-transition-width);
  min-width: 0;
  background: var(--sidepane-bg);
}

body[data-sidepane-animating="1"] #plot-pane {
  flex: 1 1 auto;
}

body[data-sidepane-animating="1"] #pane-resizer {
  display: block;
  pointer-events: none;
}

body[data-sidepane-animating="1"] #sidepane-body,
body[data-sidepane-animating="1"] #sidepane-topbar .sidepane-topbar-btn:not(#sidepane-toggle) {
  display: flex;
}

body[data-sidepane-animating="1"] #sidepane-topbar .sidepane-topbar-btn:not(#sidepane-toggle) {
  pointer-events: none;
}

em {
  color: var(--accent);
  font-style: normal;
  font-weight: bold;
}

#editor {
  flex: 1;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  background: var(--sidepane-shell-bg);
  min-height: 0;
  height: 100%;
  min-width: 0;
}

.sidepane-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#sidepane-settings-tab {
  flex: 1;
  position: relative;
}

#sidepane-mode-switch[data-active="settings"] + #sidepane-container #sidepane-settings-tab {
  flex: 0 0 auto;
}

.sidepane-content[hidden] {
  display: none;
}

#sidepane-settings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: transparent;
  border: none;
  box-sizing: border-box;
}

#sidepane-mode-switch[data-active="settings"] + #sidepane-container {
  min-height: min-content;
}

#sidepane-mode-switch[data-active="settings"] + #sidepane-container #sidepane-settings {
  flex: 0 0 auto;
  overflow: visible;
}

#plotting-busy-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--sidepane-shell-bg) 75%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 5;
}

#plotting-busy-overlay[data-active="1"] {
  opacity: 1;
  pointer-events: auto;
  cursor: wait;
}

#plotting-busy-text {
  padding: 0.5rem 0.8rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

#sidepane-setup {
  flex: 1;
  display: flex;
  padding: 0;
  background: transparent;
  border: none;
  box-sizing: border-box;
  min-height: 0;
}

#setup-grid {
  --setup-run-min-open: 5rem;
  flex: 1;
  display: grid;
  grid-template-rows: minmax(var(--setup-run-min-open), 1fr) minmax(0, 0.2fr);
  gap: 0.5rem;
  min-height: 0;
  width: 100%;
}

#setup-grid[data-run-only="true"] {
  grid-template-rows: minmax(var(--setup-run-min-open), 1fr);
}

#setup-grid[data-has-selection="true"] {
  grid-template-rows: minmax(var(--setup-run-min-open), 1fr) minmax(0, 0.2fr);
}

#setup-grid[data-has-selection="true"][data-augment-open="true"] {
  grid-template-rows: minmax(var(--setup-run-min-open), 0.2fr) minmax(0, 1fr);
}

#setup-grid[data-run-collapsed="true"] {
  grid-template-rows: auto minmax(0, 1fr);
}

#setup-grid[data-varies-collapsed="true"] {
  grid-template-rows: minmax(var(--setup-run-min-open), 1fr) auto;
}

#setup-grid[data-run-collapsed="true"][data-varies-collapsed="true"] {
  grid-template-rows: auto auto;
}

#setup-grid[data-has-selection="true"][data-run-collapsed="true"] {
  grid-template-rows: auto minmax(0, 1fr);
}

#setup-grid[data-has-selection="true"][data-varies-collapsed="true"] {
  grid-template-rows: minmax(var(--setup-run-min-open), 1fr) auto;
}

#setup-grid[data-has-selection="true"][data-run-collapsed="true"][data-varies-collapsed="true"] {
  grid-template-rows: auto auto;
}

#setup-grid[data-run-only="true"][data-run-collapsed="true"] {
  grid-template-rows: auto;
}

.setup-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--sidepane-shell-bg);
  border: 1px solid var(--border-strong);
  padding: 0.1rem 0.4rem;
  box-sizing: border-box;
}

.setup-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.setup-block-title-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.setup-head-actions {
  display: flex;
  align-items: center;
}

.setup-block-title {
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--fg);
  letter-spacing: 0.02em;
}

.setup-fold-toggle {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--muted);
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease;
}

.setup-head-actions span {
  font: inherit;
  font-family: var(--font-symbols);
  font-size: 0.68rem;
  width: 1.2em;
  text-align: center;
}

.setup-head-save {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-family: var(--font-symbols);
  font-size: 0.72rem;
  line-height: 1;
  width: 1.2em;
  padding: 0;
  text-align: center;
  cursor: pointer;
}

.setup-head-save:hover {
  background: none !important;
  color: var(--accent);
}

.setup-head-save:focus-visible {
  outline: none;
  color: var(--accent-strong);
}

.setup-head-actions span.help {
  color: var(--muted);
  cursor: help;
}

.setup-head-actions span.ok {
  display: none;
  color: var(--accent);
}

.setup-head-actions span.eager {
  display: none;
  color: var(--accent);
  cursor: pointer;
}

.setup-head-actions span.working {
  display: none;
  color: var(--accent);
  cursor: wait;
}

.setup-head-actions span.err {
  display: none;
  color: var(--danger);
  cursor: pointer;
}

#setup-run-fold {
  padding-left: 0.4rem;
}

#setup-run-reload,
#setup-run-sort,
#setup-run-star-filter,
#setup-run-show-hidden,
#setup-run-copy-selection,
#setup-run-paste-selection,
#setup-run-apply-all-tabs {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0 0.15rem;
}

#setup-run-reload,
#setup-run-sort,
#setup-run-copy-selection,
#setup-run-paste-selection,
#setup-run-apply-all-tabs {
  color: var(--muted);
}

#setup-run-reload:hover,
#setup-run-sort:hover,
#setup-run-copy-selection:hover,
#setup-run-paste-selection:hover,
#setup-run-apply-all-tabs:hover {
  color: var(--fg);
}

#setup-run-star-filter,
#setup-run-show-hidden {
  color: inherit;
}

#setup-run-star-filter:hover,
#setup-run-star-filter[data-active="true"],
#setup-run-show-hidden:hover,
#setup-run-show-hidden[data-active="true"] {
  color: var(--accent);
}

#setup-varies-tidy {
  border: none;
  background: none;
  font: inherit;
  font-size: 0.68rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

#setup-varies-tidy[data-active="true"] {
  color: var(--accent);
}

.setup-fold-toggle:hover,
.setup-fold-toggle:focus-visible {
  background: none;
  color: var(--fg);
  outline: none;
}

.setup-block-body {
  flex: 1;
  min-height: 0;
}

#setup-run-block[data-collapsed="true"] .setup-block-head,
#setup-varies-block[data-collapsed="true"] .setup-block-head,
#setup-configs-block[data-collapsed="true"] .setup-block-head,
#setup-metrics-block[data-collapsed="true"] .setup-block-head {
  margin-bottom: 0;
}

#setup-run-block[data-collapsed="true"] #setup-run-list,
#setup-varies-block[data-collapsed="true"] #setup-varies,
#setup-configs-block[data-collapsed="true"] #setup-augment-configs,
#setup-metrics-block[data-collapsed="true"] #setup-augment-metrics {
  display: none;
}

.setup-editor {
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  overflow: hidden;
}

.setup-editor[data-saved-dirty="true"] {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.setup-editor .cm-activeLine,
.setup-editor .cm-activeLineGutter {
  background: transparent;
}

.cm-placeholder {
  color: var(--fg);
  opacity: 0.4;
}

.setup-editor[data-state="pending"] {
  border-color: var(--border-strong);
}

.setup-editor[data-state="ok"] {
  border-color: var(--accent);
}

.setup-editor[data-state="error"] {
  border-color: var(--danger);
}

#setup-run-block {
  padding: 0.35rem 0;
}

#setup-run-block[data-busy="true"] {
  opacity: 0.55;
  cursor: wait;
}

#setup-run-block[data-busy="true"] .setup-block-head,
#setup-run-block[data-busy="true"] #setup-run-list {
  pointer-events: none;
}

#setup-run-block .setup-block-title {
  margin-left: 0;
}

#setup-run-filter {
  flex: 1;
  min-width: 10ch;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.7rem;
  padding: 0.2rem 0.45rem;
  border-radius: 0.35rem;
  outline: none;
}

#setup-run-filter::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

#setup-run-filter:focus-visible {
  border-color: var(--accent);
}

#setup-run-block .setup-head-actions {
  margin-right: 0.4rem;
  gap: 0.15rem;
  margin-left: auto;
}

#setup-run-list {
  flex: 0 0 auto;
  width: 100%;
  color: var(--muted);
  font-family: var(--font-mono);
  overflow: visible;
}

.run-tree-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.15rem;
  padding-left: calc(var(--depth, 0) * 0.9rem + 0.15rem);
  font-size: 0.68rem;
}

.run-tree-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.run-tree-expand {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  width: 0.68rem;
  height: 0.68rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.run-tree-expand:disabled {
  opacity: 0.4;
  cursor: default;
}

.run-tree-spacer {
  width: 0.68rem;
  height: 0.68rem;
}

.run-tree-checkbox {
  width: 0.68rem;
  height: 0.68rem;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
}

.run-tree-label {
  cursor: pointer;
  user-select: none;
  font-size: 0.68rem;
  min-height: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.run-tree-count {
  color: var(--muted);
  opacity: 0.7;
}

.run-tree-hint {
  color: var(--muted);
  opacity: 0.6;
  margin-left: auto;
  padding-left: 0.5rem;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-tree-copy,
.run-tree-hide {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  padding: 0 0.1rem;
  cursor: pointer;
  text-decoration: none;
}

.run-tree-row:hover .run-tree-copy {
  display: inline-flex;
}

.run-tree-copy:hover {
  color: var(--accent);
}

.run-tree-row:hover .run-tree-hide,
.run-tree-hide[data-active="true"] {
  display: inline-flex;
}

.run-tree-hide:hover {
  color: var(--accent);
}

.run-tree-star {
  display: none;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-size: 0.68rem;
  font-family: var(--font-sans);
  padding: 0 0.1rem;
  cursor: pointer;
  text-decoration: none;
}

.run-tree-row:hover .run-tree-star,
.run-tree-star[data-active="true"] {
  display: inline-flex;
}

.run-tree-row:hover .run-tree-star-hint {
  display: none;
}

.run-tree-star:hover {
  color: var(--accent);
  background: none;
}

.run-tree-star-hint {
  display: inline-flex;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-size: 0.68rem;
  font-family: var(--font-sans);
  padding: 0 0.1rem;
  pointer-events: none;
  text-decoration: none;
}

.setup-varies {
  margin: 0;
  background: var(--sidepane-shell-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  white-space: pre-line;
  overflow: auto;
}

.setup-varies b {
  color: var(--accent);
}

.sidepane-setting {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  position: relative;
}

.sidepane-setting#smoothing-setting {
  align-items: flex-start;
}

.sidepane-setting-label {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex: 0 0 auto;
}

.sidepane-setting-input {
  flex: 1;
  position: relative;
  display: flex;
  min-width: 5ch;
}

.sidepane-setting-input > input,
.sidepane-setting-input > select {
  flex: 1;
  min-width: 5ch;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.4rem 0.55rem;
  border-radius: 0.4rem;
  outline: none;
}

#sidepane-setting-facet-layout {
  gap: 0.4rem;
}

#sidepane-setting-facet-layout .sidepane-setting-input {
  flex: 1 1 0;
  min-width: 0;
}

#settings-facet-columns,
#settings-facet-rows {
  width: 100%;
}

.sidepane-setting-help {
  color: var(--muted);
  cursor: help;
  font-family: var(--font-symbols);
  font-size: 0.72rem;
  line-height: 1;
  margin-left: 0.35rem;
  align-self: center;
}

#settings-cmap {
  flex: 1;
  position: relative;
}

#settings-cmap-button {
  flex: 1;
  width: 100%;
  min-width: 5ch;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  border-radius: 0.4rem;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

#settings-cmap-button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.cmap-preview {
  width: 2.5rem;
  height: 0.5rem;
  border-radius: 0.2rem;
  display: flex;
  gap: 1px;
  overflow: hidden;
}

.cmap-preview.is-gradient {
  display: block;
}

.cmap-preview.is-swatches > span {
  flex: 1;
  height: 100%;
}

#settings-cmap-label {
  flex: 1;
  text-align: left;
}

#settings-cmap-options {
  position: absolute;
  top: calc(100% + 0.2rem);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.35);
  padding: 0.25rem;
  max-height: 12rem;
  overflow-y: auto;
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

#settings-cmap-options[hidden] {
  display: none;
}

.cmap-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.76rem;
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
  cursor: pointer;
}

.cmap-option.is-active {
  border-color: var(--accent);
  background: var(--sidepane-setting-group-bg);
}

.settings-pill-toggle {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  padding: 0.2rem 0.35rem;
  margin-left: -0.3rem;
  cursor: pointer;
  height: 100%;
  line-height: 1;
  text-transform: lowercase;
  border-radius: 0.3rem;
  transition: color 0.12s ease;
}

#settings-cmap-linked {
  font-family: var(--font-symbols);
}

.settings-pill-toggle[data-pressed="true"] {
  color: var(--accent);
  background: var(--sidepane-setting-group-bg);
}

#settings-xtidy-toggle,
#settings-ytidy-toggle,
#setup-varies-tidy-icon {
  font-family: var(--font-symbols);
}

.settings-pill-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.sidepane-setting-input.axis-limit-row {
  align-items: center;
  gap: 0.5rem;
}

.sidepane-setting-input.axis-limit-row .settings-pill-toggle {
  margin-left: 0;
  min-width: 1.7rem;
  min-height: 1.7rem;
  text-align: center;
}

.axis-limit-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  background: var(--sidepane-shell-bg);
  transition: border-color 0.12s ease;
  min-width: 0;
}

.axis-limit-field:focus-within {
  border-color: var(--accent);
}

.axis-limit-toggle {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  font-family: var(--font-symbols);
  padding: 0;
  cursor: pointer;
  transition: color 0.12s ease;
}

.axis-limit-toggle:hover {
  background: none !important;
}

.axis-limit-toggle:focus-visible {
  outline: none;
  color: var(--accent);
}

.axis-limit-field.is-shared .axis-limit-toggle,
.axis-limit-toggle.is-active {
  color: var(--accent);
}

.axis-limit-input {
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  padding: 0;
  width: 100%;
  min-width: 0;
  outline: none;
}

.axis-limit-input::placeholder {
  color: var(--muted);
  opacity: 1;
}


.axis-limit-field.is-manual,
#settings-highlight.is-manual {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-strong));
}

#settings-smoothing {
  display: flex;
  flex-direction: column;
  width: 100%;
}

#smooth-setting-label {
  margin-top: 0.7em;
}

#smoothing-options-row {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
}

.smoothing-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  background: var(--sidepane-shell-bg);
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
  flex: 0 0 auto;
  cursor: pointer;
}

.smoothing-chip-label {
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  white-space: pre;  /* Keep the final space for spacing. */
}

.smoothing-chip.is-active {
  border-color: var(--border);
  background: var(--mode-option-hover-bg);
}

.smoothing-chip.is-active .smoothing-chip-label {
  color: var(--fg);
}

.smoothing-chip[data-mode="none"].is-active {
  border-color: var(--danger);
  background: rgba(255, 64, 64, 0.08);
}

.smoothing-chip[data-mode="none"].is-active .smoothing-chip-label {
  color: var(--danger);
}

.smoothing-chip-parameter {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.smoothing-chip.is-active .smoothing-chip-parameter {
  max-width: 12rem;
  opacity: 1;
}

.smoothing-chip-input {
  width: 6ch;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.74rem;
  text-align: center;
  padding: 0.2rem;
  border-radius: 0.4rem;
  outline: none;
  transition: border-color 0.14s ease, background 0.14s ease;
  cursor: text;
}

.smoothing-chip-input:focus {
  border-color: var(--accent);
}

.smoothing-chip-input:disabled {
  color: var(--muted);
  background: transparent;
  border-color: var(--chip-border);
}

.smoothing-chip.is-active.is-invalid {
  border-color: var(--danger);
}

.smoothing-chip.is-active.is-invalid .smoothing-chip-input {
  border-color: var(--danger);
}

#smoothing-advanced-toggle {
  margin: auto 0 auto auto;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.74rem;
  padding-right: 0.35rem;
  transition: color 0.14s ease, background 0.14s ease;
}

#smoothing-advanced-toggle:hover,
#smoothing-advanced-toggle:focus-visible {
  color: var(--fg);
}

#settings-smoothing[data-advanced="open"] #smoothing-advanced-toggle {
  color: var(--fg);
}

#smoothing-advanced-row {
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.18s ease, opacity 0.18s ease, margin 0.18s ease;
}

#settings-smoothing[data-advanced="open"] #smoothing-advanced-row {
  opacity: 1;
  max-height: 4rem;
  margin-top: 0.1rem;
}

#smoothing-advanced-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

#smoothing-advanced-label {
  color: var(--muted);
}

#settings-smoothing-alpha {
  width: 4.5ch;
  border: 1px solid var(--border-strong);
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.74rem;
  padding: 0.28rem 0.45rem 0.28rem 0.35rem;
  border-radius: 0.4rem;
  text-align: right;
  outline: none;
  transition: border-color 0.14s ease;
}

#smoothing-advanced-input-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
}

#smoothing-advanced-suffix {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

#settings-smoothing-alpha:focus {
  border-color: var(--accent);
}

#smoothing-advanced-row.is-disabled #smoothing-advanced-label,
#smoothing-advanced-row.is-disabled #settings-smoothing-alpha {
  color: var(--muted);
}

#smoothing-advanced-row.is-disabled #settings-smoothing-alpha {
  border-color: var(--chip-border);
  background: transparent;
}

#smoothing-advanced-row.is-disabled #smoothing-advanced-suffix {
  color: var(--muted);
  opacity: 0.6;
}

#smoothing-advanced-row.is-invalid #settings-smoothing-alpha {
  border-color: var(--danger);
}

.axis-limit-separator {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

#settings-highlight {
  appearance: none;
}

#settings-highlight-row {
  gap: 0.4rem;
}

#settings-highlight-row #settings-highlight {
  flex: 0 1 13ch;
}

#settings-highlight-metric {
  flex: 1 1 9ch;
}

#settings-highlight-at {
  flex: 2 1 16ch;
  min-width: 13ch;
}

.sidepane-setting-input > input:focus,
.sidepane-setting-input > select:focus {
  border-color: var(--accent);
}

.sidepane-setting-input.is-invalid > input {
  border-color: var(--danger);
}

.sidepane-setting-input[data-state="pending"] > input {
  border-color: var(--border-strong);
}

.sidepane-setting-input[data-state="ok"] > input {
  border-color: var(--accent);
}

.sidepane-setting-input[data-state="error"] > input {
  border-color: var(--danger);
}

.sidepane-setting-input.is-invalid .settings-chip-editor {
  border-color: var(--danger);
}

.settings-chip-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-height: 2.1rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  background: var(--sidepane-shell-bg);
  cursor: text;
  transition: border-color 0.12s ease;
}

.settings-chip-editor:focus-within {
  border-color: var(--accent);
}

.settings-chip-editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0.7;
}

.settings-chip-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 5ch;
  position: relative;
}

.settings-chip-editor.is-dragging,
.settings-chip-list.is-dragging {
  cursor: grabbing;
}

.settings-chip {
  display: inline-flex;
  align-items: center;
  /* the remove glyph carries its own side bearing, so it needs less gap than plain text would */
  gap: 0.15rem;
  padding: 0 0 0 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--surface-glass);
  color: var(--fg);
  font-size: 0.72rem;
  user-select: none;
  flex: 0 0 auto;
  cursor: pointer;
  touch-action: none;
}

.settings-chip-label {
  padding-block: 0.25rem;
}

.settings-chip.is-dragging {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0.4rem 0.9rem rgba(0, 0, 0, 0.28);
  cursor: grabbing;
}

.settings-chip.is-drag-source {
  opacity: 0.35;
}

.settings-chip-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.2rem;
  border-radius: 999px;
  background: var(--accent);
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 1;
}

.settings-chip-muted {
  color: var(--muted);
}

.settings-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6ch;
  background: none;
  color: var(--muted);
  font-size: 0.68rem;
  pointer-events: none;
}

.settings-chip-count.is-error {
  color: var(--danger);
}

.settings-chip-count.is-input {
  order: 2;
}

.settings-chip-count.is-stitch-status {
  color: var(--fg);
  cursor: help;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
}

.settings-chip-count.is-stitch-status.is-warning {
  color: var(--warning);
}

.settings-chip-count.is-stitch-status.is-error {
  color: var(--danger);
}

.settings-chip-count.is-input.is-error {
  border-color: var(--danger);
}

.settings-chip.is-custom {
  border-style: dashed;
}

.settings-chip.is-stitch-warning {
  border-color: var(--warning);
  color: var(--warning);
}

.settings-chip.is-armed {
  border-color: var(--danger);
  color: var(--danger);
}

.settings-chip-remove {
  background: none;
  background-color: transparent;
  border: none;
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  align-self: stretch;
  min-width: 1.2rem;
  margin: 0;
  padding: 0.35rem 0.4rem 0.25rem 0.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 999px 999px 0;
  text-decoration: none;
}

.settings-chip-remove:hover {
  background: none;
  background-color: transparent;
  color: var(--danger);
}

.settings-chip-remove:focus {
  background: none;
  background-color: transparent;
  outline: none;
  text-decoration: none;
}

.settings-chip-text {
  order: 1;
  min-width: 4ch;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.25rem;
  outline: none;
}

.settings-chip-text::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.sidepane-setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-radius: 0.45rem;
  padding: 0.25rem 0.25rem 0.25rem 0.5rem;
  background: var(--sidepane-setting-group-bg);
  position: relative;
}

/* Butts against the tab strip, so square the top off and let the two flow together. */
#sidepane-settings > .sidepane-setting-group:first-child {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

#sidepane-setting-inline {
  flex: 1;
}

.settings-dropdown-open #sidepane-settings {
  overflow: visible;
}

.settings-suggestions {
  position: absolute;
  top: calc(100% + 0.2rem);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.35);
  padding: 0.2rem 0;
  max-height: 10rem;
  overflow-y: auto;
  z-index: 40;
}

.settings-suggestion-separator {
  height: 1px;
  margin: 0.2rem 0;
  background: var(--border-strong);
}

.settings-suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}

.settings-suggestion-label {
  flex: 1 1 auto;
  min-width: 0;
}

.settings-suggestion-detail {
  color: var(--muted);
  font-size: 0.72rem;
}

.settings-suggestion-item.is-muted {
  color: var(--muted);
}

.settings-suggestion-item.is-active,
.settings-suggestion-item:hover,
.settings-suggestion-item:focus {
  background: var(--border-strong);
}

#sidepane-container {
  padding: 0;
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#editor-footer {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-top: none;
  overflow: hidden;
}

#editor-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem 0.75rem;
  min-height: 2rem;
  border: 1px solid var(--toolbar-btn-border);
  border-right: none;
  border-radius: 0;
  background: var(--toolbar-btn-bg);
  color: var(--toolbar-btn-color);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border 0.12s ease;
}

#editor-footer button:hover:not(:disabled) {
  background: var(--button-hover-bg);
  color: var(--fg);
}

#editor-footer button:last-child {
  border-right: 1px solid var(--toolbar-btn-border);
}

#editor-footer button:disabled {
  opacity: var(--button-disabled-opacity);
  cursor: not-allowed;
}

#reset-code-btn {
  flex: 1;
}

#editor-footer .editor-footer-toggle {
  flex: 0 0 3rem;
  width: 3rem;
  padding: 0;
}

#editor-footer .editor-footer-toggle[data-pressed="true"],
#editor-footer .editor-footer-toggle[data-pressed="true"]:hover:not(:disabled) {
  color: var(--accent);
}

.cm-editor {
  height: 100%;
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 0.70rem;
}

.cm-scroller {
  overflow: auto;
  height: 100%;
}

#plot {
  flex: var(--plot-area-flex);
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: var(--plot-area-bg);
  border: none;
  min-height: 120px;
  position: relative;
  text-align: center;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sole vertical scroller: notes and figure move together. `container-type: size`
   makes it the reference for the `cqh` figure heights set in settingsTab.js. */
#plot #plot-content {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100%;
  container-type: size;
}

/* Horizontal scroller for the figure alone, so the notes stay put sideways.
   Height stays auto so tall figures grow the pane instead of scrolling here.
   No scrollbar: a reserved one adds its own height, which would make fit_height
   overshoot the pane by ~15px. Wheel/trackpad still scroll. */
#plot-figure-viewport {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

#plot-figure {
  position: relative;
}

#plot-figure svg {
  user-select: none;
}

#plot-preview {
  position: relative;
  width: 100%;
}

#plot-preview-image {
  display: block;
  width: 100%;
  height: auto;
}

#plot-preview-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.4rem 0.65rem;
  border-radius: 0.35rem;
  background: rgb(20 20 20 / 78%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
  pointer-events: none;
  z-index: 5;
}

#plot[data-fig-stretch-mode="fit_height"] #plot-preview,
#plot[data-fig-stretch-mode="fit"] #plot-preview {
  height: 100cqh;
}

#plot[data-fig-stretch-mode="fit_height"] #plot-preview-image {
  width: auto;
  height: 100%;
  margin: 0 auto;
}

#plot[data-fig-stretch-mode="fit"] #plot-preview-image {
  width: 100%;
  height: 100%;
}

#plot-figure-viewport:has(.plot-placeholder),
#plot-figure:has(.plot-placeholder) {
  height: 100cqh;
}

.plot-note {
  position: relative;
  z-index: 5;
  text-align: left;
}

.plot-note[data-position="above"]:not([data-empty="true"]) {
  margin-top: 2rem;
}

.plot-note[data-empty="true"] {
  height: 0;
}

.plot-note[data-empty="true"] .plot-note-rendered {
  display: none;
}

body:not([data-tab-edit="1"]) .plot-note[data-empty="true"] {
  overflow: hidden;
}

.plot-note-rendered {
  padding: 0.75rem 2rem;
  color: var(--fg);
  line-height: 1.45;
  cursor: default;
}

body[data-tab-edit="1"] .plot-note:not([data-empty="true"]):hover .plot-note-rendered {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.plot-note-edit {
  position: absolute;
  top: 0.45rem;
  right: 0.75rem;
  z-index: 7;
  display: none;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border-radius: 0.35rem;
  font-family: var(--font-symbols);
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

body[data-tab-edit="1"] .plot-note:not([data-empty="true"]) .plot-note-edit {
  display: grid;
  place-items: center;
}

body[data-tab-edit="1"] .plot-note:not([data-empty="true"]):hover .plot-note-edit,
body[data-tab-edit="1"] .plot-note:not([data-empty="true"]):focus-within .plot-note-edit {
  opacity: 1;
  pointer-events: auto;
}

body[data-tab-edit="1"] .plot-note[data-editing="true"] .plot-note-edit {
  display: none;
}

.plot-note-rendered > :first-child {
  margin-top: 0;
}

.plot-note-rendered > :last-child {
  margin-bottom: 0;
}

.plot-note-rendered code {
  font-family: var(--font-mono);
}

.plot-note-rendered :not(pre) > code {
  padding: 0.1em 0.3em;
  border: 1px solid var(--border);
  border-radius: 0.3em;
  background: var(--text-code-bg);
  font-size: 0.8em;
}

.plot-note-rendered pre {
  max-width: 100%;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--text-code-bg);
  color: var(--fg);
  font: 0.86rem/1.5 var(--font-mono);
  white-space: pre;
}

.plot-note-rendered pre code {
  font: inherit;
}

.plot-note-rendered table {
  width: max-content;
  max-width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  border-spacing: 0;
  overflow: hidden;
  background: var(--surface-raised);
}

.plot-note-rendered th,
.plot-note-rendered td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.plot-note-rendered th + th,
.plot-note-rendered td + td {
  border-left: 1px solid var(--border);
}

.plot-note-rendered th {
  background: var(--surface-hover);
  font-weight: 700;
}

.plot-note-rendered tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-raised) 55%, transparent);
}

.plot-note-rendered tr:last-child td {
  border-bottom: 0;
}

.plot-note-rendered a {
  color: var(--accent);
}

.plot-note-rendered a.plot-note-link-broken {
  color: var(--danger);
  cursor: not-allowed;
  text-decoration-style: dashed;
}

.plot-note-editor {
  padding: 0.6rem 2rem;
  background: var(--plot-area-bg);
}

.plot-note-editor textarea {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--accent);
  border-radius: 0.35rem;
  background: var(--sidepane-shell-bg);
  color: var(--fg);
  font: 0.82rem/1.4 var(--font-mono);
}

.plot-note-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.plot-note-insertion {
  display: none;
}

body[data-tab-edit="1"] .plot-note[data-empty="true"] .plot-note-insertion {
  position: absolute;
  left: 2rem;
  right: 2rem;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.8rem;
  padding: 0;
  border: 0;
  background: linear-gradient(
    transparent calc(50% - 0.5px),
    var(--accent) calc(50% - 0.5px),
    var(--accent) calc(50% + 0.5px),
    transparent calc(50% + 0.5px)
  );
  color: var(--accent);
  opacity: 0;
  cursor: pointer;
  z-index: 6;
}

body[data-tab-edit="1"] .plot-note[data-position="below"][data-empty="true"] .plot-note-insertion {
  top: auto;
  bottom: 0;
}

body[data-tab-edit="1"] .plot-note[data-empty="true"] .plot-note-insertion:hover,
body[data-tab-edit="1"] .plot-note[data-empty="true"] .plot-note-insertion:focus-visible {
  opacity: 1;
}

.plot-note-insertion span {
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--plot-area-bg);
  font-size: 0.72rem;
}

#plot #plot-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.55rem 2.5rem 0.55rem 0.9rem;
  background: var(--plot-area-bg);
  color: var(--danger);
  font-weight: 700;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-100%);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 7;
  text-align: center;
}

#plot-banner-dismiss {
  position: absolute;
  top: 0.3rem;
  right: 0.55rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

#plot-banner-dismiss:hover {
  opacity: 0.75;
}

#plot #plot-banner .plot-banner-reset {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

#plot #plot-banner .plot-banner-reset:hover {
  opacity: 0.82;
}

#plot #plot-banner[data-active="1"] {
  opacity: 1;
  transform: translateY(0);
}

#plot #plot-actions {
  position: absolute;
  top: 0;
  right: 0.4rem;
  display: flex;
  align-items: flex-start;
  z-index: 6;
  pointer-events: none;
}

#plot #plot-action-controls {
  display: flex;
  gap: 0.4rem;
  border-radius: 0.25rem;
  background: var(--plot-actions-bg);
  pointer-events: auto;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

#plot #plot-actions[data-collapsed="true"] #plot-action-controls {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

#plot #plot-actions-toggle {
  flex: 0 0 1.8rem;
  width: 1.8rem;
  height: 2rem;
  margin-left: 0.4rem;
  border-radius: 0.25rem;
  background: var(--plot-actions-bg);
  pointer-events: auto;
}

#plot #plot-actions .plot-action-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#plot #plot-actions .plot-action-group + .plot-action-group {
  padding-left: 0.55rem;
}

#plot #plot-actions .plot-action-group + .plot-action-group::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 1px;
  height: 1.15rem;
  transform: translateY(-50%);
  background: var(--border-subtle);
}

#plot #plot-actions button {
  height: 2rem;
  width: 1rem;
  text-shadow: 0 0 1px black;
  padding: 0;
  background: none;
  border: none;
  font-size: 0.8rem;
}

#plot-copy-png {
  font-size: 1rem;
}

#plot #plot-actions #settings-fig-stretch-toggle {
  width: 1.2rem;
  font-size: 0.9rem;
}

#plot #plot-actions #plot-text-scale {
  flex: 0 0 1.2rem;
  width: 1.2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  text-shadow: 0 0 1px black;
}

#plot #plot-actions #plot-text-scale-slider {
  background: linear-gradient(var(--border-subtle), var(--border-subtle)) 33.333% center / 1px 0.6rem no-repeat;
}

#plot #plot-actions .plot-slider {
  flex: 0 0 4rem;
  width: 4rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: ew-resize;
}

#plot #plot-actions .plot-slider::-webkit-slider-runnable-track {
  height: 0.12rem;
  border-radius: 0.1rem;
  background: color-mix(in srgb, var(--fg) 30%, transparent);
}

#plot #plot-actions .plot-slider::-moz-range-track {
  height: 0.12rem;
  border-radius: 0.1rem;
  background: color-mix(in srgb, var(--fg) 30%, transparent);
}

#plot #plot-actions .plot-slider::-webkit-slider-thumb {
  width: 0.62rem;
  height: 0.62rem;
  margin-top: -0.25rem;
  border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent);
  border-radius: 50%;
  background: var(--accent);
  -webkit-appearance: none;
}

#plot #plot-actions .plot-slider::-moz-range-thumb {
  width: 0.62rem;
  height: 0.62rem;
  border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent);
  border-radius: 50%;
  background: var(--accent);
}

#plot #plot-actions .plot-slider:focus-visible {
  outline: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 0.1rem;
}

#plot #plot-actions .plot-slider::-moz-range-progress {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
}

#plot #plot-actions button:hover {
  color: var(--accent);
}

#plot-visibility-toggle {
  width: 1.2rem;
  font-size: 0.95rem;
}

#plot-visibility-toggle:disabled {
  opacity: 0.4;
}

#plot-text-scale[data-active="1"] {
  color: var(--accent);
}

#plot-toggle-labels[data-active="1"] {
  color: var(--accent);
}

#plot-label-inside-axis[data-active="1"] {
  color: var(--accent);
}

#plot-wiggle-labels[data-active="1"] {
  color: var(--accent);
}

#plot .mpld3-figure {
  box-sizing: border-box;
  background: var(--muted);
}

body[data-theme="light"] #plot .mpld3-figure {
  background: none;
}

/* Margin text (ticks, facet titles) hangs off mpld3-baseaxes, which we tag with the facet
   index, so it would make the facet hit area glyph-shaped instead of the plot rect. Let it
   fall through. Run labels live under g.mpld3-textgroup and keep their pointer events —
   brettli hovers them to highlight a run. */
#plot .mpld3-xaxis,
#plot .mpld3-yaxis,
#plot .mpld3-static-element > text.mpld3-text {
  pointer-events: none;
}

#plot-table-resizer {
  flex: 0 0 6px;
  cursor: row-resize;
  background: var(--border);
  position: relative;
}

#plot-table-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

#plot-table-resizer:hover,
#plot-table-resizer:focus-visible,
#plot-table-resizer.dragging {
  background: var(--accent);
}

#brettli-pane {
  flex: var(--brettli-flex);
  display: flex;
  flex-direction: column;
  min-height: 36px;
  border-top: 1px solid var(--border);
  background: var(--pane-plot-bg);
  position: relative;
}

#brettli-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

#brettli-title-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#brettli-toggle {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--muted);
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease;
}

#brettli-toggle:hover,
#brettli-toggle:focus-visible {
  color: var(--fg);
}

#brettli-title {
  font-weight: 600;
  color: var(--accent);
}

#brettli-runs-toggle {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

#brettli-runs-toggle:disabled {
  cursor: default;
  opacity: 0.4;
}

#brettli-runs-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

#brettli-container {
  flex: 1;
  overflow: auto;
  position: relative;
  transition: transform var(--sidepane-collapse-duration) ease,
    opacity var(--sidepane-collapse-duration) ease;
}

#plot-stack[data-brettli-transition="closing"] #brettli-container,
#plot-stack[data-brettli-transition="opening"] #brettli-container {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

#plot-stack[data-brettli-collapsed="1"] #brettli-container {
  display: none;
}

#brettli-container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

#brettli-container thead {
  position: sticky;
  top: 0;
  background: var(--pane-plot-bg);
  z-index: 1;
}

#brettli-container th,
#brettli-container td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

#brettli-container th.brettli-groupby-start,
#brettli-container td.brettli-groupby-start {
  border-left: 2px solid var(--accent);
}

#brettli-container th.brettli-groupby-end,
#brettli-container td.brettli-groupby-end {
  border-right: 2px solid var(--accent);
}

#brettli-container th.brettli-facetby,
#brettli-container td.brettli-facetby {
  color: var(--muted);
}

#brettli-highlight-toggle {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
}

#brettli-highlight-toggle[data-disabled="1"] {
  opacity: 0.4;
}

#brettli-highlight-toggle button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease;
}

#brettli-highlight-toggle button:disabled {
  cursor: default;
}

#brettli-highlight-toggle button[data-active="1"] {
  color: var(--accent);
}

#brettli-highlight-toggle button:hover {
  color: var(--fg);
}

#brettli-highlight-toggle button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}


.brettli-header-cell {
  white-space: nowrap;
}

.brettli-more-columns-cell {
  text-align: center;
}

.brettli-more-columns-cell button {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.brettli-more-columns-cell button:hover,
.brettli-more-columns-cell button:focus-visible {
  color: var(--fg);
}

.brettli-sort-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  border-radius: 0.25rem;
  margin-right: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s ease, background 0.12s ease;
}

.brettli-sort-btn:hover,
.brettli-sort-btn:focus-visible {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
}

.brettli-sort-btn.is-active {
  color: var(--accent);
  background: rgba(75, 192, 200, 0.12);
}

body[data-theme="light"] .brettli-sort-btn:hover,
body[data-theme="light"] .brettli-sort-btn:focus-visible {
  background: rgba(7, 54, 66, 0.12);
}

body[data-theme="light"] .brettli-sort-btn.is-active {
  background: rgba(38, 139, 210, 0.18);
}

#brettli-container tbody tr:nth-child(2n) {
  background: rgba(255, 255, 255, 0.02);
}

body[data-theme="light"] #brettli-container tbody tr:nth-child(2n) {
  background: rgba(0, 0, 0, 0.03);
}

#brettli-container tbody tr.is-highlighted {
  background: rgba(255, 255, 255, 0.06);
}

.run-color-swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  background: var(--run-color, #000000);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}

#brettli-container th.brettli-header-cell-color,
#brettli-container td.brettli-color-cell {
  width: 1.3rem;
  min-width: 1.3rem;
  padding: 0 0.2rem;
  text-align: right;
}

#brettli-container th.brettli-header-cell-color {
}

.brettli-header-cell-color .run-color-swatch,
.brettli-color-cell .run-color-swatch {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

.brettli-color-cell .run-color-swatch {
  cursor: pointer;
}

.run-color-swatch-header {
  pointer-events: none;
}

#brettli-container td.brettli-run-cell,
#brettli-container th.brettli-run-header {
  padding-left: 0.15rem;
}

#brettli-container td.brettli-runs-cell.is-expandable {
  cursor: pointer;
}

#brettli-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#brettli-pane[data-state="active"] #brettli-hint {
  opacity: 0;
}

#brettli-pane[data-state="active"] #brettli-hint::after {
  content: '';
}

.plot-placeholder {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
}

.plot-placeholder[data-tone="warning"] {
  color: var(--warning);
}

#log-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50vh;
  background: var(--log-panel-bg);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 30;
  pointer-events: none;
}

#log-panel.open {
  transform: translateY(0);
  pointer-events: auto;
  box-shadow: 0 -10px 20px rgba(0, 0, 0, 0.35);
}

#code-diff-dialog,
#app-settings-dialog {
  width: min(96vw, 1400px);
  height: min(92vh, 900px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
}

#app-settings-dialog {
  width: min(92vw, 980px);
  height: min(84vh, 720px);
}

#code-diff-dialog::backdrop,
#app-settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

#code-diff-header,
#app-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-glass);
}

#code-diff-title,
#app-settings-title {
  font-family: var(--font-mono);
  color: var(--muted);
}

#code-diff-body {
  height: calc(100% - 44px);
}

#app-settings-body {
  height: calc(100% - 44px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.2rem;
  overflow: auto;
}

#app-settings-fields {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.app-settings-row {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.app-settings-label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.app-settings-label {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.app-settings-editor {
  width: 100%;
}

#app-settings-remotes-warning {
  grid-column: 2 / -1;
  margin: -0.3rem 0 0;
  color: var(--warning);
  font-size: 0.78rem;
  line-height: 1.35;
}

#app-settings-remotes-warning a {
  color: inherit;
}

#app-settings-share-url {
  width: 100%;
  min-width: 0;
}

#app-settings-brettli-config-columns {
  width: 7rem;
}

#app-settings-share-url.is-invalid {
  border-color: var(--danger);
}

#app-settings-metric-cache-control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

#app-settings-metric-cache-gib {
  width: 7rem;
}

#app-settings-metric-cache-usage {
  color: var(--muted);
  font-size: 0.78rem;
}

#app-settings-metric-cache-clear {
  white-space: nowrap;
}

.app-settings-reset {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  border-radius: 0.35rem;
}

.app-settings-reset:hover {
  color: var(--fg);
  background: var(--surface-hover);
}

.app-settings-help {
  color: var(--muted);
  cursor: help;
  font-size: 0.8rem;
  line-height: 1;
}

#app-settings-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

#app-settings-api-guide {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.72rem;
}

#app-settings-api-guide:hover {
  color: var(--fg);
}

#code-diff-body .cm-mergeView {
  height: 100%;
}

#code-diff-body .cm-mergeViewEditor + .cm-mergeViewEditor {
  border-left: 3px solid var(--border);
}

#code-diff-body .cm-editor {
  height: 100%;
}

#code-diff-body .cm-scroller {
  font-family: var(--font-mono);
}

#log-header {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.6rem 0.8rem 0.4rem;
}

#close-log {
  font-size: 1.3rem;
  line-height: 1;
}

#log-entries {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg);
}

.log-entry {
  background: var(--log-entry-bg);
  border: 1px solid var(--log-entry-border);
  border-left-width: 3px;
  border-radius: 0.65rem;
  padding: 0.55rem 0.7rem;
  line-height: 1.4;
}

.log-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.log-entry.info {
  border-left-color: var(--accent);
}

.log-entry.warn {
  border-left-color: var(--accent-strong);
}

.log-entry.error {
  border-left-color: var(--danger);
}

.log-copy-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 0.45rem;
  border: 1px solid var(--border);
  background: var(--surface-glass);
  color: var(--fg);
  flex-shrink: 0;
}

.log-copy-btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.log-entry.error .log-copy-btn {
  border-color: var(--danger);
  color: var(--danger);
}

.log-entry time {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}

.log-entry pre {
  margin: 0.4rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

body#shares-page {
  height: auto;
  overflow: auto;
}

#shares-page #app-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

#shares-brand {
  color: inherit;
  text-decoration: none;
}

#shares-open-app {
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--fg);
  padding: 0.45rem 0.9rem;
  border-radius: 0.45rem;
  text-decoration: none;
}

#shares-open-app:hover {
  background: var(--button-hover-bg);
}

#shares-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

#shares-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#shares-search {
  flex: 1;
  min-width: 12rem;
  min-height: 2.4rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface-glass);
  color: var(--fg);
  font: inherit;
  padding: 0.5rem 0.75rem;
  outline: none;
}

#shares-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--selection-bg);
}

#shares-count {
  min-width: 5rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

#shares-table-shell {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--pane-plot-bg);
}

#shares-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-family: var(--font-sans);
}

#shares-table thead {
  position: sticky;
  top: 0;
  background: var(--pane-plot-bg);
  z-index: 1;
}

#shares-table th,
#shares-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

#shares-table th:first-child,
#shares-table td.shares-expand-cell {
  width: 1.25rem;
  min-width: 1.25rem;
  max-width: 1.25rem;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
  text-align: center;
}

#shares-table th:nth-child(2),
#shares-table td:nth-child(2) {
  min-width: 4rem;
}

#shares-table th:nth-child(3),
#shares-table td:nth-child(3) {
  min-width: 14rem;
}

#shares-table th:nth-child(4),
#shares-table td:nth-child(4) {
  min-width: 12rem;
}

#shares-table .shares-name-cell {
  font-family: var(--font-sans);
}

#shares-table .shares-name-cell[data-editable="true"] {
  cursor: text;
}

#shares-table .shares-name-cell[data-editable="true"]:hover {
  color: var(--accent);
}

#shares-table .share-name-input {
  width: 100%;
  min-width: 8rem;
  border: 1px solid var(--accent);
  border-radius: 0.3rem;
  background: var(--surface-glass);
  color: var(--fg);
  font: inherit;
  padding: 0.2rem 0.35rem;
  outline: none;
}

#shares-table .shares-link-cell {
  min-width: 14rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

#shares-table .shares-truncated {
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

#shares-table .shares-thin {
  width: 2.3rem;
  min-width: 2.3rem;
  max-width: 2.3rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  text-align: center;
  font-family: var(--font-symbols);
}

#shares-table .shares-yes {
  color: var(--accent);
}

#shares-table .shares-no {
  color: var(--muted);
}

#shares-table .share-expand {
  width: 0.8rem;
  height: 0.8rem;
  min-width: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#shares-table .share-expand:hover,
#shares-table .share-expand:focus-visible {
  background: none;
  color: var(--accent);
}

#shares-table a {
  color: var(--accent);
  text-decoration: none;
}

#shares-table a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

#shares-table tbody tr:nth-child(2n) {
  background: var(--surface-raised);
}

#shares-table tbody tr[data-error="true"] {
  color: var(--danger);
}

#shares-table .share-detail-row td {
  white-space: normal;
  background: var(--surface-glass);
}

#shares-table .share-detail-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.45rem 0.9rem;
  margin: 0;
}

#shares-table .share-detail-grid dt {
  color: var(--muted);
  font-weight: 600;
}

#shares-table .share-detail-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

#shares-table [id^="share-error-"] {
  margin-top: 0.25rem;
  color: var(--danger);
  font-size: 0.78rem;
  white-space: normal;
  word-break: break-word;
}

.icon-button,
.emoji-icon,
#tab-edit-toggle,
#sidepane-toggle-label,
#plot-type-menu-btn,
.tab-rename-btn,
.tab-action,
.axis-limit-toggle,
.setup-fold-toggle,
#setup-run-sort,
#setup-run-star-filter,
#setup-run-show-hidden,
#setup-run-copy-selection,
#setup-run-paste-selection,
#setup-run-apply-all-tabs,
#setup-run-reload,
.settings-chip-remove,
.brettli-sort-btn,
.app-settings-help,
.run-tree-expand,
.run-tree-copy,
.run-tree-hide,
.run-tree-star,
.run-tree-star-hint,
#plot-banner-dismiss,
#brettli-toggle,
#settings-group-join-toggle,
#settings-cmap-reverse,
#settings-facet-join-toggle,
#shares-table .share-expand {
  font-family: var(--font-symbols);
}

.symbol-button {
  font-family: var(--font-symbols);
}

.text-button {
  font-family: var(--font-sans);
}

@media (max-width: 760px) {
  #shares-page #app-header {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  #shares-page #header-actions {
    justify-self: start;
  }

  #shares-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  #shares-count {
    min-width: 0;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
