/* =========================================================
   热播Live 协议文档 — 样式
   PC：左侧固定目录 + 正文；移动端（≤960px）：目录收为抽屉
   ========================================================= */

:root {
  --brand: #ff3d5a;
  --brand-soft: rgba(255, 61, 90, 0.1);
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2329;
  --text-2: #4e5969;
  --text-3: #86909c;
  --border: #e5e6eb;
  --strong: #111418;
  --topbar-h: 56px;
  --sidebar-w: 280px;
  --content-w: 820px;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(15, 20, 30, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #ff5a73;
    --brand-soft: rgba(255, 90, 115, 0.14);
    --bg: #121316;
    --surface: #1b1d21;
    --text: #e6e8eb;
    --text-2: #b4b9c2;
    --text-3: #7f8792;
    --border: #2c2f35;
    --strong: #ffffff;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.85;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: calc(var(--sidebar-w) + var(--content-w) + 96px);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.doc-nav { display: flex; gap: 4px; }
.doc-nav a {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 14px;
  white-space: nowrap;
}
.doc-nav a:hover { background: var(--bg); text-decoration: none; }
.doc-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------- 主布局 ---------- */
.layout {
  max-width: calc(var(--sidebar-w) + var(--content-w) + 96px);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

/* ---------- 目录（PC 为固定侧栏） ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 16px;
  scrollbar-width: thin;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
}
.sidebar-close { display: none; }

.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  line-height: 1.5;
  border-left: 2px solid transparent;
}
.toc a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.toc-l1 { font-size: 14px; font-weight: 500; margin-top: 2px; }
.toc-sub { margin: 2px 0 6px 12px !important; }
.toc-l2 { font-size: 13px; color: var(--text-3) !important; }
.toc a.current {
  background: var(--brand-soft);
  color: var(--brand) !important;
  border-left-color: var(--brand);
  border-radius: 0 8px 8px 0;
}

/* ---------- 正文 ---------- */
.content { min-width: 0; }
.doc {
  max-width: var(--content-w);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 56px 56px;
}
.doc-title {
  margin: 0 0 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 28px;
  line-height: 1.35;
  color: var(--strong);
  text-align: center;
}
.doc h2 {
  margin: 40px 0 14px;
  padding-left: 12px;
  border-left: 4px solid var(--brand);
  font-size: 20px;
  line-height: 1.45;
  color: var(--strong);
}
.doc h3 {
  margin: 28px 0 10px;
  font-size: 17px;
  line-height: 1.5;
  color: var(--strong);
}
.doc h4 {
  margin: 20px 0 8px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.doc h2:first-of-type { margin-top: 8px; }
.doc p {
  margin: 0 0 12px;
  text-align: justify;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.doc p.item { padding-left: 1em; }
.doc strong { color: var(--strong); font-weight: 600; }

.doc-footer {
  max-width: var(--content-w);
  padding: 24px 4px 8px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

/* ---------- 悬浮按钮 ---------- */
.fab {
  position: fixed;
  right: 24px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.fab:hover { color: var(--brand); }
.fab-top { bottom: 24px; opacity: 0; pointer-events: none; transform: translateY(8px); }
.fab-top.show { opacity: 1; pointer-events: auto; transform: none; }
.fab-toc { display: none; }

.overlay { display: none; }

/* =========================================================
   平板 / 手机（≤960px）：目录变为侧滑抽屉
   ========================================================= */
@media (max-width: 960px) {
  .layout {
    display: block;
    padding: 16px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: min(84vw, 320px);
    max-height: none;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 8px 8px calc(24px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
  }
  body.toc-open .sidebar { transform: none; }

  .sidebar-head {
    position: sticky;
    top: -8px;
    margin: -8px -8px 4px;
    padding: 14px 16px 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    color: var(--text);
    letter-spacing: 0;
  }
  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-2);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s;
  }
  body.toc-open .overlay { opacity: 1; pointer-events: auto; }
  body.toc-open { overflow: hidden; }

  .toc a { padding: 9px 12px; }

  .doc { padding: 32px 28px 40px; }

  .fab-toc { display: inline-flex; bottom: calc(24px + env(safe-area-inset-bottom)); }
  .fab-top { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

/* 手机（≤600px） */
@media (max-width: 600px) {
  :root { --topbar-h: 52px; }

  body { font-size: 15px; line-height: 1.8; }

  .topbar-inner { padding: 0 12px; }
  .brand { font-size: 16px; }
  .doc-nav a { padding: 5px 10px; font-size: 13px; }

  .layout { padding: 0; }

  .doc {
    border: none;
    border-radius: 0;
    padding: 24px 18px 32px;
  }
  .doc-title { font-size: 22px; margin-bottom: 20px; padding-bottom: 16px; }
  .doc h2 { font-size: 18px; margin-top: 32px; }
  .doc h3 { font-size: 16px; margin-top: 22px; }
  .doc p { text-align: left; }

  .doc-footer { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }

  .fab { right: 16px; }
}

@media (max-width: 360px) {
  .brand-dot { display: none; }
}

/* 打印：隐藏导航，只保留正文 */
@media print {
  .topbar, .sidebar, .overlay, .fab { display: none !important; }
  .layout { display: block; padding: 0; }
  .doc { border: none; padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar, .overlay, .fab { transition: none; }
}
