body.formal-language-tool-page #app-content > .page,
body.formal-language-tool-page #app-content .hero,
body.formal-language-tool-page .formal-language-tool-shell {
  width: 100%;
  max-width: none;
  min-width: 0;
}

body.formal-language-tool-page #app-content > .page {
  margin-inline: 0;
}

.formal-language-tool-shell {
  display: grid;
  gap: 0;
  margin-top: clamp(18px, 2.5vw, 32px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.formal-language-tool-shell [hidden] {
  display: none;
}

.formal-language-hero {
  display: grid;
  gap: 0;
  margin-bottom: var(--space-8);
  padding-bottom: clamp(18px, 2.5vw, 32px);
}

.formal-language-hero > .tool-shell {
  width: 100%;
  max-width: none;
  margin-right: 0;
  margin-bottom: 0;
  margin-left: 0;
}

.formal-language-confirmation-dialog__details,
.formal-language-automaton-reference__metadata {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.formal-language-confirmation-dialog__details dt,
.formal-language-automaton-reference__metadata dt { font-weight: 800; }
.formal-language-confirmation-dialog__details dd,
.formal-language-automaton-reference__metadata dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }

.formal-language-automaton-reference-host {
  padding: 0 clamp(16px, 2vw, 24px) clamp(16px, 2vw, 24px);
}

.formal-language-editable-import-origin,
.formal-language-editable-import-actions {
  margin-top: var(--space-3);
}

.formal-language-editable-import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.formal-language-automaton-reference {
  border: 1px solid rgba(145, 183, 244, 0.34);
  border-radius: 10px;
  background: rgba(2, 10, 23, 0.2);
}

.formal-language-automaton-reference > summary { padding: var(--space-3); cursor: pointer; font-weight: 800; }

.formal-language-automaton-reference__body,
.formal-language-automaton-reference__heading,
.formal-language-automaton-reference__grid,
.formal-language-automaton-reference__diagram,
.formal-language-automaton-reference__table { display: grid; min-width: 0; gap: var(--space-3); }

.formal-language-automaton-reference__body { padding: 0 var(--space-3) var(--space-3); }
.formal-language-automaton-reference__heading { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.formal-language-automaton-reference__heading > div > * { margin: 0; }
.formal-language-automaton-reference__grid { grid-template-columns: minmax(18rem, 1.3fr) minmax(16rem, 1fr); }
.formal-language-automaton-reference__canvas-wrap,
.formal-language-automaton-reference__table-wrap { min-width: 0; overflow: auto; border: 1px solid rgba(145, 183, 244, 0.22); border-radius: 8px; }
.formal-language-automaton-reference__canvas { display: block; min-width: 34rem; min-height: 20rem; }

@media (max-width: 760px) {
  .formal-language-automaton-reference__grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .formal-language-confirmation-dialog__details,
  .formal-language-automaton-reference__metadata { grid-template-columns: minmax(0, 1fr); }
  .formal-language-automaton-reference__heading { grid-template-columns: minmax(0, 1fr); }
  .formal-language-automaton-reference__heading .ui-button { width: 100%; }
}

.formal-language-tool-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: clamp(18px, 2.2vw, 28px) clamp(16px, 2.4vw, 30px) var(--space-3);
}

.formal-language-tool-header > * {
  margin: 0;
}

.formal-language-tool-header > .sr-only {
  grid-column: 1 / -1;
  grid-row: 1;
}

.formal-language-tool-header__eyebrow {
  color: rgba(203, 216, 238, 0.78);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.formal-language-tool-header__summary {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  color: rgba(220, 231, 249, 0.84);
  font-size: 0.95rem;
}

.formal-language-tool-header .tool-workspace-menu-mount {
  grid-column: 2;
  grid-row: 1;
  width: clamp(18rem, 26vw, 26rem);
}

.formal-language-tool-header .ui-status {
  justify-self: end;
}

.formal-language-tool-header .ui-status {
  grid-column: 1 / -1;
}

.formal-language-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 0;
}

.formal-language-workspace > * {
  min-width: 0;
}

.formal-language-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 clamp(16px, 2.4vw, 30px) var(--space-3);
  border-bottom: 1px solid rgba(145, 183, 244, 0.26);
}

.formal-language-tool-shell button.formal-language-mode-tab {
  appearance: none;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid rgba(145, 183, 244, 0.4);
  border-radius: 999px;
  background: rgba(2, 10, 23, 0.26);
  color: #dceaff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.formal-language-tool-shell button.formal-language-mode-tab[aria-selected="true"] {
  border-color: rgba(165, 210, 255, 0.9);
  background: rgba(37, 92, 166, 0.88);
  color: #fff;
}

.formal-language-tool-shell button.formal-language-mode-tab:focus-visible,
.formal-language-tool-shell button.formal-language-workflow-step:focus-visible {
  outline: 3px solid #f4d58d;
  outline-offset: 2px;
}

.formal-language-free-context {
  display: grid;
  gap: var(--space-3);
  padding: clamp(16px, 2.2vw, 26px) clamp(16px, 2.4vw, 30px) 0;
}

.formal-language-free-entry,
.formal-language-workspace-summary {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid rgba(145, 183, 244, 0.3);
  border-radius: 12px;
  background: rgba(5, 20, 43, 0.5);
}

.formal-language-free-entry > div > *,
.formal-language-workspace-summary__header > * {
  margin: 0;
}

.formal-language-free-entry h2,
.formal-language-workspace-summary h2 {
  font-size: clamp(1.08rem, 1.6vw, 1.3rem);
}

.formal-language-context-label {
  color: rgba(195, 219, 248, 0.8);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.formal-language-free-entry__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}

.formal-language-free-entry__actions .ui-form-group {
  flex: 1 1 16rem;
  margin: 0;
}

.formal-language-free-entry__actions .ui-button {
  flex: 0 1 auto;
}

.formal-language-workspace-summary__header {
  display: grid;
  gap: 3px;
}

.formal-language-workspace-summary__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px 16px;
  margin: 0;
}

.formal-language-workspace-summary__list dt {
  color: rgba(195, 219, 248, 0.76);
  font-size: 0.78rem;
  font-weight: 800;
}

.formal-language-workspace-summary__list dd {
  min-width: 0;
  margin: 2px 0 0;
  overflow: hidden;
  color: #f1f6ff;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formal-language-workspace[data-ui-mode="free"] > .formal-language-task-area,
.formal-language-workspace[data-ui-mode="free"] > .formal-language-task-rail {
  display: none;
}

.formal-language-workspace[data-ui-mode="free"][data-free-entry-visible="true"] > .formal-language-interaction-area,
.formal-language-workspace[data-ui-mode="free"][data-free-entry-visible="true"] > .formal-language-evaluation-area {
  display: none;
}

.formal-language-workspace[data-ui-mode="tasks"] > .formal-language-free-context {
  display: none;
}

.formal-language-workspace[data-ui-mode="tasks"][data-workspace-mode="free"] > .formal-language-interaction-area,
.formal-language-workspace[data-ui-mode="tasks"][data-workspace-mode="free"] > .formal-language-evaluation-area {
  display: none;
}

.formal-language-workspace[data-ui-mode="tasks"][data-workspace-mode="free"] > .formal-language-task-area {
  display: grid;
}

.formal-language-interaction-area {
  container-type: inline-size;
}

.formal-language-workflow-navigation {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.formal-language-tool-shell button.formal-language-workflow-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid rgba(145, 183, 244, 0.3);
  border-radius: 9px;
  background: rgba(3, 13, 29, 0.34);
  color: #e9f2ff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: left;
}

.formal-language-tool-shell button.formal-language-workflow-step > span {
  display: grid;
  grid-row: span 2;
  width: 1.6rem;
  height: 1.6rem;
  place-items: center;
  border-radius: 999px;
  background: rgba(145, 183, 244, 0.2);
  font-size: 0.8rem;
}

.formal-language-tool-shell button.formal-language-workflow-step small {
  grid-column: 2;
  overflow: hidden;
  color: rgba(207, 224, 248, 0.75);
  font-size: 0.76rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formal-language-tool-shell button.formal-language-workflow-step[aria-pressed="true"] {
  border-color: rgba(162, 208, 255, 0.8);
  background: rgba(37, 92, 166, 0.6);
}

.formal-language-tool-shell button.formal-language-workflow-step[aria-pressed="true"] > span {
  background: #d8ebff;
  color: #09264a;
}

.formal-language-representation-choice {
  display: grid;
  grid-template-columns: minmax(0, 15rem);
  gap: 4px;
}

.formal-language-representation-choice[hidden] {
  display: none;
}

@container (max-width: 58rem) {
  .formal-language-workflow-navigation {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (max-width: 34rem) {
  .formal-language-workflow-navigation {
    grid-template-columns: minmax(0, 1fr);
  }
}

.formal-language-task-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--space-4);
  padding: clamp(16px, 2vw, 24px);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(145, 183, 244, 0.24);
  box-shadow: inset 0 -1px 0 rgba(210, 231, 255, 0.06);
}

.formal-language-task-area > h2,
.formal-language-task-selectors,
.formal-language-activity-description,
.formal-language-task-help,
.formal-language-task-actions,
.formal-language-task-progress {
  grid-column: 1 / -1;
}

.formal-language-task-selectors {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-3);
}

.formal-language-task-selectors .ui-form-group {
  min-width: 0;
  margin: 0;
}

.formal-language-task-selectors #formal-language-start-task {
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  white-space: nowrap;
}

.formal-language-task-selectors #formal-language-start-task[hidden] {
  display: none;
}

.formal-language-task-module__body {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.formal-language-task-module__body > * {
  min-width: 0;
}

.formal-language-interaction-area,
.formal-language-evaluation-area {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
  padding: clamp(16px, 2vw, 24px);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-evaluation-area {
  background: rgba(2, 10, 23, 0.18);
}

.formal-language-evaluation-area[data-diagnostic-empty="true"] {
  gap: var(--space-2);
  padding-block: var(--space-3);
}

.formal-language-evaluation-area[data-diagnostic-empty="true"] .formal-language-area-eyebrow,
.formal-language-evaluation-area[data-diagnostic-empty="true"] h2 {
  display: none;
}

.formal-language-area-header {
  display: grid;
  gap: 4px;
}

.formal-language-area-header > * {
  margin: 0;
}

.formal-language-area-header h2,
.formal-language-task-area > h2 {
  font-size: clamp(1.2rem, 1.6vw, 1.45rem);
}

.formal-language-area-eyebrow {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.formal-language-activity-description {
  display: grid;
  gap: 8px;
}

.formal-language-activity-description > * {
  margin: 0;
}

.formal-language-activity-description h3 {
  font-size: clamp(1.15rem, 1.6vw, 1.4rem);
}

.formal-language-task-brief__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.formal-language-task-brief__meta span {
  padding: 3px 8px;
  border: 1px solid rgba(145, 183, 244, 0.38);
  border-radius: 999px;
  color: rgba(220, 231, 249, 0.9);
  font-size: 0.8rem;
  font-weight: 700;
}

.formal-language-task-brief__instruction {
  max-width: none;
  text-align: justify;
  hyphens: auto;
}

.formal-language-task-brief__label,
.formal-language-task-brief__criteria-title {
  color: rgba(220, 231, 249, 0.9);
  font-size: 0.9rem;
  font-weight: 800;
}

.formal-language-task-brief__criteria {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 1.25rem;
}

.formal-language-task-help {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.formal-language-task-help[hidden] {
  display: none;
}

.formal-language-editor-controls[hidden] {
  display: none;
}

.formal-language-task-actions,
.formal-language-editor-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}

.formal-language-task-actions {
  justify-content: flex-start;
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-task-actions > .ui-button {
  box-sizing: border-box;
  max-width: 100%;
}

.formal-language-task-actionbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-task-actionbar[hidden] {
  display: none;
}

.formal-language-task-surface-label {
  margin: 0;
  color: rgba(220, 231, 249, 0.86);
  font-weight: 700;
}

.formal-language-task-progress {
  margin: 0;
  color: rgba(220, 231, 249, 0.84);
  font-weight: 700;
}

.formal-language-task-progress[hidden],
.formal-language-task-input-host[hidden] {
  display: none;
}

.formal-language-task-actions > [hidden] {
  display: none;
}

.formal-language-editor-controls {
  padding: 0 0 var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-editor-controls .ui-form-group {
  flex: 1 1 min(100%, 18rem);
  margin: 0;
}

.formal-language-representation-tabs {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 4px;
  border: 1px solid rgba(145, 183, 244, 0.38);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(10, 29, 62, 0.96), rgba(4, 14, 32, 0.96));
  box-shadow: inset 0 1px 0 rgba(210, 231, 255, 0.06);
  scrollbar-width: thin;
}

.formal-language-tool-shell button.formal-language-representation-tab {
  appearance: none;
  position: relative;
  flex: 1 1 0;
  min-width: 10rem;
  min-height: 42px;
  padding: 7px 12px;
  border: 0;
  border-left: 1px solid rgba(145, 183, 244, 0.24);
  border-radius: 7px;
  background: transparent;
  color: #dceaff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.formal-language-tool-shell button.formal-language-representation-tab:first-child {
  border-left: 0;
}

.formal-language-tool-shell button.formal-language-representation-tab:hover:not([aria-selected="true"]) {
  background: rgba(72, 117, 181, 0.22);
}

.formal-language-tool-shell button.formal-language-representation-tab[aria-selected="true"] {
  color: #ffffff;
  background: rgba(32, 82, 151, 0.92);
  box-shadow: inset 0 -3px 0 #d8ebff;
}

.formal-language-tool-shell button.formal-language-representation-tab:focus-visible {
  outline: 3px solid #f4d58d;
  outline-offset: 2px;
}

.formal-language-representation-shell {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.formal-language-representation-shell__header,
.formal-language-section-heading {
  display: grid;
  gap: 4px;
}

.formal-language-representation-shell__header {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-representation-shell__header > *,
.formal-language-section-heading > * {
  margin: 0;
}

.formal-language-representation-shell__header h3 {
  font-size: 1.12rem;
}

.formal-language-representation-shell__header p,
.formal-language-section-heading + p {
  color: rgba(220, 231, 249, 0.84);
}

.formal-language-representation-shell__body {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.formal-language-representation-shell__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-representation-shell__actions > .ui-button[hidden] {
  display: none;
}

.formal-language-activity-toolbar #formal-language-representation-return[hidden] {
  display: none;
}

.formal-language-language-definition,
.formal-language-test-words {
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-language-definition__header,
.formal-language-test-words__header {
  display: grid;
  gap: 4px;
}

.formal-language-language-definition__header > *,
.formal-language-test-words__header > * {
  margin: 0;
}

.formal-language-language-definition__header h4,
.formal-language-test-words__header h4 {
  font-size: 1.05rem;
}

.formal-language-language-definition__grid {
  display: grid;
  grid-template-columns: minmax(0, 34rem) minmax(14rem, 20rem);
  align-items: start;
  gap: var(--space-4);
}

@container (min-width: 70rem) {
  #formal-language-panel-words .formal-language-representation-shell__body {
    grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.75fr);
    align-items: start;
  }

  #formal-language-panel-words .formal-language-language-definition {
    grid-column: 1;
  }

  #formal-language-panel-words .formal-language-test-words {
    grid-column: 2;
    grid-row: 1;
    margin-top: var(--space-4);
    padding: var(--space-3);
    border: 1px solid rgba(145, 183, 244, 0.26);
    border-radius: 10px;
    background: rgba(2, 10, 23, 0.18);
  }

  #formal-language-panel-words .formal-language-language-details,
  #formal-language-panel-words .formal-language-description-accordion {
    grid-column: 1 / -1;
  }
}

.formal-language-language-definition__grid > * {
  min-width: 0;
  margin: 0;
}

.formal-language-language-context {
  display: grid;
  gap: 6px;
  padding-left: var(--space-4);
  border-left: 2px solid rgba(145, 183, 244, 0.42);
}

.formal-language-language-context > * {
  margin: 0;
}

.formal-language-language-context__label {
  color: rgba(203, 216, 238, 0.78);
  font-size: 0.82rem;
  font-weight: 700;
}

.formal-language-canonical-notation {
  color: #eaf2ff;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 1.05rem;
  font-weight: 700;
}

.formal-language-test-words {
  display: grid;
}

.formal-language-test-words .ui-form-group {
  margin: 0;
}

.formal-language-description-accordion {
  width: 100%;
  max-width: none;
  margin-top: var(--space-4);
}

.formal-language-description-accordion[hidden] {
  display: none;
}

.formal-language-description-accordion summary {
  cursor: pointer;
}

.formal-language-description-accordion .subaccordion-title {
  display: grid;
  gap: 3px;
}

.formal-language-description-accordion .subaccordion-title > * {
  margin: 0;
}

.formal-language-description-accordion .subaccordion-title p {
  color: rgba(203, 216, 238, 0.78);
  font-size: 0.9rem;
}

.formal-language-grammar-definition {
  display: grid;
  gap: var(--space-3);
}

.formal-language-grammar-definition__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: var(--space-4);
}

.formal-language-grammar-definition__grid > * {
  min-width: 0;
}

.formal-language-grammar-disclosure {
  width: 100%;
  max-width: none;
}

.formal-language-grammar-disclosure[hidden] {
  display: none;
}

.formal-language-grammar-disclosure .subaccordion-body {
  display: grid;
  gap: var(--space-3);
}

.formal-language-grammar-disclosure .ui-form-group {
  margin: 0;
}

.formal-language-active-grammar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border-left: 3px solid rgba(145, 183, 244, 0.58);
  background: rgba(255, 255, 255, 0.035);
}

.formal-language-active-grammar > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.formal-language-active-grammar__label {
  margin: 0;
  color: rgba(203, 216, 238, 0.78);
  font-size: 0.82rem;
  font-weight: 800;
}

.formal-language-active-grammar__notation {
  color: #eaf2ff;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.formal-language-task-disclosure {
  min-width: 0;
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-task-disclosure summary {
  cursor: pointer;
  font-weight: 700;
}

.formal-language-task-disclosure > div {
  margin-top: 10px;
}

.formal-language-task-disclosure p {
  margin: 0;
}

.formal-language-materials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  align-items: start;
  gap: var(--space-3);
}

.formal-language-material {
  min-width: 0;
  padding: var(--space-3);
  border-left: 3px solid rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.045);
}

.formal-language-material[data-material-role="reference"] {
  border-left-color: rgba(255, 255, 255, 0.22);
  background: transparent;
}

.formal-language-material__header {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
}

.formal-language-material__header h3,
.formal-language-material__header p,
.formal-language-material__body > * {
  margin: 0;
}

.formal-language-material__header h3 {
  font-size: 1rem;
}

.formal-language-material__role {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.formal-language-material__body {
  display: grid;
  gap: 8px;
  overflow-wrap: anywhere;
}

.formal-language-material__body ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 1.2rem;
}

.formal-language-material__body pre {
  margin: 0;
  white-space: pre-wrap;
}

.formal-language-task-input {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  padding: var(--space-4);
  border-left: 3px solid rgba(244, 213, 141, 0.78);
  background: rgba(244, 213, 141, 0.07);
}

.formal-language-task-input > h3,
.formal-language-task-input p {
  margin: 0;
}

.formal-language-classification-response,
.formal-language-binary-comparison {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.formal-language-classification-response__reasons {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(145, 183, 244, 0.3);
}

.formal-language-classification-response__reasons > h4 {
  margin: 0;
}

.formal-language-task-surface-layout {
  display: grid;
  grid-template-columns: minmax(17rem, 0.85fr) minmax(0, 1.15fr);
  align-items: start;
  gap: var(--space-3);
}

.formal-language-task-surface-layout[data-spatial-profile="comparison"] {
  grid-template-columns: minmax(0, 1fr);
}

.formal-language-task-surface-layout__source,
.formal-language-task-surface-layout__response {
  display: grid;
  min-width: 0;
  gap: var(--space-2);
}

.formal-language-task-surface-layout__source > h3,
.formal-language-task-surface-layout__response > h3,
.formal-language-response-group > header > * {
  margin: 0;
}

.formal-language-task-surface-layout__source > h3,
.formal-language-task-surface-layout__response > h3 {
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d8ebff;
}

.formal-language-task-surface-layout .formal-language-materials {
  display: grid;
  min-width: 0;
  gap: var(--space-2);
}

.formal-language-task-surface-layout[data-spatial-profile="comparison"] .formal-language-materials {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.formal-language-task-surface-layout[data-spatial-profile="comparison"][data-source-count="3"] .formal-language-materials {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.formal-language-task-surface-layout .formal-language-material {
  margin: 0;
  min-height: 0;
}

.formal-language-task-surface-layout .formal-language-material__body {
  max-height: min(42vh, 30rem);
  overflow: auto;
}

.formal-language-response-groups {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.formal-language-response-group {
  display: grid;
  min-width: 0;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.34);
  border-radius: 8px;
  background: rgba(5, 15, 31, 0.22);
}

.formal-language-response-group > header {
  display: grid;
  gap: 4px;
}

.formal-language-response-group > header h4 {
  font-size: 1rem;
}

.formal-language-response-group > header p,
.formal-language-task-derivation-builder .formal-language-note {
  color: #c8d8ed;
  font-size: 0.9rem;
}

.formal-language-response-group__fields {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  align-items: start;
}

.formal-language-response-group[data-response-group-layout="grid"] .formal-language-response-group__fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.formal-language-response-group .ui-select {
  align-self: start;
  min-height: 2.75rem;
}

.formal-language-task-derivation-builder,
.formal-language-derivation-set__builder {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.formal-language-task-derivation-builder .derivation-builder {
  padding: var(--space-3);
  border: 1px solid rgba(244, 213, 141, 0.52);
  border-radius: 8px;
  background: rgba(5, 15, 31, 0.3);
}

.formal-language-task-derivation-builder__advanced {
  display: grid;
  gap: var(--space-2);
}

.formal-language-task-derivation-builder__advanced summary {
  cursor: pointer;
}

@media (max-width: 1100px) {
  .formal-language-task-surface-layout,
  .formal-language-task-surface-layout[data-spatial-profile="comparison"],
  .formal-language-task-surface-layout[data-spatial-profile="comparison"][data-source-count="3"] .formal-language-materials,
  .formal-language-response-group[data-response-group-layout="grid"] .formal-language-response-group__fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-task-surface-layout .formal-language-material__body {
    max-height: none;
  }
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-interaction-area {
  gap: var(--space-3);
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-evaluation-area {
  padding: var(--space-4) 0 0;
  border-top: 0;
  background: transparent;
}

.formal-language-task-input__grid,
.formal-language-derivation-set__rows {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.formal-language-task-input__grid--wide {
  margin-top: var(--space-3);
}

.formal-language-task-input .ui-form-group,
.formal-language-derivation-set__row .ui-form-group {
  min-width: 0;
  margin: 0;
}

.formal-language-derivation-set {
  display: grid;
  gap: var(--space-3);
}

.formal-language-derivation-set__row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(9rem, 0.35fr) minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.3);
  background: rgba(5, 15, 31, 0.28);
}

[data-formal-language-editable-field][hidden],
[data-formal-language-derived-control][hidden] {
  display: none;
}

.formal-language-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: var(--space-4);
}

.formal-language-field-grid > * {
  min-width: 0;
}

.formal-language-field--wide {
  grid-column: 1 / -1;
}

.formal-language-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: var(--space-4);
}

.formal-language-actions > .ui-button[hidden] {
  display: none;
}

[data-formal-language-surface][hidden],
[data-formal-language-input-mode][hidden],
[data-formal-language-evaluation-surface][hidden],
.formal-language-materials[hidden],
.formal-language-task-disclosure[hidden] {
  display: none;
}

.formal-language-output,
.formal-language-derivation,
.formal-language-table td,
.formal-language-table th,
.formal-language-note {
  min-width: 0;
  overflow-wrap: anywhere;
}

.formal-language-output {
  display: grid;
  gap: 10px;
}

.formal-language-output > * {
  margin: 0;
}

.formal-language-output pre,
.formal-language-derivation code {
  max-width: 100%;
  white-space: pre-wrap;
}

.regular-expression-workspace {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.regular-expression-workspace__section {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.regular-expression-workspace__section > * {
  margin: 0;
}

.regular-expression-workspace__alphabet-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.regular-expression-workspace__alphabet-row .formal-language-canonical-notation {
  margin: 0;
}

.regular-expression-workspace__structure summary {
  cursor: pointer;
}

.regular-expression-workspace__tree,
.regular-expression-workspace__tree ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.2rem;
}

.regular-expression-workspace__tree li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.regular-expression-workspace__tree li.is-match-active,
.regular-expression-workspace__tree li.is-failure-frontier {
  padding: 3px 6px;
  border-left: 3px solid #f4d58d;
  background: rgba(244, 213, 141, 0.16);
}

.regular-expression-workspace__tree li.is-match-current {
  outline: 2px solid #d8ebff;
  outline-offset: 2px;
}

.regular-expression-workspace__result-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d8ebff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.regular-expression-workspace__result-button[aria-current="true"] {
  color: #ffffff;
  text-decoration-color: #f4d58d;
}

.regular-expression-workspace__result-button:focus-visible {
  outline: 3px solid #f4d58d;
  outline-offset: 3px;
}

.regular-expression-workspace__detail {
  display: grid;
  gap: 8px;
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.regular-expression-workspace__detail > * {
  margin: 0;
}

.regular-expression-workspace__detail ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.3rem;
}

.formal-language-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.formal-language-table th,
.formal-language-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.formal-language-table th {
  color: rgba(255, 255, 255, 0.84);
  font-weight: 700;
}

.formal-language-table th:first-child,
.formal-language-table td:first-child {
  width: 22%;
}

.formal-language-table th:nth-child(2),
.formal-language-table td:nth-child(2) {
  width: 27%;
}

.formal-language-evaluation-section {
  display: grid;
  gap: 8px;
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-evaluation-section h3,
.formal-language-evaluation-section p {
  margin: 0;
}

.formal-language-derivation {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.formal-language-derivation li {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.formal-language-derivation-builder {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.formal-language-derivation-builder[hidden] {
  display: none;
}

.derivation-builder,
.derivation-builder__start,
.derivation-builder__forms,
.derivation-builder__history,
.derivation-builder__tree {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.3);
  border-radius: 10px;
  background: rgba(4, 15, 33, 0.3);
}

.derivation-builder > header,
.derivation-builder__start > *,
.derivation-builder__forms header > *,
.derivation-builder__history > *,
.derivation-builder__tree header > * {
  margin: 0;
}

.derivation-builder__forms-layout,
.derivation-builder__split,
.derivation-builder__tree-layout {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.derivation-builder__split {
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
}

.derivation-builder__tree-layout {
  grid-template-columns: minmax(0, 1.3fr) minmax(15rem, 0.7fr);
}

.derivation-builder__forms-layout {
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.55fr);
}

.derivation-builder__forms.is-visually-secondary {
  background: rgba(255, 255, 255, 0.02);
}

.derivation-builder__tokens {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-height: 3rem;
  padding: 10px;
  border: 1px solid rgba(145, 183, 244, 0.22);
  border-radius: 7px;
  background: rgba(1, 11, 26, 0.52);
}

.derivation-builder__token {
  display: inline-grid;
  min-width: 2.15rem;
  min-height: 2.15rem;
  place-items: center;
  padding: 3px 7px;
  border: 1px solid rgba(203, 216, 238, 0.62);
  border-radius: 999px;
  color: #eaf2ff;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-weight: 750;
}

.derivation-builder__token--nonterminal {
  border-radius: 5px;
  background: rgba(27, 70, 125, 0.8);
}

.derivation-builder__token--terminal {
  background: rgba(69, 97, 144, 0.64);
}

.derivation-builder__token--epsilon {
  border-radius: 2px;
  background: rgba(87, 72, 127, 0.78);
}

.derivation-builder__token.is-active {
  border: 3px solid #f4d58d;
  outline: 2px dashed #f4d58d;
  outline-offset: 2px;
}

.derivation-builder__productions {
  display: grid;
  gap: 9px;
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.derivation-builder__productions h5,
.derivation-builder__productions p {
  margin: 0;
}

.derivation-builder__productions > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 9px;
}

.derivation-builder__productions .ui-button {
  min-height: 2.75rem;
  text-align: left;
}

.derivation-builder__history ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 1.4rem;
}

.derivation-builder__history li {
  overflow-wrap: anywhere;
}

.derivation-builder__history code {
  margin-right: 5px;
}

.derivation-builder__tree .derivation-tree-preview__canvas {
  min-height: 12rem;
}

.formal-language-manual-sequence-editor {
  width: 100%;
  max-width: none;
}

.syntax-diagram-workspace {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.derivation-tree-workspace {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.derivation-tree-active-grammar,
.derivation-tree-controls,
.derivation-tree-structure,
.derivation-tree-preview,
.derivation-tree-draft {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.26);
  border-radius: 10px;
  background: rgba(4, 15, 33, 0.3);
}

.derivation-tree-active-grammar header > *,
.derivation-tree-controls header > *,
.derivation-tree-structure header > *,
.derivation-tree-preview header > *,
.derivation-tree-draft > * {
  margin: 0;
}

.derivation-tree-active-grammar code {
  max-height: 12rem;
  overflow: auto;
  white-space: pre-wrap;
}

.derivation-tree-workspace__split {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr);
  align-items: start;
  gap: clamp(18px, 2.5vw, 32px);
}

.derivation-tree-node-list,
.derivation-tree-node-list__children {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.derivation-tree-node-list {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.derivation-tree-node-list__children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 2px solid rgba(145, 183, 244, 0.28);
}

.derivation-tree-node-list__select {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(145, 183, 244, 0.42);
  border-radius: 6px;
  background: rgba(38, 82, 143, 0.3);
  color: #eaf2ff;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.derivation-tree-node-list__row,
.syntax-diagram-rule-manager__header,
.syntax-diagram-selection-inspector > header,
.derivation-tree-node-actions > header,
.syntax-context-surface > header,
.tree-context-surface > header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.derivation-tree-node-list__item.is-selected .derivation-tree-node-list__select,
.derivation-tree-node-list__select:focus-visible {
  border-color: #f4d58d;
  outline: 3px solid #f4d58d;
  outline-offset: 2px;
}

.derivation-tree-node-list__select span {
  color: rgba(220, 231, 249, 0.78);
  font-size: 0.88rem;
}

.derivation-tree-node-list__select code {
  margin-left: auto;
}

.derivation-tree-node-actions,
.derivation-tree-production-actions {
  display: grid;
  gap: 8px;
}

.derivation-tree-node-actions h5,
.derivation-tree-node-actions p {
  margin: 0;
}

.derivation-tree-production-actions {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.derivation-tree-preview__canvas {
  min-width: 0;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(145, 183, 244, 0.2);
  border-radius: 7px;
  background: rgba(1, 11, 26, 0.52);
}

.derivation-tree-empty-state,
.syntax-diagram-empty-state {
  display: grid;
  min-height: 13rem;
  align-content: center;
  justify-items: start;
  gap: var(--space-3);
  padding: clamp(18px, 4vw, 36px);
  border: 1px dashed rgba(145, 183, 244, 0.56);
  border-radius: 8px;
  background: rgba(8, 30, 61, 0.36);
}

.derivation-tree-empty-state h5,
.derivation-tree-empty-state p,
.syntax-diagram-empty-state p {
  margin: 0;
}

.derivation-tree-empty-state .ui-button,
.syntax-diagram-empty-state .ui-button {
  width: auto;
}

.derivation-tree-svg {
  display: block;
  min-width: 24rem;
  width: 100%;
  height: auto;
  font-family: inherit;
}

.derivation-tree-svg .derivation-tree-edge line {
  stroke: rgba(188, 218, 255, 0.78);
  stroke-width: 2;
}

.derivation-tree-svg .derivation-tree-node rect,
.derivation-tree-svg .derivation-tree-node ellipse,
.derivation-tree-svg .derivation-tree-node polygon {
  fill: rgba(27, 70, 125, 0.94);
  stroke: #d8ebff;
  stroke-width: 2;
}

.derivation-tree-svg .derivation-tree-terminal ellipse {
  fill: rgba(69, 97, 144, 0.92);
}

.derivation-tree-svg .derivation-tree-epsilon polygon {
  fill: rgba(87, 72, 127, 0.94);
}

.derivation-tree-svg .derivation-tree-node.is-unexpanded rect {
  stroke-dasharray: 6 4;
}

.derivation-tree-svg .derivation-tree-node.is-selected rect,
.derivation-tree-svg .derivation-tree-node.is-selected ellipse,
.derivation-tree-svg .derivation-tree-node.is-selected polygon {
  stroke: #fff4bc;
  stroke-width: 4;
}

.derivation-tree-svg .derivation-tree-node.is-invalid rect,
.derivation-tree-svg .derivation-tree-node.is-invalid ellipse,
.derivation-tree-svg .derivation-tree-node.is-invalid polygon {
  stroke: #ff9d9d;
  stroke-width: 4;
}

.derivation-tree-svg .derivation-tree-node.is-incomplete text {
  text-decoration: underline;
}

.derivation-tree-svg text {
  fill: #f6f9ff;
  font-weight: 700;
}

.derivation-tree-svg .derivation-tree-node:focus-visible rect,
.derivation-tree-svg .derivation-tree-node:focus-visible ellipse,
.derivation-tree-svg .derivation-tree-node:focus-visible polygon {
  stroke: #f4d58d;
  stroke-width: 4;
}

.derivation-tree-description pre {
  overflow: auto;
  white-space: pre;
}

.derivation-tree-draft.is-valid {
  border-color: rgba(112, 216, 170, 0.62);
}

.derivation-tree-draft.is-invalid {
  border-color: rgba(255, 157, 157, 0.62);
}

.syntax-diagram-rule-manager,
.syntax-diagram-structure,
.syntax-diagram-preview,
.syntax-diagram-word-check {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.syntax-diagram-rule-manager {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.syntax-diagram-rule-manager h4,
.syntax-diagram-structure header > *,
.syntax-diagram-preview header > * {
  margin: 0;
}

.syntax-diagram-rule-manager__header .formal-language-eyebrow {
  margin: 0 0 3px;
}

.syntax-diagram-rule-manager__controls,
.syntax-diagram-rule-manager__actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
}

.syntax-diagram-rule-manager .ui-form-group {
  flex: 1 1 min(100%, 12rem);
  min-width: 0;
  margin: 0;
}

.syntax-diagram-workspace__split {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.15fr);
  align-items: start;
  gap: clamp(18px, 2.5vw, 32px);
}

.syntax-diagram-structure,
.syntax-diagram-preview,
.syntax-diagram-word-check {
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.26);
  border-radius: 10px;
  background: rgba(4, 15, 33, 0.3);
}

.syntax-diagram-builder {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.syntax-diagram-add-menu,
.syntax-diagram-add-menu > div,
.syntax-diagram-empty-state > div,
.syntax-diagram-empty-state details > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.syntax-diagram-add-menu {
  align-items: start;
  padding: 10px;
  border: 1px solid rgba(145, 183, 244, 0.34);
  border-radius: 8px;
  background: rgba(8, 30, 61, 0.5);
}

.syntax-diagram-add-menu details,
.syntax-diagram-empty-state details {
  width: 100%;
}

.syntax-diagram-add-menu summary,
.syntax-diagram-empty-state summary {
  cursor: pointer;
  color: rgba(220, 231, 249, 0.9);
  font-weight: 700;
}

.syntax-diagram-builder .ui-button,
.syntax-diagram-tree__actions .ui-button {
  min-height: 34px;
  padding: 5px 8px;
  font-size: 0.86rem;
}

.syntax-diagram-tree {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.syntax-diagram-tree__node {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding-left: 10px;
  border-left: 2px solid rgba(145, 183, 244, 0.28);
}

.syntax-diagram-tree__node.is-selected {
  border-left-color: #f4d58d;
}

.syntax-diagram-tree__row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.syntax-diagram-tree__select {
  appearance: none;
  min-height: 34px;
  border: 1px solid rgba(145, 183, 244, 0.42);
  border-radius: 6px;
  background: rgba(38, 82, 143, 0.3);
  color: #eaf2ff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.syntax-diagram-tree__select:focus-visible,
.syntax-diagram-tree .ui-input:focus-visible,
.syntax-diagram-tree .ui-select:focus-visible {
  outline: 3px solid #f4d58d;
  outline-offset: 2px;
}

.syntax-diagram-tree__children {
  display: grid;
  min-width: 0;
  gap: 8px;
  margin-left: 10px;
}

.syntax-diagram-selection-inspector,
.syntax-context-surface,
.tree-context-surface {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(244, 213, 141, 0.55);
  border-radius: 8px;
  background: rgba(34, 54, 88, 0.48);
}

.syntax-diagram-selection-inspector h5,
.syntax-context-surface h5,
.syntax-context-surface h6,
.tree-context-surface h6,
.derivation-tree-node-actions h5 {
  margin: 0;
}

.syntax-context-surface__group,
.tree-context-surface__group {
  display: grid;
  gap: 7px;
}

.syntax-context-surface .is-destructive,
.tree-context-surface .is-destructive {
  border-color: rgba(255, 157, 157, 0.75);
  color: #ffe0e0;
}

.syntax-diagram-preview__canvas {
  min-width: 0;
  overflow: auto;
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.3);
  border-radius: 8px;
  background: radial-gradient(circle at top left, rgba(49, 100, 167, 0.18), transparent 48%), #07172f;
}

.syntax-diagram-svg {
  display: block;
  width: 100%;
  min-width: 28rem;
  height: auto;
  color: #eaf2ff;
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 15px;
}

.syntax-diagram-svg .syntax-diagram-node ellipse,
.syntax-diagram-svg .syntax-diagram-node rect {
  fill: rgba(27, 70, 125, 0.94);
  stroke: #d8ebff;
  stroke-width: 2;
}

.syntax-diagram-svg .syntax-diagram-hitarea {
  fill: transparent !important;
  stroke: transparent !important;
  pointer-events: all;
}

.syntax-diagram-svg .syntax-diagram-node,
.syntax-diagram-svg .syntax-diagram-epsilon,
.syntax-diagram-svg .syntax-diagram-optional-label,
.syntax-diagram-svg .syntax-diagram-repeat-label {
  cursor: pointer;
}

.syntax-diagram-svg .syntax-diagram-node.is-selected ellipse,
.syntax-diagram-svg .syntax-diagram-node.is-selected rect {
  stroke: #fff4bc;
  stroke-width: 4;
}

.syntax-diagram-svg .syntax-diagram-node:focus-visible ellipse,
.syntax-diagram-svg .syntax-diagram-node:focus-visible rect,
.syntax-diagram-svg .syntax-diagram-optional-label:focus-visible text,
.syntax-diagram-svg .syntax-diagram-repeat-label:focus-visible text {
  stroke: #f4d58d;
  stroke-width: 3;
}

.syntax-diagram-svg .syntax-diagram-terminal ellipse {
  fill: rgba(69, 97, 144, 0.92);
}

.syntax-diagram-svg .syntax-diagram-nonterminal rect {
  fill: rgba(11, 45, 87, 0.94);
}

.syntax-diagram-svg text {
  fill: #f6f9ff;
  font-weight: 700;
}

.syntax-diagram-svg .syntax-diagram-optional-bypass,
.syntax-diagram-svg .syntax-diagram-repeat-bypass {
  stroke: #f4d58d;
  stroke-dasharray: 5 4;
}

.syntax-diagram-svg .syntax-diagram-repeat-loop {
  stroke: #a9d7ff;
}

.syntax-diagram-svg .syntax-diagram-entry-marker,
.syntax-diagram-svg .syntax-diagram-exit-marker {
  fill: none;
  stroke: #f4d58d;
  stroke-width: 3;
}

.syntax-diagram-svg .syntax-diagram-epsilon text,
.syntax-diagram-svg .syntax-diagram-optional-label text,
.syntax-diagram-svg .syntax-diagram-repeat-label text {
  fill: #f4d58d;
  font-size: 12px;
}

.syntax-diagram-svg .is-trace-active ellipse,
.syntax-diagram-svg .is-trace-active rect,
.syntax-diagram-svg .syntax-diagram-path.is-trace-active {
  stroke: #f4d58d;
  stroke-width: 3;
}

.syntax-diagram-svg .is-trace-consumed ellipse,
.syntax-diagram-svg .is-trace-consumed rect {
  fill: rgba(104, 165, 226, 0.96);
}

.syntax-diagram-svg .is-trace-current ellipse,
.syntax-diagram-svg .is-trace-current rect,
.syntax-diagram-svg .syntax-diagram-path.is-trace-current {
  stroke: #fff4bc;
  stroke-width: 4;
  stroke-dasharray: 8 3;
}

.syntax-diagram-svg .is-trace-alternative text {
  text-decoration: underline;
}

.syntax-diagram-svg .is-trace-failure-frontier ellipse,
.syntax-diagram-svg .is-trace-failure-frontier rect,
.syntax-diagram-svg .syntax-diagram-path.is-trace-failure-frontier {
  stroke: #ff9d9d;
  stroke-width: 4;
  stroke-dasharray: 4 3;
}

.syntax-diagram-svg .is-trace-failure-frontier text {
  fill: #ffd0d0;
  text-decoration: underline;
}

.syntax-diagram-description {
  width: 100%;
  max-width: none;
}

.syntax-diagram-description summary {
  cursor: pointer;
  font-weight: 700;
}

.syntax-diagram-word-check {
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.32);
  border-radius: 10px;
  background: rgba(4, 15, 33, 0.3);
}

.syntax-diagram-word-check header > * {
  margin: 0;
}

.syntax-diagram-word-check .ui-form-group {
  margin: 0;
}

.syntax-diagram-word-check__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.syntax-diagram-word-results.is-stale {
  opacity: 0.62;
}

.syntax-diagram-word-result__select {
  appearance: none;
  width: 100%;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #eaf2ff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.syntax-diagram-word-results tr.is-selected .syntax-diagram-word-result__select {
  border-color: #f4d58d;
  background: rgba(244, 213, 141, 0.14);
}

.syntax-diagram-word-result__select:focus-visible {
  outline: 3px solid #f4d58d;
  outline-offset: 2px;
}

.formal-language-derivation code {
  font-size: 1rem;
}

.formal-language-transformation-relationship {
  margin: var(--space-3) 0 0;
}

.formal-language-transformation-workspace {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid rgba(145, 183, 244, 0.34);
  border-radius: 12px;
  background: rgba(4, 15, 33, 0.32);
}

.formal-language-transformation-workspace__header,
.formal-language-transformation-card,
.formal-language-transformation-generated,
.formal-language-transformation-diagnostics,
.formal-language-transformation-mappings {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.formal-language-transformation-workspace__stages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.formal-language-transformation-workspace__stages .ui-button[aria-current="step"] {
  border-color: rgba(115, 240, 191, 0.82);
  box-shadow: inset 0 0 0 1px rgba(115, 240, 191, 0.34);
}

.formal-language-transformation-details {
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.formal-language-transformation-details > summary {
  cursor: pointer;
  font-weight: 800;
}

.formal-language-transformation-details > .formal-language-transformation-diagnostics,
.formal-language-transformation-details > .formal-language-transformation-mappings {
  margin-top: var(--space-3);
}

.formal-language-transformation-workspace__header > *,
.formal-language-transformation-card header > *,
.formal-language-transformation-generated > *,
.formal-language-transformation-diagnostics > *,
.formal-language-transformation-mappings header > * {
  margin: 0;
}

.formal-language-transformation-workspace__compare {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(18px, 2.5vw, 32px);
}

.formal-language-transformation-card {
  align-content: start;
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.28);
  border-radius: 10px;
}

.formal-language-transformation-card[data-transformation-side="source"] {
  border-style: dashed;
}

.formal-language-transformation-card header > p {
  color: rgba(234, 242, 255, 0.76);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.formal-language-transformation-grammar,
.formal-language-transformation-diagram,
.formal-language-transformation-rule {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.formal-language-transformation-rule {
  padding-top: var(--space-3);
  border-top: 1px solid rgba(145, 183, 244, 0.2);
}

.formal-language-confirmation-dialog {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(0, 0, 0, 0.62);
}

.formal-language-confirmation-dialog__panel {
  display: grid;
  width: min(100%, 42rem);
  max-height: calc(100dvh - (var(--space-4) * 2));
  min-width: 0;
  gap: var(--space-3);
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--space-4);
  border: 1px solid rgba(145, 183, 244, 0.48);
  border-radius: var(--ui-radius-md);
  background: rgba(4, 15, 33, 0.98);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.5);
  color: var(--color-text, #eaf2ff);
}

.formal-language-confirmation-dialog__panel > * {
  margin: 0;
}

.formal-language-confirmation-dialog__panel--danger {
  border-color: rgba(226, 115, 115, 0.72);
}

.formal-language-confirmation-dialog__panel:focus-visible,
.formal-language-confirmation-dialog__panel .ui-button:focus-visible {
  outline: 3px solid var(--color-accent, #f4d58d);
  outline-offset: 3px;
}

.formal-language-confirmation-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

@media (max-width: 520px) {
  .formal-language-confirmation-dialog {
    align-items: end;
    padding: var(--space-3);
  }

  .formal-language-confirmation-dialog__panel {
    max-height: calc(100dvh - (var(--space-3) * 2));
    padding: var(--space-3);
  }

  .formal-language-confirmation-dialog__actions > .ui-button {
    width: 100%;
  }
}

.formal-language-transformation-rule:first-child {
  padding-top: 0;
  border-top: 0;
}

.formal-language-transformation-rule h4,
.formal-language-transformation-rule p {
  margin: 0;
}

.formal-language-transformation-productions,
.formal-language-transformation-mappings ol,
.formal-language-transformation-diagnostics ul {
  display: grid;
  min-width: 0;
  gap: 8px;
  margin: 0;
  padding-left: 1.35rem;
}

.formal-language-transformation-productions li,
.formal-language-transformation-mappings li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.formal-language-transformation-mappings header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-3);
}

.formal-language-transformation-mappings .ui-form-group {
  min-width: min(100%, 15rem);
  margin: 0;
}

.formal-language-transformation-mappings li {
  padding: 8px;
  border-left: 3px solid rgba(145, 183, 244, 0.45);
  border-radius: 0 6px 6px 0;
  background: rgba(27, 70, 125, 0.18);
  cursor: default;
}

.formal-language-transformation-mappings li:focus-visible {
  outline: 3px solid #f4d58d;
  outline-offset: 2px;
}

.formal-language-transformation-generated {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(145, 183, 244, 0.2);
}

.formal-language-transformation-generated .ui-form-group {
  margin: 0;
}

.syntax-diagram-svg .is-transformation-mapping-highlight ellipse,
.syntax-diagram-svg .is-transformation-mapping-highlight rect,
.formal-language-transformation-productions .is-transformation-mapping-highlight {
  outline: 3px solid #f4d58d;
  outline-offset: 3px;
  background: rgba(244, 213, 141, 0.18);
}

.syntax-diagram-svg .is-transformation-mapping-highlight ellipse,
.syntax-diagram-svg .is-transformation-mapping-highlight rect {
  stroke: #f4d58d;
  stroke-width: 4;
}

.formal-language-transformation-workspace__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(145, 183, 244, 0.2);
}

.formal-language-note {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

/* UI-FS-P1: tätigkeitsspezifische Präsentation über denselben Fachsurfaces. */
.formal-language-task-module,
.formal-language-workspace-details {
  min-width: 0;
}

.formal-language-task-module > summary,
.formal-language-workspace-details > summary,
.formal-language-activity-menu__more > summary {
  cursor: pointer;
  font-weight: 800;
}

.formal-language-task-module > summary {
  padding: 0;
  color: rgba(234, 242, 255, 0.96);
  font-size: clamp(1.1rem, 1.45vw, 1.35rem);
}

.formal-language-task-module__body {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-3);
}

/* The component body defines its own grid display, so make the closed
   disclosure state explicit instead of relying on the browser's UA rule. */
.formal-language-task-module:not([open]) > .formal-language-task-module__body {
  display: none;
}

.formal-language-activity-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-activity-toolbar__primary {
  position: relative;
}

.formal-language-activity-view-control {
  display: grid;
  min-width: min(100%, 14rem);
  gap: 4px;
}

.formal-language-activity-view-control[hidden],
.formal-language-representation-tabs[hidden],
.formal-language-workspace-details[hidden] {
  display: none;
}

.formal-language-activity-view-control label {
  color: rgba(220, 231, 249, 0.84);
  font-size: 0.84rem;
  font-weight: 700;
}

.formal-language-activity-menu {
  position: absolute;
  z-index: 20;
  display: grid;
  min-width: min(22rem, calc(100vw - 3rem));
  gap: 4px;
  margin-top: 8px;
  padding: var(--space-2);
  border: 1px solid rgba(145, 183, 244, 0.5);
  border-radius: 10px;
  background: #071a35;
  box-shadow: 0 14px 30px rgba(1, 8, 22, 0.38);
}

.formal-language-activity-menu[hidden] {
  display: none;
}

.formal-language-activity-menu__label {
  margin: 0;
  padding: 6px 8px 2px;
  color: rgba(220, 231, 249, 0.76);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.formal-language-activity-menu__item {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #eaf2ff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.formal-language-activity-menu__item:hover,
.formal-language-activity-menu__item:focus-visible {
  background: rgba(72, 117, 181, 0.34);
}

.formal-language-activity-menu__more {
  display: grid;
  gap: 4px;
  padding: 7px 8px 0;
  border-top: 1px solid rgba(145, 183, 244, 0.24);
}

.formal-language-workspace-details {
  margin-left: auto;
}

.formal-language-workspace-details > summary {
  padding: 8px 12px;
  border: 1px solid rgba(145, 183, 244, 0.44);
  border-radius: 7px;
  color: #dceaff;
}

.formal-language-workspace-details[open] {
  flex: 1 1 100%;
}

.formal-language-workspace-details[open] > .formal-language-editor-controls {
  margin-top: var(--space-3);
}

.formal-language-language-details,
.formal-language-grammar-syntax-view,
.formal-language-grammar-word-try {
  min-width: 0;
}

.formal-language-language-details .ui-form-group,
.formal-language-grammar-word-try {
  margin: 0;
}

.formal-language-grammar-word-try {
  display: grid;
  gap: 8px;
  padding: var(--space-3);
  border-left: 3px solid rgba(145, 183, 244, 0.5);
  background: rgba(255, 255, 255, 0.035);
}

.formal-language-grammar-word-try > label {
  color: rgba(220, 231, 249, 0.92);
  font-weight: 800;
}

.formal-language-grammar-word-try__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.formal-language-grammar-syntax-view {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid rgba(145, 183, 244, 0.32);
  border-radius: 10px;
  background: rgba(2, 10, 23, 0.18);
}

.formal-language-grammar-syntax-view[hidden] {
  display: none;
}

.formal-language-grammar-syntax-view > * {
  margin: 0;
}

.formal-language-grammar-syntax-view__canvas {
  min-width: 0;
  overflow: auto;
}

.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] .formal-language-grammar-definition__grid--source,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] .formal-language-grammar-inline-status,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] .formal-language-grammar-word-try,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] .formal-language-grammar-details,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] #formal-language-generation-settings,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] #formal-language-expected-type,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="syntax-diagram"] .formal-language-representation-shell__actions {
  display: none;
}

.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="split"] .formal-language-grammar-definition {
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 1fr);
  align-items: start;
}

.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="split"] .formal-language-grammar-definition > .formal-language-section-heading,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="split"] .formal-language-grammar-inline-status,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="split"] .formal-language-grammar-word-try,
.formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="split"] .formal-language-grammar-details {
  grid-column: 1 / -1;
}

/* UI-FS-P3: task presentation changes exposure only. The task rail and band
   keep the active assignment reachable while the representation workspace
   remains the dominant area. */
.formal-language-task-rail[hidden],
.formal-language-task-panel[hidden],
.formal-language-task-band[hidden],
.formal-language-task-more-actions[hidden] {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] {
  grid-template-columns: minmax(0, 1fr) clamp(22rem, 25vw, 30rem);
  gap: 0;
}

.formal-language-workspace[data-workspace-mode="task"] > .formal-language-mode-tabs {
  grid-column: 1 / -1;
}

.formal-language-workspace[data-workspace-mode="task"] > .formal-language-task-area {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] #formal-language-workflow-navigation,
.formal-language-workspace[data-workspace-mode="task"] #formal-language-representation-choice {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] > .formal-language-interaction-area,
.formal-language-workspace[data-workspace-mode="task"] > .formal-language-evaluation-area {
  grid-column: 1;
  min-width: 0;
  max-width: 100%;
}

.formal-language-task-rail {
  grid-column: 2;
  grid-row: 2 / span 2;
  align-self: stretch;
  min-width: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 1px solid rgba(145, 183, 244, 0.24);
  border-bottom: 1px solid rgba(145, 183, 244, 0.24);
  background: rgba(2, 10, 23, 0.24);
  box-shadow: inset 0 -1px 0 rgba(210, 231, 255, 0.06);
}

.formal-language-task-panel {
  position: sticky;
  top: var(--space-3);
  align-self: start;
  min-width: 0;
  max-height: calc(100vh - (var(--space-3) * 2));
  overflow: auto;
  padding: clamp(16px, 2vw, 24px);
}

.formal-language-workspace[data-workspace-mode="task"] > .formal-language-interaction-area {
  overflow: clip;
}

.formal-language-workspace[data-workspace-mode="task"][data-task-density="compact"] > .formal-language-interaction-area {
  width: min(100%, 72rem);
  justify-self: center;
}

.formal-language-workspace[data-workspace-mode="task"][data-task-density="editor"] > .formal-language-interaction-area {
  width: min(100%, 92rem);
  justify-self: center;
}

.formal-language-workspace[data-workspace-mode="task"][data-task-density="wide"] > .formal-language-interaction-area {
  width: 100%;
}

.formal-language-task-panel > .formal-language-task-module {
  display: block;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-module > summary {
  margin-bottom: var(--space-2);
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-selectors {
  display: none;
}

.formal-language-task-more-actions {
  min-width: 0;
}

.formal-language-task-more-actions > summary {
  cursor: pointer;
  color: rgba(220, 231, 249, 0.88);
  font-weight: 700;
}

.formal-language-task-more-actions > div {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

.formal-language-task-more-actions .ui-button {
  width: 100%;
}

.formal-language-task-panel-diagnostics {
  margin: 0;
  color: #ffe5a8;
  font-size: 0.86rem;
}

.formal-language-task-panel-diagnostics:empty {
  display: none;
}

.formal-language-task-panel .formal-language-task-input-host {
  min-width: 0;
}

.formal-language-task-panel .formal-language-task-input__grid,
.formal-language-task-panel .formal-language-task-input .formal-language-field-grid {
  grid-template-columns: minmax(0, 1fr);
}

.formal-language-task-panel .formal-language-task-input table,
.formal-language-task-panel .formal-language-task-input .formal-language-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.formal-language-task-band {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: flex;
  grid-column: 1;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  padding: 10px clamp(16px, 2vw, 24px);
  border-top: 1px solid rgba(115, 240, 191, 0.48);
  background: rgba(4, 19, 37, 0.97);
  box-shadow: 0 -8px 24px rgba(1, 8, 22, 0.28);
}

@media (min-width: 1180px) {
  .formal-language-workspace[data-ui-mode="free"] {
    grid-template-columns: minmax(38rem, 1fr) minmax(19rem, 0.48fr);
    align-items: start;
  }

  .formal-language-workspace[data-ui-mode="free"] > .formal-language-mode-tabs,
  .formal-language-workspace[data-ui-mode="free"] > .formal-language-free-context {
    grid-column: 1 / -1;
  }

  .formal-language-workspace[data-ui-mode="free"] > .formal-language-interaction-area {
    grid-column: 1;
  }

  .formal-language-workspace[data-ui-mode="free"] > .formal-language-evaluation-area {
    grid-column: 2;
    align-self: start;
    margin-top: clamp(16px, 2vw, 24px);
    border: 1px solid rgba(145, 183, 244, 0.28);
    border-radius: 12px;
    background: rgba(2, 10, 23, 0.28);
  }
}

.formal-language-task-band > span {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formal-language-task-band__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media (max-width: 1100px) {
  .formal-language-workspace[data-workspace-mode="task"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-workspace[data-workspace-mode="task"] > .formal-language-interaction-area,
  .formal-language-workspace[data-workspace-mode="task"] > .formal-language-evaluation-area,
  .formal-language-task-rail,
  .formal-language-task-panel,
  .formal-language-task-band {
    grid-column: 1;
    grid-row: auto;
  }

  .formal-language-task-rail {
    position: static;
    border-left: 0;
    border-bottom: 1px solid rgba(145, 183, 244, 0.24);
  }

  .formal-language-task-panel { position: static; max-height: none; }

  .syntax-diagram-workspace__split {
    grid-template-columns: minmax(0, 1fr);
  }

  .derivation-tree-workspace__split {
    grid-template-columns: minmax(0, 1fr);
  }

  .derivation-builder__split,
  .derivation-builder__tree-layout,
  .derivation-builder__forms-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .formal-language-workspace-summary__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .formal-language-task-area {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-task-area > h2,
  .formal-language-task-selectors,
  .formal-language-activity-description,
  .formal-language-task-help,
  .formal-language-task-actions,
  .formal-language-task-progress {
    grid-column: auto;
  }

  .formal-language-task-help,
  .formal-language-task-selectors,
  .formal-language-field-grid,
  .formal-language-grammar-definition__grid,
  .formal-language-language-definition__grid,
  .formal-language-task-input__grid,
  .formal-language-derivation-set__rows {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-task-selectors #formal-language-start-task {
    width: 100%;
    white-space: normal;
  }

  .formal-language-derivation-set__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-language-context {
    padding-top: var(--space-3);
    padding-left: 0;
    border-top: 2px solid rgba(145, 183, 244, 0.42);
    border-left: 0;
  }

  .formal-language-field--wide {
    grid-column: auto;
  }

  .syntax-diagram-workspace__split {
    grid-template-columns: minmax(0, 1fr);
  }

  .derivation-tree-workspace__split {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-transformation-workspace__compare {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .formal-language-tool-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-tool-header .tool-workspace-menu-mount,
  .formal-language-tool-header .ui-status {
    grid-column: auto;
    justify-self: start;
  }

  .formal-language-tool-header .tool-workspace-menu-mount {
    width: 100%;
  }

  .formal-language-mode-tabs,
  .formal-language-free-entry__actions {
    align-items: stretch;
  }

  .formal-language-mode-tabs .formal-language-mode-tab,
  .formal-language-free-entry__actions .ui-button,
  .formal-language-free-entry__actions .ui-form-group {
    width: 100%;
  }

  .formal-language-workspace-summary__list {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-representation-choice {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-task-band {
    align-items: stretch;
    flex-direction: column;
  }

  .formal-language-task-band__actions,
  .formal-language-task-band__actions .ui-button {
    width: 100%;
  }

  .formal-language-task-band__actions .ui-button {
    flex: 1 1 auto;
  }

  .formal-language-activity-toolbar {
    align-items: stretch;
  }

  .formal-language-activity-toolbar__primary,
  .formal-language-activity-toolbar__primary > .ui-button,
  .formal-language-activity-view-control,
  #formal-language-task-module-trigger,
  .formal-language-workspace-details {
    width: 100%;
  }

  .formal-language-activity-menu {
    position: static;
    min-width: 0;
    width: 100%;
  }

  .formal-language-workspace-details {
    margin-left: 0;
  }

  .formal-language-grammar-word-try__controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-grammar-word-try__controls .ui-button {
    width: 100%;
  }

  .formal-language-workspace[data-active-activity="grammar-authoring"][data-active-view="split"] .formal-language-grammar-definition {
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-actions > .ui-button {
    flex: 1 1 auto;
  }

  .formal-language-tool-shell button.formal-language-representation-tab {
    flex: 0 0 auto;
    min-width: 10rem;
  }

  .formal-language-representation-shell__actions > .ui-button {
    flex: 1 1 auto;
  }

  .formal-language-transformation-workspace {
    padding: var(--space-3);
  }

  .formal-language-transformation-workspace__actions > .ui-button {
    flex: 1 1 100%;
  }

  .formal-language-transformation-mappings header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .formal-language-active-grammar {
    align-items: stretch;
  }

  .formal-language-active-grammar > .ui-button {
    width: 100%;
  }

  .syntax-diagram-rule-manager__controls,
  .syntax-diagram-rule-manager__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .syntax-diagram-rule-manager .ui-form-group,
  .syntax-diagram-rule-manager .ui-button {
    width: 100%;
  }

  .syntax-diagram-tree__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .syntax-diagram-tree__actions {
    grid-column: auto;
  }

  .syntax-diagram-svg {
    min-width: 24rem;
  }

  .derivation-tree-svg {
    min-width: 22rem;
  }

  .syntax-context-surface,
  .tree-context-surface {
    position: fixed;
    z-index: 45;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: min(68vh, 38rem);
    overflow: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -16px 32px rgba(1, 8, 22, 0.52);
  }

  .formal-language-table,
  .formal-language-table thead,
  .formal-language-table tbody,
  .formal-language-table tr,
  .formal-language-table th,
  .formal-language-table td {
    display: block;
    width: auto;
  }

  .formal-language-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .formal-language-table tr {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }

  .formal-language-table td {
    border: 0;
    padding: 3px 0;
  }

  .formal-language-table th:first-child,
  .formal-language-table td:first-child,
  .formal-language-table th:nth-child(2),
  .formal-language-table td:nth-child(2) {
    width: auto;
  }

  .formal-language-table select {
    width: 100%;
  }
}

/* UI-WS-S1: Stable Workspace Zones.  The task context is a compact rail on
   desktop and an explicitly opened sheet on narrower screens; task feedback
   stays next to the active workspace instead of becoming a third document
   chapter. */
.formal-language-task-status {
  margin: 0;
  color: rgba(220, 231, 249, 0.9);
  font-size: 0.9rem;
  font-weight: 700;
}

.formal-language-task-status[hidden] {
  display: none;
}

.formal-language-task-brief__instruction {
  max-inline-size: 42ch;
  text-align: start;
}

.formal-language-task-brief__details {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: var(--space-2);
}

.formal-language-task-brief__details summary,
.formal-language-task-help > summary {
  cursor: pointer;
  font-weight: 700;
}

.formal-language-task-brief__details > p,
.formal-language-task-help__body {
  margin-top: var(--space-2);
}

.formal-language-task-help {
  display: block;
}

.formal-language-task-help__body {
  display: grid;
  gap: var(--space-2);
}

.formal-language-task-help .formal-language-task-disclosure {
  padding-top: var(--space-2);
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-selectors {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-selectors #formal-language-start-task {
  width: 100%;
  white-space: normal;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-input {
  gap: var(--space-3);
  padding: 0;
  border-left: 0;
  background: transparent;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-input > h3 {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-actionbar {
  display: none !important;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-evaluation-area--inplace {
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3) 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-evaluation-area--inplace .formal-language-area-eyebrow,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-evaluation-area--inplace h2 {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-evaluation-area--inplace .graph-panel-intro {
  margin: 0;
  font-size: 0.92rem;
}

.formal-language-material--compact {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 0;
  border-left: 0;
  background: transparent;
}

.formal-language-material--compact .formal-language-material__header {
  display: contents;
  margin: 0;
}

.formal-language-material--compact .formal-language-material__header h3 {
  font-size: 0.9rem;
}

.formal-language-material--compact .formal-language-material__role {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-material--compact {
  display: grid;
  gap: 4px;
  align-items: start;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-material--compact .formal-language-material__header {
  display: block;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-material--compact .formal-language-material__header h3 {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-material--compact .formal-language-material__role {
  display: block;
}

.formal-language-material--compact .formal-language-material__body pre,
.formal-language-material--compact .formal-language-material__body p {
  white-space: nowrap;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-band {
  display: none;
}

@media (max-width: 1100px) {
  .formal-language-workspace[data-workspace-mode="task"] .formal-language-task-rail {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 30;
    display: block;
    width: min(30rem, 100%);
    max-height: none;
    overflow: auto;
    transform: translateX(102%);
    visibility: hidden;
    transition: transform 180ms ease, visibility 0s linear 180ms;
    border: 0;
    border-left: 1px solid rgba(145, 183, 244, 0.36);
    background: rgba(4, 19, 37, 0.99);
    box-shadow: inset 0 -1px 0 rgba(210, 231, 255, 0.06), -16px 0 32px rgba(1, 8, 22, 0.42);
  }

  .formal-language-workspace[data-workspace-mode="task"] .formal-language-task-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .formal-language-workspace[data-workspace-mode="task"][data-task-context-open="true"] .formal-language-task-rail {
    transform: translateX(0);
    visibility: visible;
    transition-delay: 0s;
  }

  .formal-language-workspace[data-workspace-mode="task"] .formal-language-task-panel > .formal-language-task-module > summary {
    display: none;
  }

  .formal-language-workspace[data-workspace-mode="task"] .formal-language-task-band {
    position: sticky;
    bottom: 0;
    z-index: 8;
    display: flex;
  }
}

@media (max-width: 560px) {
  .formal-language-workspace[data-workspace-mode="task"] .formal-language-task-rail {
    inset: auto 0 0;
    width: 100%;
    max-height: min(78vh, 46rem);
    transform: translateY(105%);
    border-top: 1px solid rgba(145, 183, 244, 0.36);
    border-left: 0;
    box-shadow: inset 0 1px 0 rgba(210, 231, 255, 0.06), 0 -16px 32px rgba(1, 8, 22, 0.42);
  }

  .formal-language-workspace[data-workspace-mode="task"][data-task-context-open="true"] .formal-language-task-rail {
    transform: translateY(0);
  }
}

/* UI-WS-S1.1: der Task Canvas bleibt die Fachfläche; die Rail steuert nur. */
.formal-language-workspace[data-workspace-mode="task"] .formal-language-activity-toolbar,
.formal-language-workspace[data-workspace-mode="task"] #formal-language-task-module-trigger {
  display: none;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-input,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-input__grid,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-materials,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-material,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-representation-shell,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-table {
  min-width: 0;
  max-width: 100%;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-material__body,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-material__body > *,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-brief__instruction,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-description,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-panel {
  overflow-wrap: anywhere;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-material--compact .formal-language-material__body pre,
.formal-language-workspace[data-workspace-mode="task"] .formal-language-material--compact .formal-language-material__body p {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-table {
  display: block;
  overflow-x: auto;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-input[data-task-input-mode="counterexample-and-revision"] input[type="text"] {
  min-height: 2.75rem;
  height: 2.75rem;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-panel {
  overscroll-behavior: contain;
}

.formal-language-workspace[data-workspace-mode="task"] .formal-language-task-actions {
  position: sticky;
  z-index: 2;
  bottom: 0;
  padding: var(--space-2) 0;
  background: linear-gradient(to bottom, rgba(4, 19, 37, 0.88), rgba(4, 19, 37, 1));
}

@media (max-width: 1100px) {
  .formal-language-workspace[data-workspace-mode="task"][data-task-density] > .formal-language-interaction-area {
    width: 100%;
  }
}
