/* ==========================================================================
   拾贝 LinkMaw · 教程站
   与官网共用 tokens.css：颜色、字号、间距、圆角、动效全部同源。
   页面样式只负责三栏骨架、侧栏、正文排版与代码块。
   ========================================================================== */

/* ==========================================================================
   分区条（第二行，位于统一外壳之下）
   ========================================================================== */

.docbar {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.docbar-in {
  max-width: var(--wrap);
  margin: 0 auto;
  min-height: 56px;
  padding: 0 var(--s-300);
  display: flex;
  align-items: center;
  gap: var(--s-200);
}

.db-label {
  flex: none;
  padding: 2px var(--s-75);
  border: 1px solid var(--brand-line);
  border-radius: var(--r-full);
  background: var(--brand-soft);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--brand-ink);
}

.tnav {
  display: flex;
  gap: var(--s-25);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tnav::-webkit-scrollbar {
  display: none;
}

.tnav a {
  padding: var(--s-75) var(--s-100);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  color: var(--ink-2);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.tnav a:hover {
  background: var(--line-2);
  color: var(--ink);
}

.tnav a.on {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
}

.tact {
  display: flex;
  align-items: center;
  gap: var(--s-75);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-50);
  height: 32px;
  padding: 0 var(--s-100);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.icon-btn:hover {
  background: var(--line-2);
  color: var(--ink);
}

.kbd {
  padding: 0 var(--s-25);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--muted);
}

/* ==========================================================================
   三栏骨架
   ========================================================================== */

.shell {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--s-300);
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr) 188px;
  gap: var(--s-400);
  align-items: start;
}

/* ── 左侧边栏 ─────────────────────────────────────────────────────── */

.side {
  position: sticky;
  top: calc(var(--sh-total) + var(--s-100));
  max-height: calc(100vh - var(--sh-total) - var(--s-300));
  overflow: auto;
  padding: var(--s-400) 0 var(--s-600);
}

.side-home {
  display: block;
  padding: var(--s-75) var(--s-100);
  margin-bottom: var(--s-75);
  border-radius: var(--r-md);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color var(--dur-fast) var(--ease);
}

.side-home:hover {
  color: var(--brand-ink);
}

.side-sec > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-75) var(--s-100);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  transition: background-color var(--dur-fast) var(--ease);
}

.side-sec > summary::-webkit-details-marker {
  display: none;
}

.side-sec > summary:hover {
  background: var(--line-2);
}

.chev {
  width: 7px;
  height: 7px;
  margin-right: 3px;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--dur) var(--ease);
}

.side-sec[open] .chev {
  transform: rotate(-135deg);
}

.side-sec ul {
  margin: var(--s-25) 0 var(--s-75);
  padding: 0 0 0 var(--s-75);
  list-style: none;
}

.side-sec li {
  margin: 1px 0;
}

.side-sec li a {
  display: block;
  padding: var(--s-50) var(--s-100);
  border-left: 2px solid var(--line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  color: var(--ink-2);
  transition: color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.side-sec li a:hover {
  background: var(--line-2);
  color: var(--ink);
  border-left-color: var(--muted);
}

.side-sec li a.on {
  background: var(--brand-soft);
  border-left-color: var(--brand-2);
  color: var(--brand-ink);
  font-weight: 600;
}

/* ── 正文 ─────────────────────────────────────────────────────────── */

.main {
  min-width: 0;
  padding: var(--s-400) 0 var(--s-700);
}

.crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-75);
  margin-bottom: var(--s-200);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  color: var(--muted);
}

.crumb a {
  color: var(--muted);
  transition: color var(--dur-fast) var(--ease);
}

.crumb a:hover {
  color: var(--brand-ink);
}

.crumb i {
  font-style: normal;
  opacity: 0.5;
}

.crumb span {
  color: var(--ink-2);
}

.main h1 {
  margin-bottom: var(--s-200);
  font-size: var(--t-4xl);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.lead {
  max-width: 720px;
  font-size: var(--t-lg);
  line-height: 32px;
  color: var(--ink-2);
}

.meta {
  margin: var(--s-300) 0 var(--s-500);
  padding-bottom: var(--s-300);
  border-bottom: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  color: var(--muted);
}

/* 正文排版 */
.main h2 {
  margin: var(--s-600) 0 var(--s-200);
  padding-top: var(--s-75);
  font-size: var(--t-2xl);
  line-height: 1.35;
  letter-spacing: -0.02em;
  scroll-margin-top: calc(var(--sh-total) + var(--s-300));
}

.main h3 {
  margin: var(--s-400) 0 var(--s-100);
  font-size: var(--t-lg);
  line-height: var(--lh-lg);
  letter-spacing: -0.01em;
}

.main p {
  margin: 0 0 var(--s-200);
  font-size: var(--t-base);
  line-height: 1.75;
  color: var(--ink-2);
}

.main a {
  color: var(--brand-ink);
  border-bottom: 1px solid color-mix(in srgb, var(--brand-ink) 32%, transparent);
  transition: border-color var(--dur-fast) var(--ease);
}

.main a:hover {
  border-bottom-color: var(--brand-ink);
}

.main ul,
.main ol {
  margin: 0 0 var(--s-300);
  padding-left: var(--s-300);
  color: var(--ink-2);
  font-size: var(--t-base);
  line-height: 1.75;
}

.main li {
  margin: var(--s-75) 0;
}

.main li::marker {
  color: var(--muted);
}

.main strong,
.main b {
  font-weight: 600;
  color: var(--ink);
}

.main code {
  padding: 1px var(--s-50);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--line-2);
  font-family: var(--f-mono);
  font-size: var(--t-sm);
  color: var(--ink);
  /* 长路径在窄列里会折行，clone 让每行的边框与底色都完整 */
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.main kbd {
  padding: 1px var(--s-50);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  color: var(--ink-2);
}

pre.code {
  margin: 0 0 var(--s-300);
  padding: var(--s-300);
  border: 1px solid #1f1f1f;
  border-radius: var(--r-lg);
  background: #0a0a0a;
  color: #e8e8e8;
  overflow: auto;
  font-size: var(--t-sm);
  line-height: 24px;
  tab-size: 2;
}

pre.code code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

/* ── 右侧目录 ─────────────────────────────────────────────────────── */

.toc {
  position: sticky;
  top: calc(var(--sh-total) + var(--s-100));
  padding: var(--s-500) 0 var(--s-600);
  font-size: var(--t-sm);
}

.toc-t {
  margin-bottom: var(--s-75);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toc ul {
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
  list-style: none;
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: var(--s-50) 0 var(--s-50) var(--s-100);
  border: 0;
  color: var(--muted);
  line-height: 20px;
  transition: color var(--dur-fast) var(--ease);
}

.toc a:hover {
  color: var(--brand-ink);
  border: 0;
}

/* ==========================================================================
   内容块
   ========================================================================== */

/* 步骤 */
.steps {
  margin: 0 0 var(--s-300);
  padding: 0;
  list-style: none;
  counter-reset: st;
}

.steps li {
  position: relative;
  margin: 0;
  padding: 0 0 var(--s-300) var(--s-600);
  counter-increment: st;
}

.steps li::before {
  content: counter(st, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--brand-line);
  border-radius: var(--r-md);
  background: var(--brand-soft);
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--brand-ink);
}

/* 竖向引导线从编号框底部往下拉，最后一节不画 */
.steps li::after {
  content: '';
  position: absolute;
  left: 16px;
  top: 36px;
  bottom: 4px;
  width: 1px;
  background: var(--line);
}

.steps li:last-child::after {
  display: none;
}

.steps b {
  display: block;
  margin-bottom: var(--s-25);
  font-size: var(--t-base);
  font-weight: 600;
  color: var(--ink);
}

.steps div {
  font-size: var(--t-base);
  line-height: 1.75;
  color: var(--ink-2);
}

/* 表格 */
.tbl {
  margin: 0 0 var(--s-300);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: auto;
}

.tbl table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.tbl th:first-child,
.tbl td:first-child {
  width: 26%;
}

.tbl.t2 th:first-child,
.tbl.t2 td:first-child {
  width: 34%;
}

.tbl th {
  padding: var(--s-100) var(--s-200);
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tbl td {
  padding: var(--s-100) var(--s-200);
  vertical-align: top;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-2);
}

.tbl tr:last-child td {
  border-bottom: 0;
}

.tbl td:first-child {
  color: var(--ink);
}

.tbl td,
.tbl th {
  overflow-wrap: break-word;
}

.tbl code {
  overflow-wrap: anywhere;
}

/* 提示条：四档语义，边框走满一圈 */
.note {
  margin: 0 0 var(--s-300);
  padding: var(--s-200) var(--s-300);
  border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent);
  border-radius: var(--r-lg);
  background: var(--blue-soft);
  font-size: var(--t-sm);
  line-height: 1.75;
  color: var(--ink-2);
}

.note > b {
  display: block;
  margin-bottom: var(--s-25);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--blue);
}

.note-tip {
  border-color: color-mix(in srgb, var(--green) 22%, transparent);
  background: var(--green-soft);
}

.note-tip > b {
  color: var(--green);
}

.note-warn {
  border-color: color-mix(in srgb, var(--amber) 26%, transparent);
  background: var(--amber-soft);
}

.note-warn > b {
  color: var(--amber);
}

.note-danger {
  border-color: color-mix(in srgb, var(--red) 26%, transparent);
  background: var(--red-soft);
}

.note-danger > b {
  color: var(--red);
}

/* FAQ */
.faq {
  margin: 0 0 var(--s-300);
  border-top: 1px solid var(--line);
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  justify-content: space-between;
  gap: var(--s-200);
  padding: var(--s-200) 0;
  font-size: var(--t-base);
  line-height: var(--lh-base);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: color var(--dur-fast) var(--ease);
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary:hover {
  color: var(--brand-ink);
}

.faq summary::after {
  content: '+';
  color: var(--muted);
  font-weight: 400;
}

.faq details[open] summary::after {
  content: '−';
}

.faq details > div {
  padding: 0 0 var(--s-300);
  font-size: var(--t-sm);
  line-height: 1.8;
  color: var(--muted);
}

@supports (selector(:has(*))) {
  .faq details[open] summary {
    color: var(--brand-ink);
  }
}

/* 卡片 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-100);
  margin: 0 0 var(--s-400);
}

.card {
  display: block;
  padding: var(--s-200) var(--s-300);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg);
  transition: border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.card:hover {
  border-color: var(--brand-line);
  transform: translateY(-1px);
}

.card b {
  display: block;
  margin-bottom: 2px;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  font-weight: 600;
  color: var(--ink);
}

.card span {
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  color: var(--muted);
}

/* 界面示意 */
.ui {
  margin: 0 0 var(--s-400);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg);
}

.ui figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-100);
  padding: var(--s-75) var(--s-200);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  color: var(--ink-2);
}

.ui figcaption em {
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
}

.ui-body {
  padding: var(--s-50) 0;
}

.ui-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: var(--s-100);
  padding: var(--s-75) var(--s-200);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
}

.ui-row + .ui-row {
  border-top: 1px dashed var(--line-2);
}

.ui-l {
  font-weight: 600;
  color: var(--ink);
}

.ui-r {
  color: var(--muted);
}

/* 上下篇 */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-100);
  margin: var(--s-700) 0 0;
}

.pg {
  display: block;
  padding: var(--s-200) var(--s-300);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.pg:hover {
  border-color: var(--brand-line);
  background: var(--bg-soft);
}

.pg span {
  display: block;
  margin-bottom: var(--s-25);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  color: var(--muted);
}

.pg b {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}

.pg.next {
  text-align: right;
}

/* ==========================================================================
   搜索层
   ========================================================================== */

.srch {
  position: fixed;
  inset: 0;
  z-index: 120;
  padding-top: 16vh;
  background: rgba(10, 10, 10, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.srch[hidden] {
  display: none;
}

.srch-box {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  gap: var(--s-75);
  padding: var(--s-75);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg);
  box-shadow: var(--shadow-3);
}

.srch-box input {
  flex: 1;
  min-width: 0;
  padding: var(--s-100) var(--s-100);
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font-size: var(--t-base);
}

.srch-box input::placeholder {
  color: var(--muted);
}

.srch-box button {
  padding: 0 var(--s-100);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: var(--t-xs);
  cursor: pointer;
}

.srch-res {
  max-width: 620px;
  max-height: 56vh;
  margin: var(--s-75) auto 0;
  overflow: auto;
}

.srch-res a {
  display: block;
  margin-bottom: var(--s-75);
  padding: var(--s-100) var(--s-200);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
}

.srch-res a:hover {
  border-color: var(--brand-line);
}

.srch-res b {
  display: block;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink);
}

.srch-res span {
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  color: var(--muted);
}

.srch-res .none {
  padding: var(--s-300);
  text-align: center;
  font-size: var(--t-sm);
  color: var(--muted);
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 224px minmax(0, 1fr);
    gap: var(--s-400);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 var(--s-300);
  }

  .side {
    display: none;
  }

  .main {
    padding-top: var(--s-300);
  }
}

@media (max-width: 760px) {
  .docbar-in {
    padding: 0 var(--s-200);
    gap: var(--s-100);
  }

  .shell {
    padding: 0 var(--s-200);
  }

  .main h1 {
    font-size: var(--t-3xl);
    line-height: 1.2;
  }

  .main h2 {
    font-size: var(--t-xl);
  }

  .lead {
    font-size: var(--t-base);
    line-height: var(--lh-base);
  }

  .ui-row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-25);
  }

  .pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .tbl table {
    font-size: 14px;
  }

  .tbl th,
  .tbl td {
    padding: var(--s-75) var(--s-100);
  }

  .tbl th:first-child,
  .tbl td:first-child {
    width: 30%;
  }

  .steps li {
    padding-left: var(--s-500);
  }

  pre.code {
    padding: var(--s-200);
    border-radius: var(--r-md);
  }
}

@media print {
  .docbar,
  .side,
  .toc,
  .pager,
  .srch,
  .sh-top,
  .sh-bot {
    display: none;
  }

  .shell {
    display: block;
    padding: 0;
  }

  body {
    padding-top: 0;
    font-size: 12pt;
  }

  .main a {
    color: #000;
    border: 0;
  }
}
