:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #f4f6fb;
  --ink: #111827;
  --muted: #5f6b7a;
  --subtle: #d9dee8;
  --line: #e6e9f1;
  --accent: #6657d8;
  --accent-strong: #4238a8;
  --accent-soft: #efedff;
  --green: #0f8f68;
  --green-soft: #e9f8f2;
  --yellow: #a16408;
  --yellow-soft: #fff6df;
  --red: #b42318;
  --red-soft: #fff0ed;
  --code: #101828;
  --shadow: 0 20px 45px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 280px;
  min-height: 100vh;
}

.sidebar,
.right-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 18px;
}

.right-rail {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand small,
.nav-block p,
.muted,
.eyebrow {
  color: var(--muted);
}

.brand small {
  display: block;
  margin-top: -4px;
  font-size: 12px;
}

.nav-block {
  margin-bottom: 26px;
}

.nav-block p {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-block a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 10px;
  color: #344054;
  font-size: 14px;
  font-weight: 650;
}

.nav-block a:hover,
.nav-block a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-pill {
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
}

.content {
  min-width: 0;
  padding: 38px clamp(24px, 4vw, 64px) 80px;
}

.content:focus {
  outline: none;
}

.article,
.home,
.framework {
  max-width: 940px;
  margin: 0 auto;
}

.hero {
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(38px, 5vw, 62px);
}

h2 {
  margin: 52px 0 14px;
  padding-top: 12px;
  font-size: 30px;
}

h3 {
  margin: 28px 0 10px;
  font-size: 21px;
}

p {
  margin: 0 0 16px;
}

ul,
ol {
  margin-top: 8px;
  padding-left: 22px;
}

li {
  margin: 7px 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.tag,
.status,
.difficulty {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status {
  background: var(--green-soft);
  color: var(--green);
}

.difficulty {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.challenge-card,
.prep-card,
.callout,
.decision,
.entity-card,
.api-block,
.table-wrap,
.diagram,
.system-diagram,
.image-diagram,
.rail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

.challenge-card {
  padding: 20px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.challenge-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.challenge-card h2 {
  margin: 12px 0 8px;
  padding: 0;
  font-size: 23px;
}

.challenge-card.locked {
  opacity: 0.62;
}

.prep-card {
  padding: 18px;
}

.prep-card h3 {
  margin-top: 0;
}

.section-lead {
  max-width: 780px;
  color: #3b4655;
  font-size: 18px;
}

.requirements {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.requirement-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.requirement-box h3 {
  margin-top: 0;
}

.below-line {
  background: var(--panel-soft);
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.entity-card {
  padding: 16px;
}

.entity-card h3 {
  margin-top: 0;
}

.field-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0;
  list-style: none;
}

.field-list li {
  margin: 0;
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 4px 8px;
  color: #344054;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.api-grid {
  display: grid;
  gap: 14px;
}

.api-block {
  overflow: hidden;
}

.api-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.method {
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 3px 7px;
  font-size: 12px;
}

.api-block pre {
  margin: 0;
  overflow-x: auto;
  padding: 14px;
  background: var(--code);
  color: #eef2ff;
  font-size: 13px;
  line-height: 1.55;
}

.callout {
  margin: 20px 0;
  padding: 18px;
  background: var(--accent-soft);
}

.callout strong {
  color: var(--accent-strong);
}

.decision {
  margin: 18px 0;
  padding: 18px;
}

.decision.good {
  border-color: #bbf7d0;
  background: var(--green-soft);
}

.decision.warn {
  border-color: #fed7aa;
  background: var(--yellow-soft);
}

.decision.bad {
  border-color: #fecaca;
  background: var(--red-soft);
}

.decision h3 {
  margin-top: 0;
}

.diagram {
  margin: 18px 0;
  padding: 18px;
  overflow-x: auto;
}

.flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  min-width: 720px;
}

.flow-node {
  position: relative;
  min-height: 78px;
  border: 1px solid var(--subtle);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
  font-weight: 800;
}

.flow-node small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 650;
}

.flow-node:not(:last-child)::after {
  content: ">";
  position: absolute;
  top: 50%;
  right: -11px;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-align: center;
  line-height: 20px;
  font-size: 12px;
  z-index: 1;
}

.system-diagram {
  margin: 22px 0;
  overflow: hidden;
}

.image-diagram {
  margin: 22px 0;
  overflow: hidden;
}

.system-diagram figcaption {
  display: grid;
  gap: 5px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
  padding: 14px 16px;
}

.image-diagram figcaption {
  display: grid;
  gap: 5px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
  padding: 14px 16px;
}

.system-diagram figcaption strong {
  font-size: 15px;
}

.image-diagram figcaption strong {
  font-size: 15px;
}

.system-diagram figcaption span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.image-diagram figcaption span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.image-diagram-canvas {
  overflow-x: auto;
  padding: 16px;
  background: #ffffff;
}

.image-diagram img {
  display: block;
  width: 100%;
  height: auto;
}

.design-section {
  margin-top: 28px;
}

.diagram-placeholder {
  display: grid;
  gap: 6px;
  margin: 18px 0;
  border: 1px dashed var(--subtle);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.diagram-placeholder span {
  color: var(--muted);
}

.pdf-diagram {
  border-color: #24262b;
  background: #050505;
  color: #f8fafc;
}

.pdf-diagram figcaption {
  border-bottom-color: #22252b;
  background: #050505;
}

.pdf-diagram figcaption span {
  color: #cbd5e1;
}

.diagram-canvas {
  overflow-x: auto;
  padding: 12px;
  background:
    linear-gradient(rgba(102, 87, 216, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 87, 216, 0.035) 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
}

.pdf-diagram .diagram-canvas {
  padding: 18px;
  background: #050505;
}

.diagram-canvas svg {
  display: block;
  min-width: 820px;
  width: 100%;
  height: auto;
}

.diagram-edge {
  fill: none;
  stroke: #6b7280;
  stroke-width: 2;
}

.pdf-diagram .diagram-edge {
  stroke: #d4d4d8;
  stroke-width: 1.4;
}

.diagram-arrow {
  fill: #6b7280;
}

.pdf-diagram .diagram-arrow {
  fill: #d4d4d8;
}

.diagram-edge-label {
  fill: #475467;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 5px;
  stroke-linejoin: round;
  font-size: 12px;
  font-weight: 800;
}

.pdf-diagram .diagram-edge-label {
  fill: #d4d4d8;
  stroke: #050505;
  stroke-width: 6px;
  font-size: 12px;
  font-weight: 650;
}

.diagram-node rect {
  stroke-width: 1.5;
}

.diagram-node path,
.diagram-node ellipse {
  stroke-width: 1.5;
}

.diagram-node-title {
  fill: #101828;
  font-size: 14px;
  font-weight: 850;
}

.diagram-node-detail {
  fill: #475467;
  font-size: 12px;
  font-weight: 650;
}

.pdf-diagram .diagram-node-title,
.pdf-diagram .diagram-node-detail {
  fill: #d4d4d8;
}

.pdf-diagram .diagram-node-title {
  font-size: 13px;
  font-weight: 650;
}

.pdf-diagram .diagram-node-detail {
  font-size: 11px;
}

.pdf-diagram .diagram-node rect,
.pdf-diagram .diagram-node path,
.pdf-diagram .diagram-node ellipse {
  fill: #242424;
  stroke: #e5e7eb;
}

.diagram-group rect {
  fill: rgba(113, 113, 122, 0.65);
  stroke: none;
}

.diagram-group text {
  fill: #f4f4f5;
  font-size: 13px;
}

.sequence-participant rect {
  fill: #242424;
  stroke: #e5e7eb;
  stroke-width: 1.2;
}

.sequence-participant text,
.sequence-message text {
  fill: #d4d4d8;
  font-size: 11px;
}

.sequence-participant line {
  stroke: #d4d4d8;
  stroke-width: 1.1;
}

.sequence-message line {
  stroke: #d4d4d8;
  stroke-width: 1.2;
}

.sequence-message-dashed line {
  stroke-dasharray: 4 4;
}

.diagram-node-client rect {
  fill: #f5f3ff;
  stroke: #c4b5fd;
}

.diagram-node-service rect {
  fill: #eff6ff;
  stroke: #93c5fd;
}

.diagram-node-store rect {
  fill: #ecfdf3;
  stroke: #86efac;
}

.diagram-node-queue rect {
  fill: #fff7ed;
  stroke: #fdba74;
}

.diagram-node-external rect {
  fill: #fff1f2;
  stroke: #fda4af;
}

.pdf-diagram .diagram-node rect,
.pdf-diagram .diagram-node path,
.pdf-diagram .diagram-node ellipse {
  fill: #242424;
  stroke: #e5e7eb;
}

.table-wrap {
  margin: 18px 0;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-soft);
  font-size: 13px;
}

.rail-card {
  margin-bottom: 16px;
  padding: 16px;
}

.rail-card h2,
.rail-card h3 {
  margin: 0 0 10px;
  padding: 0;
  font-size: 16px;
}

.toc {
  display: grid;
  gap: 6px;
}

.toc button {
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 6px 8px;
  color: #475467;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.toc button:hover {
  background: var(--panel-soft);
  color: var(--accent-strong);
}

.prompt-list {
  padding-left: 18px;
  color: #344054;
  font-size: 14px;
}

.empty-state {
  border: 1px dashed var(--subtle);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content {
    padding: 26px 18px 56px;
  }

  .card-grid,
  .requirements,
  .entity-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 36px;
  }
}
