:root {
  /* Colors */
  --page-bg:        #f5f7fa;
  --white:          #ffffff;
  --dark:           #252525;
  --blue:           #308bf9;
  --blue-light:     #e9f3ff;
  --green:          #3faf58;
  --green-light:    #eaffef;
  --orange:         #e48326;
  --amber:          #ffbf2d;
  --red:            #e74c3c;

  /* Text hierarchy */
  --text-primary:   #252525;
  --text-secondary: #535359;
  --text-muted:     #738298;
  --text-disabled:  #a1a1a1;

  /* Surfaces & Borders */
  --border:         #e1e6ed;
  --surface:        #f5f7fa;

  /* Typography */
  --font:           'Poppins', sans-serif;

  /* Border Radii */
  --r-card:         15px;
  --r-input:        8px;
  --r-badge:        6px;
  --r-pill:         33px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text-primary);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
}
.logo-link { display: flex; align-items: center; }
.logo-lockup { height: 24px; width: auto; display: block; }
.footer-logo { height: 20px; width: auto; display: block; margin: 0 auto 8px; }
.logo-mark {
  width: 30px; height: 30px;
  background: var(--blue);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-name {
  font-size: 15px; font-weight: 600; letter-spacing: -0.3px;
  color: var(--text-primary);
}
.topbar-doc {
  font-size: 12px; font-weight: 400; letter-spacing: -0.24px;
  color: var(--text-muted);
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.topbar-version {
  margin-left: auto;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 10px; font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-badge);
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 32px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
}
.sidebar-title {
  font-size: 10px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 14px 10px;
}
/* ---------- Download PDF buttons ---------- */
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--dark);
  color: var(--white);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; letter-spacing: -0.24px;
  padding: 8px 16px;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37,37,37,0.25);
  transition: background 0.15s, transform 0.1s;
  margin-left: auto;
  white-space: nowrap;
}
.pdf-btn:hover { background: #3a3a3a; transform: translateY(-1px); }
.hero-pdf {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--dark);
  color: var(--white);
  border-radius: var(--r-card);
  font-size: 13px; font-weight: 600; letter-spacing: -0.26px;
  padding: 11px 22px;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37,37,37,0.25);
  transition: background 0.15s, transform 0.1s;
  margin-top: 20px;
}
.hero-pdf:hover { background: #3a3a3a; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,37,37,0.32); }

/* ---------- Contents button & drawer (narrow screens) ---------- */
.toc-btn {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: var(--r-pill);
  font-family: var(--font);
  font-size: 12px; font-weight: 600; letter-spacing: -0.24px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37,37,37,0.25);
  transition: background 0.15s;
}
.toc-btn:hover { background: #3a3a3a; }
.toc-btn .chev { font-size: 11px; transition: transform 0.15s; }
body.toc-open .toc-btn .chev { transform: rotate(180deg); }
.toc-backdrop {
  display: none;
  position: fixed;
  inset: 60px 0 0 0;
  background: rgba(37,37,37,0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 48;
}
body.toc-open .toc-backdrop { display: block; }

@media (max-width: 860px) {
  .toc-btn { display: inline-flex; margin-left: auto; }
  .topbar-version { display: none; }
  .pdf-btn { margin-left: 0; padding: 8px 12px; }
  .pdf-btn .pdf-btn-text { display: none; }
  .sidebar {
    display: none;
    position: fixed;
    top: 68px; left: 12px; right: 12px;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    z-index: 49;
    margin: 0;
  }
  body.toc-open .sidebar { display: block; }
  .sidebar .sidebar-title { display: none; }
  .sidebar .side-nav {
    box-shadow: 0 20px 60px rgba(37,37,37,0.18), 0 6px 16px rgba(37,37,37,0.08), 0 1px 3px rgba(37,37,37,0.05);
  }
  body.toc-open { overflow: hidden; }
}
.side-nav {
  list-style: none;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 1px 3px rgba(37,37,37,0.05);
  padding: 8px;
}
.side-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-input);
  font-size: 12px; font-weight: 500; letter-spacing: -0.22px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  line-height: 1.35;
}
.side-nav a:hover { background: var(--surface); color: var(--text-primary); }
.side-nav a.active { background: var(--blue-light); color: var(--blue); }
.side-nav a .n {
  font-size: 9px; font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: var(--r-badge);
  padding: 1px 6px;
  flex-shrink: 0;
}
.side-nav a.active .n { background: var(--white); }

/* ---------- Main ---------- */
main { min-width: 0; }

/* ---------- Hero ---------- */
.hero {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 6px 16px rgba(37,37,37,0.08), 0 1px 3px rgba(37,37,37,0.05);
  padding: 44px 44px 40px;
  margin-bottom: 40px;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--blue-light); color: var(--blue);
  border: 1px solid rgba(48,139,249,0.2);
  font-size: 10px; font-weight: 500; letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 5px 14px; border-radius: var(--r-pill);
  margin-bottom: 18px;
}
.hero-badge .dot { width: 7px; height: 7px; box-shadow: none; }
.hero h1 {
  font-size: 40px; font-weight: 700; letter-spacing: -1.2px;
  line-height: 1.12;
  color: var(--text-primary);
}
.hero h1 span { color: var(--blue); }
.hero-sub {
  font-size: 16px; font-weight: 500; letter-spacing: -0.3px;
  color: var(--text-muted);
  margin-top: 10px;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 22px;
}
.hero-meta .pill { font-size: 10px; }
.hero-info {
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.hero-info .info-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 14px;
  font-size: 12px; letter-spacing: -0.22px;
}
.hero-info .info-row + .info-row { border-top: 1px solid var(--border); }
.hero-info .k { color: var(--text-muted); width: 110px; flex-shrink: 0; font-weight: 500; }
.hero-info .v { color: var(--text-primary); font-weight: 500; line-height: 1.5; }

/* ---------- Hero grid & visual ---------- */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: center;
}
.hero-visual {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(37,37,37,0.25);
}
.hero-visual img { max-width: 100%; max-height: 300px; width: auto; display: block; filter: drop-shadow(0 14px 18px rgba(37,37,37,0.3)); }

/* ---------- Figures ---------- */
.fig { margin: 0; }
.fig-img {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.fig-img img { max-width: 100%; max-height: 190px; object-fit: contain; display: block; }
.fig-dark { background: var(--surface); }
.fig figcaption {
  font-size: 12px; font-weight: 500; letter-spacing: -0.22px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}
.fig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.fig-label {
  font-size: 10px; font-weight: 500; letter-spacing: -0.2px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
}
.fig-wide { margin-top: 16px; }
.fig-wide .fig-img { padding: 24px; }
.fig-wide .fig-img img { max-height: 260px; }

/* ---------- App screenshot row ---------- */
.app-shot-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  flex-wrap: wrap;
}
.app-shot { width: 190px; flex-shrink: 0; }
.app-shot .fig-img { height: 100%; max-height: 320px; background: var(--white); }
.app-shot .fig-img img { max-height: 270px; }

/* ---------- Symbol images ---------- */
.sym-img {
  width: 52px; height: 52px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
}
.sym-img img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* ---------- Sections ---------- */
section.doc-section {
  margin-bottom: 44px;
  scroll-margin-top: 84px;
}
.section-kicker {
  display: inline-block;
  font-size: 10px; font-weight: 600; letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--blue);
  background: var(--blue-light);
  padding: 3px 10px;
  border-radius: var(--r-badge);
  margin-bottom: 10px;
}
section.doc-section > h2 {
  font-size: 26px; font-weight: 600; letter-spacing: -0.44px;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.lede {
  font-size: 15px; font-weight: 400; letter-spacing: -0.26px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 18px;
  max-width: 720px;
}
h3.sub {
  font-size: 17px; font-weight: 600; letter-spacing: -0.3px;
  color: var(--text-primary);
  margin: 22px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
h3.sub .tick {
  width: 4px; height: 16px; border-radius: 2px;
  background: var(--blue);
  display: inline-block;
}
p { font-size: 14px; letter-spacing: -0.28px; line-height: 1.65; color: var(--text-secondary); }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(37,37,37,0.05);
  overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card-pad { padding: 18px 20px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  letter-spacing: -0.24px;
}
thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
  line-height: 1.55;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(48,139,249,0.035); }
td.label { font-weight: 600; color: var(--text-primary); font-size: 13px; }
td.num { color: var(--text-muted); font-weight: 600; width: 30px; }

/* ---------- LED dots & pills ---------- */
.led {
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 600; color: var(--text-primary); white-space: nowrap;
}
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-blue  { background: var(--blue);  box-shadow: 0 0 0 3px var(--blue-light); }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.dot-red   { background: var(--red);   box-shadow: 0 0 0 3px rgba(231,76,60,0.14); }
.dot-off   { background: var(--white); border: 1.5px solid var(--border); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.pill-blue   { background: var(--blue-light);  color: var(--blue);  border: 1px solid rgba(48,139,249,0.2); }
.pill-green  { background: var(--green-light); color: var(--green); border: 1px solid rgba(63,175,88,0.2); }
.pill-red    { background: rgba(231,76,60,0.08); color: var(--red); border: 1px solid rgba(231,76,60,0.2); }
.pill-orange { background: rgba(228,131,38,0.1); color: var(--orange); border: 1px solid rgba(228,131,38,0.25); }
.pill-neutral{ background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }

.role-badge {
  background: var(--blue-light); color: var(--blue);
  font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: var(--r-badge);
  display: inline-block;
}

/* ---------- Steps ---------- */
.steps { list-style: none; }
.steps li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; letter-spacing: -0.24px; color: var(--text-secondary);
  line-height: 1.55;
}
.steps li:last-child { border-bottom: none; }
.step-n {
  width: 22px; height: 22px; flex-shrink: 0;
  background: var(--dark); color: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
  margin-top: 0;
}
.step-n.star { background: var(--blue); }

/* ---------- Bullets ---------- */
.bullets { list-style: none; }
.bullets li {
  position: relative;
  padding: 5px 0 5px 18px;
  font-size: 13px; letter-spacing: -0.24px; color: var(--text-secondary);
  line-height: 1.55;
}
.bullets li::before {
  content: '';
  position: absolute; left: 2px; top: 11px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
}
.bullets b { font-weight: 600; color: var(--text-primary); }

/* ---------- Notes ---------- */
.note {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px; letter-spacing: -0.24px; line-height: 1.55;
  margin-top: 14px;
}
.note-icon {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--white);
  margin-top: 1px;
}
.note-info    { background: var(--blue-light); color: #1d5da8; }
.note-info    .note-icon { background: var(--blue); }
.note-warn    { background: rgba(228,131,38,0.1); color: #9c5a17; }
.note-warn    .note-icon { background: var(--orange); }
.note-danger  { background: rgba(231,76,60,0.08); color: #a33529; }
.note-danger  .note-icon { background: var(--red); }
.note-success { background: var(--green-light); color: #27753c; }
.note-success .note-icon { background: var(--green); }
.note b { font-weight: 600; }

/* ---------- Component grid ---------- */
.comp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.comp-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.comp-item h4 {
  font-size: 13px; font-weight: 600; letter-spacing: -0.24px;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 4px;
}
.comp-item h4 .dot { width: 8px; height: 8px; }
.comp-item p { font-size: 12px; color: var(--text-muted); line-height: 1.55; }

/* ---------- Contact rows ---------- */
.contact-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  font-size: 13px; letter-spacing: -0.24px;
  flex-wrap: wrap;
}
.contact-row + .contact-row { border-top: 1px solid var(--border); }
.contact-row .k { color: var(--text-muted); flex: 1; min-width: 140px; }
.contact-row .v { font-weight: 600; color: var(--text-primary); }
.contact-row .dot { width: 6px; height: 6px; }
.contact-row a { color: var(--blue); text-decoration: none; font-weight: 600; }
.contact-row a:hover { text-decoration: underline; }

.small-muted { font-size: 10px; color: var(--text-muted); letter-spacing: -0.2px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--white);
  padding: 22px 24px;
  text-align: center;
  font-size: 12px; letter-spacing: -0.24px;
  color: var(--text-muted);
}
.site-footer b { color: var(--text-primary); font-weight: 600; }

/* ---------- Back to top ---------- */
.back-top {
  position: fixed;
  right: 22px; bottom: 22px;
  width: 42px; height: 42px;
  background: var(--dark);
  color: var(--white);
  border: none;
  border-radius: var(--r-card);
  font-family: var(--font);
  font-size: 16px;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(37,37,37,0.25);
  transition: background 0.15s, transform 0.1s;
  z-index: 60;
}
.back-top:hover { background: #3a3a3a; transform: translateY(-1px); }
.back-top.show { display: flex; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 20px 16px 60px; gap: 20px; }
  .side-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
  .hero { padding: 28px 22px; }
  .hero h1 { font-size: 30px; letter-spacing: -0.9px; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { max-width: 300px; margin: 0 auto; }
  .topbar-doc { display: none; }
}
@media (max-width: 560px) {
  .side-nav { grid-template-columns: 1fr; }
  tbody td, thead th { padding: 9px 12px; }
  table { font-size: 12px; }
  .steps li { padding: 10px 14px; }
  .hero { padding: 24px 18px; }
}


/* ---------- Reading progress bar ---------- */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: var(--blue);
  z-index: 60;
  border-radius: 0 2px 2px 0;
}

/* ---------- Topbar shadow once scrolled ---------- */
.topbar.scrolled { box-shadow: 0 6px 16px rgba(37,37,37,0.08); }

/* ---------- Accessibility & polish ---------- */
::selection { background: var(--blue-light); color: var(--blue); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-light), 0 0 0 1.5px var(--blue);
  border-radius: var(--r-input);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ---------- Print: content only ---------- */
@media print {
  .topbar, .sidebar, .toc-backdrop, .back-top, .progress-bar, .pdf-btn, .hero-pdf { display: none !important; }
  .layout { display: block; padding: 0; }
  .card, .hero { box-shadow: none; }
  section.doc-section { break-inside: avoid-page; margin-bottom: 24px; }
  body { background: #fff; }
}


/* ---------- Device components annotated diagram ---------- */
.comp-diagram { padding: 28px 24px 18px; }
.comp-stage {
  position: relative;
  width: min(100%, 640px);
  aspect-ratio: 640 / 520;
  margin: 0 auto;
}
.comp-device {
  position: absolute;
  left: 50%; top: 7%;
  transform: translateX(-50%);
  height: 78%;
  width: auto;
  filter: drop-shadow(0 22px 22px rgba(37,37,37,0.28));
}
.comp-lines {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.comp-lines path {
  stroke: #9aa8ba;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.comp-lines circle { fill: #ffffff; stroke: #9aa8ba; stroke-width: 1.5; }
.comp-label { position: absolute; }
.comp-label h4 {
  font-size: 13px; font-weight: 600; letter-spacing: -0.26px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.comp-label p {
  font-size: 11px; letter-spacing: -0.22px; line-height: 1.5;
  color: var(--text-muted);
}
.comp-caption {
  text-align: center;
  font-size: 12px; font-weight: 500; letter-spacing: -0.24px;
  color: var(--text-muted);
  margin-top: 10px;
}
/* diagram on wide screens, cards on narrow */
@media (min-width: 721px) {
  .comp-diagram + .comp-grid { display: none; }
}
@media (max-width: 720px) {
  .comp-diagram { display: none; }
}

.sym-txt { font-size: 10px; font-weight: 700; letter-spacing: 0; color: var(--text-primary); }
