:root {
  --paper: #f4f4ed;
  --card: #fffefa;
  --ink: #203f38;
  --muted: #6d7971;
  --rule: #dce1d5;
  --green: #285b49;
  --mint: #e6eee4;
  --amber: #e9b668;
  --domain: #fff0dd;
  --domain-ink: #854e21;
  --blue: #d4e7e3;
  --radius: 12px;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  font-size: 14px;
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 40% 0%, #e9ede2 0, transparent 60%);
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  outline-offset: 4px;
}
button {
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover:not(:disabled) {
  background: var(--mint);
  border-color: #a9b9aa;
}
button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.filled {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.filled:hover:not(:disabled) {
  background: #1a4434;
}
input,
select,
textarea {
  background: var(--card);
  color: var(--ink);
  border: 1px solid #d1d9cc;
  border-radius: 6px;
  padding: 8px;
  min-width: 0;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #8cae90;
  border-color: transparent;
}
label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
h1,
h2,
p {
  margin: 0;
}
h1,
h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 500;
}
h1 {
  font-size: 27px;
}
h2 {
  font-size: 22px;
}
.text-button {
  background: none;
  border-color: transparent;
  padding: 4px 0;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 600;
  display: block;
  margin-bottom: 7px;
}
.masthead {
  height: 82px;
  padding: 0 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fffefa;
  border-bottom: 1px solid var(--rule);
  gap: 18px;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 23px;
}
.mark {
  font-style: italic;
  font-size: 41px;
  background: var(--green);
  border-radius: 50%;
  width: 43px;
  height: 43px;
  line-height: 37px;
  text-align: center;
  color: #fffefa;
}
.wordmark small {
  display: block;
  font:
    9px "Avenir Next",
    sans-serif;
  letter-spacing: 0.2em;
  margin-top: 5px;
  color: var(--muted);
}
.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.file-actions > span {
  font-size: 11px;
  color: var(--muted);
  margin-right: 12px;
}
.app-shell {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  min-height: calc(100vh - 82px);
}
.sidebar {
  padding: 25px 18px 20px 22px;
  border-right: 1px solid var(--rule);
  background: #f0f2e9;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e5eadd;
  border-radius: 30px;
  min-width: 24px;
  height: 23px;
  font:
    11px "Avenir Next",
    sans-serif;
  padding: 0 7px;
}
.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.tabs button {
  font-size: 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  border-radius: 0;
  padding: 8px 6px;
}
.tabs [aria-selected="true"] {
  border-bottom-color: var(--green);
  font-weight: 700;
}
.library-items {
  min-height: 110px;
  max-height: 260px;
  overflow: auto;
}
.library-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 7px;
  text-align: left;
  background: #fafbf6;
  border-color: #d5ddd0;
}
.library-symbol {
  font:
    italic 22px Georgia,
    serif;
  min-width: 26px;
}
.library-entry small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}
.library-entry.is-active {
  background: #dce9db;
  border-color: var(--green);
}
.library-empty {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  padding: 4px 0 20px;
}
.library-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}
.library-actions button {
  flex: 1;
  font-size: 11px;
}
.library-help {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 15px;
}
.library-help p {
  margin: 10px 0;
}
summary {
  cursor: pointer;
}
.environment {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.environment label {
  margin-bottom: 12px;
  font-weight: 500;
  color: #56675a;
}
.environment select,
.environment input {
  width: 100%;
  font-size: 12px;
}
.level-badge {
  font-size: 11px;
  background: var(--green);
  color: white;
  border-radius: 4px;
  padding: 4px 7px;
}
#display-settings,
#debug-settings {
  margin: 17px 0;
  font-size: 12px;
}
#display-settings summary,
#debug-settings summary {
  margin-bottom: 14px;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.environment small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 6px;
}
.pilot-note {
  font-family: Georgia, serif;
  font-size: 15px;
  line-height: 1.6;
  color: #6e7c6a;
  margin-top: 28px;
}
.pilot-note span {
  font:
    10px "Avenir Next",
    sans-serif;
}
.workbench {
  padding: 25px 26px;
  min-width: 0;
}
.input-panel {
  margin-bottom: 19px;
}
.input-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.input-topline label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
#parse-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
#expression {
  resize: vertical;
  flex: 1;
  min-height: 62px;
  max-height: 190px;
  font:
    18px/1.45 "Iowan Old Style",
    Georgia,
    serif;
  padding: 13px 16px;
  background: #fffefa;
}
.parse-button {
  min-width: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.examples {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.examples button {
  border: 0;
  background: none;
  padding: 3px 0;
  font-size: 11px;
  color: #527360;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 4px;
}
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(350px, 1.25fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: stretch;
}
.tree-panel,
.history-panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.panel-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 21px 22px 14px;
  gap: 12px;
}
.history-controls {
  display: flex;
  gap: 5px;
}
.history-controls button {
  font-size: 11px;
  padding: 7px 10px;
}
.tree-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  color: var(--muted);
  font-size: 10px;
}
.tree-tools button {
  font-size: 10px;
}
.tree-canvas {
  height: 340px;
  min-height: 240px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: radial-gradient(#d5dfd1 0.6px, transparent 0.6px);
  background-size: 18px 18px;
}
.tree-canvas svg {
  display: block;
  flex-shrink: 0;
}
.tree-edge {
  stroke: #95afa1;
  stroke-width: 1.4;
}
.tree-node {
  cursor: pointer;
}
.tree-node rect {
  fill: var(--blue);
  stroke: #a6c9bd;
  stroke-width: 1;
}
.tree-node:hover rect {
  fill: #bfdbce;
  stroke: #44795e;
}
.tree-node[aria-pressed="true"] rect {
  fill: var(--green);
  stroke: var(--green);
  stroke-width: 2;
}
.tree-node text {
  font:
    17px "Iowan Old Style",
    Georgia,
    serif;
  fill: var(--ink);
  pointer-events: none;
}
.tree-node[aria-pressed="true"] text {
  fill: white;
}
.tree-comment {
  font:
    11px "Avenir Next",
    sans-serif;
  fill: #96533a;
}
.selection-strip {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 54px;
  padding: 10px 18px;
  border-top: 1px solid var(--rule);
  background: #f4f7ef;
}
.selection-strip > span {
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
}
#selected-expression {
  flex: 1;
  min-width: 0;
  overflow: auto;
}
.selection-strip button {
  font-size: 10px;
  white-space: nowrap;
  padding: 7px 9px;
  background: #faeedc;
  border-color: #e5cda8;
}
.command-panel {
  border-top: 1px solid var(--rule);
  padding: 18px 20px;
  min-height: 180px;
}
.command-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
.command-heading h2 {
  font-size: 18px;
  white-space: nowrap;
}
.command-heading .count {
  vertical-align: middle;
  margin-left: 3px;
}
#command-filter {
  width: 140px;
  font-size: 11px;
  padding: 7px;
}
.command-group + .command-group {
  margin-top: 17px;
}
.command-group h3 {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 8px;
}
.command-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.command-list button {
  font-size: 11px;
  padding: 7px 9px;
}
.command-list .compute-action {
  background: #edf2df;
}
.empty-state {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  padding: 20px;
}
.history-panel {
  display: flex;
  flex-direction: column;
  min-height: 650px;
  height: min(820px, calc(100vh - 230px));
}
.history-panel .panel-topline {
  border-bottom: 1px solid var(--rule);
}
#step-count {
  font-size: 10px;
  color: var(--muted);
}
.history-scroll {
  height: 530px;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 8px 22px 18px;
  scroll-behavior: smooth;
}
.working-step {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 8px;
  padding: 20px 0;
  border-bottom: 1px solid #edf0e7;
  min-height: 70px;
}
.working-step:last-child {
  border-bottom: 0;
}
.step-index {
  font-size: 10px;
  color: #889582;
  padding-top: 6px;
}
.step-math {
  overflow: auto;
  padding: 3px 0 7px;
}
.working-step:last-child .step-index {
  color: var(--green);
  font-weight: 700;
}
.working-step:last-child {
  background: linear-gradient(90deg, transparent, #f4f7ed);
  margin-right: -12px;
  padding-right: 12px;
}
.katex {
  font-size: 1.05em;
}
.step-math .katex {
  font-size: 1.13em;
}
.history-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.history-footer button {
  font-size: 10px;
}
.history-footer > span {
  font:
    italic 12px Georgia,
    serif;
  color: var(--muted);
}
#notification {
  padding: 11px 15px;
  background: #fbe8de;
  border: 1px solid #eac4ad;
  border-radius: 7px;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.5;
}
#notification.info {
  background: #e9f0e2;
  border-color: #c8d8bc;
}
#context-banner {
  padding: 15px 19px;
  margin-bottom: 14px;
  background: var(--domain);
  border: 1px solid #e5ccaa;
  border-radius: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
#context-banner[hidden] {
  display: none;
}
#context-title {
  font-size: 12px;
  color: var(--domain-ink);
}
#context-source {
  margin-top: 7px;
  overflow: auto;
}
#context-actions {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
}
#context-actions button {
  font-size: 11px;
  background: #fff8ed;
  border-color: #d9b384;
}
body.domain .tree-panel {
  border-color: #d8b88c;
}
body.domain .tree-canvas {
  background-color: #fffbf1;
}
body.domain .tree-node rect {
  fill: #f1dbb5;
  stroke: #d5ba90;
}
body.domain .tree-node[aria-pressed="true"] rect {
  fill: #85582f;
  stroke: #85582f;
}
dialog {
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  padding: 29px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 24px 90px #18362c33;
}
dialog::backdrop {
  background: #19392f55;
  backdrop-filter: blur(3px);
}
dialog h2 {
  font-size: 26px;
  margin: 10px 0 21px;
}
dialog label {
  margin-bottom: 8px;
}
dialog input {
  width: 100%;
  font-size: 17px;
  padding: 11px;
}
dialog p {
  font-size: 13px;
  line-height: 1.7;
  margin: 12px 0 18px;
}
dialog code {
  background: #ecf0e5;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 23px;
}
#prompt-error {
  font-size: 12px;
  color: #98472f;
  margin: 9px 0;
}
body:not(.ready) .workbench {
  opacity: 0.55;
}
.ready .input-panel {
  animation: arrive 0.35s ease-out;
}
.ready .workspace-grid {
  animation: arrive 0.45s ease-out;
}
@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
@media (min-width: 1700px) {
  .workbench {
    max-width: 1650px;
    padding: 30px 38px;
  }
  .tree-canvas {
    height: 410px;
  }
}
@media (max-width: 1150px) {
  .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .sidebar {
    padding: 22px 14px;
  }
  .workbench {
    padding: 20px 17px;
  }
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .history-panel {
    min-height: 340px;
    height: 420px;
  }
  .history-scroll {
    max-height: 450px;
  }
  .tree-canvas {
    height: 310px;
  }
  .file-actions > span {
    display: none;
  }
}
@media (max-width: 650px) {
  .masthead {
    height: auto;
    padding: 15px;
    flex-wrap: wrap;
    gap: 15px;
  }
  .wordmark {
    font-size: 21px;
  }
  .file-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .file-actions button {
    font-size: 11px;
  }
  .app-shell {
    display: flex;
    flex-direction: column;
  }
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 17px;
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .environment {
    margin: 0;
    padding: 0;
    border: 0;
  }
  .library-items {
    max-height: 160px;
    min-height: 60px;
  }
  .section-heading h2 {
    font-size: 20px;
  }
  .pilot-note {
    display: none;
  }
  .environment label {
    font-size: 10px;
    margin-bottom: 8px;
  }
  .environment select {
    padding: 6px;
  }
  .workbench {
    padding: 18px 12px;
  }
  .input-topline label {
    font-size: 9px;
  }
  #expression {
    font-size: 17px;
  }
  .parse-button {
    min-width: 73px;
  }
  .examples {
    gap: 11px;
    flex-wrap: wrap;
  }
  .workspace-grid {
    gap: 14px;
  }
  .panel-topline {
    padding: 18px 15px 12px;
  }
  h1 {
    font-size: 24px;
  }
  .tree-canvas {
    height: 300px;
    justify-content: flex-start;
  }
  .selection-strip {
    padding: 10px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .selection-strip > span {
    width: 45px;
  }
  .selection-strip button {
    margin-left: auto;
  }
  .command-panel {
    padding: 16px 12px;
  }
  .command-heading h2 {
    font-size: 17px;
  }
  #command-filter {
    width: 118px;
  }
  .history-scroll {
    padding: 8px 15px;
  }
  .history-footer {
    padding: 13px;
    flex-wrap: wrap;
  }
  #context-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  #context-actions {
    align-self: flex-end;
  }
  .library-help {
    font-size: 10px;
  }
  .tree-node rect {
    stroke-width: 1.5;
  }
}

@media (max-width: 650px) {
  .sidebar {
    order: 2;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .workbench {
    order: 1;
  }
  .command-heading {
    flex-wrap: wrap;
  }
  #command-filter {
    width: 100%;
  }
  .panel-topline {
    flex-wrap: wrap;
  }
  .selection-strip {
    min-width: 0;
  }
  #context-source {
    max-width: 100%;
  }
  .tree-canvas {
    align-items: flex-start;
  }
}

#context-source {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Desktop workbench: fit the viewport; scroll content rather than the page. */
@media (min-width: 900px) and (min-height: 480px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }
  .masthead {
    height: 58px;
    padding: 0 18px;
    gap: 12px;
  }
  .wordmark {
    font-size: 21px;
    gap: 9px;
  }
  .mark {
    width: 33px;
    height: 33px;
    line-height: 29px;
    font-size: 33px;
  }
  .wordmark small {
    font-size: 8px;
    margin-top: 3px;
  }
  .file-actions button {
    padding: 7px 11px;
    font-size: 12px;
  }
  .file-actions > span {
    font-size: 10px;
    margin-right: 4px;
  }
  .app-shell {
    grid-template-columns: 188px minmax(0, 1fr);
    height: calc(100dvh - 58px);
    min-height: 0;
    overflow: hidden;
  }
  .sidebar {
    min-height: 0;
    overflow: auto;
    padding: 16px 13px;
  }
  .section-heading {
    margin-bottom: 9px;
  }
  .section-heading h2 {
    font-size: 21px;
  }
  .tabs {
    margin-bottom: 8px;
  }
  .tabs button {
    padding: 6px 5px;
  }
  .library-items {
    min-height: 58px;
    max-height: 130px;
  }
  .library-empty {
    font-size: 11px;
    line-height: 1.5;
    padding-bottom: 10px;
  }
  .library-entry {
    padding: 6px 8px;
  }
  .library-actions {
    margin-top: 7px;
  }
  .library-actions button {
    padding: 6px 8px;
  }
  .library-help {
    margin-top: 10px;
    font-size: 10px;
  }
  .environment {
    margin-top: 17px;
    padding-top: 16px;
  }
  .environment label {
    gap: 4px;
    margin-bottom: 8px;
    font-size: 11px;
  }
  .environment input,
  .environment select {
    padding: 6px 7px;
    font-size: 11px;
  }
  #display-settings,
  #debug-settings {
    margin: 12px 0;
    font-size: 11px;
  }
  #display-settings summary,
  #debug-settings summary {
    margin-bottom: 10px;
  }
  .pilot-note {
    display: none;
  }
  .workbench {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    max-width: none;
    overflow: hidden;
    padding: 12px;
  }
  .input-panel {
    flex-shrink: 0;
    margin: 0;
  }
  .input-topline {
    margin-bottom: 4px;
  }
  .input-topline label,
  .input-topline button {
    font-size: 10px;
  }
  #parse-form {
    gap: 8px;
  }
  #expression {
    height: 50px;
    min-height: 50px;
    max-height: 90px;
    padding: 8px 12px;
    font-size: 18px;
    line-height: 1.4;
  }
  .parse-button {
    min-width: 82px;
  }
  .examples {
    margin-top: 4px;
  }
  .workspace-grid {
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(0, 1.16fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
  }
  .tree-panel {
    display: grid;
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1.3fr) auto minmax(100px, 1fr);
  }
  .panel-topline {
    padding: 12px 14px 9px;
    gap: 8px;
  }
  .panel-topline h1,
  .panel-topline h2 {
    font-size: 23px;
  }
  .eyebrow {
    font-size: 9px;
    margin-bottom: 4px;
  }
  .history-controls button {
    padding: 6px 8px;
    font-size: 11px;
  }
  .tree-tools {
    padding: 0 14px 4px;
    gap: 6px;
  }
  .tree-canvas {
    height: auto;
    min-height: 0;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 5px 0;
  }
  .tree-canvas svg {
    margin: auto;
  }
  .selection-strip {
    min-height: 42px;
    padding: 7px 10px;
    gap: 8px;
  }
  .selection-strip button {
    padding: 6px 7px;
    font-size: 10px;
  }
  .command-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 10px 12px;
  }
  .command-heading {
    flex-shrink: 0;
    margin-bottom: 9px;
    gap: 7px;
  }
  .command-heading h2 {
    font-size: 17px;
  }
  #command-filter {
    width: 118px;
    min-width: 0;
    padding: 6px;
  }
  #commands {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-right: 3px;
  }
  .command-group + .command-group {
    margin-top: 12px;
  }
  .command-list {
    gap: 5px;
  }
  .command-list button {
    padding: 6px 8px;
  }
  .history-panel {
    height: 100%;
    min-height: 0;
  }
  .history-scroll {
    height: 0;
    min-height: 0;
    max-height: none;
    padding: 4px 14px 12px;
  }
  .working-step {
    min-height: 60px;
    padding: 14px 0;
  }
  .history-footer {
    flex-shrink: 0;
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 6px;
  }
  .history-footer > span {
    font-size: 11px;
  }
  #notification {
    flex-shrink: 0;
    max-height: 64px;
    overflow: auto;
    margin: 0;
    padding: 8px 12px;
  }
  #context-banner {
    flex-shrink: 0;
    min-width: 0;
    margin: 0;
    padding: 9px 12px;
    gap: 12px;
  }
  #context-banner > div:first-child {
    min-width: 0;
  }
  #context-source {
    max-height: 58px;
    margin-top: 4px;
  }
  dialog {
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }
}

[hidden] {
  display: none !important;
}
.mode-summary {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  margin: 10px 0;
}
.history-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 215px;
}
.tree-panel > .panel-topline {
  flex-wrap: wrap;
}
.tree-tools {
  flex-wrap: wrap;
  gap: 6px 10px;
  padding-bottom: 6px;
}
.tree-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
.tree-zoom button {
  min-width: 27px;
  min-height: 26px;
  padding: 3px 6px;
}
#tree-scale {
  width: 35px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.tree-canvas {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.tree-canvas.panning {
  cursor: grabbing;
}
.tree-canvas svg {
  position: absolute;
  inset: 0;
  margin: 0;
}
.tree-node text {
  font-size: 14px;
}
.tree-node .tree-comment {
  font-size: 10px;
}
.tree-node:focus-visible rect {
  stroke: var(--ink);
  stroke-width: 3;
}
:fullscreen {
  background: var(--paper, #f4f5ef);
}
.action-search {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.subzone-label {
  align-self: center;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  padding: 3px;
}
.command-list + .command-list {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--rule);
}
#manage-library {
  margin-top: 8px;
  font-size: 11px;
}
#reset-settings {
  padding: 5px 10px;
  font-size: 11px;
}
#library-dialog {
  width: min(650px, calc(100vw - 28px));
}
#library-dialog > p {
  font-size: 12px;
  line-height: 1.6;
}
#library-manager-items {
  max-height: 40dvh;
  overflow: auto;
}
.library-manager-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.library-manager-row label {
  display: grid;
  gap: 4px;
  font-size: 11px;
}
.library-manager-row input {
  width: 100%;
  min-width: 0;
}
.library-manager-row button {
  padding: 8px;
}
.danger-button {
  color: #983f31;
  border-color: #dab7ad;
}
#library-manager-error {
  color: #983f31;
}
#library-delete-confirmation {
  padding: 12px;
  border: 1px solid #dab7ad;
  background: #fbefe9;
  font-size: 12px;
}
@media (min-width: 900px) and (min-height: 480px) {
  #commands {
    display: flex;
    gap: 10px;
    overflow: hidden;
  }
  .command-group {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding-right: 3px;
  }
  .command-group + .command-group {
    margin-top: 0;
    padding-left: 9px;
    border-left: 1px solid var(--rule);
  }
  .command-list button {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
