/* 文章页侧边栏：阅读工具 + 工具箱（Modules/Common/SidebarTools，配合 ytea-tools.js） */

.ytea-read-tools, .ytea-toolbox {
  --yt-accent: var(--deep, #1d4e89);
  --yt-soft: var(--sky-soft, #eef5fb);
  --yt-line: var(--line, #e3ebf3);
  --yt-ink: var(--ink, #2b3a4a);
  --yt-muted: var(--ink-muted, #6b7c8f);
  --yt-field: #f7fafd;
}
/* A2 小工具卡片本身没有内边距（标题和内容各自留白），内容区和分类云的 .tagcloud 对齐 */
.ytea-w-body { padding: 6px 14px 16px; }
.ytea-read-tools button, .ytea-toolbox button, .ytea-toolbox select, .ytea-toolbox input, .ytea-toolbox textarea { font: inherit; }

/* ---------- 阅读工具 ---------- */
.ytr-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ytr-label { flex: none; font-size: 13px; color: var(--yt-muted); }
.ytr-seg { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; border-radius: 10px; background: var(--yt-soft); }
.ytr-seg button {
  height: 28px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--yt-muted);
  font-size: 13px; line-height: 1; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.ytr-seg button sup { font-size: 9px; margin-left: 1px; }
.ytr-seg button:hover { color: var(--yt-accent); }
.ytr-seg button[aria-pressed="true"] { background: #fff; color: var(--yt-accent); font-weight: 700; box-shadow: 0 1px 4px rgba(29, 78, 137, .15); }
.ytr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ytr-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 8px;
  border: 1px solid var(--yt-line); border-radius: 10px; background: #fff; color: var(--yt-ink);
  font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s, background .15s, transform .1s;
}
.ytr-btn:hover { border-color: var(--sky, #5fa8dc); color: var(--yt-accent); }
.ytr-btn:active { transform: scale(.97); }
.ytr-btn[aria-pressed="true"] { background: var(--yt-accent); border-color: var(--yt-accent); color: #fff; }
.ytr-seg button:focus-visible, .ytr-btn:focus-visible { outline: 2px solid var(--sky, #5fa8dc); outline-offset: 2px; }
/* 图标（CSS 遮罩，跟随文字颜色） */
.ytr-ico { flex: none; width: 15px; height: 15px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ytr-ico-focus { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 9V5a1 1 0 0 1 1-1h4M20 9V5a1 1 0 0 0-1-1h-4M4 15v4a1 1 0 0 0 1 1h4M20 15v4a1 1 0 0 1-1 1h-4'/%3E%3Ccircle cx='12' cy='12' r='2.5'/%3E%3C/svg%3E"); }
.ytr-ico-link { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1'/%3E%3Cpath d='M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1'/%3E%3C/svg%3E"); }
.ytr-ico-cite { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='5' width='19' height='14' rx='2'/%3E%3Cpath d='M6 15V9l2.5 3L11 9v6M16 9v6M14 13l2 2 2-2'/%3E%3C/svg%3E"); }
.ytr-ico-print { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M7 9V3h10v6'/%3E%3Crect x='3' y='9' width='18' height='8' rx='2'/%3E%3Cpath d='M7 14h10v7H7z'/%3E%3C/svg%3E"); }

/* 字号（data-ytfs，在 html 上；header.html 里提前应用，刷新不闪） */
html[data-ytfs="-1"] .single-article .entry-content p, html[data-ytfs="-1"] .single-article .entry-content li { font-size: 15.5px !important; }
html[data-ytfs="1"] .single-article .entry-content p, html[data-ytfs="1"] .single-article .entry-content li { font-size: 19px !important; }
html[data-ytfs="2"] .single-article .entry-content p, html[data-ytfs="2"] .single-article .entry-content li { font-size: 21px !important; }
html[data-ytfs] .single-article .entry-content pre li { font-size: inherit !important; }
/* 手机上基准字号是 16px（ytea-reading.css），档位同样相对放大 */
@media (max-width: 767px) {
  html[data-ytfs="-1"] body.single .single-article .entry-content p, html[data-ytfs="-1"] body.single .single-article .entry-content li { font-size: 14.5px !important; }
  html[data-ytfs="1"] body.single .single-article .entry-content p, html[data-ytfs="1"] body.single .single-article .entry-content li { font-size: 18px !important; }
  html[data-ytfs="2"] body.single .single-article .entry-content p, html[data-ytfs="2"] body.single .single-article .entry-content li { font-size: 20px !important; }
}

/* 专注阅读：只留正文 */
html.ytea-focus #secondary,
html.ytea-focus .ytea-lantern, html.ytea-focus .rana-wrap, html.ytea-focus .ytp,
html.ytea-focus .ytea-mtoc-btn { display: none !important; }
html.ytea-focus .b2-single-content.wrapper { justify-content: center; }
html.ytea-focus .b2-single-content #primary-home { width: 100% !important; max-width: 860px !important; margin: 0 auto !important; flex: none !important; }
.ytea-focus-exit {
  position: fixed; right: 20px; bottom: 24px; z-index: 999; display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 16px; border: 0; border-radius: 20px; background: var(--deep, #1d4e89); color: #fff;
  font-size: 14px; box-shadow: 0 6px 20px rgba(29, 78, 137, .3); cursor: pointer;
}
.ytea-focus-exit[hidden] { display: none; }
.ytea-focus-exit i { font-style: normal; font-size: 18px; line-height: 1; }
.ytea-focus-exit kbd { font: 11px/1 inherit; padding: 2px 5px; border-radius: 4px; background: rgba(255, 255, 255, .2); }

/* ---------- 工具箱 ---------- */
.ytb-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; margin-bottom: 12px; border-radius: 10px; background: var(--yt-soft); }
.ytb-tabs button {
  height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--yt-muted); font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.ytb-tabs button:hover { color: var(--yt-accent); }
.ytb-tabs button[aria-selected="true"] { background: #fff; color: var(--yt-accent); font-weight: 700; box-shadow: 0 1px 4px rgba(29, 78, 137, .15); }
.ytb-tabs button:focus-visible { outline: 2px solid var(--sky, #5fa8dc); outline-offset: 1px; }
/* 切换成英文后标签变长（Encode / Decode、Timestamp）：改成可换行的弹性布局，不撑出边框 */
html[lang="en"] .ytb-tabs, html[lang="en"] .ytr-seg { display: flex; flex-wrap: wrap; }
html[lang="en"] .ytb-tabs button, html[lang="en"] .ytr-seg button { flex: 1 1 auto; padding: 0 6px; font-size: 12px; white-space: nowrap; }
.ytb-panel[hidden] { display: none; }

.ytea-toolbox textarea, .ytea-toolbox input, .ytea-toolbox select {
  width: 100%; box-sizing: border-box; border: 1px solid var(--yt-line); border-radius: 10px; background: var(--yt-field);
  color: var(--yt-ink); font-size: 13px; transition: border-color .15s, box-shadow .15s;
}
.ytea-toolbox textarea { display: block; padding: 8px 10px; resize: vertical; min-height: 64px; line-height: 1.5;
  font-family: Consolas, "JetBrains Mono", Menlo, monospace; word-break: break-all; }
.ytea-toolbox input, .ytea-toolbox select { height: 34px; padding: 0 10px; }
.ytea-toolbox textarea:focus, .ytea-toolbox input:focus, .ytea-toolbox select:focus {
  outline: none; border-color: var(--sky, #5fa8dc); box-shadow: 0 0 0 3px rgba(95, 168, 220, .18); background: #fff; }
.ytb-bar { display: flex; gap: 6px; margin: 8px 0; }
.ytb-bar select { flex: 1; min-width: 0; }
.ytb-bar .ytb-num { flex: 1.4; min-width: 0; font-family: Consolas, Menlo, monospace; }
.ytb-go {
  flex: none; height: 34px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--yt-accent); color: #fff;
  font-size: 13px; cursor: pointer; transition: filter .15s, transform .1s;
}
.ytb-go[data-dir="dec"] { background: var(--sky, #5fa8dc); }
.ytb-go:hover { filter: brightness(1.1); }
.ytb-go:active { transform: scale(.96); }
.ytb-out-wrap { position: relative; }
.ytb-out-wrap .ytb-out { padding-right: 52px; background: #fff; }
.ytb-copy {
  position: absolute; right: 6px; top: 6px; height: 24px; padding: 0 8px; border: 1px solid var(--yt-line); border-radius: 6px;
  background: #fff; color: var(--yt-muted); font-size: 12px; cursor: pointer;
}
.ytb-copy:hover, .ytb-copy-sm:hover { color: var(--yt-accent); border-color: var(--sky, #5fa8dc); }
.ytb-msg { margin: 6px 0 0; min-height: 0; font-size: 12px; color: var(--yt-muted); }
.ytb-msg:empty { display: none; }
.ytb-msg.is-err { color: #d9534f; }

.ytb-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: start; margin: 10px 0 0; font-size: 12.5px; }
.ytb-kv dt { color: var(--yt-muted); padding-top: 3px; white-space: nowrap; }
.ytb-kv dd { display: flex; gap: 6px; align-items: flex-start; margin: 0; min-width: 0; }
.ytb-kv code, .ytb-now code {
  flex: 1; min-width: 0; padding: 3px 6px; border-radius: 6px; background: var(--yt-field); color: var(--yt-ink);
  font: 12px/1.45 Consolas, Menlo, monospace; word-break: break-all; }
.ytb-copy-sm {
  flex: none; height: 22px; padding: 0 6px; border: 1px solid var(--yt-line); border-radius: 6px; background: #fff;
  color: var(--yt-muted); font-size: 11.5px; cursor: pointer; }
.ytb-now { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; color: var(--yt-muted); }
.ytb-now code { flex: 0 1 auto; font-size: 13px; color: var(--yt-accent); font-weight: 700; }
.ytb-field { display: block; margin-top: 8px; }
.ytb-field span { display: block; margin-bottom: 4px; font-size: 12.5px; color: var(--yt-muted); }
.ytb-res { margin: 6px 0 0; min-height: 18px; font: 12.5px/1.5 Consolas, Menlo, monospace; color: var(--yt-accent); word-break: break-all; }
.ytb-note { margin: 12px 0 0; font-size: 11.5px; color: var(--yt-muted); text-align: center; opacity: .8; }

/* ---------- 黑夜模式 ---------- */
html.yt-dark .ytea-read-tools, html.yt-dark .ytea-toolbox { --yt-soft: rgba(143, 195, 234, .1); --yt-line: rgba(255, 255, 255, .1); --yt-field: rgba(255, 255, 255, .04); }
html.yt-dark .ytr-btn, html.yt-dark .ytb-copy, html.yt-dark .ytb-copy-sm { background: rgba(255, 255, 255, .04); }
html.yt-dark .ytr-seg button[aria-pressed="true"], html.yt-dark .ytb-tabs button[aria-selected="true"] { background: rgba(143, 195, 234, .18); color: #8fc3ea; }
html.yt-dark .ytea-toolbox textarea:focus, html.yt-dark .ytea-toolbox input:focus, html.yt-dark .ytea-toolbox select:focus,
html.yt-dark .ytb-out-wrap .ytb-out { background: rgba(255, 255, 255, .06) !important; }

/* ---------- 打印 / 保存 PDF：只保留文章 ---------- */
@media print {
  .site-header, .header-banner, #secondary, #colophon, .footer, .comments-box, #comments, .post-pre-next, .related-posts,
  .aside-container, .aside-bar, .ytea-lantern, .rana-wrap, .ytp, .aplayer, .ytea-progress, .ytea-mtoc-btn, .ytea-focus-exit,
  .post-meta-left, .b2-widget-toc, .code-copy, .ytea-anchor, .ytea-outdated, .single-ad-top, .single-ad-bottom, ins.adsbygoogle { display: none !important; }
  body, .site, .site-content, .b2-single-content, .single-article { background: #fff !important; box-shadow: none !important; }
  .b2-single-content #primary-home { width: 100% !important; max-width: none !important; margin: 0 !important; }
  .single-article { padding: 0 !important; border: 0 !important; }
  .single-article .entry-content a { color: inherit; text-decoration: underline; }
  .single-article .entry-content pre, .single-article .entry-content img { break-inside: avoid; }
}
