/* ==========================================================================
   Telecom Tower Compliance Automation — stylesheet
   Light, professional palette · responsive · widescreen-aware
   ========================================================================== */

:root {
  /* Brand */
  --teal: #0e7490;
  --teal-dark: #0b5468;
  --cyan: #0891b2;
  --sky: #38bdf8;
  --amber: #d97706;
  --amber-bright: #f59e0b;
  --rose: #f43f5e;
  --violet: #7c3aed;

  /* Neutrals */
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --surface-3: #e3edf3;
  --border: #d6e2ea;
  --border-strong: #bcccd6;
  --text: #1d2a32;
  --muted: #566872;
  --heading: #0b3a48;

  /* Accent tints */
  --tint-teal: #e2f4f7;
  --tint-amber: #fdf0db;
  --tint-violet: #efe9fd;

  /* System */
  --header-h: 66px;
  --shell: 1280px;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(13, 42, 54, 0.06), 0 2px 8px rgba(13, 42, 54, 0.05);
  --shadow-md: 0 6px 24px rgba(13, 42, 54, 0.1);
  --shadow-lg: 0 18px 48px rgba(13, 42, 54, 0.14);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  line-height: 1.7;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, #e8f5f8 0%, rgba(232, 245, 248, 0) 60%),
    radial-gradient(900px 500px at -10% 0%, #eef0fb 0%, rgba(238, 240, 251, 0) 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.site-main { flex: 1 0 auto; }

img, svg { max-width: 100%; }
svg { display: block; }

a { color: var(--teal); text-decoration: none; transition: color 0.18s var(--ease); }
a:hover { color: var(--amber); }

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 3vw, 2.75rem);
}

.ico { width: 1.25em; height: 1.25em; flex: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--teal);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:where(a, button, input, summary):focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Accent helpers */
.accent-teal { color: var(--teal); }
.accent-amber { color: var(--amber-bright); }
.accent-violet { color: var(--violet); }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--heading); }
.brand__mark { transition: transform 0.4s var(--ease); }
.brand:hover .brand__mark { transform: rotate(-6deg) scale(1.05); }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-weight: 750; font-size: 1.06rem; letter-spacing: -0.01em; }
.brand__sub { font-size: 0.74rem; font-weight: 600; color: var(--cyan); letter-spacing: 0.02em; }

.primary-nav { margin-left: auto; }
.primary-nav__list { display: flex; align-items: center; gap: 0.25rem; list-style: none; margin: 0; padding: 0; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  position: relative;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav-link__ico { width: 1.15rem; height: 1.15rem; }
.nav-link:hover { color: var(--heading); background: var(--surface-2); }
.nav-link.is-active { color: var(--teal-dark); background: var(--tint-teal); }
.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 0.9rem; right: 0.9rem; bottom: 0.15rem;
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--teal), var(--sky));
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 44px; height: 44px;
  color: var(--heading);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-toggle .ico { width: 1.5rem; height: 1.5rem; }
.nav-toggle__close { display: none; }

/* ==========================================================================
   Hero / Home
   ========================================================================== */
.hero { padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(1.5rem, 3vw, 2.5rem); }
.hero__inner { text-align: center; display: flex; flex-direction: column; align-items: center; }
.hero__logo {
  width: clamp(96px, 14vw, 140px);
  height: auto;
  filter: drop-shadow(0 12px 22px rgba(14, 116, 144, 0.22));
  animation: floaty 6s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.hero__title {
  margin: 1.4rem 0 0;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--heading);
  font-weight: 800;
  max-width: 18ch;
}
.hero__title-accent {
  background: linear-gradient(100deg, var(--teal) 0%, var(--cyan) 45%, var(--sky) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__lead {
  margin: 1.3rem 0 0;
  max-width: 62ch;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem);
  color: var(--text);
}
.hero__sub { margin: 1rem 0 0; max-width: 70ch; color: var(--muted); }

.hero__cta {
  margin-top: 2.2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  max-width: 860px;
}
.cta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-align: left;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--heading);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.cta:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); color: var(--heading); }
.cta__ico {
  flex: none;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: #fff;
}
.cta__ico .ico { width: 1.5rem; height: 1.5rem; }
.cta--teal:hover { border-color: var(--teal); }
.cta--amber:hover { border-color: var(--amber-bright); }
.cta--violet:hover { border-color: var(--violet); }
.cta--teal .cta__ico { background: linear-gradient(135deg, var(--teal), var(--sky)); }
.cta--amber .cta__ico { background: linear-gradient(135deg, var(--amber-bright), var(--rose)); }
.cta--violet .cta__ico { background: linear-gradient(135deg, var(--violet), #a855f7); }
.cta__text { display: flex; flex-direction: column; line-height: 1.2; }
.cta__label { font-weight: 700; }
.cta__go { font-size: 0.82rem; color: var(--cyan); display: inline-flex; align-items: center; gap: 0.3rem; }
.cta__arrow { width: 0.95rem; height: 0.95rem; transition: transform 0.2s var(--ease); }
.cta:hover .cta__arrow { transform: translateX(4px); }

.error-code {
  margin: 0;
  font-size: clamp(3.5rem, 2rem + 8vw, 7rem);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(120deg, var(--teal) 0%, var(--cyan) 45%, var(--amber-bright) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.home-intro { padding-top: clamp(1.5rem, 4vw, 3rem); }
.section-heading {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  color: var(--heading);
  letter-spacing: -0.01em;
}
.home-intro__text { color: var(--muted); font-size: 1.08rem; }

.sections {
  padding: clamp(1.5rem, 4vw, 2.5rem) auto clamp(3rem, 6vw, 4.5rem);
  padding-block: clamp(1.5rem, 4vw, 2.5rem) clamp(3rem, 6vw, 4.5rem);
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
.section-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.section-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
}
.section-card--teal::before { background: linear-gradient(90deg, var(--teal), var(--sky)); }
.section-card--amber::before { background: linear-gradient(90deg, var(--amber-bright), var(--rose)); }
.section-card--violet::before { background: linear-gradient(90deg, var(--violet), #a855f7); }
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.section-card__head { display: flex; align-items: center; gap: 0.75rem; }
.section-card__ico {
  flex: none; width: 44px; height: 44px; border-radius: 11px;
  display: grid; place-items: center; color: #fff;
}
.section-card__ico .ico { width: 1.45rem; height: 1.45rem; }
.section-card--teal .section-card__ico { background: linear-gradient(135deg, var(--teal), var(--sky)); }
.section-card--amber .section-card__ico { background: linear-gradient(135deg, var(--amber-bright), var(--rose)); }
.section-card--violet .section-card__ico { background: linear-gradient(135deg, var(--violet), #a855f7); }
.section-card__title { margin: 0; font-size: 1.18rem; line-height: 1.25; }
.section-card__title a { color: var(--heading); }
.section-card__title a:hover { color: var(--teal); }
.section-card__sum { margin: 0; color: var(--muted); font-size: 0.96rem; }
.section-card__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.section-card__list a {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.5rem; border-radius: 8px;
  color: var(--text); font-weight: 550; font-size: 0.95rem;
}
.section-card__list a:hover { background: var(--surface-2); color: var(--teal-dark); }
.list-arrow { width: 0.9rem; height: 0.9rem; color: var(--cyan); flex: none; }
.section-card__more {
  margin-top: auto; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 650; color: var(--teal);
}
.more-arrow { width: 1rem; height: 1rem; transition: transform 0.2s var(--ease); }
.section-card__more:hover .more-arrow { transform: translateX(4px); }

/* ==========================================================================
   Content pages
   ========================================================================== */
.content-shell { padding-block: clamp(1.25rem, 3vw, 2rem) clamp(2.5rem, 5vw, 4rem); }

.breadcrumbs { margin-bottom: 1.4rem; font-size: 0.86rem; }
.breadcrumbs ol {
  list-style: none; display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.3rem 0.55rem; margin: 0; padding: 0;
}
.breadcrumbs li { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--muted); }
.breadcrumbs li:not(:first-child)::before { content: "›"; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); font-weight: 600; }
.breadcrumbs a:hover { color: var(--teal); }
.breadcrumbs [aria-current="page"] span { color: var(--heading); font-weight: 650; }

/* Prose: wide, comfortable, NOT a narrow column on desktop.
   Content pages share the same shell width as the home page. */
.prose { max-width: 78ch; }
@media (min-width: 1024px) {
  .prose { max-width: none; }
}

.prose > * + * { margin-top: 1.15rem; }
.prose h1 {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 820;
  margin: 0 0 0.4rem;
  background: linear-gradient(100deg, var(--teal-dark) 0%, var(--cyan) 55%, var(--sky) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.prose h2, .prose h3, .prose h4 {
  color: var(--heading); letter-spacing: -0.01em; line-height: 1.25;
  scroll-margin-top: calc(var(--header-h) + 1rem);
  margin-top: 2.2rem;
}
.prose h2 {
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.85rem);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--surface-3);
}
.prose h3 { font-size: clamp(1.18rem, 1.1rem + 0.4vw, 1.4rem); }
.prose h4 { font-size: 1.1rem; }
.prose p { color: var(--text); }
.prose strong { color: var(--heading); font-weight: 700; }

.prose a:not(.heading-anchor) {
  color: var(--teal);
  font-weight: 550;
  border-bottom: 1px solid color-mix(in srgb, var(--teal) 35%, transparent);
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.prose a:not(.heading-anchor):hover {
  color: var(--amber);
  border-bottom-color: var(--amber-bright);
  background: var(--tint-amber);
}
.prose a.external-link::after {
  content: "↗"; font-size: 0.78em; margin-left: 0.15em;
  color: var(--muted); vertical-align: super;
}

/* Heading anchors */
.heading-anchor {
  margin-left: 0.4rem;
  color: var(--border-strong);
  opacity: 0;
  border: 0 !important;
  font-weight: 600;
  transition: opacity 0.18s var(--ease), color 0.18s var(--ease);
}
.prose :hover > .heading-anchor,
.heading-anchor:focus-visible { opacity: 1; }
.heading-anchor:hover { color: var(--teal); }

/* Lists */
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.4rem; }
.prose ul li::marker { color: var(--cyan); }
.prose ol li::marker { color: var(--cyan); font-weight: 700; }

/* Blockquote */
.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.6rem 1.2rem;
  border-left: 4px solid var(--cyan);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
}

/* Inline code — light tint, no border, low focus */
.prose :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-3);
  color: #0c4a5a;
  padding: 0.12em 0.42em;
  border-radius: 6px;
  white-space: nowrap;
}

/* Horizontal rule */
.prose hr { border: 0; height: 1px; background: var(--border); margin: 2.4rem 0; }

/* ---- Code blocks -------------------------------------------------------- */
.code-block {
  margin: 1.6rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.code-block__bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.45rem 0.45rem 0.45rem 0.95rem;
  background: linear-gradient(180deg, #eef4f8, #e6eef4);
  border-bottom: 1px solid var(--border);
}
.code-block__lang {
  font-family: var(--mono); font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--teal-dark);
}
.code-block__copy {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font: inherit; font-size: 0.78rem; font-weight: 650;
  color: var(--teal-dark);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 0.28rem 0.7rem;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.code-block__copy:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.code-block__copy.is-copied { background: #15803d; color: #fff; border-color: #15803d; }
.code-block pre {
  margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto;
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.6;
  background: #f8fafc;
  -webkit-overflow-scrolling: touch;
}
.code-block code { font-family: var(--mono); background: none; padding: 0; white-space: pre; }

/* Prism light token theme */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7b8a93; font-style: italic; }
.token.punctuation { color: #5b6b75; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant,
.token.symbol, .token.deleted { color: #b45309; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin,
.token.inserted { color: #047857; }
.token.operator, .token.entity, .token.url, .language-css .token.string,
.style .token.string { color: #0e7490; }
.token.atrule, .token.attr-value, .token.keyword { color: #7c3aed; font-weight: 600; }
.token.function, .token.class-name { color: #0369a1; }
.token.regex, .token.important, .token.variable { color: #c2410c; }
.token.important, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

/* ---- Tables ------------------------------------------------------------- */
.table-scroll {
  margin: 1.6rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 0.95rem; }
.table-scroll th, .table-scroll td {
  padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border);
}
.table-scroll thead th {
  background: var(--surface-2); color: var(--heading); font-weight: 700;
  position: sticky; top: 0;
}
.table-scroll tbody tr { background: var(--surface); transition: background 0.15s var(--ease); }
.table-scroll tbody tr:nth-child(even) { background: #fbfdfe; }
.table-scroll tbody tr:hover { background: var(--tint-teal); }

/* ---- Task lists (interactive checkboxes) -------------------------------- */
.prose ul.contains-task-list { list-style: none; padding-left: 0.2rem; }
.task-list-item { display: flex; align-items: flex-start; gap: 0.6rem; }
.task-list-item::marker { content: ""; }
.task-list-item-checkbox {
  appearance: none; -webkit-appearance: none;
  margin-top: 0.28rem; flex: none;
  width: 1.15rem; height: 1.15rem;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  display: inline-grid; place-content: center;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}
.task-list-item-checkbox:hover { border-color: var(--teal); }
.task-list-item-checkbox::before {
  content: ""; width: 0.65rem; height: 0.65rem;
  transform: scale(0); transform-origin: center;
  transition: transform 0.15s var(--ease);
  background: #fff;
  clip-path: polygon(14% 52%, 0 66%, 40% 100%, 100% 22%, 86% 8%, 38% 70%);
}
.task-list-item-checkbox:checked {
  background: linear-gradient(135deg, var(--teal), var(--cyan));
  border-color: var(--teal);
}
.task-list-item-checkbox:checked::before { transform: scale(1); }
.task-list-item.is-checked > label,
.task-list-item.is-checked { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

/* ---- FAQ accordion ------------------------------------------------------ */
.faq-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0.7rem 0;
  overflow: hidden;
}
.faq-accordion summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.95rem 1.15rem;
  font-weight: 650; color: var(--heading);
}
.faq-accordion summary::-webkit-details-marker { display: none; }
.faq-accordion summary::after {
  content: "+"; font-size: 1.3rem; color: var(--cyan); line-height: 1;
  transition: transform 0.2s var(--ease);
}
.faq-accordion[open] summary::after { transform: rotate(45deg); }
.faq-accordion summary:hover { background: var(--surface-2); }
.faq-accordion__body { padding: 0 1.15rem 1.1rem; color: var(--text); }

/* ---- Mermaid diagrams + fullscreen lightbox ----------------------------- */
pre.mermaid {
  position: relative;
  margin: 1.6rem 0; padding: 1.4rem 1.2rem; text-align: center;
  background:
    linear-gradient(180deg, #ffffff, #fbfdfe);
  border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow-x: auto;
  transition: box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}
pre.mermaid:not([data-processed]) { color: transparent; min-height: 80px; }
pre.mermaid svg { display: block; margin-inline: auto; max-width: 100%; height: auto; }

/* Zoomable affordance */
pre.mermaid.is-zoomable { cursor: zoom-in; }
pre.mermaid.is-zoomable:hover,
pre.mermaid.is-zoomable:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--shadow-md);
  outline: none;
}
.diagram-expand {
  position: absolute; top: 0.6rem; right: 0.6rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  color: var(--teal-dark);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(-2px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
  pointer-events: none;
}
pre.mermaid.is-zoomable:hover .diagram-expand,
pre.mermaid.is-zoomable:focus-visible .diagram-expand { opacity: 1; transform: translateY(0); }
pre.mermaid.is-zoomable:hover .diagram-expand { background: var(--teal); color: #fff; }

/* Fullscreen modal */
.diagram-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
}
.diagram-modal.is-open { display: flex; }
.diagram-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 30, 38, 0.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: ttfade 0.18s var(--ease);
}
.diagram-modal__panel {
  position: relative;
  width: min(96vw, 1500px); height: min(92vh, 1000px);
  display: flex;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1rem, 2.5vw, 2rem);
  animation: ttpop 0.2s var(--ease);
}
.diagram-modal__stage {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
}
.diagram-modal__stage svg { width: 100%; height: 100%; max-width: none; }
.diagram-modal__close {
  position: absolute; top: -0.6rem; right: -0.6rem;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--heading);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.diagram-modal__close:hover { background: var(--teal); color: #fff; transform: rotate(90deg); }
body.modal-open { overflow: hidden; }
@keyframes ttfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ttpop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* ---- KaTeX -------------------------------------------------------------- */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }

/* ---- KaTeX -------------------------------------------------------------- */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4rem 0; }

/* ==========================================================================
   Related / siblings
   ========================================================================== */
.related, .siblings { margin-top: clamp(2.5rem, 5vw, 3.5rem); }
.related__title, .siblings__title {
  font-size: 1.25rem; color: var(--heading); margin-bottom: 1.1rem;
}
.related__grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
.related-card {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--heading);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--teal); color: var(--heading); }
.related-card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.related-card__name { font-weight: 700; line-height: 1.25; }
.related-card__arrow { width: 1.1rem; height: 1.1rem; color: var(--cyan); flex: none; transition: transform 0.2s var(--ease); }
.related-card:hover .related-card__arrow { transform: translateX(4px); }
.related-card__sum { color: var(--muted); font-size: 0.92rem; }

.siblings__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.siblings__list a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-weight: 600; font-size: 0.92rem; color: var(--teal-dark);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.siblings__list a:hover { background: var(--tint-teal); border-color: var(--teal); color: var(--teal-dark); }
.siblings__up a { background: var(--surface-2); }
.sib-ico { width: 0.9rem; height: 0.9rem; transform: rotate(180deg); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  flex-shrink: 0;
  margin-top: clamp(3rem, 6vw, 5rem);
  background: linear-gradient(180deg, #0b3a48, #0c2b36);
  color: #cfe3ea;
}
.site-footer__inner {
  display: flex; flex-wrap: wrap; gap: 2rem 3rem; justify-content: space-between;
  padding-block: clamp(2rem, 4vw, 3rem);
}
.site-footer__brand { display: flex; gap: 0.9rem; align-items: flex-start; max-width: 42ch; }
.site-footer__mark { background: #fff; border-radius: 10px; padding: 4px; }
.site-footer__name { margin: 0; font-weight: 700; color: #fff; }
.site-footer__tag { margin: 0.3rem 0 0; font-size: 0.9rem; color: #9fc1cd; }
.site-footer__heading { margin: 0 0 0.7rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: #7fa7b5; }
.site-footer__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.site-footer__nav a { display: inline-flex; align-items: center; gap: 0.5rem; color: #cfe3ea; font-weight: 550; }
.site-footer__nav a:hover { color: var(--sky); }
.foot-ico { width: 1.05rem; height: 1.05rem; }
.site-footer__base {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between;
  padding-block: 1.1rem; border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 0.84rem; color: #8fb0bc;
}
.site-footer__base p { margin: 0; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    margin: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  }
  .primary-nav.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .primary-nav__list { flex-direction: column; align-items: stretch; padding: 0.75rem; gap: 0.2rem; }
  .nav-link { border-radius: 10px; padding: 0.8rem 1rem; font-size: 1rem; }
  .nav-link.is-active::after { display: none; }
  body.nav-open .nav-toggle__open { display: none; }
  body.nav-open .nav-toggle__close { display: block; }
  .hero__cta { grid-template-columns: 1fr; max-width: 420px; }
}

@media (min-width: 1440px) {
  :root { --shell: 1340px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}
