/* ============================================================
   术数词典前台（2026-11-03）
   —— 只作用于 dictionary.html：左目录 + 右速览 + 「完整详解」弹窗
   —— 桌面 720px 居中弹窗；移动端满屏底部抽屉
   —— 依赖 skin-gemini.css 的 --sg-* 变量，不覆盖其他页面
   ============================================================ */

/* ---------------- 左侧目录 ---------------- */
.dict-page .dict-nav { margin-top: var(--sg-space-2); }
.dict-page .dict-cat { border-bottom: 1px solid var(--sg-border-decor); }
.dict-page .dict-cat:last-child { border-bottom: 0; }
.dict-page .dict-cat-head {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  min-height: 44px; padding: .5rem 0;
  background: none; border: 0; cursor: pointer;
  font-family: var(--sg-serif); font-size: 1rem; font-weight: 500;
  color: var(--sg-text); text-align: left;
}
.dict-page .dict-cat-head:hover { color: var(--sg-accent-ink); }
.dict-page .dict-cat-head[aria-expanded="false"] .dict-caret { transform: rotate(45deg); }
.dict-page .dict-cat-head[aria-expanded="true"] .dict-caret { transform: rotate(-135deg); }
.dict-page .dict-count {
  flex: none; font-family: var(--sg-sans, inherit); font-size: .75rem;
  color: var(--sg-accent-ink); background: rgba(197, 160, 89, .14);
  border-radius: 999px; padding: .05rem .48rem; line-height: 1.4;
}
.dict-page .dict-cat-name { flex: 1 1 auto; }
.dict-page .dict-cat-head.is-target { color: var(--sg-accent-ink); }
.dict-page .dict-nojs { font-size: .875rem; color: var(--sg-text-3); line-height: 1.7; }
.dict-page .dict-caret {
  flex: none; width: .45rem; height: .45rem; margin-right: .2rem;
  border: solid var(--sg-accent-ink); border-width: 0 1.5px 1.5px 0;
  padding: 3px; transform: rotate(45deg); transition: transform .18s;
}
.dict-page .dict-terms {
  list-style: none; margin: 0 0 .55rem; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.dict-page .dict-cat[data-open="false"] .dict-terms { display: none; }
.dict-page .dict-terms a {
  display: flex; align-items: center; min-height: 40px;
  padding: .35rem .55rem; border-radius: var(--sg-radius-sm);
  color: var(--sg-text-2); font-size: .9375rem; text-decoration: none;
  transition: background .15s, color .15s, box-shadow .15s;
}
.dict-page .dict-terms a:hover { background: rgba(197, 160, 89, .13); color: var(--sg-text); }
.dict-page .dict-terms a.active {
  background: rgba(197, 160, 89, .2); color: var(--sg-text); font-weight: 500;
  box-shadow: inset 3px 0 0 var(--sg-accent);
}
.dict-page .dict-about {
  margin-top: var(--sg-space-3); padding-top: var(--sg-space-3);
  border-top: 1px solid var(--sg-border-decor);
}
.dict-page .dict-about a { font-size: .875rem; color: var(--sg-text-3); text-decoration: none; }
.dict-page .dict-about a:hover { color: var(--sg-accent-ink); }

/* ---------------- 热门词条：只放真实存在的词条 ---------------- */
.dict-page .dict-hot {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
  margin: 0 0 var(--sg-space-3);
}
.dict-page .dict-hot-label {
  font-size: .75rem; color: var(--sg-text-3); letter-spacing: .08em;
  margin-right: .15rem;
}
.dict-page .dict-hot .dict-chip { min-height: 32px; padding: .2rem .65rem; font-size: .8125rem; }
.dict-page .dict-cta-note {
  margin: .45rem 0 0; font-size: .8125rem; color: var(--sg-text-3); line-height: 1.5;
}
.dict-page .dict-modal-actions .dict-cta-note { margin: 0; align-self: center; }

/* ---------------- 关键词搜索 ---------------- */
.dict-page .dict-search { margin: 0 0 var(--sg-space-2); }
.dict-page .dict-search-label {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.dict-page .dict-search-input {
  width: 100%; min-height: 44px; padding: .5rem .95rem;
  border: 1px solid var(--sg-border); border-radius: 999px;
  background: #FFFDF8; color: var(--sg-text);
  font-family: inherit; font-size: .9375rem; line-height: 1.4;
  -webkit-appearance: none; appearance: none;
}
.dict-page .dict-search-input::placeholder { color: var(--sg-text-3); }
.dict-page .dict-search-input:focus {
  outline: none; border-color: var(--sg-accent);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, .18);
}
.dict-page .dict-empty {
  margin: var(--sg-space-3) 0; padding: var(--sg-space-3) var(--sg-space-4);
  border: 1px dashed var(--sg-border); border-radius: var(--sg-radius-sm);
  background: #FBF7EF; color: var(--sg-text-2);
  font-size: .9375rem; line-height: 1.7;
}
.dict-page .dict-terms a.is-picked {
  background: rgba(197, 160, 89, .2); color: var(--sg-text); font-weight: 500;
  box-shadow: inset 3px 0 0 var(--sg-accent);
}

/* ---------------- 右侧速览 ---------------- */
.dict-page .dict-quick { max-width: 46rem; }
.dict-page .dict-quick-title {
  font-family: var(--sg-serif); font-size: clamp(1.6rem, 2vw + 1rem, 2.2rem);
  color: var(--sg-text); margin: 0 0 .15rem; font-weight: 600;
}
.dict-page .dict-quick-py {
  font-size: 1rem; color: var(--sg-text-3); letter-spacing: .06em; margin: 0 0 var(--sg-space-4);
}
.dict-page .dict-quick-def {
  font-size: var(--sg-fs-body); color: var(--sg-text-2);
  line-height: var(--sg-lh-loose); margin: 0 0 var(--sg-space-4);
}
.dict-page .dict-quick-mis {
  background: #F6F1E6; border-left: 3px solid var(--sg-accent);
  border-radius: var(--sg-radius-sm); padding: var(--sg-space-3) var(--sg-space-4);
  margin: 0 0 var(--sg-space-4); color: var(--sg-text-2); line-height: var(--sg-lh-normal);
}
.dict-page .dict-quick-rel { font-size: var(--sg-fs-body); color: var(--sg-text-2); }
.dict-page .dict-quick-rel a {
  color: var(--sg-accent-ink); text-decoration: none;
  border-bottom: 1px dotted var(--sg-border); margin: 0 .15rem; padding-bottom: 1px;
}
.dict-page .dict-quick-rel a:hover { color: var(--sg-text); border-color: var(--sg-accent); }
.dict-page .dict-quick-actions { margin-top: var(--sg-space-4); display: flex; gap: .75rem; flex-wrap: wrap; }
.dict-page .dict-quick-open {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: .55rem 1.15rem; border: 1px solid var(--sg-accent);
  border-radius: var(--sg-radius); background: var(--sg-accent); color: #fff;
  font-family: inherit; font-size: .95rem; cursor: pointer;
}
.dict-page .dict-quick-open:hover { filter: brightness(.94); }
.dict-page .dict-quick-hint { align-self: center; color: var(--sg-text-3); font-size: .85rem; }

/* ---------------- 完整详解弹窗：桌面 720px 居中 ---------------- */
.dict-modal, .dict-modal * { box-sizing: border-box; }
.dict-modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
}
.dict-modal[hidden] { display: none; }
.dict-modal-mask {
  position: absolute; inset: 0;
  background: rgba(20, 26, 34, .46);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.dict-modal-card {
  position: relative; display: flex; flex-direction: column;
  width: min(720px, 100%); max-height: calc(100dvh - 2.5rem);
  background: var(--sg-surface, #fff);
  border: 1px solid var(--sg-border); border-radius: var(--sg-radius-lg);
  box-shadow: 0 24px 64px rgba(26, 26, 26, .24);
  overflow: hidden;
  animation: dictPop .18s ease-out both;
}
@keyframes dictPop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.dict-modal-grab { display: none; }
.dict-modal-head {
  flex: 0 0 auto; display: flex; align-items: flex-start; gap: 1rem;
  padding: 1.1rem 1.35rem .85rem;
  border-bottom: 1px solid var(--sg-border-decor);
  background: var(--sg-surface, #fff);
}
.dict-modal-head > div { min-width: 0; }
.dict-modal-title {
  margin: 0; font-family: var(--sg-serif); font-size: 1.55rem; line-height: 1.3;
  font-weight: 600; color: var(--sg-text);
}
.dict-modal-meta {
  margin: .15rem 0 0; font-size: .9375rem; line-height: 1.5;
  color: var(--sg-text-3); letter-spacing: .04em;
}
.dict-modal-x {
  flex: none; width: 40px; height: 40px; margin-left: auto;
  display: grid; place-items: center;
  border: 1px solid var(--sg-border-decor); border-radius: 50%;
  background: var(--sg-surface, #fff); color: var(--sg-text-3);
  font-family: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
.dict-modal-x:hover { color: var(--sg-text); border-color: var(--sg-accent); background: rgba(197, 160, 89, .1); }
.dict-modal-body {
  flex: 1 1 auto; min-height: 0;
  max-height: 404px; overflow-y: auto; overscroll-behavior: contain;
  padding: .25rem 1.35rem .5rem;
}
.dict-modal-body::-webkit-scrollbar { width: 8px; }
.dict-modal-body::-webkit-scrollbar-thumb { background: #ded4c1; border-radius: 8px; }
.dict-modal-body:focus-visible { outline: 2px solid var(--sg-accent-ink); outline-offset: -2px; }
.dict-blk { padding: .95rem 0; border-bottom: 1px dashed var(--sg-border-decor); }
.dict-blk:last-child { border-bottom: 0; }
.dict-blk h3 {
  margin: 0 0 .4rem; font-size: .8125rem; font-weight: 600;
  letter-spacing: .1em; color: var(--sg-accent-ink);
}
.dict-blk p { margin: 0 0 .5rem; font-size: 1rem; line-height: 1.8; color: var(--sg-text-2); }
.dict-blk p:last-child { margin-bottom: 0; }
.dict-quote {
  margin: 0 0 .5rem; padding: .65rem .8rem;
  border-left: 3px solid var(--sg-accent); border-radius: 0 var(--sg-radius-sm) var(--sg-radius-sm) 0;
  background: rgba(197, 160, 89, .1);
  font-family: var(--sg-serif); font-size: 1rem; line-height: 1.75; color: var(--sg-text);
}
.dict-qsrc { margin: 0; font-size: .875rem; line-height: 1.6; color: var(--sg-text-3); }
.dict-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .15rem; }
.dict-chip {
  display: inline-flex; align-items: center; min-height: 36px;
  padding: .25rem .8rem; border: 1px solid var(--sg-border);
  border-radius: 999px; color: var(--sg-accent-ink);
  font-size: .875rem; text-decoration: none; line-height: 1.5;
}
.dict-chip:hover { border-color: var(--sg-accent); background: rgba(197, 160, 89, .12); color: var(--sg-text); }
.dict-modal-foot {
  flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: .6rem;
  padding: .8rem 1.35rem .95rem;
  border-top: 1px solid var(--sg-border-decor);
  background: #FBF7EF;
}
.dict-modal-actions { display: flex; align-items: center; gap: .6rem; }
.dict-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; padding: .55rem 1.1rem;
  border: 1px solid var(--sg-border); border-radius: var(--sg-radius);
  background: var(--sg-surface, #fff); color: var(--sg-text);
  font-family: inherit; font-size: .95rem; text-decoration: none; cursor: pointer;
}
.dict-btn-primary { background: var(--sg-accent); border-color: var(--sg-accent); color: #fff; }
.dict-btn-primary:hover { filter: brightness(.94); }
.dict-btn-ghost {
  background: transparent; border-color: var(--sg-border-decor);
  color: var(--sg-text-2); font-weight: 400;
}
.dict-btn-ghost:hover { color: var(--sg-text); border-color: var(--sg-accent); }
.dict-share {
  margin-left: auto; min-height: 40px; padding: .35rem .6rem;
  border: 0; border-bottom: 1px dotted var(--sg-border); border-radius: 0;
  background: none; color: var(--sg-text-3);
  font-family: inherit; font-size: .8125rem; cursor: pointer;
}
.dict-share:hover { color: var(--sg-accent-ink); border-bottom-color: var(--sg-accent); }
.dict-share-note { color: var(--sg-accent-ink); font-size: .8125rem; line-height: 1.4; }
.dict-share-url {
  flex: 1 1 100%; width: 100%; min-height: 40px; padding: .4rem .6rem;
  border: 1px solid var(--sg-accent); border-radius: var(--sg-radius-sm);
  background: #fff; color: var(--sg-text); font-family: inherit; font-size: .8125rem;
}
.dict-foot-tip { margin-left: auto; color: var(--sg-text-3); font-size: .8125rem; line-height: 1.4; text-align: right; }
.dict-share-note:not(:empty) + .dict-foot-tip { display: none; }
body.dict-lock { overflow: hidden; }
/* 打开弹窗时，正文与词条列表仍可键盘到达，但视觉焦点只在弹窗 */
.dict-page .dict-terms a:focus-visible,
.dict-page .dict-cat-head:focus-visible,
.dict-modal :focus-visible { outline: 2px solid var(--sg-accent-ink); outline-offset: 2px; }

/* ---------------- 移动端：满屏底部抽屉 ---------------- */
@media (max-width: 48rem) {
  .dict-page .sg-article-body { display: none; }
  .dict-page .dict-terms a { min-height: 44px; font-size: 1rem; }
  .dict-page .dict-cat-head { font-size: 1.0625rem; }
  .dict-page .dict-count { font-size: .875rem; }
  .dict-page .dict-search-input { min-height: 46px; font-size: 1rem; }
  .dict-page .dict-hot .dict-chip { min-height: 36px; }
  .dict-page .dict-modal-actions .dict-cta-note { flex: 1 1 100%; text-align: center; }

  .dict-modal { align-items: flex-end; padding: 0; }
  .dict-modal-card {
    width: 100%; height: 100dvh; max-height: 100dvh;
    border: 0; border-radius: 16px 16px 0 0;
    padding-top: max(.35rem, env(safe-area-inset-top));
    animation: dictSheet .24s ease-out both;
  }
  @keyframes dictSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .dict-modal-grab {
    display: block; flex: none; width: 44px; height: 5px; border-radius: 5px;
    background: #cfc5b2; margin: .25rem auto .15rem; touch-action: none;
  }
  .dict-modal-head { touch-action: none; }
  .dict-modal-head { padding: .35rem 1rem .8rem; }
  .dict-modal-title { font-size: 1.35rem; }
  .dict-modal-meta { font-size: 1rem; }
  .dict-modal-x { width: 44px; height: 44px; font-size: 1.35rem; }
  .dict-modal-body {
    max-height: none; flex: 1 1 auto; padding: .15rem 1rem .5rem;
    -webkit-overflow-scrolling: touch;
  }
  .dict-blk { padding: .9rem 0; }
  .dict-blk h3 { font-size: 1rem; letter-spacing: .06em; }
  .dict-blk p { font-size: 1rem; line-height: 1.85; }
  .dict-quote { font-size: 1rem; line-height: 1.8; }
  .dict-qsrc { font-size: .9375rem; }
  .dict-chip { min-height: 44px; padding: .4rem .95rem; font-size: 1rem; }
  .dict-modal-foot {
    position: sticky; bottom: 0; z-index: 2;
    padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px rgba(26, 26, 26, .06);
  }
  .dict-modal-actions { width: 100%; gap: .6rem; }
  .dict-modal-foot .dict-btn { flex: 1 1 auto; min-height: 48px; font-size: 1rem; }
  .dict-share {
    width: 100%; margin-left: 0; min-height: 36px;
    border-bottom: 1px solid var(--sg-border-decor); text-align: center;
  }
  .dict-share-note { width: 100%; text-align: center; }
  .dict-foot-tip { display: none; }
  .dict-modal-card.is-dragging { animation: none; transition: transform .05s linear; }
}

@media (prefers-reduced-motion: reduce) {
  .dict-modal-card { animation: none !important; }
  .dict-page .dict-caret { transition: none; }
}
