/* ═══════════ DIAGRAM CONTAINER ═══════════ */
.dia {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 28px 20px;
  margin: 24px 0 28px;
}

/* ═══════════ FLOW ROW (L0, L1, L5) ═══════════ */
.flow {
  display: flex;
  align-items: center;
  gap: 0;
  justify-content: center;
  flex-wrap: nowrap;
}
.flow-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  text-align: center;
  min-width: 0;
  flex-shrink: 1;
}
.flow-card h4 {
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -.01em;
}
.flow-card p {
  font-size: .75rem;
  color: var(--t2);
  margin: 0;
  line-height: 1.4;
}
.flow-arrow {
  flex: 0 0 auto;
  padding: 0 10px;
  font-size: 1.125rem;
  color: var(--t2);
  display: flex;
  align-items: center;
}
.flow-break {
  flex: 0 0 auto;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.flow-break .x {
  font-size: 1rem;
  font-weight: 700;
  color: var(--red);
}
.flow-break .dash {
  width: 28px;
  height: 0;
  border-top: 1.5px dashed var(--red);
}
.faded { opacity: .35; }
.err {
  border-color: var(--red);
  border-style: dashed;
  border-width: 1.5px;
}

/* ═══════════ HIGHLIGHT STRIPS (L1) ═══════════ */
.strip {
  background: rgba(0,113,227,.07);
  border-radius: 6px;
  padding: 5px 10px;
  margin: 5px 0;
  font-size: .75rem;
  color: var(--blue);
  line-height: 1.4;
  text-align: left;
}
.quote-strip {
  padding: 5px 10px;
  margin: 5px 0;
  font-size: .75rem;
  color: var(--t1);
  line-height: 1.4;
  text-align: left;
  font-style: italic;
}

/* ═══════════ THREE-CARD ROW (L2) ═══════════ */
.trio {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
}
.trio-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 14px;
  text-align: center;
}
.trio-card h4 {
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.trio-card .sep {
  height: 1px;
  background: var(--divider);
  margin: 8px 0;
}
.trio-card .ins {
  font-size: .75rem;
  color: var(--t1);
  line-height: 1.45;
  margin-bottom: 8px;
}
.trio-card .verdict {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--green);
}
.trio-gap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  flex-direction: column;
  gap: 2px;
}
.trio-gap .dash {
  width: 16px;
  height: 0;
  border-top: 1.5px dashed var(--orange);
}
.trio-gap .q {
  font-size: .875rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}

/* ═══════════ CONSTRAINT WINDOW (L3, L4) ═══════════ */
.cw {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
}
.cw-label {
  width: 68px;
  flex: 0 0 68px;
  font-size: .6875rem;
  font-weight: 500;
  color: var(--t2);
  text-align: right;
  line-height: 1.25;
}
.cw-track {
  flex: 1;
  position: relative;
  height: 28px;
  background: rgba(0,0,0,.018);
  border-radius: 8px;
}
.cw-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .625rem;
  font-weight: 500;
}
.cw-a { background: rgba(0,113,227,.07); border: 1px solid rgba(0,113,227,.2); color: rgba(0,113,227,.55); }
.cw-b { background: rgba(52,199,89,.07); border: 1px solid rgba(52,199,89,.25); color: rgba(52,199,89,.6); }
.cw-c { background: rgba(255,149,0,.07); border: 1px solid rgba(255,149,0,.22); color: rgba(255,149,0,.6); }
.cw-plan {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .625rem;
  font-weight: 600;
}
.cw-plan-bad { background: rgba(255,59,48,.07); border: 1.5px dashed rgba(255,59,48,.35); color: var(--red); }
.cw-plan-good { background: rgba(52,199,89,.12); border: 1.5px solid rgba(52,199,89,.4); color: var(--green); }
.cw-divider { height: 1px; background: var(--divider); margin: 4px 0 4px 78px; }
.cw-zone {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 8px;
  background: rgba(52,199,89,.06);
  border: 1px dashed rgba(52,199,89,.3);
}

/* ═══════════ VERDICT ROW ═══════════ */
.verdict-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 0 4px;
  flex-wrap: wrap;
}
.v-pass {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  color: var(--green);
  font-weight: 500;
}
.v-pass::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.v-fail {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  color: var(--red);
  font-weight: 600;
}
.v-fail::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}

/* ═══════════ FAN-OUT (L6) ═══════════ */
.fan {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.fan-arrow {
  color: var(--purple);
  font-size: .875rem;
  padding: 4px 0;
}
.fan-arrow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  width: 100%;
  text-align: center;
  color: var(--purple);
  font-size: 1.25rem;
  padding: 4px 0;
}
.fan-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.fan-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}
.fan-card h4 {
  font-size: .75rem;
  font-weight: 600;
  margin-bottom: 3px;
}
.fan-card p {
  font-size: .6875rem;
  color: var(--t2);
  margin: 0;
  line-height: 1.35;
}
.fan-abstract {
  background: rgba(88,86,214,.05);
  border: 1.5px solid rgba(88,86,214,.3);
  border-radius: 12px;
  padding: 14px 20px;
  text-align: center;
  width: 80%;
  max-width: 420px;
}
.fan-abstract h4 {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 3px;
}
.fan-abstract p {
  font-size: .75rem;
  color: var(--purple);
  margin: 0;
  line-height: 1.35;
}

/* ═══════════ CAPTION + CHALLENGE PILL ═══════════ */
.dia-caption {
  text-align: center;
  font-size: .8125rem;
  color: var(--t2);
  padding: 12px 0 8px;
  line-height: 1.4;
}
.challenge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 20px;
  margin-top: 4px;
}
.ch-red { background: rgba(255,59,48,.06); color: var(--red); }
.ch-orange { background: rgba(255,149,0,.07); color: var(--orange); }
.ch-green { background: rgba(52,199,89,.06); color: var(--green); }
.ch-purple { background: rgba(88,86,214,.06); color: var(--purple); }

/* ═══════════ RESPONSIVE DIAGRAMS — TABLET/MOBILE ═══════════ */
@media (max-width: 768px) {
  .dia { padding: 24px 16px 16px; }
  .flow {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }
  .flow-card { min-width: 0; flex: none !important; max-width: none !important; width: 100%; }
  .flow-arrow {
    flex-direction: column;
    padding: 8px 0;
    transform: none;
    /* Hide the inline right-arrow text node */
    font-size: 0;
    line-height: 0;
  }
  /* Show a downward arrow via pseudo-element */
  .flow-arrow::before {
    content: "\2193";
    font-size: 1.125rem;
    line-height: 1;
    display: block;
  }
  /* Restore font-size for the label span inside the arrow */
  .flow-arrow span {
    font-size: .625rem !important;
    line-height: 1.3;
  }
  .flow-break { flex: 0 0 auto; flex-direction: row; justify-content: center; }
  .cw-bar, .cw-plan { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ═══════════ RESPONSIVE DIAGRAMS — SMALL MOBILE ═══════════ */
@media (max-width: 640px) {
  .trio { grid-template-columns: 1fr; gap: 8px; }
  .trio-gap {
    flex-direction: row;
    gap: 6px;
    padding: 2px 0;
  }
  .trio-gap .dash {
    width: 0;
    height: 16px;
    border-top: none;
    border-left: 1.5px dashed var(--orange);
  }
  .fan-row { grid-template-columns: 1fr; }
  .cw-label { width: 56px; flex: 0 0 56px; font-size: .625rem; }
  .cw-row { gap: 8px; }
  .cw-plan {
    overflow: visible;
    white-space: nowrap;
    font-size: 0;
  }
  .cw-plan::after {
    content: attr(data-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: .5625rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
  }
  .cw-plan-bad::after { color: var(--red); }
  .cw-plan-good::after { color: var(--green); }
  .fan-arrow { letter-spacing: 0 !important; font-size: 1.1rem !important; }
}
@media (min-width: 429px) and (max-width: 640px) {
  .fan-row { grid-template-columns: 1fr 1fr; }
  .fan-arrow-grid {
    grid-template-columns: 1fr 1fr;
  }
  .fan-arrow-grid span:last-child {
    display: none;
  }
}
@media (max-width: 428px) {
  .fan-arrow-grid {
    grid-template-columns: 1fr;
  }
  .fan-arrow-grid span:not(:nth-child(2)) {
    display: none;
  }
}
