:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #5f6d7a;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #d9dee6;
  --blue: #2266aa;
  --green: #287a59;
  --amber: #a26113;
  --rose: #a83d5c;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(34, 102, 170, 0.08), transparent 34rem),
    linear-gradient(315deg, rgba(40, 122, 89, 0.08), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

a {
  color: var(--blue);
  font-weight: 700;
}

.top,
main,
footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.top {
  min-height: 64vh;
  display: grid;
  align-content: center;
  padding: 64px 0 28px;
}

.top.compact {
  min-height: 34vh;
}

.kicker {
  margin: 0 0 10px;
  color: var(--rose);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 840px;
  margin-bottom: 18px;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.25;
  letter-spacing: 0;
}

.lead {
  max-width: 760px;
  color: #354452;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.source {
  width: fit-content;
  margin-top: 8px;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

main {
  display: grid;
  gap: 18px;
  padding-bottom: 36px;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 24px;
  align-items: center;
}

.overview-layers {
  display: grid;
  gap: 2px;
}

.official-overview {
  display: grid;
  gap: 8px;
}

.source-note {
  max-width: 760px;
  color: var(--muted);
}

.translation {
  display: grid;
  gap: 14px;
  max-width: 900px;
}

.translation p {
  margin-bottom: 0;
  color: #2f3d49;
}

.overview-map {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.overview-operations {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.overview-detail-flow {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

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

.detail-flow {
  display: grid;
  gap: 12px;
}

.map-table {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.map-table > div {
  display: grid;
  grid-template-columns: 0.65fr 1.35fr 0.75fr;
  gap: 1px;
}

.map-table span,
.map-table b {
  background: white;
  padding: 12px;
}

.map-table b {
  background: #eef6ff;
}

.overview-reading {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

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

.layer-grid article,
.overview-reading article,
.operation-grid article,
.detail-flow article,
.doc-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.layer-grid h3,
.overview-reading h3,
.operation-grid h3,
.detail-flow h3,
.doc-card h3 {
  margin: 8px 0 8px;
  font-size: 1.08rem;
}

.layer-grid p,
.overview-reading p,
.operation-grid p,
.detail-flow p,
.doc-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.example-reading {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.example-reading ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: examples;
}

.example-reading li {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 16px 16px 16px 52px;
  color: #334250;
}

.example-reading li::before {
  counter-increment: examples;
  content: counter(examples);
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 0.86rem;
  font-weight: 850;
}

.example-reading b {
  display: block;
  margin-bottom: 5px;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--blue);
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 850;
}

.mini-flow {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-flow li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.mini-flow span {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.mini-flow p {
  min-width: 0;
  margin: 0;
  color: #334250;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.mini-flow b {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 18px;
}

.section-title {
  margin-bottom: 18px;
}

.buttons,
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

button:focus-visible {
  outline: 3px solid rgba(34, 102, 170, 0.32);
  outline-offset: 2px;
}

.chip {
  min-height: 42px;
  padding: 8px 14px;
}

.chip.active,
.step.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.explain {
  min-height: 168px;
  border-left: 4px solid var(--blue);
  padding: 2px 0 2px 16px;
}

.explain h3 {
  margin: 0 0 8px;
  font-size: 1.12rem;
}

.explain p {
  color: var(--muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}

.must { background: var(--blue); }
.should { background: var(--green); }
.may { background: var(--amber); }

.code-panel {
  min-width: 0;
}

pre {
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #edf7ff;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

pre code {
  display: block;
  padding: 18px;
}

.json-line {
  display: block;
  margin: 0 -8px;
  padding: 0 8px;
  border-radius: 5px;
}

.json-line.on {
  background: rgba(90, 180, 255, 0.19);
}

.json-line.must.on {
  box-shadow: inset 4px 0 var(--blue);
}

.json-line.should.on {
  box-shadow: inset 4px 0 var(--green);
}

.json-line.may.on {
  box-shadow: inset 4px 0 var(--amber);
}

.playground {
  display: grid;
  gap: 18px;
}

.step {
  min-height: 40px;
  padding: 7px 13px;
}

.diagram {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 16px;
  min-height: 230px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f2f6fa);
  padding: 22px;
}

.node,
.box {
  display: grid;
  min-height: 58px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
  font-weight: 800;
}

.lane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actor {
  grid-column: 1 / -1;
  background: #eef6ff;
  border-color: rgba(34, 102, 170, 0.28);
}

.box.on {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(34, 102, 170, 0.13);
}

.message {
  position: absolute;
  top: 50%;
  left: 8%;
  min-width: 108px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--rose);
  color: white;
  padding: 9px 14px;
  text-align: center;
  font-weight: 850;
  transition: left 250ms ease, top 250ms ease, background 250ms ease;
}

.message.to-outbox {
  left: 44%;
  top: 65%;
}

.message.to-inbox {
  left: 58%;
  top: 32%;
  background: var(--blue);
}

.message.read-inbox {
  left: 25%;
  top: 33%;
  background: var(--green);
}

.message.read-outbox {
  left: 72%;
  top: 65%;
  background: var(--amber);
}

.flow-copy {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 18px;
  align-items: start;
}

.flow-copy p {
  margin: 0;
  color: #334250;
}

.summary ul {
  margin: 0;
  padding-left: 22px;
}

.summary li + li {
  margin-top: 8px;
}

.section-map {
  box-shadow: none;
}

.doc-layout {
  display: grid;
  grid-template-columns: minmax(210px, 0.36fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.doc-nav {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 8px;
}

.hub-nav {
  position: static;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reading-paths {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.reading-paths article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 16px;
}

.reading-paths h3 {
  margin: 8px 0;
}

.reading-paths p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.section-catalog article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 16px;
}

.section-catalog h3 {
  margin: 8px 0;
}

.section-catalog p {
  margin-bottom: 0;
  color: var(--muted);
}

.doc-link {
  display: block;
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 12px;
  text-decoration: none;
  text-align: left;
  font-weight: 750;
}

.doc-link.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.doc-teaser {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: clamp(18px, 3vw, 28px);
}

.doc-teaser h3 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.doc-teaser p {
  color: var(--muted);
}

.doc-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: clamp(18px, 3vw, 28px);
}

.doc-detail h3 {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.18;
}

.doc-detail h4 {
  margin: 26px 0 8px;
  font-size: 1.05rem;
}

.doc-detail h5 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.doc-detail p {
  color: #2f3d49;
}

.doc-detail ul {
  margin: 0;
  padding-left: 22px;
}

.doc-detail li + li {
  margin-top: 7px;
}

.doc-detail .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.doc-detail .example {
  margin-top: 14px;
}

.example-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 750;
}

.mini-code {
  margin-bottom: 6px;
}

.faq-list {
  display: grid;
  gap: 8px;
}

.faq-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px 14px;
}

.faq-list summary {
  cursor: pointer;
  font-weight: 850;
}

.faq-list p {
  margin: 10px 0 0;
}

.subsection-list {
  display: grid;
  gap: 10px;
}

.subsection-list section {
  border-left: 4px solid rgba(34, 102, 170, 0.35);
  background: #f7f9fb;
  border-radius: 8px;
  padding: 12px 14px;
}

.subsection-list p {
  margin: 0;
}

.subsection-source {
  display: inline-block;
  margin: 0 0 8px;
  font-size: 0.9rem;
}

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

.glossary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.glossary dt {
  margin-bottom: 5px;
  font-weight: 850;
}

.glossary dd {
  margin: 0;
  color: var(--muted);
}

.doc-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.doc-pager a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  text-decoration: none;
}

.doc-pager a:last-child {
  text-align: right;
}

footer {
  padding: 0 0 34px;
  color: var(--muted);
  font-size: 0.94rem;
}

@media (max-width: 820px) {
  .top {
    min-height: 56vh;
  }

  .intro,
  .grid,
  .flow-copy,
  .map-table > div,
  .operation-grid,
  .layer-grid,
  .overview-reading,
  .example-reading ol,
  .glossary,
  .reading-paths,
  .section-catalog,
  .doc-layout {
    grid-template-columns: 1fr;
  }

  .doc-nav {
    position: static;
  }

  .diagram {
    grid-template-columns: 1fr;
    min-height: 460px;
  }

  .lane {
    grid-template-columns: 1fr;
  }

  .message,
  .message.to-outbox,
  .message.to-inbox,
  .message.read-inbox,
  .message.read-outbox {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
