/* Calculation tools page */
.md-typeset .calc {
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  margin: 1em 0 1.5em;
  background: var(--md-code-bg-color);
}

[data-md-color-scheme="slate"] .md-typeset .calc {
  box-shadow: 0 0 0 1px rgba(124, 77, 255, 0.15);
}

.md-typeset .calc-top {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1rem 1.4rem;
  align-items: center;
}

@media screen and (max-width: 44em) {
  .md-typeset .calc-top {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Wide, short schematics (op amps): drawing on top, fields in a row below */
.md-typeset .calc-top.wide {
  grid-template-columns: minmax(0, 1fr);
}

.md-typeset .calc-top.wide .sch {
  max-width: 440px;
}

.md-typeset .calc-top.wide .calc-grid {
  grid-template-columns: repeat(auto-fit, minmax(5.4rem, 1fr));
}

.md-typeset .calc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 0.8rem;
  align-content: start;
}

.md-typeset .calc label {
  display: block;
  font-size: 0.66rem;
  line-height: 1.3;
  color: var(--md-default-fg-color--light);
}

.md-typeset .calc label sub {
  line-height: 0;
}

.md-typeset .calc input,
.md-typeset .calc select {
  font-family: var(--md-code-font-family);
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 4px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
}

.md-typeset .calc-grid input,
.md-typeset .calc-grid select {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  box-sizing: border-box;
}

.md-typeset .calc input:focus,
.md-typeset .calc select:focus {
  outline: none;
  border-color: var(--md-accent-fg-color);
  box-shadow: 0 0 8px rgba(124, 77, 255, 0.4);
}

.md-typeset .calc input.calc-bad {
  border-color: #e05561;
}

.md-typeset .calc-scope-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
  margin-top: 1rem;
  font-size: 0.66rem;
  color: var(--md-default-fg-color--light);
}

.md-typeset .calc-scope-ctl .t {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: auto;
}

.md-typeset .calc-scope-ctl label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.md-typeset .calc-scope-ctl input {
  width: 4.5rem;
}

@media screen and (max-width: 44em) {
  .md-typeset .calc-scope-ctl .t {
    flex-basis: 100%;
  }
}

.md-typeset .calc-out {
  margin-top: 0.9rem;
  border-top: 1px dashed var(--md-default-fg-color--lightest);
  padding-top: 0.6rem;
}

.md-typeset .calc-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0;
  font-size: 0.75rem;
}

.md-typeset .calc-row b {
  font-family: var(--md-code-font-family);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.md-typeset .calc-row.main b {
  color: var(--md-accent-fg-color);
  font-size: 0.95rem;
}

[data-md-color-scheme="slate"] .md-typeset .calc-row.main b {
  text-shadow: 0 0 8px rgba(124, 77, 255, 0.5);
}

.md-typeset .calc-warn {
  margin: 0.4rem 0;
  padding: 0.4rem 0.6rem;
  border-left: 3px solid #e0a83a;
  background: rgba(224, 168, 58, 0.1);
  font-size: 0.72rem;
}

.md-typeset table.calc-table:not([class*="highlight"]) {
  display: table;
  width: 100%;
  margin: 0.6rem 0 0.3rem;
  font-size: 0.72rem;
}

.md-typeset table.calc-table td,
.md-typeset table.calc-table th {
  padding: 0.2rem 0.6rem;
  font-family: var(--md-code-font-family);
}

/* Schematics */
.md-typeset .calc-schem {
  display: flex;
  justify-content: center;
}

.md-typeset .sch {
  width: 100%;
  max-width: 360px;
  height: auto;
  overflow: visible;
  color: var(--md-default-fg-color);
}

.md-typeset .sch path,
.md-typeset .sch rect,
.md-typeset .sch polygon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.md-typeset .sch .opt path,
.md-typeset .sch .opt rect {
  stroke-dasharray: 4 3;
  opacity: 0.6;
}

.md-typeset .sch .dot {
  fill: currentColor;
  stroke: none;
}

.md-typeset .sch .term {
  fill: var(--md-code-bg-color);
  stroke: currentColor;
  stroke-width: 1.5;
}

.md-typeset .sch text {
  fill: currentColor;
  stroke: none;
  font-family: var(--md-code-font-family);
  font-size: 11px;
}

.md-typeset .sch .sub {
  font-size: 8px;
}

.md-typeset .sch .sign {
  font-size: 13px;
  font-weight: 700;
}

.md-typeset .sch .val {
  fill: var(--md-accent-fg-color);
}

/* Scope */
.md-typeset .calc {
  --calc-ch1: #f2c94c;
  --calc-ch2: #4dd0e1;
}

.md-typeset .calc-scope {
  margin-top: 0.4rem;
}

.md-typeset .calc-scope .scope {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
  border-radius: 4px;
}

.md-typeset .scope .bg {
  fill: #0d1117;
}

.md-typeset .scope .gr,
.md-typeset .scope .ax {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.md-typeset .scope .ax {
  stroke: rgba(255, 255, 255, 0.28);
}

.md-typeset .scope .rail {
  fill: none;
  stroke: #e05561;
  stroke-width: 1;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
}

.md-typeset .scope .ch1,
.md-typeset .scope .ch2 {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.md-typeset .scope .ch1 {
  stroke: var(--calc-ch1);
}

.md-typeset .scope .ch2 {
  stroke: var(--calc-ch2);
  filter: drop-shadow(0 0 3px var(--calc-ch2));
}

.md-typeset .scope-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-top: 0.4rem;
  font-family: var(--md-code-font-family);
  font-size: 0.68rem;
  color: var(--md-default-fg-color--light);
}

.md-typeset .scope-legend .l1::before,
.md-typeset .scope-legend .l2::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 3px;
  margin-right: 0.4em;
  vertical-align: middle;
}

.md-typeset .scope-legend .l1::before {
  background: var(--calc-ch1);
}

.md-typeset .scope-legend .l2::before {
  background: var(--calc-ch2);
}

.md-typeset .scope-legend .clip {
  color: #e05561;
}
