.flow-section {
  width: 100%;
  max-width: none;
  padding-right: max(20px, calc((100vw - 1120px) / 2));
  padding-left: max(20px, calc((100vw - 1120px) / 2));
  background:
    radial-gradient(circle at 14% 12%, rgb(194 122 24 / 14%), transparent 26rem),
    radial-gradient(circle at 88% 78%, rgb(13 127 120 / 10%), transparent 24rem),
    linear-gradient(180deg, #efe4d4 0%, #e8dcc8 100%);
}

.flow-section .section-heading {
  max-width: 820px;
}

.flow-lede {
  max-width: 680px;
  color: var(--color-muted-text);
  font-size: 1.05rem;
  line-height: 1.55;
}

.consilium-flow {
  position: relative;
  display: grid;
  gap: 28px;
  perspective: 1400px;
  transform: rotateX(var(--flow-tilt-y, 0deg)) rotateY(var(--flow-tilt-x, 0deg));
  transform-style: preserve-3d;
  transition: transform 160ms ease-out;
}

.consilium-flow::before {
  position: absolute;
  inset: -8% -4%;
  z-index: -1;
  background: radial-gradient(circle at 50% 40%, rgb(194 122 24 / 10%), transparent 62%);
  content: "";
  pointer-events: none;
}

.flow-lane {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.flow-step {
  position: relative;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 168px;
  padding: 20px 20px 18px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background:
    linear-gradient(155deg, rgb(255 255 255 / 62%), transparent 52%),
    linear-gradient(180deg, var(--color-surface-raised), var(--color-surface));
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transform: translateZ(0);
  transform-style: preserve-3d;
  transition:
    border-color 220ms ease,
    box-shadow 220ms ease,
    transform 220ms ease,
    opacity 220ms ease;
}

.flow-step:hover {
  border-color: var(--color-border-strong);
  transform: translateZ(12px) translateY(-3px);
}

.flow-step.is-passed {
  opacity: 0.82;
}

.flow-step.is-active {
  border-color: rgb(194 122 24 / 42%);
  box-shadow:
    var(--shadow-soft),
    0 0 0 1px rgb(194 122 24 / 14%),
    0 18px 48px rgb(194 122 24 / 16%);
  transform: translateZ(28px) scale(1.02);
}

.flow-step.is-active::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-human), var(--color-accent-strong));
  content: "";
}

.flow-step:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

.flow-step::after {
  position: absolute;
  right: -20px;
  bottom: -28px;
  width: 88px;
  height: 88px;
  border: 1px solid rgb(194 122 24 / 18%);
  border-radius: 50%;
  content: "";
}

.flow-step-hub {
  border-color: rgb(194 122 24 / 34%);
  background:
    radial-gradient(circle at 50% 28%, rgb(255 243 207 / 90%), transparent 58%),
    linear-gradient(180deg, #fff8eb, var(--color-surface));
  box-shadow: var(--shadow-glow);
}

.flow-hub-glow {
  position: absolute;
  inset: 18px;
  border: 1px solid rgb(194 122 24 / 22%);
  border-radius: 50%;
  pointer-events: none;
}

.flow-hub-glow::before,
.flow-hub-glow::after {
  position: absolute;
  inset: -14px;
  border: 1px solid rgb(194 122 24 / 12%);
  border-radius: 50%;
  content: "";
}

.flow-hub-glow::after {
  inset: -28px;
  border-color: rgb(13 127 120 / 14%);
}

.flow-step-num {
  color: rgb(108 95 79 / 42%);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 820;
}

.flow-step-tag {
  width: max-content;
  padding: 4px 9px;
  border: 1px solid rgb(13 127 120 / 22%);
  border-radius: 6px;
  background: rgb(13 127 120 / 8%);
  color: var(--color-accent-strong);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.flow-step-tag.human {
  border-color: rgb(194 122 24 / 28%);
  background: rgb(194 122 24 / 12%);
  color: var(--color-human);
}

.flow-step-tag.system {
  border-color: rgb(194 122 24 / 34%);
  background: rgb(194 122 24 / 16%);
  color: #8f520f;
}

.flow-step h3 {
  margin: 2px 0 0;
  font-size: 1.08rem;
}

.flow-step p {
  margin: 0;
  color: var(--color-muted-text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.flow-connector {
  position: relative;
  align-self: center;
  height: 2px;
  background: linear-gradient(90deg, var(--color-human), var(--color-accent-strong));
}

.flow-connector::before,
.flow-connector::after {
  position: absolute;
  top: 50%;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transform: translateY(-50%);
  content: "";
}

.flow-connector::after {
  right: -2px;
  border-left: 9px solid var(--color-accent-strong);
}

.flow-connector::before {
  left: -4px;
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 50%;
  background: var(--color-human);
  box-shadow: 0 0 0 4px rgb(194 122 24 / 18%);
  transform: translateY(-50%);
  animation: flow-pulse 2.4s ease-in-out infinite;
}

.flow-connector.is-active::before {
  animation: flow-signal-travel 1.8s ease-in-out infinite;
}

.flow-connector.is-active {
  background: linear-gradient(90deg, var(--color-human), var(--color-accent-strong), var(--color-human));
  background-size: 200% 100%;
  animation: flow-line-shift 2.4s linear infinite;
}

@keyframes flow-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgb(194 122 24 / 18%);
  }

  50% {
    box-shadow: 0 0 0 8px rgb(194 122 24 / 8%);
  }
}

@keyframes flow-line-shift {
  to { background-position: 200% 0; }
}

@keyframes flow-signal-travel {
  0% { left: -4px; opacity: 0.4; }
  50% { left: calc(100% - 4px); opacity: 1; }
  100% { left: -4px; opacity: 0.4; }
}

@keyframes flow-chamber-glow {
  0%,
  100% { box-shadow: var(--shadow-soft); }
  50% { box-shadow: var(--shadow-soft), 0 0 48px rgb(194 122 24 / 18%); }
}

.flow-council-chamber {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 8px 0 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: translateZ(16px);
  transform-style: preserve-3d;
}

.flow-council-scene {
  position: relative;
  padding: 20px 0 14px;
  overflow: hidden;
  border-radius: 0;
  background:
    radial-gradient(ellipse 120% 68% at 50% -6%, rgb(194 122 24 / 14%), transparent 58%),
    radial-gradient(ellipse 100% 54% at 18% 88%, rgb(13 127 120 / 7%), transparent 52%),
    radial-gradient(ellipse 100% 54% at 82% 88%, rgb(194 122 24 / 8%), transparent 52%),
    linear-gradient(
      180deg,
      rgb(239 228 212 / 0%) 0%,
      rgb(239 228 212 / 55%) 6%,
      rgb(210 190 165 / 42%) 14%,
      rgb(92 76 58 / 38%) 24%,
      rgb(48 40 30 / 92%) 34%,
      #2a241c 48%,
      #211c15 62%,
      #1c1814 100%
    );
}

.flow-council-scene::before {
  position: absolute;
  inset: 0 0 auto;
  height: 48px;
  background: linear-gradient(180deg, rgb(239 228 212 / 72%), transparent);
  content: "";
  pointer-events: none;
}

.flow-council-scene::after {
  position: absolute;
  inset: auto 0 0;
  height: 36px;
  background: linear-gradient(0deg, rgb(232 220 200 / 28%), transparent);
  content: "";
  pointer-events: none;
}

.flow-council-viz {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chamber-floor-glow {
  animation: chamber-floor-pulse 4.8s ease-in-out infinite;
}

.chamber-arc {
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  opacity: 0.72;
  animation: council-arc-draw 5.6s ease-in-out infinite;
}

.chamber-arc-designer { animation-delay: 0s; }
.chamber-arc-architect { animation-delay: 0.4s; }
.chamber-arc-principal { animation-delay: 0.8s; }
.chamber-arc-reviewer { animation-delay: 1.2s; }
.chamber-arc-security { animation-delay: 1.6s; }

.chamber-beam {
  stroke-width: 2;
  opacity: 0.14;
  stroke-dasharray: 6 8;
  transition: opacity 220ms ease, stroke-width 220ms ease;
}

.chamber-beam.is-active {
  opacity: 0.92;
  stroke-width: 3;
  animation: chamber-beam-pulse 1.4s ease-in-out infinite;
}

.chamber-eye .eye-pupil {
  transition: transform 100ms ease-out;
}

.chamber-eye circle:first-child {
  filter: drop-shadow(0 0 18px rgb(230 184 107 / 42%));
}

.flow-council-chamber.is-live .chamber-eye circle:first-child {
  animation: council-core-glow 2.4s ease-in-out infinite;
}

.flow-council-chamber.is-live .chamber-arc {
  opacity: 1;
}

@keyframes chamber-floor-pulse {
  0%,
  100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes chamber-beam-pulse {
  0%,
  100% { opacity: 0.72; }
  50% { opacity: 1; }
}

.flow-roles {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  width: min(1040px, 100%);
  padding: 0 10px;
  margin: -8px auto 0;
  list-style: none;
}

.flow-roles li {
  display: grid;
  gap: 6px;
  padding: 14px 12px;
  border: 1px solid rgb(230 218 200 / 14%);
  border-radius: 10px;
  background:
    linear-gradient(160deg, rgb(194 122 24 / 10%), transparent 42%),
    rgb(36 30 24 / 42%);
  color: rgb(239 228 212 / 78%);
  font-size: 0.84rem;
  line-height: 1.35;
  transition: border-color 180ms ease, transform 180ms ease;
}

.flow-roles li:hover {
  border-color: rgb(230 184 107 / 34%);
  transform: translateY(-2px);
}

.flow-roles li.is-active {
  border-color: rgb(230 184 107 / 52%);
  background:
    linear-gradient(160deg, rgb(194 122 24 / 22%), transparent 42%),
    rgb(255 246 231 / 8%);
  color: #fff6e7;
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 14px 32px rgb(0 0 0 / 28%);
}

.flow-roles li span {
  color: #e6b86b;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.flow-ring {
  display: none;
}

.flow-lane-output {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.flow-lane-output .flow-step {
  min-height: 156px;
}

.flow-step-gate {
  border-color: rgb(194 122 24 / 38%);
  background:
    linear-gradient(135deg, rgb(194 122 24 / 16%), transparent 58%),
    linear-gradient(180deg, var(--color-surface-raised), var(--color-surface));
}

.flow-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.flow-gate-actions em {
  padding: 4px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  background: rgb(255 250 241 / 82%);
  color: var(--color-ink);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 760;
}

.flow-gate-actions em.yes {
  border-color: rgb(13 127 120 / 28%);
  background: rgb(13 127 120 / 10%);
  color: var(--color-accent-strong);
}

.flow-gate-actions em.no {
  border-color: rgb(194 122 24 / 24%);
  background: rgb(194 122 24 / 8%);
  color: #8f520f;
}

@media (max-width: 1040px) {
  .flow-lane {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .flow-connector {
    width: 2px;
    height: 28px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--color-human), var(--color-accent-strong));
  }

  .flow-connector::after {
    top: auto;
    right: auto;
    bottom: -2px;
    left: 50%;
    border-top: 9px solid var(--color-accent-strong);
    border-right: 6px solid transparent;
    border-left: 6px solid transparent;
    transform: translateX(-50%);
  }

  .flow-connector::before {
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
  }

  .flow-roles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flow-lane-output {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.flow-section {
  position: relative;
}

.consilium-flow.is-council-phase .flow-step-hub {
  animation: flow-hub-pulse 2.2s ease-in-out infinite;
}

@keyframes flow-hub-pulse {
  0%,
  100% { box-shadow: var(--shadow-glow); }
  50% { box-shadow: var(--shadow-glow), 0 0 36px rgb(194 122 24 / 28%); }
}

@media (prefers-reduced-motion: reduce) {
  .consilium-flow {
    transform: none;
    transition: none;
  }

  .flow-step,
  .flow-connector,
  .flow-council-chamber,
  .flow-roles li {
    transition: none;
    animation: none !important;
  }

  .flow-step.is-active {
    transform: none;
  }
}

@media (max-width: 620px) {
  .flow-roles,
  .flow-lane-output {
    grid-template-columns: 1fr;
  }

  .flow-step,
  .flow-lane-output .flow-step {
    min-height: auto;
  }
}