:root {
  --sop-primary: #003D7A;
  --sop-primary-soft: #E3EEFB;
  --sop-ok: #1B873F;
  --sop-ok-soft: #E6F4EA;
  --sop-ok-line: #1B873F;
  --sop-bad: #C62828;
  --sop-bad-soft: #FDECEC;
  --sop-bad-line: #C62828;
  --sop-neutral: #475569;
  --sop-line: #334155;
}

html { font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; }
body { font-feature-settings: "ss01","tnum"; }

/* ===== Flow chart layout ===== */
.sop-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding-bottom: 2rem;
}

.sop-chart .row {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Nodes */
.node {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #fff;
  border: 2.5px solid var(--sop-primary);
  border-radius: 12px;
  padding: 16px 22px;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  cursor: help;
}
.node:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -8px rgba(0,61,122,.25);
}
.node-kicker {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--sop-neutral);
  margin-bottom: 4px;
}
.node-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.node-desc {
  margin-top: 6px;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.45;
}

/* Terminal (rounded pill) */
.node-terminal {
  border-radius: 999px;
  background: var(--sop-primary);
  border-color: var(--sop-primary);
  padding: 14px 28px;
  min-width: 280px;
}
.node-terminal .node-kicker { color: #BBD3EC; }
.node-terminal .node-title { color: #fff; }
.node-terminal .node-desc { color: #DCE9F6; }

.node-call {
  background: var(--sop-bad);
  border-color: var(--sop-bad);
}
.node-call .node-kicker { color: #FBD9D9; }
.node-call .node-title { color: #fff; }
.node-call .node-desc { color: #FBE3E3; }

/* Step (process) box */
.node-step {
  background: var(--sop-primary-soft);
  border-color: var(--sop-primary);
}

/* Decision (diamond-ish) */
.node-decision {
  border: 2.5px solid #475569;
  background: #fff;
  transform: rotate(45deg);
  width: 180px;
  height: 180px;
  min-width: 0;
  padding: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.node-decision .node-title {
  transform: rotate(-45deg);
  font-size: 15px;
  color: var(--sop-primary);
  padding: 0 8px;
}
.node-decision:hover { transform: rotate(45deg) translateY(-2px); }

/* Action (side branch) */
.node-action {
  min-width: 240px;
  padding: 14px 18px;
}
.node-bad {
  background: var(--sop-bad-soft);
  border-color: var(--sop-bad);
}
.node-bad .node-title { color: #7f1d1d; }
.node-bad .node-desc { color: #991b1b; }

/* ===== Arrows — thicker, darker, clearer ===== */
.arrow {
  position: relative;
  height: 72px;
  width: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 4px 0;
}
.arrow-line {
  flex: 1;
  width: 5px;
  background: var(--sop-line);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px rgba(15,23,42,.15);
}
.arrow-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.85) 45%, transparent 60%);
  background-size: 100% 200%;
  animation: flow-down 2.2s linear infinite;
}
.arrow-head {
  width: 0; height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 14px solid var(--sop-line);
  margin-top: -2px;
  filter: drop-shadow(0 1px 0 rgba(15,23,42,.15));
}

/* Inline label on the arrow */
.arrow-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 1.5px solid;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 3;
  box-shadow: 0 2px 6px -2px rgba(15,23,42,.15);
}
.arrow-label .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}

/* OK arrow */
.arrow-ok .arrow-line { background: var(--sop-ok-line); }
.arrow-ok .arrow-head { border-top-color: var(--sop-ok-line); }
.arrow-ok .arrow-label {
  color: #14532d;
  border-color: var(--sop-ok-line);
  background: var(--sop-ok-soft);
}
.arrow-ok .arrow-label .dot { background: var(--sop-ok-line); }

/* BAD arrow */
.arrow-bad .arrow-line { background: var(--sop-bad-line); }
.arrow-bad .arrow-head { border-top-color: var(--sop-bad-line); }
.arrow-bad .arrow-label {
  color: #7f1d1d;
  border-color: var(--sop-bad-line);
  background: var(--sop-bad-soft);
}
.arrow-bad .arrow-label .dot { background: var(--sop-bad-line); }

/* Neutral arrow label (start → step1 etc.) */
.arrow-neutral .arrow-label {
  color: #0f172a;
  border-color: var(--sop-line);
  background: #fff;
}
.arrow-neutral .arrow-label .dot { background: var(--sop-line); }

@keyframes flow-down {
  0%   { background-position: 0 -100%; }
  100% { background-position: 0 100%; }
}

/* Branch row layout — wider gap so OK/BAD lines never visually collide */
.branch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  align-items: start;
  position: relative;
  column-gap: 48px;
}
.branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
  position: relative;
}
.branch-left { padding-top: 8px; }
.branch-right { padding-top: 8px; }

/* Resolution side card */
.resolution-note {
  margin-top: 32px;
  width: 100%;
  display: flex;
  justify-content: center;
}
.resolution-card {
  border: 1.5px dashed var(--sop-ok-line);
  background: var(--sop-ok-soft);
  border-radius: 12px;
  padding: 14px 18px;
  max-width: 480px;
  text-align: left;
}

/* Compact mode */
.sop-chart.is-compact .node { padding: 10px 16px; min-width: 220px; }
.sop-chart.is-compact .node-desc { display: none; }
.sop-chart.is-compact .node-decision { width: 140px; height: 140px; }
.sop-chart.is-compact .arrow { height: 56px; }
.sop-chart.is-compact .node-terminal { padding: 10px 22px; }

/* Tooltip */
#sop-tooltip {
  position: fixed;
  z-index: 60;
  max-width: 320px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 12px 32px -8px rgba(15,23,42,.45);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
#sop-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}
#sop-tooltip::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 16px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #0f172a;
}

/* Print friendly */
@media print {
  header, footer, .sticky { display: none !important; }
  body { background: #fff; }
  .arrow-line::after { animation: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .arrow-line::after { animation: none; }
  .node:hover { transform: none; }
}

/* Small screen tweaks: allow horizontal scroll wrapper instead of breaking layout */
@media (max-width: 640px) {
  .node-decision { width: 160px; height: 160px; }
  .node { min-width: 220px; }
  .arrow-label { font-size: 10.5px; padding: 2px 7px; }
}
