:root {
  color: #1f2937;
  background: #eef2f6;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1f2937;
  border-radius: 6px;
  padding: 8px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  min-height: 36px;
}

button:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  color: #111827;
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}

.appShell {
  min-height: 100vh;
}

.topBar {
  min-height: 72px;
  background: #ffffff;
  border-bottom: 1px solid #d8dee9;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
}

.brandMark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid #f0b66a;
  color: #b45309;
  background: #fff7ed;
  display: grid;
  place-items: center;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

.topBar p {
  color: #64748b;
  margin-top: 4px;
  font-size: 13px;
}

.topActions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.workspaceTabs {
  display: flex;
  gap: 8px;
  padding: 14px 16px 0;
  border-bottom: 1px solid #d8dee9;
}

.workspaceTabs button {
  min-height: 44px;
  padding: 8px 14px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: #f8fafc;
}

.workspaceTabs button.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.workspaceGrid {
  display: grid;
  grid-template-columns: 370px minmax(580px, 1fr) 390px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.diagramWorkspaceGrid {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 390px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.specWorkspaceGrid {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(340px, 430px);
  gap: 16px;
  padding: 16px;
  align-items: start;
}

.textualWorkspaceGrid {
  display: grid;
  padding: 16px;
}

.textualWorkspacePanel {
  display: grid;
  gap: 12px;
}

.textualWorkspacePanel .notationPanel pre {
  min-height: 650px;
  max-height: calc(100vh - 230px);
}

.diagramSideRail {
  display: grid;
  gap: 14px;
}

.diagramSideRail .rightRail {
  display: grid;
  gap: 14px;
}

.leftRail,
.rightRail,
.editorColumn {
  display: grid;
  gap: 14px;
}

.panel,
.scenarioBand {
  background: #ffffff;
  border: 1px solid #d8dee9;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.panel {
  padding: 14px;
}

.compactPanel h2,
.diagramPanel h2,
.scenarioHeader h2,
.bandHeader h2 {
  font-size: 15px;
}

.mutedText,
.emptyState {
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

.fieldStack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

#useCaseDiagramCanvas {
  display: block;
  width: 1200px;
  height: 760px;
  max-width: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.diagramCanvasShell {
  display: grid;
  grid-template-columns: 176px 1200px;
  gap: 10px;
  align-items: start;
  margin-top: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
}

.diagramHeader,
.diagramConnectRow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diagramHeader {
  justify-content: space-between;
}

.diagramConnectRow button {
  min-height: 32px;
  padding: 6px 9px;
}

.diagramPalette {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-content: start;
  padding: 8px;
  background: #ffffff;
  border: 2px solid #2563eb;
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.paletteTitle {
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.diagramPalette button {
  min-height: 34px;
  padding: 6px;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 6px;
  align-items: center;
  justify-content: start;
  font-size: 12px;
  font-weight: 750;
}

.specOnlyGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 16px;
  align-items: start;
}

.diagramPalette button.active {
  background: #eaf1ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

.paletteGlyph {
  font-size: 20px;
  line-height: 1;
}

.paletteActorGlyph {
  width: 20px;
  height: 24px;
  position: relative;
  display: inline-block;
}

.paletteActorGlyph::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 1px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    0 8px 0 -3px currentColor,
    -7px 12px 0 -4px currentColor,
    7px 12px 0 -4px currentColor,
    -5px 19px 0 -4px currentColor,
    5px 19px 0 -4px currentColor;
}

.paletteUseCaseGlyph {
  width: 24px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.paletteConnectorGlyph {
  width: 24px;
  height: 2px;
  background: currentColor;
  position: relative;
}

.paletteConnectorGlyph::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -4px;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.paletteConnectorGlyph.dashed {
  background: repeating-linear-gradient(to right, currentColor 0 5px, transparent 5px 8px);
}

.diagramConnectRow {
  margin-top: 10px;
  flex-wrap: wrap;
}

.diagramConnectRow label {
  min-width: 150px;
}

.diagramInspector {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.diagramInspector p {
  color: #64748b;
  font-size: 13px;
}

.diagramNode {
  cursor: grab;
}

.diagramNode text,
.diagramEdge text {
  fill: #1f2937;
  font-size: 13px;
  font-weight: 750;
}

.diagramNode text {
  cursor: text;
  pointer-events: auto;
}

.diagramInlineEditor {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.diagramInlineEditor input {
  width: 100%;
  height: 28px;
  padding: 2px 6px;
  border: 2px solid #2563eb;
  border-radius: 5px;
  background: #ffffff;
  color: #1f2937;
  font: 750 13px/1.2 Arial, sans-serif;
  text-align: center;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
}

.diagramEdge text {
  pointer-events: none;
}

.actorNode circle {
  fill: #2d3748;
  stroke: #2d3748;
}

.actorNode path {
  fill: none;
  stroke: #2d3748;
  stroke-width: 5;
  stroke-linecap: round;
}

.actorNode text {
  font-size: 14px;
}

.useCaseNode ellipse {
  fill: #edf5ff;
  stroke: #4d7bd9;
  stroke-width: 2.5;
}

.diagramNode.selected ellipse,
.diagramNode.selected circle {
  stroke: #f59e0b;
}

.diagramEdge {
  cursor: pointer;
}

.diagramEdge path {
  fill: none;
  stroke: #334155;
  stroke-width: 2;
}

.diagramEdge.selected path {
  stroke: #f59e0b;
  stroke-width: 3;
}

#arrowHead path {
  fill: #334155;
}

.diagramText {
  fill: #334155;
  font-size: 13px;
  font-weight: 650;
}

.diagramTitle {
  fill: #1f2937;
  font-size: 11px;
  font-weight: 750;
}

.specificationPanel {
  padding: 12px 14px;
}

.formGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.wideField {
  grid-column: 1 / -1;
}

.toolbarPanel {
  display: flex;
  gap: 8px;
  padding: 9px;
  overflow-x: auto;
}

.scenarioPanel {
  overflow: hidden;
  padding: 0;
}

.scenarioHeader {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
}

.scenarioHeader h2 {
  color: #1d4ed8;
}

.scenarioPanel.alternate .scenarioHeader {
  background: #f0f9f4;
}

.scenarioPanel.exception .scenarioHeader {
  background: #fff1f2;
}

.scenarioPanel.alternate .scenarioHeader h2,
.alternateText {
  color: #15803d;
}

.scenarioPanel.exception .scenarioHeader h2,
.exceptionText {
  color: #b91c1c;
}

.scenarioMetaGrid {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.scenarioMetaGrid.singleField {
  grid-template-columns: minmax(220px, 1fr);
}

.scenarioMetaGrid input {
  font-weight: 700;
}

.scenarioActions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.scenarioActions label {
  width: 112px;
}

.iconButton {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
}

.iconTextButton {
  height: 34px;
}

.dangerButton {
  color: #b91c1c;
}

.stepTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.stepTable th,
.stepTable td {
  border-bottom: 1px solid #e2e8f0;
  padding: 0;
  vertical-align: middle;
}

.stepTable th {
  height: 34px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  text-transform: uppercase;
}

.stepTable th:first-child,
.stepTable td:first-child {
  width: 86px;
  text-align: center;
  font-weight: 750;
}

.stepTable th:last-child,
.stepTable td:last-child {
  width: 48px;
  text-align: center;
}

.stepTable input {
  border: 0;
  border-radius: 0;
  min-height: 38px;
  background: transparent;
}

.stepTable input:focus {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.22);
}

.stepTable tbody tr {
  cursor: default;
}

.scenarioPanel.nominal .stepTable tbody tr {
  cursor: pointer;
}

.selectedRow {
  background: #fff7e6;
  outline: 2px solid #f2c56b;
  outline-offset: -2px;
}

.rejoinRow {
  color: #15803d;
  font-weight: 800;
  background: #f8fafc;
}

.scenarioPanel.exception .rejoinRow {
  color: #b91c1c;
}

.postconditionField {
  padding: 12px 14px 14px;
}

.scenarioBand {
  padding: 0;
  overflow: hidden;
}

.bandHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #d8dee9;
}

.bandHeader span {
  min-width: 28px;
  height: 24px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.alternateBand > .bandHeader {
  background: #eaf8ef;
  color: #166534;
}

.exceptionBand > .bandHeader {
  background: #fff1f2;
  color: #991b1b;
}

.scenarioBand > .scenarioPanel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.emptyState {
  padding: 14px;
}

.tabBar {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 6px;
  margin-bottom: 12px;
}

.tabBar button {
  min-height: 34px;
}

.tabBar .active {
  color: #ffffff;
  border-color: #2563eb;
  background: #2563eb;
}

.documentPreview {
  font-size: 13px;
  line-height: 1.45;
  max-height: 520px;
  overflow: auto;
}

.documentPreview h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.documentPreview h3 {
  font-size: 14px;
  margin: 16px 0 6px;
}

.documentPreview dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 7px 10px;
  margin: 0 0 12px;
}

.documentPreview dt {
  font-weight: 800;
  color: #334155;
}

.documentPreview dd {
  margin: 0;
}

.documentPreview ol {
  margin: 0;
  padding-left: 22px;
}

.generatedScenario {
  border-top: 1px solid #e2e8f0;
  margin-top: 12px;
  padding-top: 2px;
}

.jsonPanel,
.notationPanel {
  display: grid;
  gap: 10px;
}

.jsonPanel textarea {
  min-height: 430px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.notationPanel pre {
  min-height: 430px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #0f172a;
  color: #dbeafe;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.jsonActions,
.buttonRow {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.jsonPanel p {
  color: #64748b;
  font-size: 13px;
}

.primaryButton {
  background: #0f62d9;
  color: #ffffff;
  border-color: #0f62d9;
}

.primaryButton:hover:not(:disabled) {
  background: #0b55c4;
  border-color: #0b55c4;
}

@media (max-width: 1180px) {
  body {
    min-width: 0;
  }

  .workspaceGrid {
    grid-template-columns: 1fr;
  }

  .diagramWorkspaceGrid,
  .specWorkspaceGrid {
    grid-template-columns: 1fr;
  }

  .specOnlyGrid {
    grid-template-columns: 1fr;
  }

  .diagramCanvasShell {
    grid-template-columns: 176px 1200px;
  }

  .topBar {
    grid-template-columns: 42px 1fr;
  }

  .topActions {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .formGrid,
  .scenarioHeader,
  .scenarioMetaGrid {
    grid-template-columns: 1fr;
  }

  .scenarioActions {
    flex-wrap: wrap;
  }
}
