main {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem 2.5rem;
  text-align: left;
  align-self: stretch;
  box-sizing: border-box;
}

:root {
  --font-body: "Calibri", "Times New Roman", "Arial", "Segoe UI", sans-serif;
  --font-display: "Calibri", "Times New Roman", "Arial", "Segoe UI", sans-serif;
}

body {
  font-family: var(--font-body);
}

.mda-app {
  display: grid;
  gap: 1rem;
}

header .mda-header-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  margin: 0 auto;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
}

header .mda-header-brand-image {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

header .mda-header-brand-text {
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  header .mda-header-brand {
    gap: 0.5rem;
  }

  header .mda-header-brand-image {
    width: 32px;
    height: 32px;
  }

  header .mda-header-brand-text {
    font-size: 0.98rem;
  }
}

.mda-intro-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
}

.mda-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.58rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.mda-button:hover {
  background: var(--panel);
  border-color: color-mix(in srgb, var(--line) 75%, var(--ink));
}

.mda-button.is-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mda-button.is-secondary {
  background: var(--panel-strong);
}

.mda-workspace {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.mda-panel,
.mda-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
}

.mda-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 16px;
  align-self: start;
  height: auto;
  max-height: calc(100vh - 128px);
  overflow: hidden;
}

.mda-panel-body {
  display: grid;
  gap: 14px;
  flex: 0 0 auto;
  min-height: 0;
  align-content: start;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
}

.mda-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
  margin-bottom: 0;
}

.mda-panel-header h2,
.mda-stage-header h2,
.mda-summary-card h3,
.mda-preview-card h3,
.mda-help-panel h2,
.mda-help-panel h3 {
  margin: 0;
}

.mda-panel-header p,
.mda-stage-header p,
.mda-summary-card p,
.mda-preview-note,
.mda-help-panel p,
.mda-help-panel li {
  color: var(--muted);
}

.mda-help-open {
  flex: 0 0 auto;
}

.mda-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  align-content: start;
}

.mda-panel-body > .mda-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.mda-section h3 {
  margin: 0;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.mda-field {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.mda-field label {
  font-weight: 600;
}

.mda-inline-row {
  display: grid;
  gap: 0.5rem;
}

.mda-inline-control {
  display: grid;
  grid-template-columns: minmax(0, 220px);
  gap: 0.35rem;
}

.mda-inline-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.mda-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 170px;
  height: 170px;
  max-height: 260px;
  resize: vertical;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  font: inherit;
  color: var(--ink);
  background: var(--panel-strong);
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
}

.mda-textarea:focus,
.mda-select:focus,
.mda-file:focus,
.mda-number:focus,
.mda-textinput:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.mda-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: start;
  align-content: start;
}

.mda-control {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.mda-select,
.mda-file,
.mda-number,
.mda-textinput {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
  padding: 0.62rem 0.75rem;
}

.mda-number,
.mda-textinput {
  background: var(--panel);
  color: var(--ink);
}

.mda-file[hidden] {
  display: none;
}

.mda-file {
  padding: 0.5rem 0.6rem;
}

.mda-select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 10px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.mda-status {
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: transparent;
  padding: 0.5rem 0.15rem 0;
  margin-top: 0.15rem;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 400;
  font-style: italic;
  line-height: 1.35;
  letter-spacing: 0;
  pointer-events: none;
}

.mda-status.is-error {
  color: color-mix(in srgb, #b91c1c 55%, var(--muted));
  font-style: normal;
}

.mda-status.is-ok {
  color: color-mix(in srgb, #0f766e 45%, var(--muted));
  font-style: normal;
}

.mda-issues {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.25rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding-top: 0.5rem;
}

.mda-issues li {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.84rem;
  line-height: 1.35;
  color: color-mix(in srgb, #b91c1c 40%, var(--muted));
  font-style: italic;
  overflow-wrap: anywhere;
}

.mda-stage {
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.mda-stage-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
}

.mda-stage-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.mda-stage-controls > .mda-button {
  border-radius: 999px;
  padding: 0 10px;
  height: 30px;
  font-size: 0.86rem;
  line-height: 1;
  box-sizing: border-box;
}

.mda-tool-panel {
  display: inline-flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  overflow: visible;
  position: relative;
  width: auto;
  min-width: 0;
}

.mda-tool-panel.is-accent > summary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mda-tool-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 0 10px;
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  line-height: 1;
  height: 30px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  background-clip: padding-box;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mda-tool-panel summary::-webkit-details-marker {
  display: none;
}

.mda-tool-panel[open] summary {
  background: color-mix(in srgb, var(--panel-strong) 92%, var(--panel));
}

.mda-tool-panel:not(.is-accent):hover:not([open]) summary {
  background: var(--panel);
  border-color: color-mix(in srgb, var(--line) 75%, var(--ink));
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.mda-tool-panel.is-accent[open] summary {
  background: var(--accent);
  color: #fff;
}

.mda-tool-panel.is-accent:hover:not([open]) summary {
  background: color-mix(in srgb, var(--accent) 85%, #000);
  color: #fff;
}

.mda-tool-panel-body {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  width: fit-content;
  min-width: 0;
  max-width: calc(100vw - 2rem);
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 10px 12px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 5;
}

.mda-tool-panel:not([open]) .mda-tool-panel-body {
  display: none;
}

.mda-export-row {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  white-space: nowrap;
}

.mda-tool-panel .mda-button,
.mda-tool-panel button {
  min-width: 0;
}

.mda-tool-panel .mda-button {
  padding: 5px 10px;
}

.mda-inline-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.mda-inline-details summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.mda-inline-details summary::-webkit-details-marker {
  display: none;
}

.mda-inline-details-body {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.mda-reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
}

.mda-reference-toggle {
  align-self: end;
  min-width: 4.8rem;
}

.mda-inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 500;
  user-select: none;
}

.mda-inline-checkbox input {
  accent-color: var(--accent);
}

.mda-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.mda-summary-card,
.mda-preview-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  padding: 0.9rem 1rem;
}

.mda-summary-value {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
}

.mda-preview-card {
  display: grid;
  gap: 0.75rem;
}

.mda-reference-controls {
  display: grid;
  gap: 0.5rem;
}

.mda-preview-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  max-height: 240px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
}

.mda-preview-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 340px;
  font-size: 0.95rem;
}

.mda-preview-table th,
.mda-preview-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.mda-preview-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

.mda-preview-details {
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.mda-preview-details summary {
  list-style: none;
  cursor: pointer;
  padding: 0.45rem 0;
  font-weight: 700;
  color: var(--ink);
}

.mda-preview-details summary::-webkit-details-marker {
  display: none;
}

.mda-empty {
  padding: 1rem;
  color: var(--muted);
}

.mda-plot {
  min-height: 300px;
  border-radius: 14px;
  border: 1px solid #d5dbe5;
  background: #ffffff;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: none;
  --mda-plot-bg: #ffffff;
  --mda-plot-ink: #111827;
  --mda-plot-muted: #4b5563;
  --mda-plot-grid: #e2e8f0;
  --mda-plot-border: #cfd8e3;
}

.mda-plot svg {
  display: block;
  width: 100%;
  height: auto;
}

.mda-plot-empty {
  padding: 1.25rem;
  color: var(--muted);
  text-align: center;
}

.mda-plot-label {
  font-size: 0.9rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-self: end;
}

.mda-plot-label:empty {
  display: none;
}

.mda-plot-label::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 0;
  border-top: 2px solid var(--accent);
  border-radius: 999px;
}

.mda-plot-axis-label {
  font-size: 12px;
  fill: var(--mda-plot-ink);
  font-family: Arial, "Segoe UI", sans-serif;
  font-weight: 400;
}

.mda-plot-axis-x {
  fill: var(--mda-plot-ink);
}

.mda-plot-grid {
  stroke: var(--mda-plot-grid);
  stroke-width: 0.6;
}

.mda-plot-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: butt;
}

.mda-plot-line-current {
  stroke: #2563eb;
}

.mda-plot-line-diffusion {
  stroke: #111111;
}

.mda-plot-frame {
  fill: var(--mda-plot-bg);
  stroke: var(--mda-plot-border);
  stroke-width: 0.8;
}

.mda-plot-value {
  font-size: 11px;
  fill: var(--mda-plot-ink);
  font-family: Arial, "Segoe UI", sans-serif;
  font-weight: 400;
}

.mda-plot-value-current,
.mda-plot-axis-right {
  fill: #2563eb;
}

.mda-plot-value-diffusion,
.mda-plot-axis-left {
  fill: #111111;
}

.mda-plot-note {
  font-size: 11px;
  fill: var(--mda-plot-muted);
  font-family: Arial, "Segoe UI", sans-serif;
  font-weight: 400;
}

.mda-plot-ref-line {
  stroke-width: 1;
  stroke-linecap: round;
  fill: none;
  cursor: grab;
}

.mda-plot-ref-hitline {
  stroke: transparent;
  stroke-width: 14;
  stroke-linecap: round;
  fill: none;
  cursor: grab;
  pointer-events: stroke;
}

.mda-plot-ref-line.mda-plot-ref-baseline,
.mda-plot-ref-label.mda-plot-ref-baseline {
  stroke: #4b5563;
  fill: #4b5563;
  color: #4b5563;
}

.mda-plot-ref-line.mda-plot-ref-steady,
.mda-plot-ref-label.mda-plot-ref-steady {
  stroke: #111111;
  fill: #111111;
  color: #111111;
}

.mda-plot-ref-label {
  font-size: 10px;
  font-family: Arial, "Segoe UI", sans-serif;
  font-weight: 400;
  paint-order: normal;
  stroke: none;
  dominant-baseline: middle;
}

.mda-plot-legend-group {
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: 10.5px;
  font-weight: 400;
}

.mda-plot-legend-group text {
  fill: #111111;
  font-weight: 400;
}

.mda-plot-legend-line {
  stroke-width: 2.2;
  stroke-linecap: butt;
}

.mda-plot-legend-diffusion .mda-plot-legend-line {
  stroke: #111111;
}

.mda-plot-legend-current .mda-plot-legend-line {
  stroke: #2563eb;
}

.mda-plot-ref-label.mda-plot-ref-baseline,
.mda-plot-ref-label.mda-plot-ref-steady {
  fill: #111111;
  stroke: none;
}

.mda-help-drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}

.mda-help-drawer.is-open {
  display: block;
}

.mda-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.mda-help-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(460px, 92vw);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 32px rgba(15, 23, 42, 0.2);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 16px;
  resize: horizontal;
  overflow: hidden;
  min-width: 320px;
}

.mda-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.mda-help-close {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.mda-help-body {
  display: grid;
  gap: 1rem;
  overflow: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
}

.mda-help-body p {
  margin: 0.35rem 0 0;
}

.mda-help-list {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
}

.mda-help-list li + li {
  margin-top: 0.35rem;
}

.mda-panel-body::-webkit-scrollbar,
.mda-textarea::-webkit-scrollbar,
.mda-preview-wrap::-webkit-scrollbar,
.mda-help-body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.mda-panel-body::-webkit-scrollbar-thumb,
.mda-textarea::-webkit-scrollbar-thumb,
.mda-preview-wrap::-webkit-scrollbar-thumb,
.mda-help-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 55%, transparent);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.mda-panel-body::-webkit-scrollbar-track,
.mda-textarea::-webkit-scrollbar-track,
.mda-preview-wrap::-webkit-scrollbar-track,
.mda-help-body::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 980px) {
  .mda-workspace {
    grid-template-columns: 1fr;
  }

  .mda-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .mda-stage-header,
  .mda-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .mda-panel {
    position: static;
    height: auto;
    overflow: visible;
  }

  .mda-control-grid,
  .mda-summary-grid {
    grid-template-columns: 1fr;
  }

  .mda-inline-control {
    grid-template-columns: 1fr;
  }

  .mda-help-panel {
    width: 100vw;
    border-radius: 0;
    min-width: 0;
    resize: none;
  }
}
