/* 巴利三藏深度搜索 —— 苹果式的克制：大留白、弱色彩、层次靠间距和字重，不靠线框 */

:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --line: rgba(0, 0, 0, .08);
  --accent: #8a6f4e;           /* 暖棕，替掉苹果蓝——这是佛典站 */
  --accent-soft: rgba(138, 111, 78, .1);
  --mula: #2f6b4f;             /* 本文 */
  --atta: #8a6f4e;             /* 义注 */
  --tika: #6b5b95;             /* 复注 */
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --line: rgba(255, 255, 255, .1);
    --accent: #c4a47c;
    --accent-soft: rgba(196, 164, 124, .14);
    --mula: #5cc08e;
    --atta: #c4a47c;
    --tika: #a992d4;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 760px; margin: 0 auto; padding: 0 22px 90px; }

/* ── 头部 ─────────────────────────────── */
.hero { text-align: center; padding: 88px 22px 40px; }

/* 站名用宋体，与一道主站同一套字体栈。
   不用仿宋：iOS／Android 基本没有，会掉进各不相同的 fallback；
   且仿宋笔画细、无粗细对比，放大做标题撑不住。 */
.hero h1 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif SC", "SimSun", "STSong", serif;
  font-size: clamp(40px, 9vw, 64px);
  /* 不加粗：多数设备没有宋体粗体，浏览器会合成假粗，笔画糊成一团 */
  font-weight: 400;
  letter-spacing: .3em;
  /* 字距会在最后一个字后面也留一段空，居中时整体左偏；
     text-indent 取同值正好抵掉，两个字才真的居中 */
  text-indent: .3em;
  line-height: 1.25;
}

/* 题辞：比标题轻、比副标题重，四句随机（见 docs/标语决策记录.md） */
.hero .motto {
  margin: 12px 0 0;
  color: var(--text-2);
  font-size: 17px;
  letter-spacing: .08em;
}

.hero .sub {
  margin: 8px 0 0;
  color: var(--text-3);
  font-size: 15px;
  letter-spacing: .01em;
}

/* ── 项目说明 ─────────────────────────── */
.intro {
  margin: 0 0 24px;
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.85;
}
.intro > p { margin: 0; }
.intro .origin {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.8;
}
.intro .origin b { color: var(--text-2); font-weight: 600; }
.intro b { color: var(--text); font-weight: 600; }

.intro details { margin-top: 10px; }
.intro summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  width: fit-content;
}
.intro summary::marker { font-size: .8em; }
.intro ul {
  margin: 12px 0 0;
  padding-left: 1.1em;
  border-left: 2px solid var(--line);
}
.intro li { margin: 0 0 10px; }
.intro li:last-child { margin-bottom: 0; }


/* 缘起与致谢：details 里的段落 */
.intro details p { margin: 10px 0 0; }
.intro details > p:first-of-type { margin-top: 12px; }
.intro code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 5px;
}
.intro details + details { margin-top: 6px; }

/* ── 搜索框 ───────────────────────────── */
.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

.searchbar input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 19px;
  padding: 14px 0;
  min-width: 0;
}

.searchbar input::placeholder { color: var(--text-3); }
.searchbar input::-webkit-search-cancel-button { -webkit-appearance: none; }

.searchbar button {
  flex: none;
  width: 46px; height: 46px;
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .2s var(--ease), opacity .2s var(--ease);
}

.searchbar button:hover { opacity: .88; }
.searchbar button:active { transform: scale(.94); }
.searchbar button svg { fill: currentColor; }
.searchbar button:disabled { opacity: .4; cursor: default; }

/* ── 变音符号 ─────────────────────────── */
.diacritics {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 14px; padding-left: 4px;
}

.dia-hint { color: var(--text-3); font-size: 13px; margin-right: 2px; }

.diacritics button {
  min-width: 38px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: background .18s var(--ease), transform .18s var(--ease);
}

.diacritics button:hover { background: var(--accent-soft); }
.diacritics button:active { transform: scale(.92); }

/* ── 进度瀑布 ─────────────────────────── */
.progress { margin-top: 40px; }

.eta {
  color: var(--text-2);
  font-size: 14px;
  text-align: center;
  margin-bottom: 20px;
  min-height: 20px;
}

.steps { list-style: none; margin: 0; padding: 0; }

.steps li {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 13px 0;
  opacity: .3;
  transition: opacity .45s var(--ease);
}

.steps li.active, .steps li.done { opacity: 1; }
.steps li div { flex: 1; min-width: 0; }
.steps li b { font-weight: 500; font-size: 15px; display: block; }

.steps li em {
  font-style: normal;
  color: var(--text-2);
  font-size: 13.5px;
  display: block;
  min-height: 20px;
}

.dot {
  flex: none;
  width: 20px; height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  position: relative;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}

.steps li.active .dot {
  border-color: var(--accent);
  border-right-color: transparent;
  animation: spin .8s linear infinite;
}

.steps li.done .dot { border-color: var(--accent); background: var(--accent); }

.steps li.done .dot::after {
  content: "";
  position: absolute;
  left: 5px; top: 1.5px;
  width: 5px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .steps li.active .dot { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ── 面板 ─────────────────────────────── */
.panel, #resultBox { margin-top: 44px; animation: rise .5s var(--ease) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0 0 18px;
}

.muted { color: var(--text-3); font-weight: 400; font-size: 15px; }

.note {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.65;
  margin: 16px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}

/* 词形 chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 15px;
}

.chip s { text-decoration: none; color: var(--text-3); font-size: 12.5px; }
.chip.bold-hit { border-color: var(--accent); background: var(--accent-soft); }

/* 层次统计 */
.layers { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

.layer {
  flex: 1; min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 17px;
}

.layer b { display: block; font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.layer span { color: var(--text-2); font-size: 13px; }
.layer.mula b { color: var(--mula); }
.layer.atta b { color: var(--atta); }
.layer.tika b { color: var(--tika); }

table.dist { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.dist td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.dist td:first-child { color: var(--text-2); width: 62px; font-variant-numeric: tabular-nums; }
table.dist tr:last-child td { border-bottom: 0; }

/* ── 结果 ─────────────────────────────── */
.results-h { position: sticky; top: 0; background: var(--bg); padding: 10px 0; z-index: 2; }

.hit {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}

.hit:hover { box-shadow: var(--shadow); }

.hit-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
  margin-bottom: 11px;
}

.coord {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 9px;
  border-radius: 7px;
  cursor: pointer;
  border: 0;
}

.coord:active { transform: scale(.95); }

.tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid currentColor;
  letter-spacing: .02em;
}

.tag.mula { color: var(--mula); }
.tag.atta { color: var(--atta); }
.tag.tika { color: var(--tika); }

.path { color: var(--text-3); font-size: 12.5px; margin-bottom: 10px; line-height: 1.5; }

.snippet { font-size: 15.5px; line-height: 1.75; color: var(--text); word-break: break-word; }
.snippet .bld { font-weight: 600; }
.snippet mark { background: var(--accent-soft); color: inherit; border-radius: 4px; padding: 1px 3px; }
.snippet .paranum { color: var(--text-3); font-size: 13px; margin-right: 4px; }

.more {
  display: block; width: 100%;
  margin-top: 10px; padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  font: inherit; font-size: 15px;
  cursor: pointer;
  transition: background .2s var(--ease);
}

.more:hover { background: var(--accent-soft); }

.empty {
  margin-top: 44px; text-align: center;
  color: var(--text-2); font-size: 15.5px; line-height: 1.8;
}

.empty b { color: var(--text); display: block; margin-bottom: 8px; font-size: 17px; }

footer {
  text-align: center; padding: 40px 22px 60px;
  color: var(--text-3); font-size: 13px;
  border-top: 1px solid var(--line);
  margin-top: 60px;
}

footer p { margin: 5px 0; }
footer a { color: var(--text-2); }
.tiny { font-size: 12px; }

@media (max-width: 520px) {
  .hero { padding: 56px 20px 32px; }
  body { font-size: 16px; }
  .hit { padding: 17px 18px; }
  .layer { min-width: 100%; }
}

/* ── 示例问题 ─────────────────────────── */
.examples { margin-top: 22px; }
.ex-hint { color: var(--text-3); font-size: 13px; margin: 0 0 10px 4px; }
.ex-list { display: flex; flex-wrap: wrap; gap: 8px; }

.ex-list button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 999px;
  padding: 8px 15px;
  font: inherit; font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}

.ex-list button:hover { background: var(--accent-soft); color: var(--text); }
.ex-list button:active { transform: scale(.97); }

/* ── 答案 ─────────────────────────────── */
.answer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 44px 0 16px;
}
.answer-head h2 { margin: 0; }

.copybtn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 10px;
  padding: 8px 15px;
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
}

.copybtn:hover { background: var(--accent-soft); color: var(--text); }
.copybtn:active { transform: scale(.96); }

.answer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  font-size: 16.5px;
  line-height: 1.85;
  animation: rise .5s var(--ease) both;
  user-select: text;
}

.answer p { margin: 0 0 15px; }
.answer p:last-child { margin-bottom: 0; }
.answer strong { font-weight: 600; }

.coord-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

/* 可点的坐标：本次检索真的取到了这一段。取不到的保持上面那个静态样式，
   不做成可点——不假装能回查。 */
button.coord-has {
  border: 0;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid currentColor;
}
button.coord-has:hover { background: var(--accent); color: #fff; }

/* 点开坐标弹出的原文气泡 */
.coordpop {
  position: absolute;
  z-index: 50;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
  padding: 14px 16px;
  max-height: 46vh;
  overflow-y: auto;
}
.coordpop-head {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.coordpop-body {
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.disclaim {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.7;
  margin: 14px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}

@media (max-width: 520px) {
  .answer { padding: 20px 18px; font-size: 16px; }
  .ex-list button { font-size: 13.5px; padding: 7px 13px; }
}
