:root {
  --redblue-gap: 16px;
  --redblue-controls: 380px;
  --redblue-red: #e1574f;
  --redblue-blue: #62c5ff;
  --redblue-field: rgb(3 11 17 / 88%);
}

.redblue-app {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

.redblue-layout {
  display: grid;
  width: 100%;
  min-height: 100dvh;
  padding: 16px;
  grid-template-areas: "title controls analysis";
  grid-template-columns: auto var(--redblue-controls) minmax(600px, 900px);
  align-items: start;
  justify-content: center;
  gap: var(--redblue-gap);
}

.redblue-controls {
  display: grid;
  width: var(--redblue-controls);
  padding: 12px;
  grid-area: controls;
  align-content: start;
  gap: 9px;
}

.global-header,
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.redblue-app h2,
.card-label,
.redblue-app dt {
  margin: 0;
  color: var(--starsector-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.global-header h2,
.control-panel h2,
.chart-header h2 {
  font-size: 13px;
}

.control-panel,
.model-note {
  display: grid;
  padding: 9px;
  gap: 8px;
}

.model-note summary {
  color: var(--starsector-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.model-note-body {
  display: grid;
  margin-top: 9px;
  color: var(--starsector-weak);
  font-family: var(--starsector-font-mono);
  font-size: 11px;
  line-height: 1.4;
  gap: 7px;
}

.model-note-body p {
  margin: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.redblue-app label {
  display: grid;
  min-width: 0;
  color: var(--starsector-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  gap: 4px;
}

.range-field {
  display: grid;
  gap: 3px;
}

.redblue-app output {
  order: -1;
  justify-self: end;
  color: var(--starsector-weak);
  font-size: 11px;
  line-height: 1;
  text-align: right;
}

.analysis {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  overflow: visible;
  grid-area: analysis;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.verdict-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.verdict-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgb(68 152 176 / 42%);
  background: rgb(3 11 17 / 70%);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 54%) inset;
}

.verdict-card h2 {
  margin-top: 4px;
  color: #e8f7ff;
  font-family: var(--starsector-font-mono);
  font-size: 17px;
  letter-spacing: 0.04em;
}

.color-word {
  font: inherit;
}

.color-word-red {
  color: #ff8a82;
}

.color-word-blue {
  color: #8eddff;
}

.flip-multiple {
  display: inline-block;
  margin-left: 5px;
  color: var(--starsector-weak);
  font-family: var(--starsector-font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  vertical-align: 2px;
}

.redblue-app dl {
  display: grid;
  margin: 9px 0 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.redblue-app dt {
  color: var(--starsector-weak);
  font-size: 9px;
}

.redblue-app dd {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--starsector-text);
  font-family: var(--starsector-font-mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-grid {
  display: grid;
  min-height: 0;
  overflow: visible;
  grid-template-rows: minmax(300px, 1.15fr) minmax(190px, 0.8fr) minmax(170px, 0.65fr);
  gap: 9px;
}

.chart-panel {
  display: grid;
  min-height: 0;
  padding: 9px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
}

.chart-header p {
  margin: 0;
  color: var(--starsector-weak);
  font-family: var(--starsector-font-mono);
  font-size: 11px;
  text-align: right;
}

.chart-host {
  min-height: 0;
  overflow: hidden;
}

.chart-host svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 190px;
}

.chart-host-short svg {
  min-height: 150px;
}

.chart-field {
  fill: var(--redblue-field);
  stroke: rgb(68 152 176 / 26%);
}

.failure-zone {
  fill: rgb(225 87 79 / 7.5%);
}

.atom-marker {
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.atom-marker-red {
  fill: rgb(225 87 79 / 34%);
  stroke: rgb(255 138 130 / 78%);
}

.atom-marker-blue {
  fill: rgb(98 197 255 / 32%);
  stroke: rgb(142 221 255 / 78%);
}

.curve {
  fill: none;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.curve-red {
  stroke: var(--redblue-red);
}

.curve-blue {
  stroke: var(--redblue-blue);
}

.curve-neutral {
  stroke: #e0b85d;
}

.curve-reference {
  opacity: 0.72;
  stroke-width: 1.45;
  stroke-dasharray: 6 5;
}

.threshold-rule {
  stroke: var(--redblue-red);
}

.pivotal-rule {
  stroke: var(--redblue-blue);
}

.threshold-rule,
.pivotal-rule {
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
}

.neutral-rule,
.axis-line {
  stroke: rgb(199 224 239 / 50%);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.legend-red,
.legend-blue,
.rule-label,
.axis-label,
.axis-title {
  font-family: var(--starsector-font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.legend-red {
  fill: #ff8a82;
}

.legend-blue {
  fill: #8eddff;
}

.rule-label,
.axis-label,
.axis-title {
  fill: var(--starsector-weak);
}

.axis-title {
  font-size: 12px;
}

.redblue-app .error {
  position: sticky;
  z-index: 4;
  top: 8px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid #a34f40;
  color: #ffd0c8;
  background: #32130e;
  font-size: 12px;
}

@media (max-width: 1160px) {
  .redblue-layout {
    grid-template-areas:
      "title"
      "controls"
      "analysis";
    grid-template-columns: minmax(0, 1fr);
  }

  .redblue-controls {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .redblue-layout {
    padding: 10px;
  }

  .panel-grid,
  .verdict-grid,
  .redblue-app dl {
    grid-template-columns: 1fr;
  }

  .global-header,
  .chart-header {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-header p {
    text-align: left;
  }
}
