.jfx-lifecycle {
  --jfx-blue: #087cad;
  --jfx-cyan: #16a9df;
  --jfx-navy: #082d4e;
  --jfx-ink: #102a43;
  --jfx-muted: #567086;
  --jfx-green: #138a5b;
  background:
    radial-gradient(circle at 96% 4%, rgba(22, 169, 223, .14), transparent 25%),
    linear-gradient(145deg, #f8fcff 0%, #eef8fc 100%);
  border: 1px solid #a9d9ec;
  border-radius: 1.4rem;
  box-shadow: 0 20px 50px rgba(8, 45, 78, .12);
  color: var(--jfx-ink);
  margin: 2rem 0;
  overflow: hidden;
  padding: clamp(1rem, 2.4vw, 1.7rem);
  position: relative;
}

.jfx-lifecycle::before {
  background: linear-gradient(90deg, var(--jfx-blue), var(--jfx-cyan), #7c3aed);
  content: "";
  height: 5px;
  inset: 0 0 auto;
  position: absolute;
}

.jfx-lifecycle button { font: inherit; }

.jfx-lifecycle button:focus-visible {
  outline: 3px solid rgba(8, 124, 173, .35);
  outline-offset: 3px;
}

.jfx-lifecycle__header {
  align-items: end;
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.jfx-lifecycle__header h3 {
  color: var(--jfx-navy);
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  margin: .1rem 0 .35rem;
}

.jfx-lifecycle__header p { color: var(--jfx-muted); margin: 0; max-width: 720px; }

.jfx-lifecycle__eyebrow {
  color: var(--jfx-blue) !important;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.jfx-lifecycle__status {
  background: #fff;
  border: 1px solid #c6e2ed;
  border-radius: .85rem;
  box-shadow: 0 8px 20px rgba(8, 45, 78, .08);
  flex: 0 0 auto;
  min-width: 180px;
  padding: .7rem .85rem;
}

.jfx-lifecycle__status span,
.jfx-lifecycle__status strong { display: block; }
.jfx-lifecycle__status span { color: var(--jfx-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.jfx-lifecycle__status strong { color: var(--jfx-blue); margin-top: .15rem; }

.jfx-lifecycle__flow {
  display: grid;
  gap: .65rem;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0 0 1.25rem;
  position: relative;
}

.jfx-lifecycle__flow::before {
  background: #bddce8;
  content: "";
  height: 3px;
  left: 6%;
  position: absolute;
  right: 6%;
  top: 24px;
}

.jfx-lifecycle__phase {
  align-items: center;
  background: rgba(255, 255, 255, .92);
  border: 1px solid #c4dce6;
  border-radius: .85rem;
  color: var(--jfx-ink);
  cursor: pointer;
  display: flex;
  gap: .55rem;
  min-height: 70px;
  padding: .55rem;
  position: relative;
  text-align: left;
  transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease, background .25s ease;
  z-index: 1;
}

.jfx-lifecycle__phase:hover { border-color: var(--jfx-cyan); transform: translateY(-2px); }

.jfx-lifecycle__phase-number {
  align-items: center;
  background: #e3f4fa;
  border: 2px solid #97cbdc;
  border-radius: 50%;
  color: var(--jfx-blue);
  display: flex;
  flex: 0 0 34px;
  font-size: .82rem;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  transition: inherit;
}

.jfx-lifecycle__phase-copy { min-width: 0; }
.jfx-lifecycle__phase-copy strong,
.jfx-lifecycle__phase-copy small { display: block; }
.jfx-lifecycle__phase-copy strong { font-size: .78rem; line-height: 1.15; }
.jfx-lifecycle__phase-copy small { color: var(--jfx-muted); font-size: .66rem; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.jfx-lifecycle__phase.is-complete {
  background: #eaf8f1;
  border-color: #8dd3b4;
}
.jfx-lifecycle__phase.is-complete .jfx-lifecycle__phase-number { background: var(--jfx-green); border-color: var(--jfx-green); color: #fff; }
.jfx-lifecycle__phase.is-complete .jfx-lifecycle__phase-number::after { content: "✓"; }
.jfx-lifecycle__phase.is-complete .jfx-lifecycle__phase-number { font-size: 0; }
.jfx-lifecycle__phase.is-complete .jfx-lifecycle__phase-number::after { font-size: .9rem; }

.jfx-lifecycle__phase.is-active {
  background: linear-gradient(135deg, var(--jfx-blue), var(--jfx-cyan));
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(8, 124, 173, .3);
  color: #fff;
  transform: translateY(-4px);
}
.jfx-lifecycle__phase.is-active .jfx-lifecycle__phase-number { background: #fff; border-color: #fff; color: var(--jfx-blue); }
.jfx-lifecycle__phase.is-active small { color: rgba(255, 255, 255, .82); }
.jfx-lifecycle__phase.is-active::after {
  animation: jfx-phase-pulse 1.4s ease-out infinite;
  border: 3px solid rgba(22, 169, 223, .42);
  border-radius: 1rem;
  content: "";
  inset: -5px;
  pointer-events: none;
  position: absolute;
}

.jfx-lifecycle__workspace {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr);
}

.jfx-lifecycle__code,
.jfx-lifecycle__visual,
.jfx-lifecycle__console {
  border: 1px solid #c7dce5;
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(8, 45, 78, .08);
  overflow: hidden;
}

.jfx-lifecycle__code { background: #0c1b2a; color: #d8ebf7; }
.jfx-lifecycle__panel-bar {
  align-items: center;
  background: #12283b;
  color: #e5f4fb;
  display: flex;
  font-size: .78rem;
  gap: .6rem;
  justify-content: space-between;
  min-height: 42px;
  padding: .65rem .8rem;
}
.jfx-lifecycle__dots { display: flex; gap: .3rem; }
.jfx-lifecycle__dots i { background: #ffbd2e; border-radius: 50%; display: block; height: 9px; width: 9px; }
.jfx-lifecycle__dots i:first-child { background: #ff5f57; }
.jfx-lifecycle__dots i:last-child { background: #28c840; }

.jfx-lifecycle__code pre {
  background: transparent;
  color: inherit;
  font-size: clamp(.7rem, 1.25vw, .82rem);
  line-height: 1.55;
  margin: 0;
  max-height: 405px;
  overflow: auto;
  padding: .85rem 0;
}

.jfx-lifecycle__code code > span {
  border-left: 3px solid transparent;
  display: block;
  min-width: max-content;
  padding: 0 .85rem 0 .55rem;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.jfx-lifecycle__code code > span b { color: #66869f; display: inline-block; font-weight: 500; margin-right: .65rem; user-select: none; width: 1.6rem; }
.jfx-lifecycle__code code > span.is-active { background: rgba(22, 169, 223, .19); border-left-color: #38c8ff; color: #fff; }
.jfx-lifecycle__code code > span.is-active b { color: #80ddff; }

.jfx-lifecycle__visual { background: #fff; display: flex; flex-direction: column; }
.jfx-lifecycle__thread-card {
  align-items: center;
  background: linear-gradient(135deg, #e8f7fc, #f4edff);
  border-bottom: 1px solid #c7dce5;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  min-height: 60px;
  padding: .75rem .9rem;
}
.jfx-lifecycle__thread-card span { color: var(--jfx-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.jfx-lifecycle__thread-card strong { color: var(--jfx-navy); font-size: .82rem; text-align: right; }

.jfx-lifecycle__runtime {
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: .65rem;
  justify-content: center;
  min-height: 340px;
  padding: 1rem;
}
.jfx-lifecycle__framework { align-items: center; display: grid; gap: .15rem .65rem; grid-template-columns: auto 1fr; width: 100%; }
.jfx-lifecycle__framework > i { align-items: center; background: #dff3fb; border-radius: .75rem; color: var(--jfx-blue); display: flex; font-size: 1.25rem; grid-row: 1 / 3; height: 42px; justify-content: center; width: 42px; }
.jfx-lifecycle__framework strong { color: var(--jfx-navy); }
.jfx-lifecycle__framework span { color: var(--jfx-muted); font-size: .78rem; line-height: 1.35; }

.jfx-lifecycle__signal { background: #d4e5eb; height: 34px; overflow: hidden; position: relative; width: 3px; }
.jfx-lifecycle__signal span { background: linear-gradient(var(--jfx-cyan), #7c3aed); border-radius: 50%; height: 9px; left: -3px; opacity: 0; position: absolute; top: -10px; width: 9px; }
.jfx-lifecycle[data-active-phase] .jfx-lifecycle__signal span { animation: jfx-signal 1.6s ease-in-out infinite; opacity: 1; }

.jfx-lifecycle__stage {
  background: #f8fbfd;
  border: 1px solid #b9ced8;
  border-radius: .75rem;
  box-shadow: 0 14px 30px rgba(8, 45, 78, .14);
  max-width: 360px;
  opacity: .54;
  overflow: hidden;
  transform: scale(.94) translateY(8px);
  transition: opacity .35s ease, transform .35s ease, box-shadow .35s ease;
  width: 100%;
}
.jfx-lifecycle__stage-bar { align-items: center; background: #e4edf2; color: var(--jfx-navy); display: flex; font-size: .75rem; font-weight: 700; justify-content: space-between; min-height: 34px; padding-left: .7rem; }
.jfx-lifecycle__stage-bar button { align-self: stretch; background: transparent; border: 0; color: #6c7e8b; cursor: pointer; font-size: 1.25rem; min-width: 38px; }
.jfx-lifecycle__stage-bar button:not(:disabled):hover { background: #e5484d; color: #fff; }
.jfx-lifecycle__stage-body { align-items: center; display: flex; flex-direction: column; min-height: 170px; padding: 1rem; text-align: center; }
.jfx-lifecycle__stage-body > i { color: #9ab0bd; font-size: 1.8rem; margin-bottom: .4rem; }
.jfx-lifecycle__stage-body strong { color: var(--jfx-navy); }
.jfx-lifecycle__stage-body span { color: var(--jfx-muted); font-size: .78rem; margin: .25rem 0 .75rem; }
.jfx-lifecycle__demo-button { background: var(--jfx-blue); border: 0; border-radius: .55rem; color: #fff; cursor: pointer; font-size: .78rem; font-weight: 700; padding: .5rem .75rem; }
.jfx-lifecycle__demo-button:disabled { cursor: not-allowed; opacity: .38; }
.jfx-lifecycle__demo-button.is-handled { animation: jfx-event-success .65s ease; background: var(--jfx-green); }

.jfx-lifecycle__stage[data-stage-state="open"],
.jfx-lifecycle__stage[data-stage-state="interactive"] { opacity: 1; transform: scale(1) translateY(0); }
.jfx-lifecycle__stage[data-stage-state="interactive"] { box-shadow: 0 16px 36px rgba(8, 124, 173, .22); }
.jfx-lifecycle__stage[data-stage-state="stopped"] { opacity: .58; transform: scale(.88) translateY(12px); }

.jfx-lifecycle__console { background: #071521; color: #b8e6d0; margin-top: 1rem; }
.jfx-lifecycle__console-output { display: flex; flex-direction: column; font-family: Consolas, "Courier New", monospace; font-size: .78rem; gap: .25rem; min-height: 118px; padding: .8rem .9rem; }
.jfx-lifecycle__console-output .is-muted { color: #668295; }
.jfx-lifecycle__console-line { animation: jfx-console-line .3s ease both; animation-delay: var(--line-delay, 0ms); }
.jfx-lifecycle__console-line::before { color: #39d98a; content: "› "; }
.jfx-lifecycle__console-line.is-event { color: #68e5ff; font-weight: 700; }

.jfx-lifecycle__controls { align-items: center; display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1rem; }
.jfx-lifecycle__control { align-items: center; background: #fff; border: 1px solid #a9c9d7; border-radius: .65rem; color: var(--jfx-navy); cursor: pointer; display: inline-flex; font-size: .82rem; font-weight: 750; gap: .4rem; justify-content: center; min-height: 42px; padding: .55rem .8rem; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.jfx-lifecycle__control:hover:not(:disabled) { box-shadow: 0 7px 18px rgba(8, 45, 78, .12); transform: translateY(-2px); }
.jfx-lifecycle__control:disabled { cursor: not-allowed; opacity: .42; }
.jfx-lifecycle__control--primary { background: linear-gradient(135deg, var(--jfx-blue), var(--jfx-cyan)); border-color: transparent; color: #fff; min-width: 116px; }
.jfx-lifecycle__control--primary.is-playing { background: linear-gradient(135deg, #c2410c, #f97316); }

.jfx-lifecycle__hint { align-items: flex-start; background: #fff9df; border: 1px solid #f0d986; border-radius: .7rem; color: #624d0a; display: flex; font-size: .8rem; gap: .5rem; margin: 1rem 0 0; padding: .7rem .8rem; }
.jfx-lifecycle__hint code { background: rgba(98, 77, 10, .1); color: inherit; }

@keyframes jfx-phase-pulse { 0% { opacity: .85; transform: scale(.98); } 100% { opacity: 0; transform: scale(1.08); } }
@keyframes jfx-signal { 0% { top: -10px; } 100% { top: 36px; } }
@keyframes jfx-console-line { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
@keyframes jfx-event-success { 50% { box-shadow: 0 0 0 8px rgba(19, 138, 91, .16); transform: scale(1.04); } }

.is-explain-mode .jfx-lifecycle { max-width: 1500px; }
.is-explain-mode .jfx-lifecycle__workspace { grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); }

@media (max-width: 900px) {
  .jfx-lifecycle__flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .jfx-lifecycle__flow::before { display: none; }
  .jfx-lifecycle__workspace { grid-template-columns: 1fr; }
  .jfx-lifecycle__runtime { min-height: 310px; }
  .is-explain-mode .jfx-lifecycle__workspace { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .jfx-lifecycle { border-radius: 1rem; margin-inline: -.25rem; padding: 1rem .75rem; }
  .jfx-lifecycle__header { align-items: stretch; flex-direction: column; gap: .75rem; }
  .jfx-lifecycle__status { min-width: 0; }
  .jfx-lifecycle__flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jfx-lifecycle__phase { min-height: 64px; }
  .jfx-lifecycle__phase-copy small { display: none; }
  .jfx-lifecycle__runtime { min-height: 285px; padding: .75rem; }
  .jfx-lifecycle__thread-card { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .jfx-lifecycle__thread-card strong { text-align: left; }
  .jfx-lifecycle__controls { display: grid; grid-template-columns: repeat(2, 1fr); }
  .jfx-lifecycle__control { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .jfx-lifecycle *,
  .jfx-lifecycle *::before,
  .jfx-lifecycle *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}

@media print {
  .jfx-lifecycle { background: #fff; box-shadow: none; break-inside: avoid; }
  .jfx-lifecycle__controls,
  .jfx-lifecycle__hint,
  .jfx-lifecycle__signal { display: none !important; }
  .jfx-lifecycle__phase { box-shadow: none; transform: none !important; }
  .jfx-lifecycle__workspace { grid-template-columns: 1fr 1fr; }
  .jfx-lifecycle__code { background: #fff; color: #111; }
  .jfx-lifecycle__code code > span.is-active { background: transparent; color: #111; }
}
