/* 超声谐振器知识库 — modern clean stylesheet */
:root {
  --ink: #1f2733;
  --ink-soft: #4b5563;
  --brand: #0b5fa5;
  --brand-dark: #084a82;
  --accent: #e8f1f9;
  --line: #d9e2ec;
  --bg: #ffffff;
  --bg-soft: #f5f8fb;
  --sidebar-w: 300px;
  --maxw: 1180px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.site-title a { color: #fff; text-decoration: none; font-size: 1.15rem; font-weight: 600; }
.site-title .en { display: block; font-size: .72rem; font-weight: 400; opacity: .85; letter-spacing: .04em; }
.top-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.top-nav a {
  color: #dbe9f6; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-size: .92rem;
}
.top-nav a:hover, .top-nav a.active { background: var(--brand-dark); color: #fff; }
#lang-toggle {
  border: 1px solid rgba(255,255,255,.55); background: transparent; color: #fff;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: .9rem;
}
#lang-toggle:hover { background: rgba(255,255,255,.14); }
#sidebar-toggle { display: none; }

/* ---------- layout ---------- */
.layout {
  display: flex; align-items: flex-start; gap: 28px;
  max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 60px;
}
.sidebar {
  flex: 0 0 var(--sidebar-w);
  position: sticky; top: 74px;
  max-height: calc(100vh - 94px); overflow: auto;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft);
  padding: 14px 14px 20px; font-size: .9rem;
}
.sidebar ul { list-style: none; margin: 0; padding-left: 16px; }
.sidebar > ul { padding-left: 2px; }
.sidebar li { margin: 2px 0; }
.sidebar a { color: var(--ink); text-decoration: none; display: inline-block; padding: 2px 4px; border-radius: 4px; }
.sidebar a:hover { color: var(--brand); background: var(--accent); }
.sidebar a.current { color: var(--brand); font-weight: 600; }
.sidebar .no-link { color: var(--ink-soft); padding: 2px 4px; display: inline-block; }
.sidebar details { margin: 2px 0; }
.sidebar summary {
  cursor: pointer; color: var(--brand-dark); font-weight: 600;
  padding: 2px 4px; border-radius: 4px; list-style: none; user-select: none;
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::before {
  content: "▸"; display: inline-block; margin-right: 5px;
  color: var(--brand); transition: transform .15s ease; font-size: .8em;
}
.sidebar details[open] > summary::before { transform: rotate(90deg); }
.sidebar summary:hover { background: var(--accent); }
main.content { flex: 1 1 auto; min-width: 0; max-width: 840px; }
main.content img { max-width: 100%; height: auto; }

/* ---------- language ---------- */
[hidden] { display: none !important; }
body[data-lang="zh"] .nv-en { display: none; }
body[data-lang="en"] .nv-zh { display: none; }
.lang-note {
  background: #fff8e1; border: 1px solid #f0d98c; color: #6b5b1e;
  padding: 8px 12px; border-radius: 8px; font-size: .9rem; margin-bottom: 16px;
}

/* ---------- content typography ---------- */
h1._page_title, h1.page-topper, h1._dict_topic {
  font-size: 1.7rem; line-height: 1.3; margin: 0 0 18px;
  padding-bottom: 10px; border-bottom: 3px solid var(--brand); color: var(--brand-dark);
}
h2 { font-size: 1.32rem; color: var(--brand-dark); margin-top: 2em; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
h3 { font-size: 1.12rem; color: var(--ink); margin-top: 1.8em; }
a { color: var(--brand); }
a:hover { text-decoration: underline; }
p { margin: .8em 0; }

/* table of contents box */
._table_of_contents {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 18px; margin: 0 0 24px; font-size: .94rem;
}
._table_of_contents_title, ._table_of_contents h1 { font-size: 1.02rem; margin: 0 0 6px; color: var(--brand-dark); border: none; padding: 0; }
._table_of_contents_subhead { font-size: .95rem; font-weight: 600; margin: 6px 0 2px; }
._ul_noindent { list-style: none; padding-left: 0; }
._ul_table_of_contents li { margin: 1px 0; }
._ul_table_of_contents ul { padding-left: 18px; }

/* equations */
._eqn_latex { overflow-x: auto; padding: 4px 0; }
._eqn_defn { color: var(--ink-soft); font-style: italic; }
._where { color: var(--ink-soft); }

/* figures */
._table_img_container { margin: 24px auto; }
._table_img_container td { text-align: center; }
._table_img_container_interior { text-align: center; margin: 0 auto; }
._text_center { text-align: center; }
._table_img { max-width: 100%; margin: 0 auto; }
._table_img td, ._table_img_container td, ._table_img_container_interior td { border: none; }
._table_caption { font-size: .9rem; color: var(--ink-soft); margin-top: 6px; text-align: center; }
table._table_caption { margin-left: auto; margin-right: auto; }
._table_caption td { border: none; }
._author { font-size: .82rem; color: var(--ink-soft); }

/* tables */
._table_container { width: 100%; overflow-x: auto; margin: 18px 0; }
table { border-collapse: collapse; margin: 14px 0; font-size: .94rem; }
th, td { padding: 7px 11px; vertical-align: top; }
th { background: var(--accent); color: var(--brand-dark); }
/* 仅数据表格显示边框（_table_img/_table_caption 等布局表格无边框） */
._table_default th, ._table_default td,
._table_container_interior th, ._table_container_interior td,
.table_local th, .table_local td,
.table_mat_properties th, .table_mat_properties td,
.table_mat_characteristics th, .table_mat_characteristics td { border: 1px solid var(--line); }
table._table_default, table._table_container_interior,
table.table_local, table.table_mat_properties { margin-left: auto; margin-right: auto; }
/* 数据表格斑马纹与行悬停 */
._table_default tr:nth-child(even) td,
._table_container_interior tr:nth-child(even) td,
.table_local tr:nth-child(even) td,
.table_mat_properties > tr:nth-child(even) > td,
.table_mat_properties > tbody > tr:nth-child(even) > td { background: var(--bg-soft); }
._table_default tr:hover td,
._table_container_interior tr:hover td,
.table_local tr:hover td { background: var(--accent); }
._table_var_description td { border: none; padding: 2px 8px; }
._table_var_description tr:hover td { background: transparent; }
._table_divider td { background: var(--bg-soft); font-weight: 600; }

/* glossary */
._dict_link { text-decoration: none; }
._li_topic { margin: 2px 0; }
._title_book { font-style: italic; }
._no_link { color: var(--ink-soft); text-decoration: line-through; }

/* image lightbox */
main.content img.zoomable { cursor: zoom-in; }
#img-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  background: rgba(10, 14, 20, .88); cursor: zoom-out;
}
#img-lightbox.open { display: flex; }
#img-lightbox img {
  max-width: 92vw; max-height: 92vh; background: #fff; padding: 6px;
  cursor: grab; user-select: none; -webkit-user-drag: none;
  transform-origin: center center;
}
#img-lightbox img.dragging { cursor: grabbing; }
#img-lightbox .lb-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.75); font-size: .82rem; pointer-events: none;
}

/* footer */
.site-footer {
  border-top: 1px solid var(--line); background: var(--bg-soft);
  color: var(--ink-soft); font-size: .85rem;
  padding: 18px 20px; text-align: center;
}
.site-footer a { color: var(--brand); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: static; flex: none; width: 100%; max-height: none;
    display: none;
  }
  body.nav-open .sidebar { display: block; }
  #sidebar-toggle {
    display: inline-block; border: 1px solid rgba(255,255,255,.55);
    background: transparent; color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  }
  main.content { max-width: 100%; }
  /* 表格可横向滚动，防止溢出裁切 */
  main.content table { display: block; overflow-x: auto; max-width: 100%; }
  /* 多图并排布局改为纵向堆叠 */
  ._table_img_container_interior > tbody > tr > td,
  ._table_img_container_interior td { display: block; width: 100% !important; }
  ._table_img_container_interior colgroup col { width: 100% !important; }
}
