:root {
  color-scheme: light;
  --page: #f5f9f8;
  --surface: #ffffff;
  --surface-soft: #edf7f4;
  --surface-muted: #f0f5f4;
  --ink: #18343b;
  --ink-strong: #102b31;
  --muted: #60777b;
  --line: #d7e4e1;
  --line-strong: #b9d3cd;
  --accent: #2f8f83;
  --accent-dark: #216f67;
  --accent-soft: #dff1ed;
  --alert: #a55249;
  --alert-soft: #fbefed;
  --warning: #8a651f;
  --warning-soft: #fbf5e7;
  --radius: 12px;
  --shadow: 0 12px 34px rgb(28 78 70 / 0.06);
  --header-height: 72px;
  --content-width: 1040px;
  --toc-width: 250px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  overflow-x: clip;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 18px);
  background: var(--page);
}

body {
  min-width: 0;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background: var(--page);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  counter-reset: chapter;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--accent-dark);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

h1,
h2,
h3 {
  color: var(--ink-strong);
  line-height: 1.24;
  letter-spacing: -0.025em;
}

h1 {
  margin-bottom: 1.25rem;
  font-size: clamp(2.35rem, 5vw, 4.25rem);
  font-weight: 780;
}

h2 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.65rem, 3.1vw, 2.55rem);
  font-weight: 760;
}

h3 {
  margin-bottom: 0.55rem;
  font-size: 1.08rem;
  font-weight: 740;
}

p,
li {
  font-size: 1rem;
}

p {
  max-width: 68ch;
  margin-bottom: 1rem;
}

ul {
  margin: 0.75rem 0 0;
  padding-left: 1.35rem;
}

li {
  margin-bottom: 0.45rem;
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  overflow-wrap: anywhere;
}

::selection {
  color: var(--surface);
  background: var(--accent-dark);
}

:focus-visible {
  outline: 3px solid rgb(47 143 131 / 0.42);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 50;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  color: var(--surface);
  background: var(--ink-strong);
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgb(24 52 59 / 0.1);
  background: rgb(245 249 248 / 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-inner {
  width: min(calc(100% - 40px), 1440px);
  min-height: var(--header-height);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-strong);
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--surface);
  background: var(--accent-dark);
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.96rem;
  line-height: 1.2;
}

.brand small {
  margin-top: 0.18rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.action-button {
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-strong);
  background: transparent;
  font-size: 0.88rem;
  font-weight: 720;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.action-button:hover {
  transform: translateY(-1px);
}

.action-button:active {
  transform: translateY(1px);
}

.action-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
}

.action-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.action-primary {
  color: var(--surface);
  background: var(--accent-dark);
}

.action-primary:hover {
  background: var(--ink-strong);
}

.mobile-toc {
  display: none;
}

.report-layout {
  width: min(calc(100% - 40px), 1440px);
  margin: 2rem auto 5rem;
  display: grid;
  grid-template-columns: var(--toc-width) minmax(0, var(--content-width));
  justify-content: center;
  align-items: start;
  gap: clamp(1.5rem, 3vw, 3rem);
}

.desktop-toc {
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
  max-height: calc(100vh - var(--header-height) - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.8);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.toc-intro {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.toc-intro strong {
  color: var(--ink-strong);
  font-size: 0.96rem;
}

.toc-intro span {
  color: var(--muted);
  font-size: 0.78rem;
}

.toc-group + .toc-group {
  margin-top: 1rem;
}

.toc-group h2 {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.04em;
}

.toc-group a {
  min-height: 40px;
  padding: 0.48rem 0.5rem;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  align-items: start;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-decoration: none;
  transition:
    color 150ms ease,
    background-color 150ms ease;
}

.toc-group a span {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.toc-group a:hover,
.toc-group a[aria-current="location"] {
  color: var(--ink-strong);
  background: var(--accent-soft);
}

.report-content {
  width: 100%;
  min-width: 0;
}

.report-section {
  counter-increment: chapter;
  position: relative;
  min-width: 0;
  margin-bottom: 1.75rem;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: calc(var(--header-height) + 1.25rem);
}

.report-section::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.report-section.dark,
.report-section.tint-blue,
.report-section.tint-teal,
.report-section.tint-warm {
  color: var(--ink);
  background: var(--surface);
}

.report-section .header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.report-section .header > div:first-child {
  min-width: 0;
}

.page-no {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-weight: 720;
}

.page-no::after {
  content: counter(chapter, decimal-leading-zero);
}

.eyebrow {
  margin-bottom: 0.55rem;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 760;
  line-height: 1.4;
  letter-spacing: 0.035em;
}

.subtitle,
.muted,
.source-note {
  color: var(--muted);
}

.subtitle {
  max-width: 68ch;
  margin-bottom: 0;
  font-size: 1.03rem;
  line-height: 1.66;
}

.footer {
  margin-top: 2rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.grid {
  min-width: 0;
  display: grid;
  gap: 1rem;
}

.grid > * {
  min-width: 0;
}

.cols-2,
.split-40,
.split-60 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.card,
.metric,
.flowstep,
.zone,
.mini-item,
.stack-layer,
.endpoint,
.cost-band,
.risk-box,
.ok-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card {
  position: relative;
  padding: 1.15rem;
}

.card.compact {
  padding: 1rem;
}

.card.blue,
.card.teal,
.card.gold,
.card.violet,
.card.green,
.card.selected {
  border-color: var(--line-strong);
  border-top: 3px solid var(--accent);
}

.card.coral {
  border-color: #e8c7c3;
  border-top: 3px solid var(--alert);
}

.card .num,
.big-number,
.metric strong {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.card .num {
  margin-bottom: 0.65rem;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.card .label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.big-number {
  font-size: clamp(2.6rem, 5vw, 4rem);
  font-weight: 820;
  line-height: 1;
}

.big-number small {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.metric {
  padding: 1rem;
}

.metric strong {
  display: block;
  margin-bottom: 0.4rem;
  font-size: clamp(1.85rem, 3vw, 2.5rem);
  font-weight: 810;
  line-height: 1;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 730;
  line-height: 1.2;
  vertical-align: middle;
}

.pill {
  min-height: 28px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line-strong);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.pill.oss,
.pill.copyleft,
.pill.restricted,
.pill.freecloud,
.pill.local,
.pill.recommend {
  color: var(--accent-dark);
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.pill.paid,
.pill.required {
  color: var(--alert);
  border-color: #e8c7c3;
  background: var(--alert-soft);
}

.pill.quote {
  color: var(--surface);
  border-color: var(--ink-strong);
  background: var(--ink-strong);
}

.callout,
.hero-quote {
  padding: 1rem 1.15rem;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--accent-soft);
}

.callout.teal,
.callout.gold {
  border-color: var(--line-strong);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.callout.coral {
  border-color: #e8c7c3;
  border-left-color: var(--alert);
  background: var(--alert-soft);
}

.callout p:last-child,
.hero-quote p:last-child {
  margin-bottom: 0;
}

.hero-quote p {
  max-width: 54ch;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 720;
  line-height: 1.5;
}

.risk-box,
.ok-box {
  padding: 1rem;
}

.risk-box {
  border-color: #e8c7c3;
  background: var(--alert-soft);
}

.ok-box {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.check {
  color: var(--accent-dark);
  font-weight: 850;
}

.cross {
  color: var(--alert);
  font-weight: 850;
}

.warn {
  color: var(--warning);
  font-weight: 850;
}

.flowline {
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
}

.flowstep {
  flex: 1;
  padding: 0.9rem 0.75rem;
  text-align: center;
}

.flowstep .stepno {
  width: 2rem;
  height: 2rem;
  margin: 0 auto 0.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--surface);
  background: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.flowstep strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.88rem;
}

.flowstep span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.arrow {
  flex: 0 0 auto;
  align-self: center;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 800;
}

.arrow.big {
  font-size: 1.5rem;
}

.lane {
  margin-bottom: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: minmax(8rem, 0.35fr) minmax(0, 1fr);
  background: var(--surface);
}

.lane-title {
  padding: 0.9rem;
  display: flex;
  align-items: center;
  color: var(--surface);
  background: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 750;
}

.lane-body {
  min-width: 0;
  padding: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.node {
  min-width: 0;
  flex: 1;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.node.local,
.node.edge,
.node.ai,
.node.data {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.node.cloud,
.node.dark {
  color: var(--alert);
  border-color: #e8c7c3;
  background: var(--alert-soft);
}

.zone {
  min-height: 0;
  padding: 1rem;
}

.zone.edge,
.zone.local {
  border-color: var(--line-strong);
  background: #f8fcfb;
}

.zone.external {
  border-color: #e8c7c3;
  background: #fffafa;
}

.zone-head {
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mini-list,
.stack {
  display: grid;
  gap: 0.65rem;
}

.mini-item {
  padding: 0.8rem;
}

.mini-item strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.mini-item span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.stack-layer {
  padding: 0.8rem;
  display: grid;
  grid-template-columns: minmax(7rem, 0.28fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
}

.stack-layer > strong {
  font-size: 0.86rem;
}

.stack-chips {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  padding: 0.35rem 0.55rem;
  color: var(--ink);
  background: var(--surface-muted);
}

.chip.blue,
.chip.teal,
.chip.violet,
.chip.gold {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.chip.coral {
  color: var(--alert);
  background: var(--alert-soft);
}

.route {
  width: 100%;
  min-width: 0;
  margin-bottom: 0.65rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: minmax(8rem, 0.3fr) minmax(0, 1fr) minmax(7rem, 0.25fr);
  align-items: center;
  gap: 0.8rem;
  background: var(--surface);
}

.route strong {
  font-size: 0.88rem;
}

.route span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.route .risk {
  text-align: right;
}

.timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 1.25rem;
  right: 7%;
  left: 7%;
  height: 2px;
  background: var(--line);
}

.phase {
  position: relative;
  padding-top: 3rem;
}

.phase::before {
  content: "";
  position: absolute;
  top: 0.8rem;
  left: 1rem;
  width: 0.8rem;
  height: 0.8rem;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.diagram-frame {
  min-width: 0;
  margin: 1.25rem 0;
}

.diagram-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfa;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.diagram-scroll svg {
  width: 100%;
  height: auto;
  min-width: 0;
  display: block;
}

.diagram-frame figcaption {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.diagram text,
.cover-lines text {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
}

.diagram .d-title {
  font-size: 14px;
  font-weight: 800;
}

.diagram .d-label {
  font-size: 11px;
  font-weight: 750;
}

.diagram .d-small {
  font-size: 9px;
}

.diagram .d-tiny {
  font-size: 8px;
}

.diagram .d-edge {
  fill: none;
  stroke: #60777b;
  stroke-width: 1.6;
}

.diagram .d-zone {
  fill: none;
  stroke: #8eaaa5;
  stroke-width: 1.1;
  stroke-dasharray: 6 5;
}

#chapter-01 {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  grid-template-areas:
    "copy visual"
    "footer footer";
  align-items: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  min-height: min(760px, calc(100dvh - var(--header-height) - 3rem));
}

#chapter-01::after {
  content: "";
  position: absolute;
  inset: auto -5rem -7rem auto;
  width: 18rem;
  height: 18rem;
  border: 1px solid rgb(47 143 131 / 0.18);
  border-radius: 50%;
  pointer-events: none;
}

#chapter-01 .cover-mark {
  display: none;
}

#chapter-01 .cover-copy {
  grid-area: copy;
  position: relative;
  z-index: 1;
}

#chapter-01 .diagram-frame {
  grid-area: visual;
  margin: 0;
}

#chapter-01 .footer {
  grid-area: footer;
}

#chapter-01 .cover-copy h1 {
  max-width: 11ch;
}

@media (min-width: 901px) {
  #chapter-01 .cover-copy h1 {
    max-width: none;
    font-size: 3.75rem;
  }
}

#chapter-01 .cover-copy .subtitle {
  font-size: 1.08rem;
}

.cover-meta {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.decision-grid,
.ownership {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.decision-grid {
  grid-template-columns: minmax(9rem, 0.75fr) repeat(3, minmax(12rem, 1fr));
}

.ownership {
  grid-template-columns: minmax(9rem, 0.75fr) repeat(3, minmax(12rem, 1fr));
}

.decision-grid > div,
.ownership > div {
  min-width: 0;
  padding: 0.75rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
  line-height: 1.45;
}

.decision-grid > div:nth-child(4n),
.ownership > div:nth-child(4n) {
  border-right: 0;
}

.decision-grid > div:nth-last-child(-n + 4),
.ownership > div:nth-last-child(-n + 4) {
  border-bottom: 0;
}

.decision-grid .head,
.ownership .head {
  color: var(--surface);
  background: var(--accent-dark);
  font-weight: 750;
}

.decision-grid .selected {
  background: var(--accent-soft);
  font-weight: 700;
}

.ownership .domain {
  color: var(--ink-strong);
  background: var(--surface-muted);
  font-weight: 740;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

table {
  width: 100%;
  min-width: 720px;
  border: 0;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.84rem;
  line-height: 1.45;
}

th,
td {
  padding: 0.7rem 0.75rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: 0;
}

tr:last-child td {
  border-bottom: 0;
}

thead th {
  color: var(--surface);
  background: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 750;
}

tbody tr:nth-child(even) td {
  background: #f8fbfa;
}

.table-dense {
  font-size: 0.79rem;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.legend-row > span {
  font-size: 0.8rem;
}

.cost-band {
  padding: 0.9rem;
  display: grid;
  grid-template-columns: minmax(8rem, 0.28fr) minmax(0, 1fr);
  align-items: start;
  gap: 0.8rem;
}

.cost-band p {
  margin: 0;
  font-size: 0.86rem;
}

.source-grid {
  columns: 2;
  column-gap: 2rem;
  scroll-margin-top: calc(var(--header-height) + 1.25rem);
}

.source-grid p {
  max-width: none;
  margin-bottom: 1rem;
  break-inside: avoid;
  font-size: 0.86rem;
  line-height: 1.55;
}

.source-grid a {
  overflow-wrap: anywhere;
}

.endpoint {
  padding: 0.8rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.endpoint code {
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 720;
}

.arch {
  display: grid;
  grid-template-columns: minmax(8rem, 0.25fr) minmax(0, 1fr);
  gap: 0.6rem;
}

.arch-label {
  padding: 0.7rem;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 740;
}

.arch-row {
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fbfa;
}

.source-note {
  font-size: 0.8rem;
  line-height: 1.5;
}

.mt-1 {
  margin-top: 0.75rem;
}

.mt-2 {
  margin-top: 1.25rem;
}

.mt-3 {
  margin-top: 1.75rem;
}

.mb-0 {
  margin-bottom: 0;
}

.text-small {
  font-size: 0.86rem;
}

.tight p {
  margin-bottom: 0.65rem;
}

.tight li {
  margin-bottom: 0.25rem;
}

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 15;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--surface);
  background: var(--accent-dark);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.not-found-page {
  min-height: 100dvh;
}

.not-found-main {
  min-height: calc(100dvh - var(--header-height));
  padding: 4rem 1.25rem;
  display: grid;
  place-items: center;
}

.not-found-content {
  width: min(100%, 680px);
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (max-width: 1199px) {
  .desktop-toc {
    display: none;
  }

  .mobile-toc {
    width: min(calc(100% - 40px), var(--content-width));
    margin: 0 auto;
    display: block;
  }

  .mobile-toc summary {
    min-height: 48px;
    padding: 0.75rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ink-strong);
    font-weight: 730;
    cursor: pointer;
    list-style: none;
  }

  .mobile-toc summary::-webkit-details-marker {
    display: none;
  }

  .mobile-toc summary::after {
    content: "+";
    color: var(--accent-dark);
    font-size: 1.2rem;
  }

  .mobile-toc[open] summary::after {
    content: "−";
  }

  .mobile-toc nav {
    max-height: min(62vh, 620px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.5rem 0 1rem;
    border-top: 1px solid var(--line);
  }

  .mobile-tutorial-link {
    min-height: 44px;
    margin-bottom: 0.5rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    color: var(--accent-dark);
    font-size: 0.86rem;
    font-weight: 760;
    text-decoration: none;
  }

  .mobile-toc .toc-group {
    margin: 0;
    padding: 0.6rem 0;
  }

  .mobile-toc .toc-group a {
    min-height: 44px;
    padding-inline: 0;
  }

  .report-layout {
    width: min(calc(100% - 40px), var(--content-width));
    margin-top: 1.5rem;
    display: block;
  }
}

@media (max-width: 900px) {
  #chapter-01 {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "visual"
      "footer";
    min-height: 0;
  }

  #chapter-01 .cover-copy h1 {
    max-width: 14ch;
  }

  .cols-3,
  .cols-4,
  .cols-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .flowline .arrow {
    display: none;
  }

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

  .timeline::before {
    display: none;
  }

  .lane-body,
  .arch-row {
    flex-wrap: wrap;
  }

  .lane-body .arrow,
  .arch-row .arrow {
    display: none;
  }

  .source-grid {
    columns: 1;
  }
}

@media (max-width: 767px) {
  :root {
    --header-height: 64px;
  }

  .header-inner {
    width: calc(100% - 32px);
    min-height: var(--header-height);
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand small {
    display: none;
  }

  .header-actions .action-secondary {
    display: none;
  }

  .action-button {
    min-height: 44px;
    padding-inline: 0.75rem;
    font-size: 0.8rem;
  }

  .mobile-toc,
  .report-layout {
    width: calc(100% - 32px);
  }

  .report-layout {
    margin-top: 1rem;
  }

  .report-section {
    margin-bottom: 1rem;
    padding: 1.35rem 1rem 1.5rem 1.25rem;
  }

  .report-section .header {
    display: block;
  }

  .page-no {
    margin-top: 0.5rem;
    text-align: left;
  }

  h1 {
    font-size: clamp(2.1rem, 11vw, 3.2rem);
  }

  h2 {
    font-size: clamp(1.55rem, 8vw, 2.1rem);
  }

  p,
  li,
  .subtitle {
    font-size: 1rem;
  }

  .cols-2,
  .cols-3,
  .cols-4,
  .cols-5,
  .split-40,
  .split-60 {
    grid-template-columns: 1fr;
  }

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

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

  .lane-title {
    min-height: 44px;
  }

  .stack-layer,
  .route,
  .cost-band,
  .arch {
    grid-template-columns: 1fr;
  }

  .route .risk {
    text-align: left;
  }

  .timeline {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .phase {
    padding: 0.25rem 0 0.25rem 1.5rem;
  }

  .phase::before {
    top: 0.65rem;
    left: 0.15rem;
  }

  .diagram-scroll svg {
    width: auto;
    min-width: 720px;
  }

  #chapter-01 .diagram-scroll svg {
    min-width: 600px;
  }

  .footer {
    display: grid;
    gap: 0.35rem;
  }

  .cover-meta {
    font-size: 0.82rem;
  }

  .back-to-top {
    right: 0.75rem;
    bottom: 0.75rem;
  }
}

@media (max-width: 359px) {
  .brand strong {
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .action-button {
    padding-inline: 0.6rem;
    font-size: 0.76rem;
  }

  .report-section {
    padding-right: 0.85rem;
    padding-left: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@page {
  size: A4;
  margin: 15mm;
}

@media print {
  :root {
    --ink: #172d32;
    --ink-strong: #10272c;
    --muted: #51666a;
  }

  html,
  body {
    overflow: visible;
    color: var(--ink);
    background: #fff;
  }

  .site-header,
  .desktop-toc,
  .mobile-toc,
  .back-to-top,
  .skip-link {
    display: none !important;
  }

  .report-layout {
    width: auto;
    margin: 0;
    display: block;
  }

  .report-section {
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    break-after: page;
  }

  .report-section:last-child {
    break-after: auto;
  }

  .report-section::before,
  #chapter-01::after {
    display: none;
  }

  #chapter-01 {
    min-height: 0;
    display: block;
  }

  #chapter-01 .diagram-frame {
    margin: 1rem 0;
  }

  .header,
  h1,
  h2,
  h3 {
    break-after: avoid-page;
  }

  .card,
  .metric,
  .callout,
  .hero-quote,
  .risk-box,
  .ok-box,
  .lane,
  .zone,
  .stack-layer,
  .route,
  .cost-band,
  .endpoint,
  .diagram-frame,
  table,
  tr {
    break-inside: avoid-page;
  }

  .diagram-scroll,
  .decision-grid,
  .ownership,
  .table-scroll {
    overflow: visible;
    border-color: #cfd9d7;
  }

  .diagram-scroll svg {
    width: 100%;
    min-width: 0;
  }

  table {
    min-width: 0;
    font-size: 8.5pt;
  }

  .source-grid a::after {
    content: " (" attr(href) ")";
    color: var(--muted);
    font-size: 7pt;
    overflow-wrap: anywhere;
  }

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

  .footer {
    font-size: 8pt;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }
}
