.block-diagram-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.manual-card {

  background: #fafafa;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  padding: 18px 22px;
}

.manual-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.manual-grid section {
  flex: 1 1 240px;
  min-width: 220px;
}
.manual-grid h3 {
  margin-top: 0;
  font-size: 1.05rem;
}

.manual-grid ul,
.manual-grid ol {
  margin: 0 0 0 18px;
  padding: 0;
}

.manual-grid li {
  margin-bottom: 6px;
  line-height: 1.45;
}

.diagram-shell {
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  padding: 16px;
  background: #fff;
}

/* layout for palette and workspace */
#diagramArea {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.block-palette {
  flex: 0 0 230px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 10px;
  background: #f4f4f4;
}

.block-palette input {
  width: 100%;
  padding: 6px 8px;
  margin-bottom: 10px;
  border: 1px solid #c2c2c2;
  border-radius: 4px;
}

.block-palette ul {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
}

.block-palette li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 6px;
  border: 1px solid #c2c2c2;
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
}

.block-palette li:hover {
  background: #e7e7e7;
}

.workspace {
  flex: 1 1 680px;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  background: #f9f9f9;
}

.toolbar h4 {
  margin: 0 0 6px 0;
  width: 100%;
  font: 600 0.95rem/1 Roboto, sans-serif;
}

.toolbar button.active {
  background: #dce7f7;
}

.scene-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 10px;
  background: #f9f9f9;
}

.scene-controls select,
.scene-controls button {
  min-height: 34px;
}

canvas {
  max-width: 100%;
  height: auto;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  background: #fff;
}

.results-panel {
  border: 1px solid #dfe4ee;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.results-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #f7faff 0%, #ffffff 100%);
  border-bottom: 1px solid #e7ecf5;
}

.results-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.results-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #1b1f3b;
}

.results-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #6b7280;
}

.results-action {
  margin-left: auto;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.results-body {
  padding: 24px;
  font-family: var(--bs-font-sans-serif);
  color: #1f2937;
  line-height: 1.6;
  white-space: normal;
}

.results-body .kx {
  font-size: 1.05rem;
  overflow-x: auto;
}

.analysis-suite {
  margin-top: 20px;
  border: 1px solid #dfe4ee;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
  padding: 20px 24px;
}

.analysis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.analysis-content {
  margin-top: 18px;
}

.analysis-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.analysis-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analysis-caption {
  margin: 0;
  color: #4b5563;
  font-size: 0.9rem;
}

.analysis-export {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #4b5563;
}

.analysis-export button {
  box-shadow: none;
}

.analysis-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.9rem;
  color: #1f2937;
}

.analysis-metrics span {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.analysis-metrics strong {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.plotly-chart {
  width: 100%;
  min-height: 320px;
}

.rootlocus-toolbar {
  gap: 16px;
}

.rootlocus-toolbar .form-range {
  flex: 1 1 220px;
  min-width: 160px;
}

@media (max-width: 768px) {
  .analysis-suite {
    padding: 16px 18px;
  }
  .plotly-chart {
    min-height: 260px;
  }
}

.results-sim-canvas {
  margin-top: 18px;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 16px;
}

.summary-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f9fafb;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.summary-card h6 {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
}

.summary-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  margin: 0;
  font-size: 0.9rem;
}

.summary-card dt {
  color: #4b5563;
  font-weight: 500;
}

.summary-card dd {
  margin: 0;
  color: #111827;
}


#srcCustom {
  display: none;
}

.kx {
  font-size: 1.1rem;
  overflow-x: auto;
}

canvas + .latexNode,
canvas > * {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.15));
  border-radius: 4px;
}

canvas {
  --arrow-col: #444;
}

body.dark-mode canvas {
  --arrow-col: #ccc;
}

.latexNode {
  color: #000;
}

body.dark-mode .latexNode {
  color: #000;
}

.scope-window {
  position: absolute;
  top: 10px;
  left: 10px;
  width: clamp(320px, 48vw, 520px);
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  padding: 6px;
  border-radius: 6px;
  z-index: 1000;
}
.scope-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eee;
  padding: 4px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.scope-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.scope-readouts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.cursor-line {
  font: 12px monospace;
}

.scope-readouts .summary-grid {
  margin-top: 0;
  box-shadow: none;
}

.scope-readouts .summary-card {
  box-shadow: none;
  padding: 10px 12px;
}

@media (max-width: 992px) {
  #diagramArea {
    flex-direction: column;
  }

  .block-palette {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .manual-card {
    padding: 16px;
  }

  .scene-controls,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .scene-controls button,
  .scene-controls select,
  .toolbar button {
    width: 100%;
  }
}

body.dark-mode .manual-card,
body.dark-mode .diagram-shell,
body.dark-mode .block-palette,
body.dark-mode .toolbar,
body.dark-mode .scene-controls,
body.dark-mode .scope-window {
  background: #1f1f1f;
  border-color: #444;
  box-shadow: none;
}

body.dark-mode .results-panel {
  background: #151515;
  border-color: #333;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

body.dark-mode .results-header {
  background: linear-gradient(135deg, rgba(63, 76, 119, 0.4) 0%, rgba(32, 40, 62, 0.6) 100%);
  border-bottom-color: #333;
}

body.dark-mode .results-title {
  color: #f3f4f6;
}

body.dark-mode .results-subtitle {
  color: #a5b4fc;
}

body.dark-mode .results-body {
  color: #e5e7eb;
}

body.dark-mode .results-action {
  box-shadow: none;
}

body.dark-mode .summary-card {
  background: #1f2937;
  border-color: #374151;
  box-shadow: none;
}

body.dark-mode .summary-card h6 {
  color: #f3f4f6;
}

body.dark-mode .summary-card dt {
  color: #d1d5db;
}

body.dark-mode .summary-card dd {
  color: #f9fafb;
}


body.dark-mode .block-palette input,
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode select {
  background: #2a2a2a;
  color: #f5f5f5;
  border-color: #555;
}

body.dark-mode .block-palette li {
  background: #2a2a2a;
  border-color: #555;
}

body.dark-mode .block-palette li:hover {
  background: #333;
}

body.dark-mode .scope-header {
  background: #333;
}