:root {
  --bg: #eef6ef;
  --paper: #fafffa;
  --ink: #1a2e1f;
  --muted: #5a7260;
  --line: #cfe0d2;
  --accent: #2d7a4f;
  --accent-soft: #dff0e4;
  --shadow: 0 8px 32px rgba(26, 46, 31, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top, #f4fbf5 0%, var(--bg) 45%);
  color: var(--ink);
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 255, 250, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

header .meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button, .btn {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.15s ease;
}

button:hover, .btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  filter: brightness(1.05);
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1280px;
  margin: 0 auto;
}

aside {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
  align-self: start;
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
}

aside h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.module-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.35rem;
}

.module-item.active,
.module-item:hover {
  background: var(--accent-soft);
}

.module-item .title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

.module-item .cat {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

main {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  min-height: 60vh;
}

.module-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.module-head .usage {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-box input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  font-size: 1rem;
  background: #fff;
}

.entry-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  background: #fff;
}

.entry-card h3 {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 1.1rem;
}

.entry-card p {
  margin: 0;
  line-height: 1.75;
  font-size: 0.98rem;
}

.text-body {
  line-height: 1.85;
  white-space: pre-wrap;
  font-size: 1rem;
}

.slice-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: -0.35rem 0 1rem;
}

.slice-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  background: #fff;
}

.slice-card h3 {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 1.08rem;
}

.slice-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.slice-tag {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.slice-content {
  margin: 0;
  line-height: 1.75;
  white-space: pre-wrap;
  font-size: 0.98rem;
}

.slice-figure {
  margin: 0.85rem 0 0;
  text-align: center;
}

.slice-figure img {
  max-width: min(100%, 520px);
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 3rem 1rem;
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 560px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.15);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.12);
}

dialog::backdrop {
  background: rgba(26, 46, 31, 0.35);
}

.dialog-inner {
  padding: 1.25rem 1.5rem 1.5rem;
}

.dialog-inner h3 {
  margin: 0 0 1rem;
}

.field {
  margin-bottom: 0.85rem;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font: inherit;
}

.field textarea {
  min-height: 160px;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.show { opacity: 1; }

.hidden { display: none !important; }

.pdf-render-host {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 190mm;
  pointer-events: none;
  z-index: -1;
}

.pdf-export {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1a2e1f;
  font-size: 11pt;
  line-height: 1.7;
  background: #fff;
}

.pdf-export h1 {
  margin: 0 0 0.35rem;
  font-size: 20pt;
  color: #2d7a4f;
}

.pdf-export h2 {
  margin: 1.2rem 0 0.5rem;
  font-size: 14pt;
  color: #2d7a4f;
  page-break-before: always;
}

.pdf-export h2:first-of-type {
  page-break-before: auto;
}

.pdf-export h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 12pt;
  color: #1a2e1f;
}

.pdf-export p {
  margin: 0 0 0.55rem;
}

.pdf-meta {
  color: #5a7260;
  font-size: 9.5pt;
}

.pdf-block {
  margin-bottom: 0.75rem;
  page-break-inside: avoid;
}

.pdf-body {
  white-space: pre-wrap;
}

.pdf-figure {
  margin: 0.5rem 0 0;
  text-align: center;
}

.pdf-figure img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: static; max-height: none; }
}

.hidden {
  display: none !important;
}

/* 密码门禁 */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at top, #f4fbf5 0%, var(--bg) 45%);
}

.gate-card {
  width: min(22rem, 92vw);
  padding: 2rem 1.5rem 1.75rem;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-logo {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #3d9a62, var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.gate-title {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  color: var(--ink);
}

.gate-hint {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.gate-pins {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
}

.gate-pin {
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gate-pin:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-error {
  margin: 1rem 0 0;
  color: #c0392b;
  font-size: 0.88rem;
  display: none;
}

.gate-error.show {
  display: block;
}

.gate.shake .gate-card {
  animation: gate-shake 0.42s ease;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.btn-logout {
  color: #8b3a3a;
  border-color: rgba(192, 57, 43, 0.25);
  background: #fff8f8;
}

.btn-logout:hover {
  border-color: #c0392b;
  background: #fdecea;
  color: #a93226;
}
