/* ============ Floating TOC ============ */
  .floating-toc {
    position: fixed; right: 18px; bottom: 18px; z-index: 1000;
    font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  }
  .ft-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px 10px 14px;
    background: #2563eb; color: #fff; border: none; border-radius: 999px;
    box-shadow: 0 6px 18px rgba(37,99,235,.35), 0 2px 6px rgba(0,0,0,.08);
    cursor: pointer; font-weight: 700; font-size: 14px; line-height: 1;
    transition: transform .15s, box-shadow .15s;
    position: relative; overflow: hidden;
  }
  .ft-toggle:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(37,99,235,.45); }
  .ft-toggle-icon { font-size: 16px; }
  .ft-toggle-progress {
    position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
    background: rgba(255,255,255,.25); border-radius: 0 0 999px 999px; overflow: hidden;
  }
  #ft-progress-bar {
    display: block; height: 100%; width: 0%; background: #fff; transition: width .12s linear;
  }

  .ft-panel {
    position: fixed; right: 18px; bottom: 70px;
    width: 320px; max-width: calc(100vw - 36px); max-height: calc(100vh - 100px);
    background: #fff; border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.06);
    border: 1px solid #e5e7eb;
    display: flex; flex-direction: column;
    transform: translateY(8px) scale(.98); opacity: 0; pointer-events: none;
    transition: transform .2s ease, opacity .2s ease;
  }
  .floating-toc.is-open .ft-panel {
    transform: translateY(0) scale(1); opacity: 1; pointer-events: auto;
  }
  .ft-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px 12px; border-bottom: 1px solid #f1f5f9;
  }
  .ft-panel-title { font-weight: 800; font-size: 14px; color: #1e40af; }
  .ft-panel-close {
    width: 28px; height: 28px; border-radius: 50%;
    border: none; background: #f1f5f9; color: #475569;
    cursor: pointer; font-size: 18px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s;
  }
  .ft-panel-close:hover { background: #e2e8f0; color: #1e293b; }
  .ft-panel-list {
    list-style: none; padding: 8px 0; margin: 0; overflow-y: auto; flex: 1;
    counter-reset: ftnum;
  }
  .ft-panel-list li {
    counter-increment: ftnum;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s;
  }
  .ft-panel-list li::before { content: none; }
  .ft-panel-list a {
    display: block; padding: 10px 18px 10px 22px;
    color: #1e293b; text-decoration: none; font-size: 13px; line-height: 1.55;
    position: relative;
  }
  .ft-panel-list a::before {
    content: counter(ftnum, decimal-leading-zero);
    color: #94a3b8; font-size: 11px; font-weight: 700; margin-right: 8px;
    font-variant-numeric: tabular-nums;
  }
  .ft-panel-list a:hover { background: #f8fafc; color: #1e40af; }
  .ft-panel-list li.is-active { background: #eff6ff; border-left-color: #2563eb; }
  .ft-panel-list li.is-active a { color: #1e40af; font-weight: 700; }
  .ft-panel-list li.is-active a::before { color: #2563eb; }
  .ft-panel-footer {
    padding: 10px 14px; border-top: 1px solid #f1f5f9; text-align: center;
  }
  .ft-back-top {
    background: transparent; border: 1px solid #cbd5e1; border-radius: 999px;
    padding: 6px 14px; font-size: 12px; color: #475569; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
  }
  .ft-back-top:hover { background: #1e40af; color: #fff; border-color: #1e40af; }

  @media (max-width: 640px) {
    .floating-toc { right: 12px; bottom: 12px; }
    .ft-panel {
      right: 0; left: 0; bottom: 64px; margin: 0 12px;
      width: auto; max-width: none;
    }
    .ft-toggle-label { display: none; }
    .ft-toggle { padding: 12px 14px; }
  }
  @media print {
    .floating-toc { display: none; }
  }

  html { scroll-behavior: smooth; scroll-padding-top: 16px; }