/* ============================================================
   百家姓暗号 · 首页专用样式（方案 A）
   依赖 assets/site.css 中的颜色变量与公共组件
   ============================================================ */

/* ---------- 首屏标题 + 公告 ---------- */
.hero { padding: 40px 0 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.hero h1 { font-size: 30px; line-height: 1.25; letter-spacing: -.01em; font-weight: 800; }
.hero p { color: var(--sub); margin-top: 6px; }
.notice {
  display: flex; align-items: center; gap: 8px; max-width: 460px; min-width: 0;
  border: 1px solid var(--line2); background: var(--bg2); border-radius: 999px;
  padding: 5px 6px 5px 6px; color: var(--sub); font-size: 12.5px;
}
.notice > b { flex-shrink: 0; background: var(--accent-soft); color: var(--accent-text); border-radius: 999px; padding: 1px 9px; font-weight: 600; font-size: 12px; }
.notice-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-txt a { color: var(--accent-text); text-decoration: underline; }
.notice-x { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; border: 0; background: none; color: var(--muted); font-size: 12px; }
.notice-x:hover { background: var(--card2); color: var(--text); }

.shared-tip {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 14px;
  border-radius: 12px; background: var(--ok-soft); color: var(--text); border: 1px solid var(--line); font-size: 13px;
}
.shared-tip button { margin-left: auto; border: 0; background: none; color: var(--sub); font-size: 12px; }

/* ---------- 转换工具 ---------- */
.tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; }
.mode-tab {
  border: 0; background: none; color: var(--sub); font-weight: 600; font-size: 13px;
  padding: 8px 16px; border-radius: 9px; white-space: nowrap; transition: color .15s, background .15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.tb-right { margin-left: auto; display: flex; gap: 8px; }

.panes { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); }
.pane { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 240px; min-width: 0; transition: border-color .15s, box-shadow .15s; }
.pane-in:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pane-h { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; }
.pane-h label { cursor: text; }
#myTextArea {
  flex: 1; width: 100%; min-height: 150px; resize: vertical; border: 0; outline: 0; background: transparent;
  color: var(--text); font: 15px/1.75 var(--font); padding: 12px 14px; word-break: break-all;
}
#myTextArea::placeholder { color: var(--muted); }
.conv-result-content {
  flex: 1; padding: 12px 14px; font-size: 15.5px; line-height: 1.85; letter-spacing: .03em;
  word-break: break-all; white-space: pre-wrap; overflow: auto; max-height: 420px; color: var(--text);
}
.conv-result-content.empty { color: var(--muted); font-size: 14px; letter-spacing: 0; }
.detect { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 12px; color: var(--sub); padding: 0 14px 10px; min-height: 0; }
.detect:empty { display: none; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; font-weight: 600; background: var(--info-soft); color: var(--info); }
.pill.out { background: var(--accent-soft); color: var(--accent-text); }
.note { color: var(--muted); }
.note.warn { color: var(--warn); }
.note.ok { color: var(--ok); }
.swap { display: grid; place-items: center; }
.swap button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line2);
  background: var(--card); color: var(--sub); font-size: 15px; transition: color .15s, border-color .15s, transform .2s;
}
.swap button:hover { color: var(--text); border-color: var(--muted); transform: rotate(180deg); }
.actions { display: flex; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--line); margin-top: auto; }
.actions .btn-primary { flex: 1; }
.actions .btn-sec { white-space: nowrap; }
.tool-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 12px; margin-top: 12px; padding: 0 2px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--sub); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .sw { width: 30px; height: 18px; border-radius: 10px; background: var(--line2); position: relative; transition: background .15s; flex-shrink: 0; }
.toggle .sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + .sw { background: var(--accent); }
.toggle input:checked + .sw::after { transform: translateX(12px); }
.toggle input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 广告位 ---------- */
.ad-unit { position: relative; margin-top: 20px; }
.ad-tag {
  position: absolute; top: 6px; right: 8px; z-index: 2; font-size: 10px; line-height: 1.5;
  color: var(--muted); border: 1px solid var(--line2); background: var(--card); border-radius: 4px; padding: 0 5px; pointer-events: none;
}
.ad-slot {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 90px;
  border: 1px dashed var(--line2); border-radius: 12px; color: var(--muted);
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(127,127,160,.04) 10px 20px);
}
.ad-rect .ad-slot, .ad-slot.ad-rect { min-height: 250px; }
.ad-ph { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; text-align: center; padding: 12px; }
.ad-ph small { opacity: .75; }

/* ---------- 历史 / 统计 / 友链 ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; margin-top: 20px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.side .ad-unit { margin-top: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.card-h .card-sub { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--card2); border-radius: 6px; padding: 1px 8px; }
.card-h .ghost { margin-left: auto; padding: 4px 10px; }
.history-list { list-style: none; padding: 8px; display: flex; flex-direction: column; }
.history-item { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; transition: background .15s; }
.history-item:hover { background: var(--card2); }
.hi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hi-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.hi-meta { display: flex; align-items: center; gap: 8px; }
.hi-type { font-size: 11px; font-weight: 600; border-radius: 5px; padding: 0 6px; background: var(--card2); color: var(--sub); }
.hi-type.magnet { background: var(--info-soft); color: var(--info); }
.hi-type.ed2k { background: var(--ok-soft); color: var(--ok); }
.hi-type.values { background: var(--warn-soft); color: var(--warn); }
.hi-type.buddha { background: var(--accent-soft); color: var(--accent-text); }
.hi-time { font-size: 11px; color: var(--muted); }
.hi-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: none;
  color: var(--sub); display: grid; place-items: center; font-size: 13px; transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.hist-empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
.stat-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat-num { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.stat-lbl { font-size: 12px; color: var(--muted); }
.link-list { display: flex; flex-direction: column; padding: 8px 10px 10px; }
.link-item { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 8px; color: var(--sub); font-size: 13px; }
.link-item:hover { background: var(--card2); }
.link-item a { color: var(--text); font-weight: 500; }

/* ---------- 介绍内容 ---------- */
.content { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 44px; margin: 56px 0 20px; }
.toc-side { position: sticky; top: 84px; align-self: start; font-size: 13px; }
.toc-side .t { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; margin-bottom: 10px; }
.toc-side a { display: block; padding: 6px 12px; border-left: 2px solid var(--line); color: var(--sub); transition: color .15s, border-color .15s; }
.toc-side a:hover, .toc-side a.on { color: var(--text); border-left-color: var(--accent); }
.article { min-width: 0; }
.article section { margin-bottom: 40px; }
.article h2 { font-size: 20px; font-weight: 800; margin-bottom: 12px; letter-spacing: -.01em; }
.article p { color: var(--sub); max-width: 780px; margin-bottom: 10px; line-height: 1.85; }
.article code { font-family: var(--mono); font-size: 12.5px; background: var(--card2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.article .ad-unit { margin: 0 0 40px; }
.steps-list { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 12px; }
.steps-list li { counter-increment: s; position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 14px 54px; color: var(--sub); line-height: 1.7; }
.steps-list li::before {
  content: counter(s); position: absolute; left: 14px; top: 14px; width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 800; display: grid; place-items: center; font-size: 13px;
}
.steps-list strong { color: var(--text); }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.type-card, .why-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; transition: border-color .15s, transform .15s; }
.type-card:hover, .why-item:hover { border-color: var(--line2); transform: translateY(-2px); }
.tc-icon, .wi-icon { font-size: 22px; line-height: 1; }
.tc-title, .wi-title { font-weight: 700; margin: 10px 0 4px; font-size: 14px; }
.tc-desc, .wi-desc { color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.why-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.faq-list { border-top: 0; margin-top: 12px; }

/* ---------- 弹窗 ---------- */
#shareImageModal, #qrModal, #adblockModal {
  display: none; position: fixed; inset: 0; z-index: 9999; padding: 20px;
  background: rgba(5, 5, 10, .62); align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#adblockModal { z-index: 10000; }
#shareImageModal.show, #qrModal.show, #adblockModal.show { display: flex; }
.modal-body {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px;
  width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; text-align: center; box-shadow: var(--shadow);
}
.modal-body.wide { max-width: 480px; }
.modal-title { font-size: 16px; font-weight: 800; margin-bottom: 16px; }
.modal-tip { font-size: 12px; color: var(--muted); margin: 14px 0 16px; word-break: break-all; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns > * { flex: 1; padding: 11px 0; }
#shareImageCanvas, #shareImagePreview { border-radius: 14px; max-width: 100%; height: auto; margin: 0 auto; }
#shareImagePreview { display: block; -webkit-touch-callout: default; box-shadow: var(--shadow-sm); }
#qrBox { display: flex; align-items: center; justify-content: center; min-height: 248px; }
#qrBox img { width: 248px; height: 248px; image-rendering: pixelated; border-radius: 12px; background: #fff; padding: 8px; }
.qr-modal-tip { max-height: 60px; overflow: auto; }
.adblock-ico { font-size: 44px; line-height: 1; margin-bottom: 12px; }
.adblock-desc { font-size: 13px; line-height: 1.8; color: var(--sub); margin-bottom: 12px; }
.adblock-steps { font-size: 12px; color: var(--muted); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 16px; }
#adblockModal.block .adblock-btn.ghost { display: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 10001; transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 500;
  max-width: calc(100vw - 32px); text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 手机底部操作栏 ---------- */
.mbar { display: none; }

/* ---------- 平板 ---------- */
@media (max-width: 1000px) {
  .content { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc-side { display: none; }
}

/* ---------- 手机 ---------- */
@media (max-width: 760px) {
  .hero { padding: 18px 0 12px; flex-direction: column; align-items: stretch; gap: 10px; }
  .hero h1 { font-size: 22px; }
  .hero p { display: none; }
  .notice { max-width: none; border-radius: 12px; align-items: flex-start; }
  .notice-txt { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .tool { padding: 12px; border-radius: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .mode-tab { flex: 1; padding: 8px 4px; font-size: 12.5px; }
  .tb-right { margin: 0; }
  .tb-right .ghost { flex: 1; padding: 8px 0; }
  .panes { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 38px auto; }
  .pane { min-height: 0; }
  #myTextArea { min-height: 120px; font-size: 16px; } /* 16px 避免 iOS 聚焦时自动放大页面 */
  .conv-result-content { min-height: 96px; max-height: 300px; }
  .swap button { transform: rotate(90deg); }
  .swap button:hover { transform: rotate(270deg); }
  .actions { display: none; }
  .tool-foot { gap: 8px 14px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .content { margin-top: 36px; }
  .steps-list, .why-grid { grid-template-columns: minmax(0, 1fr); }
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article h2 { font-size: 18px; }
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .mbar {
    display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--nav-bg); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    transition: transform .2s;
  }
  .mbar .btn-primary { flex: 1; }
  .mbar .btn-sec { width: 48px; padding: 0; font-size: 17px; }
  body.typing .mbar { transform: translateY(110%); } /* 输入时让出键盘上方的空间 */
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .mode-tab { font-size: 11.5px; }
  .type-grid { grid-template-columns: minmax(0, 1fr); }
}
