.nextjs-compose-page {
  --compose-cyan: #26c6f4;
  --compose-blue: #5577ff;
  --compose-purple: #8a6cff;
  --compose-red: #ff5269;
  --compose-green: #24c98a;
  --compose-ink: #071322;
  --compose-panel: #0d1d31;
  --compose-line: rgba(103, 177, 255, 0.26);
}

.compose-hero__visual,
.compose-article-art {
  margin: 32px 0 0;
  overflow: hidden;
  border: 1px solid rgba(79, 124, 255, 0.28);
  border-radius: 22px;
  background: #050b18;
  box-shadow: 0 24px 70px rgba(5, 14, 35, 0.18);
}

.compose-hero__visual img,
.compose-article-art img {
  display: block;
  width: 100%;
  height: auto;
}

.compose-article-art figcaption {
  padding: 15px 19px;
  background: var(--compose-panel);
  color: #dcecff;
  line-height: 1.65;
}

.compose-article-art figcaption strong {
  color: #fff;
}

/* Diagram shell: the caption always occupies its own full-width row. */
.compose-diagram {
  position: relative;
  display: block !important;
  margin: 30px 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(75, 133, 255, 0.3);
  border-radius: 20px;
  background:
    radial-gradient(circle at 88% 8%, rgba(78, 96, 255, 0.15), transparent 30%),
    linear-gradient(145deg, #071322, #0d2038);
  color: #eaf5ff;
  box-shadow: 0 18px 48px rgba(4, 16, 36, 0.14);
}

.compose-diagram::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(75, 150, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(75, 150, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}

.compose-diagram figcaption {
  position: relative;
  z-index: 2;
  display: block;
  margin: 0;
  padding: 20px 24px 18px;
  border-bottom: 1px solid rgba(103, 177, 255, 0.18);
  background: rgba(4, 17, 34, 0.42);
}

.compose-diagram figcaption strong {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
  color: #fff;
  font-size: 1rem;
  line-height: 1.35;
}

.compose-diagram figcaption strong::before {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--compose-cyan), var(--compose-purple));
  box-shadow: 0 0 0 5px rgba(48, 217, 255, 0.1);
  content: "";
}

.compose-diagram figcaption span {
  display: block;
  max-width: 760px;
  color: #b9cbe0;
  font-size: 0.88rem;
  line-height: 1.65;
}

.compose-diagram > [role="img"] {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 156px;
  padding: 28px 24px;
}

.compose-diagram b,
.compose-diagram section,
.compose-diagram .node {
  box-sizing: border-box;
  min-width: 0;
  padding: 16px 14px;
  border: 1px solid rgba(48, 217, 255, 0.32);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(18, 48, 79, 0.96), rgba(10, 31, 55, 0.96));
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 8, 24, 0.2);
}

.compose-diagram b,
.compose-diagram .node {
  display: grid;
  place-content: center;
  gap: 6px;
  min-height: 66px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.compose-diagram section {
  display: grid;
  gap: 10px;
  align-content: center;
}

.compose-diagram section > strong {
  color: #fff;
  font-size: 0.95rem;
}

.compose-diagram span,
.compose-diagram em {
  color: #bdd0e5;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 500;
  line-height: 1.45;
}

.compose-diagram i {
  display: grid;
  width: 32px;
  height: 32px;
  place-content: center;
  align-self: center;
  justify-self: center;
  border: 1px solid rgba(48, 217, 255, 0.2);
  border-radius: 50%;
  background: rgba(48, 217, 255, 0.08);
  color: var(--compose-cyan);
  font-size: 1.05rem;
  font-style: normal;
}

.compose-diagram .database {
  border-color: rgba(85, 119, 255, 0.75);
  box-shadow: inset 0 0 24px rgba(85, 119, 255, 0.07), 0 10px 28px rgba(0, 8, 24, 0.2);
}

.compose-diagram .redis,
.compose-diagram .danger {
  border-color: rgba(255, 82, 105, 0.78);
  box-shadow: inset 0 0 24px rgba(255, 82, 105, 0.07), 0 10px 28px rgba(0, 8, 24, 0.2);
}

.compose-diagram .secure {
  border-color: rgba(36, 201, 138, 0.78);
  box-shadow: inset 0 0 24px rgba(36, 201, 138, 0.07), 0 10px 28px rgba(0, 8, 24, 0.2);
}

/* Only the inner diagram canvas receives layout rules. */
.compose-stack-grid > [role="img"] {
  display: grid;
  grid-template-columns: minmax(110px, 0.75fr) 34px minmax(110px, 0.75fr) 34px minmax(260px, 1.6fr);
  gap: 12px;
  align-items: center;
}

.compose-stack-grid > [role="img"] > section {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compose-stack-grid > [role="img"] > section > strong {
  grid-column: 1 / -1;
}

.compose-branch > [role="img"],
.compose-diagram:not(.compose-stack-grid):not(.compose-flow-list):not(.compose-cases):not(.compose-lanes) > [role="img"] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.compose-branch > [role="img"] > b,
.compose-branch > [role="img"] > section {
  flex: 1 1 0;
}

.compose-branch > [role="img"] > section {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compose-flow-list > [role="img"] {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 22px;
  align-items: stretch;
}

.compose-flow-list .node {
  position: relative;
}

.compose-flow-list .node:not(:last-child)::after {
  position: absolute;
  top: 50%;
  right: -19px;
  z-index: 3;
  color: var(--compose-cyan);
  content: "\2192";
  font-size: 1.05rem;
  transform: translateY(-50%);
}

.compose-cases > [role="img"] {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.compose-lanes > [role="img"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.compose-grid,
.compose-checklists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.compose-grid section,
.compose-checklists section {
  padding: 20px;
  border: 1px solid rgba(79, 124, 255, 0.18);
  border-radius: 16px;
  background: rgba(79, 124, 255, 0.045);
}

.compose-grid h3,
.compose-checklists h3 {
  margin-top: 0;
}

.compose-page-table {
  max-width: 100%;
  overflow-x: auto;
}

.compose-page-table table {
  min-width: 640px;
}

.compose-learning-path {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 28px 0;
  padding: 0;
  list-style: none;
}

.compose-learning-path li {
  padding: 16px;
  border: 1px solid rgba(79, 124, 255, 0.12);
  border-radius: 14px;
  background: rgba(79, 124, 255, 0.08);
  text-align: center;
}

.compose-learning-path span,
.compose-learning-path em {
  display: block;
  font-size: 0.78rem;
}

.compose-learning-path em {
  color: #348c68;
}

.compose-learning-path .upcoming {
  opacity: 0.72;
}

.nextjs-compose-page .code-block pre {
  max-width: 100%;
  overflow-x: auto;
}

.active-light-mode .compose-diagram {
  border-color: rgba(67, 112, 245, 0.28);
  background:
    radial-gradient(circle at 88% 8%, rgba(104, 88, 255, 0.1), transparent 32%),
    linear-gradient(145deg, #f8fbff, #f2f5ff);
  color: #172944;
  box-shadow: 0 16px 42px rgba(31, 56, 112, 0.09);
}

.active-light-mode .compose-diagram::after {
  background-image:
    linear-gradient(rgba(50, 105, 210, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 105, 210, 0.035) 1px, transparent 1px);
}

.active-light-mode .compose-diagram figcaption {
  border-bottom-color: rgba(67, 112, 245, 0.13);
  background: rgba(234, 242, 255, 0.58);
}

.active-light-mode .compose-diagram figcaption strong,
.active-light-mode .compose-diagram section > strong {
  color: #10213a;
}

.active-light-mode .compose-diagram figcaption span,
.active-light-mode .compose-diagram span,
.active-light-mode .compose-diagram em {
  color: #536780;
}

.active-light-mode .compose-diagram b,
.active-light-mode .compose-diagram section,
.active-light-mode .compose-diagram .node {
  background: linear-gradient(145deg, #fff, #f7faff);
  color: #10213a;
  box-shadow: 0 8px 22px rgba(41, 69, 128, 0.08);
}

@media (max-width: 1024px) {
  .compose-stack-grid > [role="img"],
  .compose-branch > [role="img"],
  .compose-diagram:not(.compose-stack-grid):not(.compose-flow-list):not(.compose-cases):not(.compose-lanes) > [role="img"] {
    display: flex;
    flex-direction: column;
  }

  .compose-stack-grid > [role="img"] > b,
  .compose-stack-grid > [role="img"] > section,
  .compose-branch > [role="img"] > b,
  .compose-branch > [role="img"] > section,
  .compose-diagram:not(.compose-stack-grid):not(.compose-flow-list):not(.compose-cases):not(.compose-lanes) > [role="img"] > b,
  .compose-diagram:not(.compose-stack-grid):not(.compose-flow-list):not(.compose-cases):not(.compose-lanes) > [role="img"] > section {
    width: 100%;
  }

  .compose-stack-grid > [role="img"] > i,
  .compose-branch > [role="img"] > i,
  .compose-diagram:not(.compose-stack-grid):not(.compose-flow-list):not(.compose-cases):not(.compose-lanes) > [role="img"] > i {
    transform: rotate(90deg);
  }

  .compose-flow-list > [role="img"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .compose-flow-list .node::after {
    display: none;
  }

  .compose-cases > [role="img"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .nextjs-compose-page .blog-hero--article {
    padding: 102px 0 46px;
  }

  .nextjs-compose-page .article-layout {
    width: min(100% - 28px, 760px);
  }

  .compose-hero__visual,
  .compose-article-art {
    border-radius: 15px;
  }

  .compose-diagram {
    margin-inline: -2px;
    border-radius: 16px;
  }

  .compose-diagram figcaption {
    padding: 17px 17px 15px;
  }

  .compose-diagram figcaption strong {
    font-size: 0.94rem;
  }

  .compose-diagram figcaption span {
    font-size: 0.8rem;
  }

  .compose-diagram > [role="img"],
  .compose-flow-list > [role="img"],
  .compose-cases > [role="img"],
  .compose-lanes > [role="img"] {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 12px;
    padding: 19px 16px 21px;
  }

  .compose-diagram b,
  .compose-diagram section,
  .compose-diagram .node {
    width: 100%;
  }

  .compose-stack-grid > [role="img"] > section,
  .compose-branch > [role="img"] > section {
    grid-template-columns: 1fr;
  }

  .compose-flow-list .node::after {
    display: none;
  }

  .compose-grid,
  .compose-checklists,
  .compose-learning-path {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .compose-diagram *,
  .compose-diagram *::before,
  .compose-diagram *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
