.plot-page {
  min-height: 100vh;
  background: #f2f6fc;
}
.plot-main { width: min(92rem, 100%); margin-inline: auto; padding: .875rem clamp(.75rem, 2.1vw, 2rem); }
.plot-header, .plot-identity, .plot-actions, .plot-stage-head, .plot-view-buttons,
.plot-tool-row, .plot-tool-buttons, .plot-tool-groups, .plot-inline, .plot-panes {
  display: flex;
  align-items: center;
}
.plot-header { justify-content: space-between; gap: .75rem; min-height: 3.125rem; margin-block-end: .625rem; }
.plot-identity { gap: .625rem; }
.plot-identity h1 { font-size: 1.375rem; font-weight: 675; line-height: 1.2; letter-spacing: -.02em; }
.plot-actions { flex-wrap: wrap; justify-content: flex-end; gap: .375rem; }
.plot-toolbar, .plot-sidebar, .plot-stage { min-width: 0; border: 1px solid var(--line); border-radius: .875rem; background: #fff; }
.plot-toolbar { margin-block-end: .75rem; }
.plot-tool-groups { gap: .375rem; overflow-x: auto; padding: .5rem .5rem .375rem; }
.plot-group {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  flex: 0 0 auto;
  min-height: 2.75rem;
  padding: .375rem .6rem;
  border: 1px solid transparent;
  border-radius: .625rem;
  background: transparent;
  color: #42536d;
  font: inherit;
  font-size: .875rem;
  font-weight: 550;
  white-space: nowrap;
}
.plot-group span {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  border-radius: .375rem;
  background: #edf2ff;
  color: #3158bf;
  font-size: 1.04rem;
  line-height: 1;
}
.plot-group[aria-pressed="true"] { border-color: #c9dbfc; background: #eef3ff; color: #1e429f; }
.plot-group[aria-pressed="true"] span { background: #dbe6ff; color: #234ab2; }
.plot-group:focus-visible { outline-offset: -2px; }
.plot-tool-row { min-height: 3.5rem; flex-wrap: wrap; gap: .375rem .625rem; padding: .375rem .55rem; border-top: 1px solid var(--line); }
.plot-tool-buttons { min-width: 0; flex-wrap: wrap; gap: .25rem; }
.plot-inline { gap: .375rem; font-size: .8125rem; }
.plot-inline input { width: 6.25rem; }

.plot-control, .plot-main :is(input:not([type="checkbox"], [type="range"]), select) {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: .875rem;
}
.plot-main :is(input:not([type="checkbox"], [type="range"]), select) { min-width: 0; padding-inline: .5rem; }
.plot-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .375rem .65rem;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 150ms, border-color 150ms;
}
.plot-control[aria-pressed="true"] { border-color: #b3c7ee; background: #eaf1ff; color: #1e429f; }
.plot-tool { border-color: transparent; }
.plot-control:disabled { color: #647189; opacity: .6; cursor: default; }
.plot-control.plot-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.plot-control.plot-danger { color: #a12846; }
.plot-zoom { min-width: 2.75rem; padding-inline: .25rem; font-size: 1.125rem; }

.plot-workspace { display: grid; grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr); gap: .75rem; align-items: start; }
.plot-sidebar { min-height: 14rem; }
.plot-panes { gap: .25rem; padding: .375rem; border-bottom: 1px solid var(--line); }
.plot-panes button { flex: 1; padding-inline: .25rem; }
.plot-pane { padding: .75rem; max-height: calc(100vh - 15rem); overflow: auto; }
.plot-expression { display: grid; gap: .375rem; }
.plot-expression label, .plot-inspector h2 { font-size: .9375rem; font-weight: 650; }
.plot-field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .375rem; }
.plot-expression input { width: 100%; font-family: ui-monospace, Consolas, monospace; }
.plot-expression-preview {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  max-height: 7.5rem;
  overflow: auto;
  padding: .375rem .625rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #f5f8ff;
  color: var(--muted);
  font-size: .875rem;
}
.plot-expression-preview[data-state="math"] { color: #203662; font-size: 1.0625rem; }
.plot-expression-preview[data-state="raw"] { font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.plot-latex-tools { display: flex; flex-wrap: wrap; gap: .25rem; }
.plot-latex-tools .plot-control { padding-inline: .5rem; }
.plot-expression p, .plot-empty { color: var(--muted); font-size: .8125rem; line-height: 1.55; }
.plot-expression #expression-error { color: #a12846; }
.plot-expression code { white-space: nowrap; color: #24479a; }
.plot-objects { display: grid; gap: .375rem; margin-block: .875rem .625rem; }
.plot-object { display: flex; gap: .25rem; align-items: stretch; min-width: 0; border: 1px solid var(--line); border-radius: .625rem; }
.plot-object[data-selected="true"] { border-color: #a9bfe9; background: #f2f6ff; }
.plot-object-select {
  flex: 1;
  min-width: 0;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: .1875rem;
  min-height: 2.75rem;
  padding: .375rem .5rem .375rem .65rem;
  border: 0;
  border-inline-start: 3px solid var(--object-color);
  border-radius: .5rem;
  background: transparent;
  color: var(--text, #192741);
  text-align: start;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
}
.plot-object-select span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plot-object-description { color: var(--muted); font-size: .8125rem; font-weight: 400; }
.plot-object-visibility { flex: 0 0 auto; border-color: transparent; background: transparent; color: var(--muted); }
.plot-inspector { display: grid; gap: .625rem; margin-block-start: .625rem; padding-block-start: .75rem; border-top: 1px solid var(--line); }
.plot-inspector .plot-danger { justify-self: start; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .625rem .5rem; }
.settings-grid label { display: grid; gap: .25rem; color: #42536d; font-size: .8125rem; }
.settings-grid label :is(input, select) { width: 100%; }
.settings-grid input[type="color"] { padding: .2rem !important; cursor: pointer; }
.settings-grid label.plot-check { display: flex; align-items: center; min-height: 2.75rem; gap: .3125rem; }
.plot-check input { width: 1rem !important; height: 1rem; margin: 0; accent-color: var(--accent); }
.settings-grid small { grid-column: 1 / -1; color: var(--muted); font-size: .8125rem; }
.settings-grid .plot-range { grid-column: 1 / -1; }
.plot-range input { accent-color: var(--accent); }
.plot-settings details { padding-block: .375rem; border-bottom: 1px solid var(--line); }
.plot-settings summary { min-height: 2.75rem; padding: .625rem .2rem; color: #223653; font-weight: 600; cursor: pointer; }
.plot-settings details .settings-grid { padding-block: .125rem .625rem; }

.plot-stage { overflow: clip; }
.plot-stage-head { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; padding: .5rem .625rem; border-bottom: 1px solid var(--line); }
.plot-guide { min-width: 12rem; max-width: 38rem; flex: 1; }
.plot-guide strong { font-size: .875rem; }
.plot-guide p, .plot-status { color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.plot-view-buttons { flex-wrap: wrap; gap: .25rem; }
.plot-surface { position: relative; }
#plot {
  display: block;
  width: 100%;
  height: max(24rem, calc(100dvh - 15.75rem));
  max-height: 56rem;
  background: #fcfdff;
  touch-action: none;
}
#plot[data-cursor="draw"] { cursor: crosshair; }
#plot[data-cursor="move"] { cursor: grab; }
#plot[data-cursor="move"]:active { cursor: grabbing; }
#plot:focus-visible { outline-offset: -2px; }
.coordinate-readout {
  position: absolute;
  inset: auto .75rem .75rem auto;
  padding: .3125rem .5rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: #fff;
  color: #213958;
  font: .8125rem ui-monospace, Consolas, monospace;
  pointer-events: none;
}
.plot-status { min-height: 2rem; padding: .375rem .625rem; border-top: 1px solid var(--line); }

@media (hover: hover) {
  .plot-control:hover:not(:disabled), .plot-group:hover { background: #edf3ff; }
  .plot-control.plot-primary:hover:not(:disabled) { background: #264ab8; }
}
@media (prefers-reduced-motion: reduce) { .plot-control { transition: none; } }
@media (min-width: 55.01rem) {
  #objects-pane { display: flex; flex-direction: column; overflow: hidden; }
  .plot-expression, .plot-empty { flex: 0 0 auto; }
  .plot-objects { min-height: 0; flex: 1 1 auto; overflow: auto; padding: .125rem .1875rem; }
  .plot-inspector { flex: 0 1 auto; max-height: 14rem; overflow: auto; }
}
@media (max-width: 55rem) {
  .plot-workspace { grid-template-columns: minmax(0, 1fr); }
  .plot-stage { grid-row: 1; }
  .plot-pane { max-height: none; }
  #plot { height: clamp(20rem, 51svh, 34rem); }
}
@media (max-width: 30rem) {
  .plot-header { align-items: start; }
  .plot-identity h1 { font-size: 1.0625rem; }
  .plot-editor { display: none; }
  .plot-header .plot-control { padding-inline: .4375rem; }
  .plot-tool-row { min-height: auto; }
}
