/* 判决检索 — 网页界面 */

:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eef0f3;
  --border: #dfe1e5;
  --border-strong: #c6cad1;
  --text: #1f1f1f;
  --text-2: #4d5156;
  --text-3: #70757a;
  --link: #1a0dab;
  --link-visited: #681da8;
  --accent: #1a56db;
  --accent-text: #ffffff;
  --seal: #b3261e;
  --mark-bg: #fde68a;
  --mark-text: #1f1f1f;
  --hit-bg: #f2f6ff;
  --hit-border: #1a56db;
  --warn-bg: #fff4e5;
  --warn-text: #8a4b00;
  --ok-text: #137333;
  --no-text: #b3261e;
  --shadow: 0 1px 6px rgba(32, 33, 36, .18);
  --radius: 24px;
  --brand-w: 150px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --sans-hant: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  --kai: "KaiTi", "STKaiti", "Kaiti SC", "BiauKai", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f2023;
    --surface: #2a2b2f;
    --surface-2: #33353a;
    --border: #3c4043;
    --border-strong: #5f6368;
    --text: #e8eaed;
    --text-2: #bdc1c6;
    --text-3: #9aa0a6;
    --link: #8ab4f8;
    --link-visited: #c58af9;
    --accent: #8ab4f8;
    --accent-text: #1f2023;
    --seal: #c0392b;
    --mark-bg: #6b5a14;
    --mark-text: #fff8dc;
    --hit-bg: #232c3d;
    --hit-border: #8ab4f8;
    --warn-bg: #3a2e1a;
    --warn-text: #f5c77e;
    --ok-text: #81c995;
    --no-text: #f28b82;
    --shadow: 0 1px 6px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 标志 ---------- */
.seal {
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: .18em;
  background: var(--seal);
  color: #fff;
  font-family: var(--kai);
  font-weight: 400;
  line-height: 1;
}
.brand-sm {
  flex: none;
  width: 122px;   /* + 顶栏间距 28px = --brand-w, 结果列表与搜索框左对齐 */
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.brand-sm:hover { text-decoration: none; }
.brand-sm .seal { font-size: 17px; }

/* ---------- 搜索框 ---------- */
.search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.searchbox {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 46px;
  padding: 0 6px 0 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow .15s, border-color .15s;
}
.searchbox:hover, .searchbox:focus-within {
  box-shadow: var(--shadow);
  border-color: transparent;
}
.searchbox svg { flex: none; width: 20px; height: 20px; color: var(--text-3); }
.searchbox input {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin-left: 12px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.clear-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  font-size: 20px;
  cursor: pointer;
}
.clear-btn:hover { background: var(--surface-2); color: var(--text); }

.btn {
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--surface);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border); box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.btn-primary {
  flex: none;
  height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- 首页 ---------- */
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16vh 16px 40px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: .08em;
}
.logo .seal { font-size: 46px; letter-spacing: 0; }
.tagline { margin: 10px 0 30px; color: var(--text-3); font-size: 15px; letter-spacing: .05em; }
.home .search-form { max-width: 640px; flex-direction: column; gap: 22px; }
.home .searchbox { flex: none; width: 100%; height: 50px; }
.home-buttons { display: flex; gap: 12px; }
.examples {
  max-width: 640px;
  margin-top: 34px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-3);
}
.examples a {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
}
.examples a:hover { background: var(--surface); text-decoration: none; }
.examples .label { width: 100%; text-align: center; margin-bottom: 2px; }
.home-foot {
  padding: 14px 16px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

/* ---------- 顶栏 (结果页、明细页) ---------- */
.topbar { border-bottom: 1px solid var(--border); }
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 20px 24px 12px;
}
.topbar .search-form { max-width: 720px; }
.tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 24px 0 calc(24px + var(--brand-w, 150px));
  font-size: 14px;
  overflow-x: auto;
}
.tabs a, .tabs button {
  padding: 8px 12px 10px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .tools-toggle { margin-left: auto; }
.tabs .tools-toggle.on { color: var(--text); }
.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 24px 12px calc(24px + var(--brand-w, 150px));
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
}
.tools select, .tools input {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.tools input { width: 76px; }
.tools label { display: flex; align-items: center; gap: 6px; }
.tools .reset { border: 0; background: none; color: var(--link); cursor: pointer; padding: 0; }

/* ---------- 结果页 ---------- */
.results {
  max-width: 720px;
  padding: 14px 24px 60px calc(24px + var(--brand-w, 150px));
  box-sizing: content-box;
}
.stats { color: var(--text-3); font-size: 13.5px; }
.understand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 4px;
  font-size: 13px;
}
.chip {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
}
.chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.verify {
  margin: 8px 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.6;
}
.verify b { color: var(--text); font-weight: 600; }
.verify a { margin-left: 4px; white-space: nowrap; }
.verify.warn { background: var(--warn-bg); color: var(--warn-text); }
.plan-details { margin: 4px 0 8px; font-size: 13px; color: var(--text-3); }
.plan-details summary { cursor: pointer; width: max-content; }
.plan-details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface);
}
.plan-details dt { color: var(--text-3); }
.plan-details dd { margin: 0; color: var(--text-2); word-break: break-word; }

.result-list { list-style: none; margin: 18px 0 0; padding: 0; }
.result { margin-bottom: 30px; }
.result .src {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  min-width: 0;
}
.court-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.src-text { min-width: 0; line-height: 1.3; }
.src-site { font-size: 14px; color: var(--text); }
.src-url {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
}
.src-url:hover { text-decoration: underline; }
.ext { font-size: .85em; opacity: .7; }
.result h3 { margin: 0; font-size: 20px; font-weight: 400; line-height: 1.35; }
.result h3 a:visited { color: var(--link-visited); }
.result h3 [lang="zh-HK"] { font-family: var(--sans-hant); }
.result .meta { margin-top: 3px; color: var(--text-3); font-size: 13.5px; }
.result .meta .sep { margin: 0 6px; opacity: .6; }
.snippet { margin: 4px 0 0; color: var(--text-2); font-size: 14.5px; line-height: 1.65; word-break: break-word; }
.snippet + .snippet { font-size: 13.5px; }
.snippet[lang="zh-HK"] { font-family: var(--sans-hant); }
.snippet .para { color: var(--text-3); margin-right: 6px; font-size: 13px; }
.snippet mark { background: none; color: var(--text); font-weight: 700; }
.check { display: flex; gap: 6px; margin: 4px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.check .icon { flex: none; font-weight: 700; }
.check.yes .icon { color: var(--ok-text); }
.check.no .icon { color: var(--no-text); }
.check.unknown { color: var(--text-3); }
.check q { margin-left: 4px; color: var(--text); font-family: var(--sans-hant); quotes: "「" "」"; }
.check .why { margin-left: 6px; color: var(--text-3); }
.result .links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 13px; }
.result .links .muted { color: var(--text-3); }

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 16px;
  font-size: 14px;
}
.pager a, .pager span { min-width: 36px; padding: 6px 10px; text-align: center; border-radius: 6px; }
.pager a:hover { background: var(--surface); text-decoration: none; }
.pager .cur { color: var(--text); font-weight: 700; }

.notice {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
}
.notice h2 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice.error { background: var(--warn-bg); color: var(--warn-text); }
.notice.error h2 { color: var(--warn-text); }
.notice pre { white-space: pre-wrap; margin: 8px 0 0; font-size: 12.5px; }

/* 加载中 */
.loading-msg { margin: 14px 0 20px; color: var(--text-3); font-size: 13.5px; }
.skel { margin-bottom: 30px; }
.skel div { height: 12px; margin: 8px 0; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
.skel .s1 { width: 36%; }
.skel .s2 { width: 62%; height: 18px; }
.skel .s3 { width: 96%; }
.skel .s4 { width: 80%; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .skel div { animation: none; } }

/* ---------- 明细页 ---------- */
.case {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px 24px 80px;
}
.back { display: inline-block; margin-bottom: 14px; font-size: 14px; }
.case-head h1 { margin: 0; font-size: 26px; font-weight: 600; line-height: 1.35; }
.case-head h1[lang="zh-HK"], .case-head .alt-title[lang="zh-HK"] { font-family: var(--sans-hant); }
.alt-title { margin-top: 4px; color: var(--text-3); font-size: 15px; }
.case-head .meta { margin-top: 8px; color: var(--text-2); font-size: 14px; }
.case-head .meta .sep { margin: 0 7px; opacity: .5; }
.case-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.case-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
}
.case-actions a:hover { background: var(--surface); text-decoration: none; }
.case-actions a.primary { border-color: var(--accent); color: var(--accent); }

.lang-tabs { display: flex; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--border); }
.lang-tabs a {
  padding: 8px 14px 10px;
  border-bottom: 3px solid transparent;
  color: var(--text-2);
  font-size: 14px;
}
.lang-tabs a:hover { color: var(--text); text-decoration: none; }
.lang-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.case-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 40px;
  margin-top: 20px;
  align-items: start;
}
.fulltext { max-width: 780px; }
.fulltext[lang="zh-HK"] { font-family: var(--sans-hant); font-size: 16px; line-height: 1.9; }
.fulltext[lang="en"] { font-size: 16px; line-height: 1.7; }
.fulltext p { margin: 0 0 .9em; }
.fulltext p.h { margin-top: 1.4em; font-weight: 700; }
.fulltext mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 2px; padding: 0 1px; }
.text-note { margin-bottom: 18px; color: var(--text-3); font-size: 13px; }
.chunk { scroll-margin-top: 70px; }
.chunk.hit {
  margin: 0 -16px .9em;
  padding: 12px 16px 2px 13px;
  border-left: 3px solid var(--hit-border);
  border-radius: 0 8px 8px 0;
  background: var(--hit-bg);
}
.chunk.hit.current { box-shadow: 0 0 0 2px var(--hit-border) inset; }
.hit-label { margin-bottom: 6px; color: var(--hit-border); font: 600 12px/1 var(--sans); letter-spacing: .05em; }

.hitnav {
  position: sticky;
  top: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  margin: 0 0 16px auto;
  padding: 5px 6px 5px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  color: var(--text-2);
}
.hitnav button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
}
.hitnav button:hover { background: var(--surface-2); }

.info { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.info details {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.info summary {
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.info summary::-webkit-details-marker { display: none; }
.info summary::after { content: "▾"; float: right; color: var(--text-3); }
.info details:not([open]) summary::after { content: "▸"; }
.info dl { margin: 0; padding: 0 16px 14px; font-size: 13.5px; }
.info dt { margin-top: 10px; color: var(--text-3); font-size: 12.5px; }
.info dd { margin: 2px 0 0; color: var(--text); word-break: break-word; }
.info dd[lang="zh-HK"] { font-family: var(--sans-hant); }
.info ul { margin: 0; padding-left: 18px; }
.info .more { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; font-size: 13px; }
.info .hint { color: var(--text-3); font-size: 12px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .case-body { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .info { position: static; max-height: none; order: -1; }
  .chunk.hit { margin-left: -12px; margin-right: -12px; padding-left: 9px; padding-right: 12px; }
}
@media (max-width: 760px) {
  :root { --brand-w: 0px; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 14px 16px 8px; }
  .topbar .search-form { max-width: none; }
  .tabs, .tools { padding-left: 16px; padding-right: 16px; }
  .results { padding: 12px 16px 48px; }
  .case { padding: 14px 16px 60px; }
  .logo { font-size: 34px; gap: 12px; }
  .logo .seal { font-size: 36px; }
  .home-main { padding-top: 12vh; }
  .result h3 { font-size: 18px; }
  .case-head h1 { font-size: 22px; }
}
@media (max-width: 480px) {
  .topbar .btn-primary { padding: 0 16px; }
  .searchbox { padding-left: 12px; }
  .searchbox input { margin-left: 8px; }
}


/* ============ facet 导航 (命中案件的分布, 点一下收窄) ============ */
.facets { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 18px; }
.facet { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 13px; }
.facet > b { color: var(--text-3); font-weight: 500; min-width: 5.5em; }
.facet a, .facet .facet-static {
  padding: 2px 9px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-2); text-decoration: none; background: var(--surface);
}
.facet a:hover { border-color: var(--accent); color: var(--text); }
.facet a.on { border-color: var(--accent); background: var(--hit-bg); color: var(--text); font-weight: 600; }
.facet span { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ============ 结果卡片上的标签 ============ */
.links .tag {
  padding: 1px 8px; border-radius: 999px; background: var(--surface-2);
  color: var(--text-2); font-size: 12px;
}

/* ============ 明细页「找类似案件」 ============ */
.similar-box { margin-bottom: 16px; }
.similar-list { margin: 8px 0 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.similar-list .muted { margin-left: 6px; font-size: 12px; color: var(--text-3); }
