:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.global-search { flex: 1; }

.global-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.global-search input:focus { border-color: var(--primary); }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  transition: border-color .2s, color .2s, background .2s, box-shadow .2s, transform .2s;
  user-select: none;
  -webkit-user-select: none;
}

.lang-toggle .lang-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--primary);
  transition: transform .25s ease;
}

.lang-toggle span {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  letter-spacing: .5px;
}

.lang-toggle:hover .lang-icon { transform: rotate(180deg); }

.lang-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .18);
  transform: translateY(-1px);
}

.lang-toggle:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(37, 99, 235, .12);
}

.lang-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- List view ---------- */
.meeting-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s, transform .15s;
}

.meeting-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }

.meeting-card .mc-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.meeting-card .mc-meta { font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.meeting-card .mc-snippet { font-size: 13px; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

/* ---------- Form view ---------- */
.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 860px;
  margin: 0 auto;
}

.form-card h1 { margin-top: 0; font-size: 20px; }

.field { margin-bottom: 16px; }

.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }

.field input[type="text"],
.field input[type="date"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.field textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.field textarea.tall { min-height: 260px; }

.field input:focus, .field textarea:focus { border-color: var(--primary); }

.field .hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.form-actions { display: flex; gap: 12px; margin-top: 20px; }

/* ---------- Detail view ---------- */
.detail-head { margin-bottom: 16px; }

.detail-head h1 { margin: 0 0 6px; font-size: 24px; }

.detail-meta { color: var(--text-light); font-size: 14px; }

.detail-actions { display: flex; gap: 12px; margin: 16px 0; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 24px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .tag {
  font-size: 12px;
  font-weight: 500;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
}

/* A4 sheet for pre-meeting material (五号字 = 10.5pt) */
.a4-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 20mm 22mm;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  font-size: 10.5pt;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.post-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.post-content h1, .post-content h2, .post-content h3 { margin: 1.2em 0 .5em; }
.post-content p { margin: .6em 0; }
.post-content pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
}
.post-content code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 13px; }
.post-content blockquote { border-left: 4px solid var(--border); margin: .6em 0; padding-left: 12px; color: var(--text-light); }
.post-content img { max-width: 100%; }
.post-content table { border-collapse: collapse; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 6px 10px; }

/* KaTeX */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ---------- Print: only the A4 pre-material sheets ---------- */
@page { size: A4; margin: 0; }

@media print {
  body { margin: 0; background: #fff; }
  /* 杂项不占位：display:none 而非 visibility，避免把 A4 纸推挤出页 */
  .site-header, .detail-head, .detail-actions,
  .section-title, .empty-tip, .post-content { display: none !important; }
  .container { max-width: none; padding: 0; margin: 0; }
  /* 每个 .a4-page 精确占满一页，页内禁止溢出再切页 */
  .a4-page {
    width: 210mm;
    height: 297mm;
    min-height: 0;
    margin: 0;
    padding: 20mm 22mm;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
  }
  .a4-page:last-child { break-after: auto; page-break-after: auto; }
}

@media (max-width: 640px) {
  .site-header-inner { flex-wrap: wrap; }
  .brand { flex: 1 1 100%; }
  /* 分页基准与打印保持一致：A4 宽度与 padding 不随视口变化，窄屏横向滚动 */
  #pre-content { overflow-x: auto; }
  .a4-page { width: 210mm; padding: 20mm 22mm; font-size: 10.5pt; }
}
