:root {
  --maxw: 860px;
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #0969da;
  --accent-strong: #0757b3;
  --accent-soft: #eaf2ff;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.07);
  --shadow-md: 0 6px 16px rgba(16,24,40,.10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: #cfe3ff; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

/* 顶部导航（毛玻璃吸顶） */
header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,.9);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(16,24,40,.04);
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
header.top .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
header.top h1 { font-size: 1.05rem; margin: 0; font-weight: 700; }
header.top h1 a { color: var(--text); }
header.top h1 a:hover { text-decoration: none; color: var(--accent-strong); }
header.top .sub { color: var(--muted); font-size: 0.82rem; }

main.wrap { padding: 28px 20px 64px; }

.back { display: inline-block; margin: 0 0 16px; font-size: 0.9rem; font-weight: 500; }

h1.page-title { font-size: 1.7rem; line-height: 1.35; margin: 0 0 10px; font-weight: 800; letter-spacing: -0.02em; }

.meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  letter-spacing: 0.03em;
}
.badge.en { background: var(--accent); }
.badge.fr { background: #16a34a; }

/* 视频自适应 16:9 */
.video {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  margin: 0 0 1.4em;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.video iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* 表格：卡片式圆角，强制自适应不横向滚动（关键修复） */
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.3em 0;
  font-size: 0.94rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
th, td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
}
th { background: #f4f6f8; font-weight: 600; color: #334155; }
tbody tr:nth-child(even) { background: #fafbfc; }
tr:last-child td { border-bottom: none; }
th:last-child, td:last-child { border-right: none; }
thead th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
thead th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius) - 1px); }
tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius) - 1px); }

/* <mark> 高亮 + 点击切换（默写句架） */
mark {
  background: #ffe58f;
  padding: 0 3px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
mark.hidden { background: #d0d7de; color: transparent; }

h2 { font-size: 1.35rem; margin: 2em 0 0.8em; font-weight: 700; }
h3 { font-size: 1.18rem; margin: 1.9em 0 0.7em; padding-bottom: 7px; border-bottom: 2px solid var(--accent-soft); font-weight: 700; }
h4 { font-size: 1rem; margin: 1.5em 0 0.5em; font-weight: 700; color: #0b4a8f; }
blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: var(--card);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  box-shadow: var(--shadow);
}

/* 首页：筛选栏 */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.lang-group { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--card); }
.lang-btn { border: 0; background: transparent; color: var(--muted); padding: 7px 16px; font-size: 0.9rem; cursor: pointer; font-weight: 600; }
.lang-btn.active { background: var(--accent); color: #fff; }
#search {
  flex: 1; min-width: 180px; padding: 8px 14px; font-size: 0.92rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 分类 chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 5px 12px; border-radius: 999px; font-size: 0.82rem; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: #c7d6ec; }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }

/* 卡片网格 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: #c7d6ec; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-top { display: flex; align-items: center; gap: 8px; }
.tag { font-size: 0.72rem; color: var(--muted); background: #f0f2f5; padding: 2px 8px; border-radius: 6px; }
.card-title { font-size: 0.98rem; font-weight: 600; color: var(--text); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title:hover { color: var(--accent-strong); text-decoration: none; }
.card-meta { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; color: var(--muted); }
.card-chan { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-date { white-space: nowrap; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* 内页：左边栏布局 */
.layout { max-width: 1180px; margin: 0 auto; display: flex; align-items: flex-start; }
.sidebar {
  width: 264px; flex-shrink: 0;
  position: sticky; top: 56px; height: calc(100vh - 56px);
  overflow-y: auto; padding: 18px 10px 40px; border-right: 1px solid var(--border);
}
.sidebar .back { display: block; margin: 0 0 12px 6px; }
#sideSearch {
  width: 100%; padding: 8px 12px; font-size: 0.9rem; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); outline: none;
}
#sideSearch:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.side-group {
  font-size: 0.75rem; font-weight: 700; color: var(--muted);
  padding: 14px 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; color: var(--text); font-size: 0.88rem; line-height: 1.4;
}
.nav-link .badge { flex-shrink: 0; }
.nav-link span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nav-link:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

.content { flex: 1 1 auto; min-width: 0; padding: 28px 32px 64px; }

.nav-toggle {
  display: none; border: 0; background: transparent; color: var(--text);
  font-size: 1.3rem; cursor: pointer; padding: 4px 8px; border-radius: 8px; line-height: 1;
}
.nav-toggle:hover { background: #f0f2f5; }

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: 280px;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 60;
    background: var(--card); box-shadow: var(--shadow-md); border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: translateX(0); }
  .overlay { position: fixed; inset: 0; background: rgba(15,23,42,.4); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50; }
  body.nav-open .overlay { opacity: 1; pointer-events: auto; }
  .nav-toggle { display: inline-block; }
  .content { padding: 20px 16px 56px; }
}
@media (min-width: 901px) {
  .overlay { display: none; }
}
