/* 法律数据库 · 双站共用外壳 */

:root {
  --bg: #FBFAF7;
  --card: #FFFFFF;
  --ink: #1C1917;
  --sub: #57534E;
  --mute: #A8A29E;
  --line: #E7E5E4;
  --accent: #7C2D12;
  --accent-soft: #FEF3EC;
  --ok: #15803D;
  --ok-soft: #ECFDF3;
  --warn: #B45309;
  --warn-soft: #FFFBEB;
}

* { box-sizing: border-box; }

/* [hidden] 必须真的不显示：.stats/.list 等设了 display:flex|grid 会盖掉它 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- 外壳：顶部标签栏 + 整幅内容 ---------- */
.shell { display: block; min-height: 100vh; }
.content { min-width: 0; }

/* 顶栏：品牌 + 语言切换占一行，栏目标签独占下一行；吸顶 */
.sidebar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 18px max(20px, calc((100% - 1080px) / 2)) 0;
  display: flex; align-items: center; flex-wrap: wrap; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.sidebar .langs { order: 2; margin-left: auto; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  font-size: 20px; font-weight: 700; color: var(--accent);
  text-decoration: none; letter-spacing: -.02em; white-space: nowrap;
}
.logo span { color: var(--mute); margin: 0 2px; }
h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.tagline { margin: 3px 0 0; font-size: 12.5px; color: var(--mute); }

.langs { display: flex; gap: 4px; flex-wrap: wrap; }
.langs button {
  border: 1px solid var(--line); background: transparent; color: var(--sub);
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.langs button:hover { border-color: var(--mute); }
.langs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 栏目标签：横向一排，首页排第一 ---------- */
.mainnav {
  order: 3; flex: 1 0 100%;
  display: flex; gap: 2px; flex-wrap: wrap; align-items: center;
  border-top: 1px solid var(--line); margin-top: 14px; padding: 0;
  overflow-x: auto; scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav[hidden] { display: none; }
.mainnav button, .mainnav .mn-all {
  font: inherit; font-size: 16px; padding: 13px 14px; border: 0; background: none;
  color: var(--sub); cursor: pointer; white-space: nowrap; font-family: inherit;
  border-bottom: 2px solid transparent; transition: .15s; position: relative;
}
.mainnav button:hover, .mainnav .mn-all:hover { color: var(--ink); }
.mainnav button[aria-pressed="true"], .mainnav .mn-all[aria-pressed="true"] {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
}
.mainnav .n { color: var(--mute); font-size: 13px; margin-left: 5px; font-variant-numeric: tabular-nums; }
.mainnav button[aria-pressed="true"] .n { color: var(--accent); opacity: .7; }

/* ---------- 检索 ---------- */
.searchbar { display: flex; align-items: center; gap: 14px; margin: 26px 0 16px; }
#q {
  flex: 1; font: inherit; font-size: 15px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  color: var(--ink); outline: none; transition: .15s;
}
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.count { font-size: 12.5px; color: var(--mute); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- 类目 ---------- */
.cats[hidden] { display: none; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.cats button {
  font: inherit; font-size: 13px; padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--sub); transition: .15s;
  font-variant-numeric: tabular-nums;
}
.cats button:hover { border-color: var(--mute); color: var(--ink); }
.cats button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cats .n { color: var(--mute); font-size: 11.5px; margin-left: 5px; }
.cats button[aria-pressed="true"] .n { color: var(--accent); opacity: .75; }

/* ---------- 统计 ---------- */
.stats { display: flex; gap: 26px; flex-wrap: wrap; padding: 14px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 20px; }
.stats div { font-size: 12.5px; color: var(--mute); }
.stats b { display: block; font-size: 19px; color: var(--ink); font-weight: 650;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 15px 17px; cursor: pointer; transition: .15s;
}
.card:hover { border-color: var(--mute); transform: translateY(-1px); }
.card .t { font-size: 14.5px; line-height: 1.55; margin: 0 0 7px; font-weight: 550; }
.card .t .fallback { color: var(--sub); font-weight: 450; }
.meta { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--mute); }
.chip { padding: 2px 8px; border-radius: 999px; background: #F5F5F4; color: var(--sub); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.off { background: #F5F5F4; color: var(--mute); }
.chip.mt { background: var(--warn-soft); color: var(--warn); }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--mute); }

.more-wrap { display: flex; justify-content: center; margin: 22px 0 8px; }
.more { font: inherit; font-size: 13px; padding: 9px 22px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--sub); }
.more:hover { border-color: var(--mute); color: var(--ink); }
.loading { text-align: center; color: var(--mute); font-size: 13px; padding: 40px 0; }
.empty { text-align: center; color: var(--mute); font-size: 13.5px; padding: 50px 0; }

/* ---------- 抽屉 ---------- */
.drawer { position: fixed; inset: 0; background: rgba(28, 25, 23, .35); z-index: 40; }
.drawer-inner {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(620px, 92vw);
  background: var(--card); padding: 26px 28px; overflow-y: auto;
  box-shadow: -8px 0 30px rgba(0,0,0,.08);
}
.close { position: absolute; right: 16px; top: 12px; border: 0; background: transparent;
  font-size: 26px; line-height: 1; color: var(--mute); cursor: pointer; }
.drawer h2 { font-size: 17px; line-height: 1.5; margin: 6px 40px 14px 0; font-weight: 600; }
.drawer h3 { font-size: 12.5px; color: var(--mute); font-weight: 500; margin: 22px 0 7px;
  text-transform: uppercase; letter-spacing: .06em; }
.drawer p { font-size: 13.5px; line-height: 1.7; margin: 0 0 8px; color: var(--sub); }
.drawer .lang-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.drawer .lang-row:last-child { border-bottom: 0; }
.drawer .lang-row .lbl { font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; }
.drawer .lang-row .txt { font-size: 14px; line-height: 1.6; margin-top: 3px; }
.drawer a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(124,45,18,.25); }
.drawer a:hover { border-bottom-color: var(--accent); }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 30px 20px 40px; font-size: 11.5px; color: var(--mute); }

/* 窄屏：标签一行放不下就横向滚动 */
@media (max-width: 900px) {
  .sidebar { padding: 14px 16px 0; gap: 10px; }
  .mainnav { flex-wrap: nowrap; }
}

@media (max-width: 640px) {
  .sidebar .brand { flex-direction: column; align-items: flex-start; gap: 4px; }
  .sidebar .langs { margin-left: 0; }
  .stats { gap: 18px; }
  .drawer-inner { width: 100vw; }
}

/* ---------- 科技蓝顶栏（2026-10-19 设计稿定稿） ---------- */
/* 品牌行与标签栏同色同带：#1E5EAD；当前标签用亮一档的 #2169C0 + 浅蓝下划线。 */
.sidebar {
  background: #1E5EAD;
  border-bottom: 1px solid #1A549A;
  padding-top: 16px;
  color: #EAF2FD;
}
.sidebar .logo { color: #FFFFFF; }
.sidebar .logo span { color: #BFD6F5; }
.sidebar h1 { color: #FFFFFF; font-size: 19px; font-weight: 700; }
.sidebar .tagline { color: #C8DCF7; }
.sidebar .langs button { color: #E6EFFC; border-color: rgba(255, 255, 255, .45); background: transparent; }
.sidebar .langs button:hover { color: #FFFFFF; border-color: #FFFFFF; }
.sidebar .langs button[aria-pressed="true"] { background: #EEF4FC; border-color: #EEF4FC; color: #1E5EAD; font-weight: 600; }

.mainnav { border-top: 0; margin-top: 8px; gap: 0; }
.mainnav button, .mainnav .mn-all {
  font-size: 16.5px; font-weight: 700; letter-spacing: .01em;
  padding: 14px 18px; color: #E3EEFC;
  border-bottom: 3px solid transparent;
}
.mainnav button:hover, .mainnav .mn-all:hover { color: #FFFFFF; background: rgba(255, 255, 255, .10); }
.mainnav button[aria-pressed="true"], .mainnav .mn-all[aria-pressed="true"] {
  color: #FFFFFF; background: #2169C0; border-bottom-color: #92BBED;
}
.mainnav .n { color: #BBD2F0; font-size: 12px; font-weight: 600; }
.mainnav button[aria-pressed="true"] .n, .mainnav .mn-all[aria-pressed="true"] .n { color: #DCE9FB; opacity: 1; }

.loaded { font-size: 12px; color: var(--mute); margin: -4px 0 14px; min-height: 14px; }

/* ---------- 栏目左栏：占 1/5，浅蓝标题块 + 灰底菜单（设计稿定稿） ---------- */
.page { display: block; }
.page.has-panel {
  display: grid; grid-template-columns: 20% minmax(0, 1fr); align-items: start;
  /* 灰底刷在整列上：左栏内容再短也铺满整页高度，右缘同时画出 1px 分隔线 */
  background: linear-gradient(to right,
    #E7E7E7 0 calc(20% - 1px), #D3D3D3 calc(20% - 1px) 20%, rgba(231, 231, 231, 0) 20%);
}
.panel {
  background: transparent;                /* 底色由 .page 的渐变提供 */
  border-right: 0;
  padding: 0 0 36px;
  position: sticky; top: var(--headh, 146px);
  max-height: calc(100vh - var(--headh, 146px));
  overflow-y: auto; align-self: start;
}
.panel[hidden] { display: none; }
.panel-head { background: #ADCAF9; padding: 22px 14px 14px; }
.panel .panel-title {
  font-size: 17px; font-weight: 700; letter-spacing: .01em; color: #0F2E63;
  margin: 0 0 12px; padding: 0 9px;
}
.panel nav { display: flex; flex-direction: column; }
.panel-nav { padding: 2px 0 0; }
.panel button {
  font: inherit; font-size: 17px; color: #242424; background: none; border: 0; border-radius: 0;
  padding: 13px 20px; text-align: left; cursor: pointer; display: flex; align-items: baseline;
  gap: 8px; justify-content: space-between; line-height: 1.35;
  border-bottom: 1px solid #D6D6D6;
}
.panel-head button {
  background: #FFFFFF; border-radius: 10px; border-bottom: 0;
  color: #0F2E63; font-weight: 700; padding: 9px 12px;
  box-shadow: 0 1px 3px rgba(16, 42, 90, .12);
}
.panel button:hover { background: rgba(255, 255, 255, .7); }
.panel-head button:hover { background: #FFFFFF; }
.panel button[aria-pressed="true"] {
  background: #FFFFFF; color: #0F2E63; font-weight: 700;
  border-left: 3px solid #0334D3; padding-left: 17px;
}
.panel-head button[aria-pressed="true"] { padding-left: 9px; box-shadow: 0 1px 3px rgba(16, 42, 90, .18); }
.panel .n { margin-left: auto; font-size: 14px; color: #6E6E6E; font-variant-numeric: tabular-nums; }
.panel-head .n { color: #46618F; font-weight: 600; }
.panel .sep { display: none; }
.panel .panel-group {
  font-size: 13.5px; font-weight: 700; letter-spacing: .04em; color: #4A5A70;
  margin: 16px 0 6px; padding: 0 20px;
}
.panel .tip { font-size: 12px; color: #40598F; padding: 8px; line-height: 1.6; }

/* ---------- 概况页 / 链接页 ---------- */
.pagebody { margin: 6px 0 28px; }
.pagebody[hidden] { display: none; }
.pb-crumb { font-size: 12.5px; color: var(--mute); margin: 0 0 6px; letter-spacing: .02em; }
.pb-h { font-size: 23px; line-height: 1.35; margin: 0 0 14px; font-weight: 700; letter-spacing: -.01em; }
.pb-lead { font-size: 15px; line-height: 1.95; color: var(--sub); margin: 0 0 26px; }
.pb-kpi {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0 0 26px;
}
.pb-kpi div { background: var(--card); padding: 14px 16px; }
.pb-kpi b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pb-kpi span { font-size: 12px; color: var(--mute); }
.pb-sec h3 { font-size: 13px; color: var(--mute); font-weight: 600; margin: 26px 0 8px; letter-spacing: .04em; }
.bars { border-top: 1px solid var(--line); }
.bar-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 52px 110px; gap: 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.bar-row .bar { height: 6px; background: #F0EDE9; border-radius: 3px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--accent); opacity: .55; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pb-btn {
  display: inline-block; margin-top: 24px; padding: 11px 20px; border-radius: 8px;
  background: var(--ink); color: #fff; font: inherit; font-size: 13.5px; border: 0; cursor: pointer;
}
.pb-btn:hover { background: #000; }
.pb-note { font-size: 12.5px; color: var(--mute); line-height: 1.8; margin: 22px 0 0; }
.linkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 10px; }
.linkcard {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; text-decoration: none; color: inherit; transition: .15s;
}
.linkcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.linkcard b { display: block; font-size: 14.5px; margin-bottom: 4px; font-weight: 650; }
.linkcard span { display: block; font-size: 12.5px; color: var(--sub); line-height: 1.65; }
.linkcard em { display: block; margin-top: 7px; font-size: 11.5px; color: var(--mute); font-style: normal; }

/* 链接页的两级分组：section（联合国组织系统/其他IGO）+ group（区域或机构类别） */
.linksec { margin: 0 0 10px; }
.linksec-h {
  font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 34px 0 4px;
  padding: 0 0 10px; border-bottom: 2px solid var(--ink, #241C18);
}
.linkgroup { margin: 20px 0 6px; }
.linkgroup-h {
  font-size: 13.5px; font-weight: 700; color: var(--accent); margin: 0 0 10px;
  display: flex; align-items: baseline; gap: 8px; letter-spacing: .02em;
}
.linkgroup-h em {
  font-style: normal; font-size: 12px; font-weight: 600; color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.pb-num { font-size: 14px; font-weight: 600; color: var(--mute); font-variant-numeric: tabular-nums; }

/* 窄屏：左栏折成内容上方的横向条（头块与列表用 display:contents 拉平成一行） */
@media (max-width: 900px) {
  .page.has-panel { grid-template-columns: minmax(0, 1fr); background: none; }
  .panel {
    position: static; max-height: none; padding: 10px 14px;
    background: #ADCAF9; border-bottom: 1px solid #9CBCEC;
    display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 6px;
    overflow-x: auto; scrollbar-width: none;
  }
  .panel::-webkit-scrollbar { display: none; }
  .panel-head, .panel-head nav, .panel .panel-nav { display: contents; }
  .panel .panel-title { display: none; }
  .panel button {
    white-space: nowrap; border-bottom: 0; border-left: 0; border-radius: 8px;
    padding: 6px 11px; font-size: 14px;
  }
  .panel-head button { background: #FFFFFF; box-shadow: none; }
  .panel button[aria-pressed="true"] {
    border-left: 0; padding-left: 11px; box-shadow: inset 0 -2px 0 #0334D3;
  }
  .panel .n { margin-left: 5px; }
}

/* NGO 分类卡片：首页只列分类，点开进具体链接 */
.ngogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; margin: 22px 0 8px; }
.ngocard {
  text-align: left; font: inherit; cursor: pointer; background: #fff;
  border: 1px solid var(--rule, #E3DED7); border-radius: 10px; padding: 16px 16px 14px;
  display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.ngocard:hover { border-color: #1A73E8; box-shadow: 0 2px 10px rgba(18, 64, 143, .10); transform: translateY(-1px); }
.ngocard b { font-size: 15px; font-weight: 700; color: var(--ink, #241C18); line-height: 1.35; }
.ngocard em { font-style: normal; font-size: 12.5px; font-weight: 600; color: var(--mute, #7A6E63); font-variant-numeric: tabular-nums; }
.ngoback { color: #12408F; text-decoration: none; border-bottom: 1px solid transparent; }
.ngoback:hover { border-bottom-color: #12408F; }

/* 站内自建条文入口（抽屉里的区块 + 卡片上的小标） */
.chip.txt { background: #E8F0FC; color: #1E5EAD; border-color: #C5D6EF; font-weight: 600; }
.txbox { margin: 16px 0 4px; padding: 14px 16px; background: #F5F8FD; border: 1px solid #DCE7F7; border-radius: 10px; }
.txbox-h { margin: 0 0 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; color: #0F2E63; }
.txbox-l { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.txlink { display: inline-block; padding: 5px 14px; border-radius: 999px; background: #1E5EAD; color: #fff; font-size: 13px; font-weight: 600; }
.txlink:hover { background: #1A549A; text-decoration: none; }
/* 列表卡内的三语文本入口行 */
.txmini { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px 4px; border-top: 1px dashed #D8E2EC; margin-top: 10px; }
.txmini-h { font-size: 12px; color: #5A6B7B; white-space: nowrap; }
.txmini .txlink { font-size: 12px; padding: 3px 12px; }

/* 首页「条约全文」页：自建正文清单 */
.txlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 18px; }
.txcard { border: 1px solid #E1E7F2; border-radius: 12px; padding: 18px 20px; background: #fff; }
.txcard h2 { margin: 0 0 6px; font-size: 18px; color: #0F2E63; letter-spacing: .01em; }
.txcard-sub { margin: 0 0 8px; font-size: 13px; color: #6E6E6E; }
.txcard-cnt { margin: 0 0 12px; font-size: 12px; color: #8A8A8A; letter-spacing: .04em; }
.txcard-l { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }

/* 统一条目展示（10-21）：官方文本行 + 本站条文整理中态 */
.txpending { font-size: 12px; color: #7A8896; }
.txbox.pending { background: #FAFBFC; border-color: #E4EAEF; }
.txbox.pending .txbox-h { color: #5A6B7B; }
.offrow { margin: 12px 0 4px; display: flex; align-items: center; gap: 10px; }
.offlab { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; color: #0F2E63; }
.offrow a { font-size: 13.5px; }

/* EU 四语打开按钮（10-21） */
.langbtns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 8px; }
.langbtn { display: inline-block; padding: 6px 14px; border: 1px solid #C8D4E0; border-radius: 999px; font-size: 13px; font-weight: 600; color: #0F2E63; background: #fff; text-decoration: none; }
.langbtn:hover { background: #EEF3F8; border-color: #0F2E63; }
.langbtn[data-l="zh"] { background: #0F2E63; color: #fff; border-color: #0F2E63; }
.langbtn[data-l="zh"]:hover { background: #1A4080; }

/* 列表卡内四语按钮：紧凑版 */
.txmini.compact .langbtns { margin: 4px 0 0; }
.txmini .langbtn { padding: 3px 10px; font-size: 12px; }

/* 双边条约国别页三级分类菜单 */
.fieldnav { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; padding: 10px 12px; border: 1px solid var(--border, #E3E8EF); border-radius: 12px; background: var(--card, #fff); }
.fieldnav button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--border, #D8E0EA); border-radius: 999px; background: transparent; font: inherit; font-size: 13px; cursor: pointer; color: inherit; }
.fieldnav button .n { font-size: 11px; opacity: .65; }
.fieldnav button[aria-pressed="true"] { background: var(--accent, #0F2E63); color: #fff; border-color: var(--accent, #0F2E63); }
.fieldnav button[aria-pressed="true"] .n { opacity: .85; }
