/* Widen the page for the app; minima's default content column is 800px. */
.demo-body .wrapper {
  max-width: 1500px;
}

.demo-back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #555;
  text-decoration: none;
}
.demo-back:hover {
  text-decoration: underline;
}

.stl-app {
  --ink: #1b1f23;
  --muted: #5c6570;
  --line: #d9dde1;
  --panel: #fbfbfb;
  --accent: #2f5fd6;
  --ok: #2f9e44;
  --ok-fill: rgba(47, 158, 68, 0.14);
  --bad: #d6336c;
  --bad-fill: rgba(214, 51, 108, 0.16);
  color: var(--ink);
  font-size: 0.96rem;
}

.stl-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.7rem;
}

.stl-sub {
  margin: 0 0 1.25rem;
  max-width: 68ch;
  color: var(--muted);
  line-height: 1.5;
}

/* --- scenario picker --- */

.stl-scenarios {
  margin-bottom: 1.5rem;
  padding: 0.9rem 1rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stl-scenarios-label {
  font-weight: 600;
  margin-right: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.scenario-btn,
.preset-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  margin: 0.2rem 0.35rem 0.2rem 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.scenario-btn:hover,
.preset-btn:hover {
  border-color: var(--accent);
}
.scenario-btn.active,
.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.scenario-blurb {
  margin: 0.6rem 0 0;
  font-size: 0.87rem;
  color: var(--muted);
}

/* --- two-column layout --- */

.stl-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.6fr) minmax(340px, 1fr);
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 860px) {
  .stl-grid {
    grid-template-columns: 1fr;
  }
}

.stl-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.2rem;
  background: #fff;
}

.stl-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- specification tabs --- */

.spec-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.spec-tab,
.spec-tab-add {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.spec-tab:hover,
.spec-tab-add:hover {
  border-color: var(--accent);
}
.spec-tab.active {
  background: #eaf0fd;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.spec-tab-close {
  line-height: 1;
  font-size: 0.9rem;
  color: var(--muted);
  border-radius: 4px;
}
.spec-tab-close:hover {
  color: var(--bad);
}

.spec-tab-add {
  border-style: dashed;
  color: var(--muted);
  font-weight: 600;
  justify-content: center;
}
.spec-tab-add:hover {
  color: var(--accent);
}

.preset-row {
  margin-bottom: 0.9rem;
}

/* --- formula tree editor --- */

.formula-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  background: var(--panel);
  overflow-x: auto;
  min-height: 8rem;
}

.fnode {
  font-size: 0.92rem;
}

.fnode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.fnode select,
.fnode-num {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

.fnode-type {
  font-weight: 600;
  color: var(--accent);
}

.fnode-num {
  width: 5.8rem;
}
.fnode-num-sm {
  width: 3.8rem;
}

.fnode-sep,
.fnode-unit {
  font-size: 0.78rem;
  color: var(--muted);
}

.fnode-bound {
  font-size: 0.82rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.fnode-remove {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
}
.fnode-remove:hover {
  color: var(--bad);
}

.fnode-children {
  margin: 0.35rem 0 0.5rem 1.3rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}

.fnode-branch-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0.3rem 0 0.1rem;
}

.fnode-add {
  font: inherit;
  font-size: 0.78rem;
  margin-top: 0.2rem;
  padding: 0.15rem 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.fnode-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.formula-text {
  margin-top: 0.9rem;
  padding: 0.7rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 0.88rem;
}

.formula-text-label {
  display: block;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.formula-text p {
  margin: 0;
  line-height: 1.5;
}

/* --- results --- */

.result-error {
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  background: var(--bad-fill);
  color: var(--bad);
  font-size: 0.87rem;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}
.verdict-ok {
  background: var(--ok-fill);
  color: var(--ok);
}
.verdict-bad {
  background: var(--bad-fill);
  color: var(--bad);
}
.verdict-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.violation-list {
  margin: 0 0 0.9rem;
  padding-left: 1.1rem;
  font-size: 0.83rem;
  color: var(--muted);
}

.signals-heading {
  margin: 1.1rem 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* --- charts --- */

.chart {
  margin-bottom: 0.7rem;
}

.chart-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

.chart-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.chart-unit {
  font-size: 0.74rem;
  color: var(--muted);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.chart-band-ok {
  fill: var(--ok-fill);
}
.chart-band-bad {
  fill: var(--bad-fill);
}
.chart-normal-range {
  fill: none;
  stroke: #adb5bd;
  stroke-dasharray: 3, 3;
  stroke-width: 1;
}
.chart-zero-line {
  stroke: #868e96;
  stroke-width: 1;
  stroke-dasharray: 2, 3;
}
.chart-threshold-line {
  stroke: #495057;
  stroke-width: 1;
  stroke-dasharray: 4, 3;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.chart-dim {
  opacity: 0.5;
}

.stl-footer {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
