:root {
  color-scheme: light only;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5c6573;
  --border: #d8dde6;
  --accent: #0b6e4f;
  --accent-soft: #e6f4ef;
  --warn-bg: #fff8e8;
  --warn-border: #e6c35c;
  --code-bg: #10141c;
  --code-text: #e8edf5;
  --sidebar-width: 260px;
  --font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--font-mono);
}

code {
  font-size: 0.9em;
  background: #eef1f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1rem 1.1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: #0f1720;
  color: #d7dee8;
  padding: 1.5rem 1.1rem 2rem;
}

.sidebar h1 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: #fff;
  font-weight: 600;
}

.sidebar .tagline {
  margin: 0 0 1.25rem;
  font-size: 0.8rem;
  color: #93a0b0;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar a {
  color: #c5d0dd;
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.sidebar a:hover,
.sidebar a.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.main {
  padding: 2rem 2.5rem 4rem;
  max-width: 980px;
}

.main header.doc-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.main header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.main header p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

section {
  margin: 2.25rem 0;
  scroll-margin-top: 1.25rem;
}

section h2 {
  margin: 0 0 0.85rem;
  font-size: 1.35rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

section h3 {
  margin: 1.4rem 0 0.6rem;
  font-size: 1.05rem;
}

p,
li {
  color: var(--text);
}

ul,
ol {
  padding-left: 1.25rem;
}

.callout {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}

.callout strong {
  display: block;
  margin-bottom: 0.25rem;
}

.note {
  background: var(--accent-soft);
  border: 1px solid #b7d9cb;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}

.diagram {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0 1.25rem;
  overflow-x: auto;
  cursor: zoom-in;
}

.diagram:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.diagram::after {
  content: "Click to zoom";
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  pointer-events: none;
}

.diagram .mermaid {
  display: flex;
  justify-content: center;
  background: #ffffff;
  border-radius: 6px;
}

/* Force light canvas — Mermaid may paint a dark SVG background in some themes */
.diagram .mermaid svg,
.diagram-lightbox__body svg {
  background-color: #ffffff !important;
  color: #0b1220;
}

.diagram .mermaid svg rect[class*='background'],
.diagram-lightbox__body svg rect[class*='background'] {
  fill: #ffffff !important;
}

/* Sequence message labels: bold dark ink on light canvas */
.diagram .mermaid svg .messageText,
.diagram-lightbox__body svg .messageText,
.diagram .mermaid svg .messageText tspan,
.diagram-lightbox__body svg .messageText tspan {
  fill: #0b1220 !important;
  stroke: #ffffff !important;
  stroke-width: 4px !important;
  paint-order: stroke fill !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  letter-spacing: 0.01em;
}

.diagram .mermaid svg .messageLine0,
.diagram .mermaid svg .messageLine1,
.diagram-lightbox__body svg .messageLine0,
.diagram-lightbox__body svg .messageLine1 {
  stroke: #0b1220 !important;
  stroke-width: 1.75 !important;
}

.diagram .mermaid svg .actor-line,
.diagram-lightbox__body svg .actor-line {
  stroke: #64748b !important;
}

.diagram .mermaid svg .loopText,
.diagram .mermaid svg .loopLine,
.diagram .mermaid svg .labelText,
.diagram-lightbox__body svg .loopText,
.diagram-lightbox__body svg .labelText {
  fill: #0b1220 !important;
}

.diagram .mermaid svg text:not(.sequenceNumber),
.diagram-lightbox__body svg text:not(.sequenceNumber) {
  fill: #0b1220 !important;
}

.diagram .mermaid svg .sequenceNumber,
.diagram-lightbox__body svg .sequenceNumber {
  fill: #ffffff !important;
}

.diagram-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(2px);
}

.diagram-lightbox.is-open {
  display: flex;
}

.diagram-lightbox__panel {
  position: relative;
  width: min(1200px, 100%);
  max-height: min(92vh, 100%);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  padding: 1.25rem 1.25rem 1.5rem;
  cursor: zoom-out;
}

.diagram-lightbox__close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 2;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.diagram-lightbox__close:hover {
  background: #eef2f7;
}

.diagram-lightbox__body {
  clear: both;
  display: flex;
  justify-content: center;
  min-height: 200px;
}

.diagram-lightbox__body svg {
  max-width: none;
  width: auto;
  height: auto;
  min-width: min(1100px, 160%);
  transform-origin: center top;
}

body.diagram-lightbox-open {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.92rem;
  margin: 0.85rem 0 1.25rem;
}

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

th {
  background: #eef2f7;
  font-weight: 600;
}

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

.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin: 0.5rem 0;
}

.checklist li::before {
  content: "☐ ";
  color: var(--accent);
  font-weight: 700;
}

.file-list code {
  background: #eef1f6;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .main {
    padding: 1.25rem 1rem 3rem;
  }
}
