/* /tools/ydkjs 你不知道的 JS · 中文精读
   设计令牌定义在 :root（浮层/ toast 挂在 .yd 内，仍需全局可继承）；
   满屏三规则 + body overflow:visible 让页内 sticky 生效（站点 body 默认 overflow-y:scroll）。 */
:root {
  --yd-bg: #14171c;
  --yd-card: #1b1f26;
  --yd-card-2: #20252e;
  --yd-card-3: #262c36;
  --yd-line: #2c333e;
  --yd-line-2: #383f4b;
  --yd-fg: #e7ecf3;
  --yd-sub: #a5b0bd;
  --yd-faint: #8d98a6;
  --yd-accent: #f0c34a;
  --yd-accent-2: #71c8f5;
  --yd-ok: #5fc98a;
  --yd-warn: #e8a95c;
  --yd-err: #ee7b7b;
  --yd-on-accent: #241d08;
  --yd-accent-soft: rgba(240, 195, 74, .12);
  --yd-ok-soft: rgba(95, 201, 138, .12);
  --yd-warn-soft: rgba(232, 169, 92, .12);
  --yd-err-soft: rgba(238, 123, 123, .12);
  --yd-zebra: rgba(127, 127, 127, .055);
  --yd-shadow: 0 8px 30px rgba(0, 0, 0, .28);
  --yd-shadow-sm: 0 2px 10px rgba(0, 0, 0, .18);
  --yd-r: 14px;
  --yd-r-sm: 9px;
  --yd-maxw: 100%;
  --yd-side-w: 262px;
  --yd-code-fs: 13px;
  --yd-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Mono", "Liberation Mono", monospace;
}
[data-theme="light"] {
  --yd-bg: #f4f6f9;
  --yd-card: #ffffff;
  --yd-card-2: #f7f9fc;
  --yd-card-3: #eef2f7;
  --yd-line: #e1e6ed;
  --yd-line-2: #cdd5e0;
  --yd-fg: #1b2430;
  --yd-sub: #4d5b6c;
  --yd-faint: #617082;
  --yd-accent: #9a6800;
  --yd-accent-2: #1668a8;
  --yd-ok: #167a45;
  --yd-warn: #9a5a00;
  --yd-err: #b33737;
  --yd-on-accent: #ffffff;
  --yd-accent-soft: rgba(154, 104, 0, .09);
  --yd-ok-soft: rgba(22, 122, 69, .09);
  --yd-warn-soft: rgba(154, 90, 0, .09);
  --yd-err-soft: rgba(179, 55, 55, .09);
  --yd-zebra: rgba(15, 20, 25, .035);
  --yd-shadow: 0 8px 26px rgba(24, 39, 60, .1);
  --yd-shadow-sm: 0 2px 8px rgba(24, 39, 60, .08);
}
/* 满屏：解除站点 .app / .main-content / .page-container 的限宽，保留左侧导航 */
body.page-ydkjs-full { overflow: visible; }
body.page-ydkjs-full .app,
body.page-ydkjs-full .main-content,
body.page-ydkjs-full .page-container { max-width: 100%; width: 100%; }
body.page-ydkjs-full .main-content { border-right: 0; min-width: 0; }

.yd { max-width: var(--yd-maxw); margin: 0; padding: 18px 22px 72px; color: var(--yd-fg); box-sizing: border-box; }
.yd *, .yd *::before, .yd *::after { box-sizing: border-box; }
.yd [hidden] { display: none !important; }
.yd a { color: var(--yd-accent-2); text-decoration: none; }
.yd a:hover { text-decoration: underline; }
.yd button, .yd input, .yd select, .yd textarea { font-family: inherit; }
.yd button { cursor: pointer; }
.yd :focus-visible { outline: 2px solid var(--yd-accent); outline-offset: 2px; }
.yd ::-webkit-scrollbar { width: 10px; height: 10px; }
.yd ::-webkit-scrollbar-thumb { background: var(--yd-line-2); border-radius: 8px; border: 2px solid var(--yd-card); }
.yd ::-webkit-scrollbar-track { background: transparent; }
.yd .yd-note { color: var(--yd-faint); font-size: 12.5px; line-height: 1.7; }
.yd-en { color: var(--yd-faint); font-size: 11.5px; }

/* ---------- hero ---------- */
.yd-hero { position: relative; background: var(--yd-card); background: linear-gradient(135deg, var(--yd-accent-soft), var(--yd-card) 46%); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 20px 24px; box-shadow: var(--yd-shadow-sm); }
.yd-hero-top { display: flex; align-items: flex-start; gap: 16px; }
.yd-hero-ic { flex: 0 0 auto; width: 52px; height: 52px; display: grid; place-items: center; font-size: 28px; border-radius: 14px; background: var(--yd-accent-soft); border: 1px solid var(--yd-line); }
.yd-hero-t { min-width: 0; flex: 1 1 auto; }
.yd-hero h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.3; text-wrap: balance; }
.yd-hero p { margin: 0; max-width: 92ch; color: var(--yd-sub); font-size: 13.5px; line-height: 1.75; }
.yd-hero-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.yd-hero-tags span { font-size: 11.5px; color: var(--yd-sub); background: var(--yd-card-2); border: 1px solid var(--yd-line); border-radius: 999px; padding: 3px 10px; }
.yd-fold, .yd-icon-btn { border: 0; background: transparent; color: var(--yd-sub); width: 30px; height: 30px; border-radius: 8px; font-size: 17px; line-height: 1; }
.yd-fold:hover, .yd-icon-btn:hover { background: var(--yd-card-3); color: var(--yd-fg); }
.yd-hero.is-collapsed { padding: 12px 20px; }
.yd-hero.is-collapsed .yd-hero-ic { width: 34px; height: 34px; font-size: 19px; border-radius: 9px; }
.yd-hero.is-collapsed h1 { font-size: 17px; margin: 0; }
.yd-hero-extra { margin-top: 16px; }
.yd-hero.is-collapsed .yd-hero-extra { display: none; }
.yd-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; border: 1px solid var(--yd-line); border-radius: var(--yd-r-sm); overflow: hidden; background: var(--yd-card-2); }
.yd-stat { padding: 12px 14px; border-left: 1px solid var(--yd-line); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.yd-stat:first-child { border-left: 0; }
.yd-stat b { font-size: 19px; font-weight: 700; color: var(--yd-accent); font-variant-numeric: tabular-nums; }
.yd-stat:nth-child(3n) b { color: var(--yd-accent-2); }
.yd-stat:nth-child(5n) b { color: var(--yd-ok); }
.yd-stat span { font-size: 11.5px; color: var(--yd-sub); }
.yd-source { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--yd-line-2); border-radius: var(--yd-r-sm); background: var(--yd-card-2); }
.yd-source strong { font-size: 12.5px; color: var(--yd-warn); }
.yd-source p { margin: 6px 0 0; font-size: 12px; line-height: 1.8; color: var(--yd-sub); }
.yd-source b { color: var(--yd-fg); }

/* ---------- toolbar / tabs ---------- */
.yd-toolbar { position: sticky; top: 8px; z-index: 40; margin: 14px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 8px 10px; box-shadow: var(--yd-shadow-sm); }
.yd-tabs { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; min-width: 0; }
.yd-tab { border: 1px solid transparent; background: transparent; color: var(--yd-sub); font-size: 13px; padding: 8px 12px; border-radius: 9px; white-space: nowrap; }
.yd-tab:hover { background: var(--yd-card-3); color: var(--yd-fg); }
.yd-tab.is-on { background: var(--yd-accent-soft); color: var(--yd-accent); border-color: var(--yd-accent); font-weight: 600; }
.yd-side-toggle { display: none; border: 1px solid var(--yd-line-2); background: var(--yd-card-2); color: var(--yd-fg); border-radius: 9px; padding: 8px 12px; font-size: 13px; }
.yd-search-box { position: relative; flex: 0 1 300px; min-width: 190px; display: flex; align-items: center; }
.yd-search-ic { position: absolute; left: 10px; color: var(--yd-faint); font-size: 16px; pointer-events: none; }
.yd-search { width: 100%; height: 36px; padding: 0 30px 0 30px; border: 1px solid var(--yd-line-2); border-radius: 9px; background: var(--yd-card-2); color: var(--yd-fg); font-size: 13px; }
.yd-search::placeholder { color: var(--yd-faint); }
.yd-search:focus { border-color: var(--yd-accent); outline: none; box-shadow: 0 0 0 3px var(--yd-accent-soft); }
.yd input[type="search"]::-webkit-search-cancel-button { display: none; }
.yd-search-clear { position: absolute; right: 6px; border: 0; background: transparent; color: var(--yd-sub); width: 24px; height: 24px; border-radius: 6px; }
.yd-search-clear:hover { background: var(--yd-card-3); }
.yd-search-pop { position: absolute; top: calc(100% + 8px); right: 0; width: min(420px, 90vw); max-height: 380px; overflow-y: auto; background: var(--yd-card); border: 1px solid var(--yd-line-2); border-radius: 12px; box-shadow: var(--yd-shadow); z-index: 60; overscroll-behavior: contain; }
.yd-search-i { display: flex; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--yd-line); background: transparent; color: var(--yd-fg); }
.yd-search-i:hover { background: var(--yd-card-2); }
.yd-search-tag { flex: 0 0 auto; font-size: 10.5px; color: var(--yd-accent); background: var(--yd-accent-soft); border-radius: 5px; padding: 2px 6px; height: fit-content; }
.yd-search-tt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.yd-search-tt b { font-size: 12.5px; font-weight: 600; }
.yd-search-tt small { font-size: 11px; color: var(--yd-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yd-search-empty { padding: 16px; color: var(--yd-faint); font-size: 12.5px; }

/* ---------- work / side ---------- */
.yd-work { display: grid; grid-template-columns: minmax(0, var(--yd-side-w)) minmax(0, 1fr); gap: 16px; align-items: start; }
.yd-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; overscroll-behavior: contain; background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 10px; box-shadow: var(--yd-shadow-sm); }
.yd-side-head { font-size: 11.5px; font-weight: 700; color: var(--yd-faint); letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px 10px; border-bottom: 1px solid var(--yd-line); margin-bottom: 8px; position: sticky; top: -10px; background: var(--yd-card); z-index: 2; }
.yd-side-g { font-size: 11px; color: var(--yd-faint); padding: 12px 8px 6px; font-weight: 700; }
.yd-side-i { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; text-align: left; border: 0; background: transparent; color: var(--yd-sub); font-size: 12.5px; padding: 8px 9px; border-radius: 8px; margin-bottom: 2px; }
.yd-side-i:hover { background: var(--yd-card-3); color: var(--yd-fg); }
.yd-side-i.is-on { background: var(--yd-accent-soft); color: var(--yd-accent); font-weight: 600; }
.yd-side-i.is-done::before { content: '✓'; color: var(--yd-ok); font-size: 11px; }
.yd-side-i span { color: var(--yd-faint); font-size: 11px; flex: 0 0 auto; }
.yd-side-topic { padding-left: 18px; font-size: 12px; }
.yd-side-search { padding: 0 2px 8px; }
.yd-side-search input { width: 100%; height: 32px; border: 1px solid var(--yd-line-2); border-radius: 8px; background: var(--yd-card-2); color: var(--yd-fg); padding: 0 9px; font-size: 12.5px; }
.yd-side-note { color: var(--yd-faint); font-size: 11.5px; line-height: 1.7; padding: 10px 8px; }
.yd-side-scrim { display: none; }
.yd-main { min-width: 0; }
.yd-pane { min-width: 0; }
.yd-state { padding: 40px 20px; text-align: center; color: var(--yd-sub); font-size: 13px; }
.yd-state-err { color: var(--yd-err); }
.yd-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--yd-line-2); border-top-color: var(--yd-accent); border-radius: 50%; animation: yd-spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes yd-spin { to { transform: rotate(360deg); } }
.yd-empty { padding: 26px 16px; text-align: center; color: var(--yd-faint); font-size: 12.5px; border: 1px dashed var(--yd-line-2); border-radius: var(--yd-r-sm); background: var(--yd-card-2); }

/* ---------- shared bits ---------- */
.yd-pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.yd-pane-head h2 { margin: 0 0 4px; font-size: 19px; }
.yd-pane-head p { margin: 0; color: var(--yd-sub); font-size: 12.5px; line-height: 1.7; max-width: 90ch; }
.yd-count { color: var(--yd-faint); font-size: 12px; white-space: nowrap; }
.yd-chip { border: 1px solid var(--yd-line-2); background: var(--yd-card-2); color: var(--yd-sub); border-radius: 999px; padding: 7px 14px; font-size: 12.5px; }
.yd-chip:hover { border-color: var(--yd-accent); color: var(--yd-fg); }
.yd-chip.is-on { background: var(--yd-accent-soft); border-color: var(--yd-accent); color: var(--yd-accent); font-weight: 600; }
.yd-chip-sm { padding: 4px 10px; font-size: 11.5px; }
.yd-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.yd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--yd-line-2); background: var(--yd-card-2); color: var(--yd-fg); border-radius: 9px; padding: 8px 13px; font-size: 12.5px; min-height: 34px; }
.yd-btn:hover:not(:disabled) { background: var(--yd-card-3); border-color: var(--yd-accent); }
.yd-btn:disabled { opacity: .45; cursor: not-allowed; }
.yd-btn.is-on { background: var(--yd-ok-soft); border-color: var(--yd-ok); color: var(--yd-ok); }
.yd-btn-pri { background: var(--yd-accent); border-color: var(--yd-accent); color: var(--yd-on-accent); font-weight: 600; }
.yd-btn-pri:hover:not(:disabled) { filter: brightness(1.08); background: var(--yd-accent); }
.yd-btn-danger { color: var(--yd-err); border-color: var(--yd-err); }
.yd-btn-xs { padding: 4px 9px; min-height: 26px; font-size: 11.5px; }
.yd-select { height: 34px; border: 1px solid var(--yd-line-2); background: var(--yd-card-2); color: var(--yd-fg); border-radius: 8px; padding: 0 8px; font-size: 12.5px; }
.yd-badge { font-size: 10.5px; border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.yd-badge--published { background: var(--yd-ok-soft); color: var(--yd-ok); }
.yd-badge--draft { background: var(--yd-warn-soft); color: var(--yd-warn); }
.yd-badge--canceled { background: var(--yd-err-soft); color: var(--yd-err); }
.yd-progress { height: 7px; background: var(--yd-card-3); border-radius: 999px; overflow: hidden; flex: 1 1 auto; min-width: 40px; }
.yd-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--yd-accent), var(--yd-ok)); border-radius: 999px; transition: width .25s ease; }
.yd-table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--yd-line); border-radius: var(--yd-r-sm); }
.yd table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.yd th, .yd td { padding: 8px 11px; text-align: left; border-right: 1px solid var(--yd-line); border-bottom: 1px solid var(--yd-line); vertical-align: top; }
.yd th:last-child, .yd td:last-child { border-right: 0; }
.yd tbody tr:last-child td { border-bottom: 0; }
.yd thead th { background: var(--yd-card-3); color: var(--yd-fg); font-weight: 600; position: sticky; top: 0; z-index: 1; }
.yd tbody tr:nth-child(even) { background: var(--yd-zebra); }
.yd code { font-family: var(--yd-mono); font-size: .92em; background: var(--yd-card-3); border: 1px solid var(--yd-line); border-radius: 4px; padding: 1px 4px; color: var(--yd-accent-2); }
.yd kbd { font-family: var(--yd-mono); font-size: 10.5px; border: 1px solid var(--yd-line-2); border-radius: 4px; padding: 1px 4px; opacity: .85; }

/* ---------- 1. 书系导览 ---------- */
.yd-route { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 16px 18px; margin-bottom: 16px; }
.yd-route h3 { margin: 0 0 12px; font-size: 14px; }
.yd-route-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.yd-route-i { background: var(--yd-card-2); border: 1px solid var(--yd-line); border-left: 3px solid var(--yd-accent); border-radius: 8px; padding: 10px 12px; }
.yd-route-i b { font-size: 12.5px; color: var(--yd-accent); }
.yd-route-i p { margin: 6px 0 0; font-size: 11.5px; line-height: 1.7; color: var(--yd-sub); }
.yd-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.yd-book { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); overflow: hidden; }
.yd-book.is-open { border-color: var(--yd-accent); }
.yd-book-top { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "ic t badge" "ic meta caret"; gap: 2px 10px; align-items: center; width: 100%; text-align: left; border: 0; background: transparent; color: var(--yd-fg); padding: 13px 14px; }
.yd-book-top:hover { background: var(--yd-card-2); }
.yd-book-ic { grid-area: ic; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; font-family: var(--yd-mono); letter-spacing: -.02em; }
.yd-book-ic--1st { background: var(--yd-err-soft); color: var(--yd-err); border: 1px solid var(--yd-err); }
.yd-book-ic--2nd { background: var(--yd-ok-soft); color: var(--yd-ok); border: 1px solid var(--yd-ok); }
.yd-book-t { grid-area: t; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.yd-book-t b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yd-badge { grid-area: badge; }
.yd-book-meta { grid-area: meta; font-size: 11px; color: var(--yd-faint); }
.yd-book-caret { grid-area: caret; color: var(--yd-faint); font-size: 15px; justify-self: end; }
.yd-book-body { border-top: 1px solid var(--yd-line); padding: 12px 14px 16px; }
.yd-book-intro { margin: 0 0 10px; font-size: 12px; line-height: 1.85; color: var(--yd-sub); }
.yd-book-link { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--yd-faint); margin-bottom: 10px; }
.yd-book-none { font-size: 12px; color: var(--yd-faint); background: var(--yd-card-2); border: 1px dashed var(--yd-line-2); border-radius: 8px; padding: 12px; line-height: 1.8; }
.yd-chapters { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.yd-chapter { background: var(--yd-card-2); border: 1px solid var(--yd-line); border-radius: 9px; padding: 9px 11px; }
.yd-chapter.is-done { border-left: 3px solid var(--yd-ok); }
.yd-chapter-t { display: flex; align-items: flex-start; gap: 7px; }
.yd-caret { flex: 0 0 auto; width: 20px; height: 20px; border: 0; background: transparent; color: var(--yd-accent); font-size: 12px; padding: 0; }
.yd-caret.is-static { color: var(--yd-faint); text-align: center; }
.yd-chapter-n { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.yd-chapter-n b { font-size: 12.5px; }
.yd-check { flex: 0 0 auto; font-size: 11px; color: var(--yd-faint); display: inline-flex; align-items: center; gap: 3px; cursor: pointer; white-space: nowrap; }
.yd-check input { accent-color: var(--yd-ok); }
.yd-chapter-d { margin: 5px 0 6px 27px; font-size: 11.5px; line-height: 1.7; color: var(--yd-sub); }
.yd-chapter-acts { margin-left: 27px; font-size: 11px; }
.yd-secs { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px 27px; }
.yd-secs span { font-size: 10.5px; color: var(--yd-faint); background: var(--yd-card-3); border: 1px solid var(--yd-line); border-radius: 5px; padding: 2px 6px; }

/* ---------- 2. 知识精讲 ---------- */
.yd-topic-top { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 16px 18px; margin-bottom: 14px; }
.yd-crumb { font-size: 11px; color: var(--yd-faint); margin-bottom: 8px; }
.yd-topic-head h2 { margin: 0 0 6px; font-size: 21px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.yd-topic-head h2 small { font-size: 12px; color: var(--yd-faint); font-weight: 400; }
.yd-topic-head p { margin: 0; color: var(--yd-sub); font-size: 13px; line-height: 1.8; }
.yd-topic-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.yd-topic-tags span { font-size: 10.5px; color: var(--yd-accent-2); background: var(--yd-card-2); border: 1px solid var(--yd-line); border-radius: 5px; padding: 2px 7px; }
.yd-topic-acts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--yd-line); }
.yd-topic-body { min-width: 0; }
.yd-article, .yd-box { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 18px 22px; margin-bottom: 12px; }
.yd-article { font-size: 13.5px; line-height: 1.95; color: var(--yd-fg); }
.yd-article h3 { font-size: 16px; margin: 22px 0 10px; padding-left: 10px; border-left: 3px solid var(--yd-accent); }
.yd-article h3:first-child { margin-top: 0; }
.yd-article h4 { font-size: 14px; margin: 16px 0 8px; }
.yd-article p { margin: 0 0 12px; }
.yd-article ul { margin: 0 0 12px; padding-left: 22px; }
.yd-article li { margin: 4px 0; }
.yd-article blockquote { margin: 12px 0; padding: 9px 14px; background: var(--yd-accent-soft); border-left: 3px solid var(--yd-accent); border-radius: 0 8px 8px 0; color: var(--yd-sub); }
.yd-article blockquote p { margin: 0; }
.yd-article strong { color: var(--yd-accent); }
.yd-code-block { margin: 12px 0 16px; border: 1px solid var(--yd-line-2); border-radius: 9px; overflow: hidden; background: #0f1319; }
[data-theme="light"] .yd-code-block { background: #f6f8fb; }
.yd-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: var(--yd-card-3); border-bottom: 1px solid var(--yd-line); font-size: 10.5px; color: var(--yd-faint); }
.yd-code-copy { border: 0; background: transparent; color: var(--yd-accent-2); font-size: 11px; }
.yd-code-copy:hover { text-decoration: underline; }
.yd-code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-family: var(--yd-mono); font-size: 12.5px; line-height: 1.7; color: #d7e0ea; }
[data-theme="light"] .yd-code-block pre { color: #24303d; }
.yd-code-block code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.yd-box h3 { margin: 0 0 10px; font-size: 14px; }
.yd-box ul { margin: 0; padding-left: 20px; font-size: 12.5px; line-height: 1.9; color: var(--yd-sub); }
.yd-box p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.8; color: var(--yd-sub); }
.yd-box-ok { background: var(--yd-ok-soft); border-color: var(--yd-ok); }
.yd-box-ok h3 { color: var(--yd-ok); }
.yd-box-warn { background: var(--yd-warn-soft); border-color: var(--yd-warn); }
.yd-box-warn h3 { color: var(--yd-warn); }
.yd-box-lab { background: var(--yd-accent-soft); border-color: var(--yd-accent); }
.yd-refs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.yd-refs a { font-size: 12px; border: 1px solid var(--yd-line-2); border-radius: 8px; padding: 6px 10px; background: var(--yd-card-2); }
.yd-note-item { border-left: 2px solid var(--yd-accent); padding: 4px 0 8px 12px; margin-bottom: 8px; }
.yd-note-item p { color: var(--yd-fg); white-space: pre-wrap; }
.yd-note-item small { color: var(--yd-faint); }

/* 代码高亮（代码块与编辑器共用） */
.yd-t-k { color: #ff8fa3; }
.yd-t-s { color: #a8dc8c; }
.yd-t-n { color: #f0b872; }
.yd-t-c { color: #7d8b9c; font-style: italic; }
.yd-t-b { color: #82c8f0; }
[data-theme="light"] .yd-t-k { color: #b3245b; }
[data-theme="light"] .yd-t-s { color: #1a7a37; }
[data-theme="light"] .yd-t-n { color: #9a5b00; }
[data-theme="light"] .yd-t-c { color: #6c7885; }
[data-theme="light"] .yd-t-b { color: #1668a8; }

/* ---------- 3. 代码实验室 ---------- */
.yd-lab-bar { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 10px; }
.yd-lab-tip { font-size: 11px; color: var(--yd-faint); margin-left: auto; }
.yd-editor { display: grid; grid-template-columns: 44px minmax(0, 1fr); border: 1px solid var(--yd-line-2); border-radius: var(--yd-r-sm); overflow: hidden; background: #0f1319; min-height: 300px; }
[data-theme="light"] .yd-editor { background: #f6f8fb; }
.yd-lines { padding: 12px 8px; text-align: right; font-family: var(--yd-mono); font-size: var(--yd-code-fs); line-height: 1.65; color: #59677a; background: rgba(127, 127, 127, .07); white-space: pre; overflow: hidden; user-select: none; }
.yd-code-wrap { position: relative; min-width: 0; }
.yd-hl, .yd-code { margin: 0; padding: 12px 14px; font-family: var(--yd-mono); font-size: var(--yd-code-fs); line-height: 1.65; letter-spacing: 0; tab-size: 4; white-space: pre; overflow: auto; border: 0; width: 100%; height: 100%; min-height: 300px; }
.yd-hl { position: absolute; inset: 0; pointer-events: none; color: #d7e0ea; background: transparent; overscroll-behavior: contain; }
[data-theme="light"] .yd-hl { color: #24303d; }
.yd-code { position: relative; display: block; resize: vertical; background: transparent; color: transparent; caret-color: var(--yd-accent); outline: none; -webkit-text-fill-color: transparent; }
.yd-code::selection { background: rgba(113, 200, 245, .28); }
.yd-console-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin: 12px 0 6px; font-size: 12px; color: var(--yd-sub); }
.yd-console-head span { color: var(--yd-faint); font-size: 11px; }
.yd-console { min-height: 110px; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; background: #0d1117; border: 1px solid var(--yd-line-2); border-radius: var(--yd-r-sm); padding: 8px 12px; font-family: var(--yd-mono); font-size: 12px; line-height: 1.7; }
[data-theme="light"] .yd-console { background: #f3f6fa; }
.yd-log { color: #cfd9e4; border-bottom: 1px dashed rgba(127, 127, 127, .18); padding: 3px 0; white-space: pre-wrap; word-break: break-word; }
[data-theme="light"] .yd-log { color: #26313d; }
.yd-log--warn { color: var(--yd-warn); }
.yd-log--error { color: var(--yd-err); }
.yd-log--info, .yd-log--debug { color: var(--yd-accent-2); }
.yd-sandbox { position: absolute; left: -99999px; top: 0; width: 2px; height: 2px; opacity: .01; border: 0; pointer-events: none; }
.yd-predict { margin-top: 12px; background: var(--yd-card); border: 1px solid var(--yd-accent); border-radius: var(--yd-r); padding: 14px 16px; }
.yd-predict-t { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.yd-predict-opts { display: flex; flex-wrap: wrap; gap: 7px; }
.yd-predict-opt { border: 1px solid var(--yd-line-2); background: var(--yd-card-2); color: var(--yd-fg); border-radius: 8px; padding: 8px 12px; font-size: 12px; text-align: left; }
.yd-predict-opt:hover { border-color: var(--yd-accent); }
.yd-predict-opt.is-on { background: var(--yd-accent-soft); border-color: var(--yd-accent); }
.yd-predict-res { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--yd-card-2); font-size: 12.5px; line-height: 1.8; }
.yd-predict-res p { margin: 6px 0 0; color: var(--yd-sub); }

/* ---------- 4. 题库 ---------- */
.yd-quiz-setup { display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-end; background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 14px 16px; margin-bottom: 14px; }
.yd-quiz-setup label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--yd-faint); }
.yd-quiz-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 11.5px; color: var(--yd-faint); }
.yd-quiz-card { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 18px 20px; }
.yd-quiz-meta { font-size: 11.5px; color: var(--yd-faint); margin-bottom: 10px; }
.yd-quiz-q { font-size: 15px; line-height: 1.85; white-space: pre-wrap; margin-bottom: 14px; font-weight: 600; }
.yd-quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.yd-opt { display: flex; align-items: flex-start; gap: 10px; text-align: left; width: 100%; border: 1px solid var(--yd-line-2); background: var(--yd-card-2); color: var(--yd-fg); border-radius: 9px; padding: 11px 13px; font-size: 13px; line-height: 1.7; }
.yd-opt:hover { border-color: var(--yd-accent); }
.yd-opt > span { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px; background: var(--yd-card-3); display: grid; place-items: center; font-size: 11px; color: var(--yd-sub); }
.yd-opt b { font-weight: 500; white-space: pre-wrap; word-break: break-word; }
.yd-opt.is-on { border-color: var(--yd-accent); background: var(--yd-accent-soft); }
.yd-opt.is-on > span { background: var(--yd-accent); color: var(--yd-on-accent); }
.yd-opt.is-right { border-color: var(--yd-ok); background: var(--yd-ok-soft); }
.yd-opt.is-wrong { border-color: var(--yd-err); background: var(--yd-err-soft); }
.yd-quiz-explain { margin-top: 14px; border-radius: 9px; background: var(--yd-card-2); border-left: 3px solid var(--yd-accent); padding: 12px 14px; font-size: 12.5px; line-height: 1.85; }
.yd-quiz-explain p { margin: 6px 0; color: var(--yd-sub); }
.yd-quiz-acts { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.yd-quiz-result { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 18px 20px; }
.yd-quiz-result h3 { margin: 0 0 12px; font-size: 17px; }
.yd-score { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.yd-score b { font-size: 42px; color: var(--yd-accent); line-height: 1; }
.yd-score span { color: var(--yd-sub); font-size: 13px; }
.yd-result-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.yd-result-i { border: 1px solid var(--yd-line); border-left: 3px solid var(--yd-line-2); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; }
.yd-result-i.is-ok { border-left-color: var(--yd-ok); }
.yd-result-i.is-bad { border-left-color: var(--yd-err); }
.yd-result-i b { font-weight: 600; }
.yd-result-i span { float: right; font-size: 11.5px; color: var(--yd-faint); }
.yd-result-i p { margin: 6px 0 0; color: var(--yd-sub); line-height: 1.7; }

/* ---------- 5. 速查手册 ---------- */
.yd-ref-tools { margin-bottom: 12px; }
.yd-ref-tools .yd-search { max-width: 420px; }
.yd-gloss-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.yd-gloss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.yd-gloss { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: 10px; padding: 11px 13px; }
.yd-gloss-t { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.yd-gloss-t b { font-size: 13px; }
.yd-gloss-t span { font-size: 11px; color: var(--yd-accent-2); font-family: var(--yd-mono); }
.yd-gloss p { margin: 7px 0; font-size: 12px; line-height: 1.75; color: var(--yd-sub); }
.yd-gloss small { font-size: 10.5px; color: var(--yd-faint); }
.yd-cheat { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 15px 17px; margin-bottom: 12px; }
.yd-cheat h3 { margin: 0 0 6px; font-size: 14.5px; }
.yd-cheat h3 small { color: var(--yd-faint); font-size: 11px; font-weight: 400; margin-left: 8px; }
.yd-cheat .yd-note { margin: 0 0 10px; }
.yd-snips { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 11px; align-items: start; }
.yd-snip { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 12px 14px; min-width: 0; }
.yd-snip-t { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.yd-snip-t b { font-size: 13px; margin-right: auto; }
.yd-snip-t span { font-size: 10.5px; color: var(--yd-faint); }
.yd-snip p { margin: 7px 0 9px; font-size: 11.5px; color: var(--yd-sub); line-height: 1.7; }
.yd-snip pre { margin: 0; padding: 10px 12px; overflow-x: auto; background: #0f1319; border: 1px solid var(--yd-line); border-radius: 8px; font-family: var(--yd-mono); font-size: 11.5px; line-height: 1.65; color: #d7e0ea; }
[data-theme="light"] .yd-snip pre { background: #f6f8fb; color: #24303d; }
.yd-snip pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }

/* ---------- 6. 学习记录 ---------- */
.yd-me-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; border: 1px solid var(--yd-line); border-radius: var(--yd-r); overflow: hidden; background: var(--yd-card); margin-bottom: 14px; }
.yd-me-block { background: var(--yd-card); border: 1px solid var(--yd-line); border-radius: var(--yd-r); padding: 14px 17px; margin-bottom: 12px; }
.yd-me-block h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.yd-me-g { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 12px; }
.yd-me-g > span { flex: 0 0 180px; color: var(--yd-sub); }
.yd-me-g > b { flex: 0 0 48px; text-align: right; font-size: 11.5px; color: var(--yd-faint); }
.yd-me-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.yd-me-item { border: 1px solid var(--yd-line); border-radius: 8px; padding: 9px 12px; margin-bottom: 8px; cursor: pointer; background: var(--yd-card-2); }
.yd-me-item:hover { border-color: var(--yd-accent); }
.yd-me-item b { font-size: 12.5px; }
.yd-me-item p { margin: 5px 0; font-size: 11.5px; line-height: 1.7; color: var(--yd-sub); }
.yd-me-item small { color: var(--yd-faint); font-size: 10.5px; }
.yd-me-link { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--yd-line); background: transparent; color: var(--yd-fg); font-size: 12.5px; padding: 8px 4px; }
.yd-me-link:hover { color: var(--yd-accent); }
.yd-me-data { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 浮层 / toast ---------- */
.yd-note-mask { position: fixed; inset: 0; z-index: 100000; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.yd-note-modal { width: min(560px, 100%); background: var(--yd-card); border: 1px solid var(--yd-line-2); border-radius: var(--yd-r); box-shadow: var(--yd-shadow); overflow: hidden; }
.yd-note-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--yd-line); font-size: 14px; }
.yd-note-text { display: block; width: 100%; min-height: 190px; resize: vertical; border: 0; background: var(--yd-card-2); color: var(--yd-fg); padding: 14px 16px; font-size: 14px; line-height: 1.8; outline: none; }
.yd-note-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--yd-line); font-size: 11.5px; color: var(--yd-faint); }
.yd-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100001; background: var(--yd-card-3); color: var(--yd-fg); border: 1px solid var(--yd-line-2); border-radius: 10px; padding: 10px 18px; font-size: 13px; box-shadow: var(--yd-shadow); max-width: min(90vw, 520px); text-align: center; }
.yd-toast.is-err { border-color: var(--yd-err); color: var(--yd-err); }

/* ---------- 响应式：断点降序 ---------- */
@media (min-width: 1600px) {
  .yd { padding: 24px 34px 88px; }
  :root { --yd-side-w: 300px; }
  .yd-books { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .yd-article { font-size: 14px; }
}
@media (max-width: 1400px) {
  :root { --yd-side-w: 240px; }
  .yd { padding: 16px 18px 64px; }
}
@media (max-width: 1100px) {
  :root { --yd-side-w: 216px; }
  .yd-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .yd-stat:nth-child(3n+1) { border-left: 0; }
  .yd-stat:nth-child(n+4) { border-top: 1px solid var(--yd-line); }
  .yd-me-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .yd-me-stats .yd-stat:nth-child(3n+1) { border-left: 0; }
  .yd-me-stats .yd-stat:nth-child(n+4) { border-top: 1px solid var(--yd-line); }
  .yd-books { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
  .yd-me-grid { grid-template-columns: minmax(0, 1fr); }
}
/* ≤900：侧栏转抽屉，正文单栏 */
@media (max-width: 900px) {
  .yd-work { grid-template-columns: minmax(0, 1fr); }
  .yd-side-toggle { display: inline-flex; }
  .yd-side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 99999; width: min(84vw, 330px); max-height: none; border-radius: 0 var(--yd-r) var(--yd-r) 0; transform: translateX(-102%); transition: transform .24s ease; box-shadow: var(--yd-shadow); }
  .yd-side.is-open { transform: translateX(0); }
  .yd-side-scrim { display: block; position: fixed; inset: 0; z-index: 99990; background: rgba(0, 0, 0, .5); }
  .yd-side-scrim[hidden] { display: none !important; }
  .yd-toolbar { flex-wrap: wrap; }
  .yd-tabs { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
  .yd-search-box { flex: 1 1 240px; }
  .yd-side-head { padding-top: 14px; }
  .yd-editor { min-height: 260px; }
  .yd-hl, .yd-code { min-height: 260px; }
}
/* ≤767：手机 */
@media (max-width: 767px) {
  .yd { padding: 12px 12px calc(64px + env(safe-area-inset-bottom, 0px)); }
  .yd-hero { padding: 14px 14px; }
  .yd-hero-ic { width: 40px; height: 40px; font-size: 21px; border-radius: 10px; }
  .yd-hero h1 { font-size: 19px; }
  .yd-hero p { font-size: 12.5px; }
  .yd-hero-tags span { font-size: 10.5px; padding: 2px 8px; }
  .yd-toolbar { top: 53px; padding: 7px 8px; gap: 7px; }
  .yd-tab { font-size: 12.5px; padding: 9px 11px; min-height: 40px; }
  .yd-search, .yd-select, .yd-note-text, .yd-side-search input, .yd-code, .yd-hl { font-size: 16px; }
  .yd-code, .yd-hl { font-size: var(--yd-code-fs); }
  .yd-search { height: 40px; }
  .yd-search-box { flex: 1 1 100%; }
  .yd-btn { min-height: 40px; padding: 9px 13px; font-size: 12.5px; }
  .yd-chip { padding: 8px 12px; min-height: 36px; }
  .yd-chip-sm { min-height: 30px; }
  .yd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .yd-stat { padding: 10px 12px; }
  .yd-stat:nth-child(2n+1) { border-left: 0; }
  .yd-stat:nth-child(n+3) { border-top: 1px solid var(--yd-line); }
  .yd-stat b { font-size: 17px; }
  .yd-me-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .yd-me-stats .yd-stat:nth-child(2n+1) { border-left: 0; }
  .yd-me-stats .yd-stat:nth-child(n+3) { border-top: 1px solid var(--yd-line); }
  .yd-books { grid-template-columns: minmax(0, 1fr); }
  .yd-gloss-grid, .yd-snips, .yd-me-grid { grid-template-columns: minmax(0, 1fr); }
  .yd-route-grid { grid-template-columns: minmax(0, 1fr); }
  .yd-article, .yd-box, .yd-quiz-card, .yd-quiz-result, .yd-cheat { padding: 14px 14px; }
  .yd-article { font-size: 13.5px; }
  .yd-pane-head h2 { font-size: 17px; }
  .yd-quiz-setup { flex-direction: column; align-items: stretch; }
  .yd-quiz-setup label { width: 100%; }
  .yd-quiz-setup .yd-select { width: 100%; }
  .yd-lab-tip { flex: 1 1 100%; margin-left: 0; }
  .yd-opt { min-height: 44px; }
  .yd-predict-opt { min-height: 40px; }
  .yd-note-mask { padding: 0; align-items: flex-end; }
  .yd-note-modal { width: 100%; max-width: none; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .yd-me-g > span { flex: 0 0 120px; }
  .yd-editor { grid-template-columns: 36px minmax(0, 1fr); }
  .yd-console { max-height: 240px; }
  .yd-search-pop { width: min(420px, calc(100vw - 24px)); right: 0; left: auto; }
}
@media (max-width: 420px) {
  .yd-hero-tags { display: none; }
  .yd-hero.is-collapsed { padding: 10px 12px; }
  .yd-fold { width: 32px; height: 32px; }
  .yd-topic-acts .yd-btn { flex: 1 1 calc(50% - 4px); }
  .yd-lab-bar .yd-btn { flex: 1 1 calc(50% - 4px); }
  .yd-book-top { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .yd-book-ic { font-size: 19px; }
  .yd-chapter-d, .yd-chapter-acts, .yd-secs { margin-left: 0; }
  .yd-me-g > span { flex: 0 0 96px; font-size: 11px; }
}

/* 无障碍 / 动效 / 触屏 / 打印 */
@media (hover: none) {
  .yd-book-top:hover, .yd-side-i:hover, .yd-opt:hover, .yd-btn:hover { background: transparent; }
  .yd-tab:hover { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .yd *, .yd *::before, .yd *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .yd-toolbar, .yd-side, .yd-side-toggle, .yd-side-scrim, .yd-topic-acts, .yd-lab-bar,
  .yd-console, .yd-predict, .yd-quiz-setup, .yd-me-data, .yd-toast, .yd-note-mask,
  .yd-code-copy, .yd-hero-tags, .yd-fold { display: none !important; }
  .yd { padding: 0; }
  .yd-work { display: block; }
  .yd-article, .yd-box, .yd-book { break-inside: avoid; box-shadow: none; }
  .yd-code-block pre, .yd-snip pre { white-space: pre-wrap; }
}

