:root {
  --brand: #2563eb;
  --brand-deep: #1d4ed8;
  --brand-soft: #e8f0fe;
  --ink: #1f2329;
  --text: #4e5969;
  --muted: #6b7280;
  --bg: #f1f4f8;
  --line: #e8eaee;
  --line-strong: #d8dbe1;
  --radius: 12px;
  --shadow-pop: 0 10px 28px rgba(31, 35, 41, 0.12);
  --font: "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: #f3f6fb;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }

::selection { background: rgba(37, 99, 235, 0.18); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d3d7dd; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b8bdc5; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

.brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
  margin: 0 auto;
}

.search-box .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 12px 0 34px;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: all 0.15s;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:hover { border-color: var(--line-strong); }
.search-box input:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  max-height: 320px;
  overflow: auto;
  z-index: 60;
  padding: 6px;
}

.search-results a {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--ink);
  transition: background 0.12s;
}
.search-results a:hover { background: var(--bg); color: var(--brand-deep); }
.search-results .empty { padding: 14px; color: var(--muted); font-size: 13px; text-align: center; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28); }

.btn-admin { color: #b45309; border-color: #f0c98e; background: #fffaf0; }
.btn-admin:hover { border-color: #b45309; color: #92400e; background: #fff4df; }

.btn-danger { color: #d5484f; border-color: #ecc9cb; }
.btn-danger:hover { background: #fdf1f1; border-color: #d5484f; color: #d5484f; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  justify-content: center;
}
.btn-icon svg { vertical-align: middle; }

.user-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.user-box em {
  font-style: normal;
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 8px;
}
.user-box em.role-admin { color: #1d4ed8; background: #e8f0fe; }
.user-box em.role-editor { color: #047857; background: #e7f6ef; }
.user-box em.role-member { color: #6d28d9; background: #f1ebfe; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  width: 100%;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.sidebar {
  width: 276px;
  flex: 0 0 276px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 14px 10px 24px;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.side-head {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.1em;
  padding: 4px 10px 8px;
}

.tree { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.cat { margin-bottom: 6px; }

.cat-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
  letter-spacing: 0.02em;
  padding: 14px 10px 7px;
}

.cat-ico {
  font-size: 12px;
  opacity: 0.9;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 12px 9px 18px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  font-size: 14.5px;
  color: #3f4753;
  line-height: 1.45;
  position: relative;
  transition: all 0.12s;
}
.tree-item:hover { background: #f1f4f8; color: var(--ink); }
.tree-item.active {
  background: #e8f0fe;
  color: #1d4ed8;
  font-weight: 600;
}
.tree-item.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 3px;
  background: #2563eb;
}
.tree-item.active .lock { background: #dbe7ff; color: #1d4ed8; }

.tree-item .lock {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: #e9ebee;
  border-radius: 999px;
  padding: 0 7px;
}

.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: #f3f6fb;
  padding: 32px 36px 40px;
  display: flex;
  flex-direction: column;
}

#main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.site-footer {
  max-width: none;
  margin: 32px 0 0;
  width: 100%;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--brand); }

/* ---------- Doc view ---------- */
.doc-view {
  max-width: none;
  margin: 0;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  padding: 28px 40px 36px;
  flex: 1 0 auto;
  min-height: calc(100vh - 210px);
}

.doc-head {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 0 20px;
  margin-bottom: 28px;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-deep);
  background: var(--brand-soft);
  border: 1px solid #d7e5ff;
  border-radius: 999px;
  padding: 3px 12px;
  margin-bottom: 12px;
}
.crumb b { color: var(--brand); font-weight: 600; }
.crumb span { color: var(--muted); }

.doc-head h1 {
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.015em;
  margin-bottom: 10px;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}

.doc-meta .badge {
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11px;
  font-weight: 500;
}
.badge.public { background: var(--brand-soft); color: var(--brand-deep); }
.badge.member { background: #fdf3e3; color: #a05e03; }
.badge.admin { background: #fdecec; color: #c93036; }

.doc-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.doc-actions .btn svg { vertical-align: -2px; }

.doc-body {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  flex: 1;
  justify-content: center;
}

.markdown { flex: 1; min-width: 0; max-width: 880px; }

.toc {
  flex: 0 0 176px;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  padding-left: 16px;
}
.toc-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}
.toc a {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.12s;
}
.toc a:hover { color: var(--brand-deep); background: var(--brand-soft); }
.toc a.level-3 { padding-left: 18px; }

/* ---------- Markdown ---------- */
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.45;
  scroll-margin-top: 76px;
}
.markdown h1 { font-size: 25px; margin: 1.6em 0 0.6em; }
.markdown h2 {
  font-size: 21px;
  margin: 1.8em 0 0.7em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.markdown h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 46px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, #2f7cf6, #2563eb);
}
.markdown h3 { font-size: 17px; margin: 1.6em 0 0.6em; }
.markdown h4 { font-size: 15px; margin: 1.4em 0 0.5em; }
.markdown p { margin: 0.8em 0; }
.markdown a:hover { text-decoration: underline; }
.markdown strong { color: var(--ink); font-weight: 600; }

.markdown code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: #f2f3f5;
  border-radius: 4px;
  padding: 1px 5px;
  color: #c0341d;
}

.markdown pre { background: transparent; padding: 0; margin: 0; overflow-x: auto; }
.code-block {
  background: #282c34;
  border-radius: 12px;
  margin: 1.1em 0;
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: #21252b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #8f959e;
}
.code-lang {
  font-family: var(--mono);
  text-transform: lowercase;
  color: #aeb6c2;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #b9c2cc;
  border-radius: 5px;
  padding: 2px 9px;
  font-size: 12px;
  transition: all 0.15s;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.copy-btn.copied { background: #2ea05a; border-color: #2ea05a; color: #fff; }

.markdown pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: #abb2bf;
  font-size: 13px;
  line-height: 1.7;
  display: block;
  padding: 15px 18px;
  font-family: var(--mono);
}

.markdown blockquote {
  border-left: 3px solid #d0d7e2;
  background: #f6f8fa;
  border-radius: 0 6px 6px 0;
  padding: 10px 16px;
  margin: 1.1em 0;
  color: #57606a;
}
.markdown blockquote p { margin: 0.3em 0; }
.markdown ul, .markdown ol { margin: 0.8em 0; padding-left: 1.6em; }
.markdown li { margin: 0.3em 0; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.markdown img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin: 0.8em 0;
}
.markdown .md-table-wrap { overflow-x: auto; margin: 1.1em 0; border: 1px solid var(--line); border-radius: 8px; }
.markdown table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.markdown th, .markdown td { border-bottom: 1px solid var(--line); padding: 9px 13px; text-align: left; }
.markdown th {
  background: #f6f8fa;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.markdown tbody tr:last-child td { border-bottom: 0; }
.markdown tbody tr:hover td { background: #fafbfc; }

/* ---------- Welcome ---------- */
.welcome {
  max-width: none;
  margin: 0;
  width: 100%;
  padding: 40px 0 20px;
  text-align: center;
}
.welcome .w-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--brand-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.welcome h2 { font-size: 24px; font-weight: 700; color: var(--ink); margin-bottom: 6px; letter-spacing: -0.01em; }
.welcome .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 34px; }

.welcome-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
}
.welcome-cat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 40px 36px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.welcome-cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.welcome-cat-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 18px;
}
.welcome-cat-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  transition: all 0.12s;
}
.welcome-cat-links a:hover { background: var(--brand-soft); color: var(--brand-deep); }
.welcome-cat-links .link-arrow {
  color: var(--muted);
  font-size: 14px;
  opacity: 0.6;
  flex: 0 0 auto;
}

/* ---------- Login ---------- */
.login-page {
  min-height: calc(100vh - 56px - 220px);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}
.login-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 860px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.login-hero {
  background: linear-gradient(160deg, #2f7cf6 0%, #2563eb 45%, #1e3a8a 100%);
  color: #fff;
  padding: 46px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
.login-hero-logo { height: 34px; width: auto; align-self: flex-start; }
.login-hero h2 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-top: 14px;
}
.login-hero p { color: rgba(255, 255, 255, 0.78); font-size: 13.5px; }
.login-hero ul { list-style: none; margin-top: 14px; }
.login-hero li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  margin: 9px 0;
}
.login-hero .tick {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex: 0 0 auto;
}

.login-form { padding: 46px 42px; }
.login-form h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.login-form .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
.field-input { position: relative; }
.field-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.field-input input { padding-left: 38px !important; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: all 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.field textarea { resize: vertical; line-height: 1.6; }

.err { color: #d5484f; font-size: 13px; margin-top: 10px; text-align: center; }
.login-tip { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }

/* ---------- Editor ---------- */
.editor-wrap { max-width: none; margin: 0; width: 100%; }
.editor-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.editor-tabs button {
  border: 0;
  background: transparent;
  padding: 9px 16px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.editor-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

.editor-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 40px 36px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.editor-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.editor-area { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.editor-area textarea {
  width: 100%;
  height: 60vh;
  min-height: 380px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fbfcfd;
  color: var(--ink);
  resize: vertical;
}
.preview-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 20px 20px;
  background: #fff;
  overflow-y: auto;
  height: 60vh;
  min-height: 380px;
}
.editor-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.editor-actions .spacer { flex: 1; }
.editor-hint { font-size: 12px; color: var(--muted); }

/* ---------- Admin ---------- */
.admin-wrap { max-width: none; margin: 0; width: 100%; }
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.admin-tabs button {
  border: 0;
  background: transparent;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.admin-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

.admin-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 40px 36px;
  height: calc(100vh - 250px);
  min-height: 430px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.admin-panel h2 { font-size: 17px; font-weight: 700; color: var(--ink); margin: 0; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.scroll-area {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  margin-top: 6px;
}
.scroll-area table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f8fa;
}
.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 11px 14px; text-align: left; }
.table th { color: var(--muted); font-weight: 500; font-size: 12.5px; background: #f7f8fa; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfc; }

.perm-note {
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 16px;
}

.perm-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  margin-right: 6px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.check-grid .chk {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.12s;
}
.check-grid .chk:hover { background: #f1f4f8; }
.check-grid .chk input { accent-color: var(--brand); width: 15px; height: 15px; }

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}
.inline-form input, .inline-form select {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 11px;
  font-size: 13px;
  background: #fff;
  outline: none;
}
.inline-form input:focus, .inline-form select:focus { border-color: var(--brand); }
.inline-form input[type="text"] { min-width: 160px; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 41, 0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.modal p { font-size: 13.5px; color: var(--text); margin-bottom: 18px; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Print / PDF ---------- */
@media print {
  @page { margin: 14mm 12mm; }
  body { background: #fff; }
  .topbar, .sidebar, .doc-actions, .search-box, .icon-btn, .topbar-actions, .modal-mask, .toc { display: none !important; }
  .site-footer { display: none !important; }
  .layout { display: block; height: auto; overflow: visible; }
  .main { padding: 0; overflow: visible; background: #fff; display: block; }
  .doc-view { max-width: none; }
  .doc-head { border-bottom: 1.5px solid var(--ink); }
  .doc-head h1 { font-size: 24px; }
  .doc-body { display: block; }
  .markdown { max-width: none; }
  .markdown pre { white-space: pre-wrap; word-break: break-word; }
  .code-block { background: #f4f5f7; border: 1px solid #d8dbe1; break-inside: avoid; }
  .code-head { background: #eceef1; border-bottom: 1px solid #d8dbe1; color: var(--text); }
  .copy-btn { display: none !important; }
  .markdown pre code { color: var(--ink); font-size: 11px; padding: 10px 12px; }
  .markdown a { color: var(--brand-deep); text-decoration: underline; }
  .markdown img { max-width: 100%; }
  .markdown table { font-size: 12px; }
  .markdown .md-table-wrap { overflow: visible; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .toc { display: none; }
  .main { padding: 36px 32px 100px; }
}

@media (max-width: 900px) {
  .icon-btn { display: inline-flex; }
  .layout { height: calc(100vh - 56px); }
  .main { padding: 26px 20px 40px; }
  .doc-view, .editor-card, .admin-panel, .welcome-cat { padding: 24px 28px 30px; }
  .search-box { max-width: none; }
  .brand-logo { height: 30px; }
  .editor-area { grid-template-columns: 1fr; }
  .editor-area textarea, .preview-pane { height: 45vh; min-height: 260px; }
  .editor-form .field-row { grid-template-columns: 1fr; }
  .doc-head h1 { font-size: 26px; }
  .doc-head { padding: 0 0 18px; }
  .login-hero { display: none; }
  .login-panel { grid-template-columns: 1fr; max-width: 420px; }
  .login-form { padding: 34px 30px; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    height: auto;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
    width: 280px;
    flex-basis: 280px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-pop); }
}

@media (max-width: 640px) {
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .brand-text { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { padding: 5px 8px; font-size: 12px; }
  .btn-label { display: none; }
  .user-box { display: none; }
  #manageBtn { display: none !important; }
  .main { padding: 20px 14px 40px; }
  .doc-view, .editor-card, .admin-panel, .welcome-cat { padding: 18px 16px 28px; border-radius: 12px; }
  .doc-head h1 { font-size: 23px; }
  .doc-head { padding: 0 0 14px; }
  .doc-meta { gap: 8px; }
  .doc-actions { width: 100%; margin-left: 0; }
  .markdown pre code { font-size: 12px; padding: 12px 14px; }
  .markdown h2 { font-size: 19px; }
  .markdown h3 { font-size: 16px; }
  .login-page { min-height: auto; padding: 20px 0; }
  .login-form { padding: 26px 20px; }
  .admin-panel, .editor-card { padding: 14px; }
  .table { font-size: 12.5px; }
  .welcome { padding: 24px 0 10px; }
  .welcome-cat-links { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr !important; }
}
