/* /guide — the user guide: cards like /docs, a table of contents at the side */
.guide { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 34px; max-width: 1220px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 32px) 56px; align-items: start; }
.guide-main { min-width: 0; max-width: 880px; }

/* table of contents */
.toc-side { position: sticky; top: calc(var(--top-h, 60px) + 18px); max-height: calc(100vh - var(--top-h, 60px) - var(--consent-h, 0px) - 36px); display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05); overflow: hidden; }
.toc-title { margin: 0; padding: 13px 18px 9px; font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--line); }
.toc-side .toc { overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 14px; scrollbar-width: thin; }
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc a { display: block; padding: 5px 10px; border-left: 3px solid transparent; border-radius: 0 8px 8px 0; color: #475569; font-size: 14px; line-height: 1.45; text-decoration: none; }
.toc a:hover { background: #eff6ff; color: var(--blue); }
.toc > div > ol > li { margin-top: 6px; }
.toc > div > ol > li > a { font-weight: 700; color: var(--navy2); font-size: 14.5px; }
.toc ol ol a { padding-left: 20px; }
.toc a[aria-current] { border-left-color: var(--blue); background: #e0f2fe; color: var(--blue); }
.toc a.within { color: var(--blue); }
.toc-fold, .guide-fab { display: none; }

/* text */
.chapter, .guide .intro { margin: 0 0 24px; padding: clamp(18px, 3vw, 34px); background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05); }
.guide .intro > :first-child { margin-top: 0; } .guide .intro > :last-child { margin-bottom: 0; }
.guide h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; font-size: clamp(21px, 2.6vw, 28px); line-height: 1.3; text-align: left; color: var(--navy); }
.guide h2 b { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--navy2), var(--blue)); color: #fff; font-size: 19px; }
.guide h3 { margin: 34px 0 8px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 19px; line-height: 1.4; color: var(--navy2); }
.guide h2 + h3 { margin-top: 16px; padding-top: 0; border-top: 0; }
.guide p, .guide li { line-height: 1.75; }
.guide p { margin: 10px 0; } .guide li { margin: 5px 0; }
.guide article ul, .guide article ol { padding-left: 24px; }
.guide code { padding: 1px 6px; border-radius: 5px; background: #eef2ff; font-size: 0.9em; overflow-wrap: anywhere; }
.guide blockquote { margin: 16px 0; padding: 12px 16px; border: 1px solid #bfdbfe; border-left: 4px solid var(--blue); border-radius: 10px; background: #eff6ff; color: #1e3a5f; }
.guide blockquote p { margin: 0 0 8px; } .guide blockquote p:last-child { margin-bottom: 0; }
.guide blockquote.privacy { border-color: #fecdd3; border-left-color: #e11d48; background: #fff1f2; color: #881337; }
.guide blockquote.privacy p:first-child { font-size: 17px; font-weight: 700; } .guide blockquote.privacy a { color: #be123c; font-weight: 700; }
.table-wrap { margin: 14px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table-wrap th, .table-wrap td { padding: 9px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-wrap th { background: #f1f5fd; color: var(--navy2); white-space: nowrap; } .table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td + td, .table-wrap th + th { border-left: 1px solid var(--line); }
.guide figure { margin: 18px 0; text-align: center; }
.guide figure img { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1); background: #fff; cursor: zoom-in; }
.guide figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); }

.guide .toc-title { margin: 0; }
.guide .toc li { margin: 0; }
.guide .toc > div > ol > li { margin-top: 6px; }

dialog.lightbox { max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; padding: 24px; border: 0; background: rgba(11, 20, 55, 0.86); cursor: zoom-out; }
dialog.lightbox[open] { display: grid; place-items: center; }
dialog.lightbox img { max-width: 100%; max-height: calc(100vh - 48px); object-fit: contain; border-radius: 10px; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }

/* the drawer (below 1024 px) */
dialog.toc-drawer { position: fixed; inset: 0 0 0 auto; width: min(340px, 88vw); max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: var(--card); box-shadow: -12px 0 40px rgba(15, 23, 42, 0.3); }
dialog.toc-drawer[open] { display: flex; flex-direction: column; animation: drawer 0.2s ease-out; }
dialog.toc-drawer::backdrop { background: rgba(11, 20, 55, 0.45); }
.toc-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: linear-gradient(135deg, var(--navy), var(--navy2)); color: #fff; }
.toc-drawer-head button { padding: 0 8px; border: 0; background: none; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.toc-drawer .toc { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 24px; }
.toc-drawer .toc a { padding: 8px 10px; font-size: 15px; } .toc-drawer .toc ol ol a { padding-left: 22px; }
@keyframes drawer { from { transform: translateX(40px); opacity: 0; } }

@media (max-width: 1023px) {
  .guide { grid-template-columns: minmax(0, 1fr); padding-top: 18px; }
  .guide-main { max-width: none; }
  .toc-side { display: none; }
  .toc-fold { display: block; margin: 0 0 20px; border: 1px solid #bfdbfe; border-radius: 14px; background: var(--card); }
  .toc-fold summary { padding: 13px 18px; font-weight: 700; color: var(--navy2); cursor: pointer; }
  .toc-fold .toc { padding: 0 10px 14px; }
  .guide-fab { position: fixed; right: 14px; bottom: calc(14px + var(--consent-h, 0px)); z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
  .guide-fab button { padding: 10px 16px; border: 0; border-radius: 999px; background: var(--blue); color: #fff; font: 700 15px/1.2 system-ui, 'Segoe UI', 'Microsoft JhengHei', 'PingFang TC', sans-serif; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.35); cursor: pointer; }
  .guide-fab #to-top { order: -1; background: var(--navy); }
}
@media (max-width: 640px) {
  .chapter, .guide .intro { padding: 18px 16px; border-radius: 14px; }
  .table-wrap table { min-width: 480px; font-size: 14.5px; }
  .guide article ul, .guide article ol { padding-left: 20px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto !important; } dialog.toc-drawer[open] { animation: none; } }
@media print { .toc-side, .toc-fold, .guide-fab { display: none; } .guide { display: block; } .chapter { box-shadow: none; border: 0; padding: 0; } }
