:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #17212b;
  --muted: #6b7684;
  --line: #e2e8f0;
  --brand: #13c7de;
  --brand-2: #8756ff;
  --brand-dark: #1267d8;
  --danger: #d92d20;
  --success: #07833f;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
  --bg-spot: rgba(19, 199, 222, 0.08);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f1722;
  --panel: #151f2b;
  --panel-soft: #1c2836;
  --text: #edf4fb;
  --muted: #a8b5c5;
  --line: #304055;
  --brand: #31d4e8;
  --brand-2: #9b7cff;
  --brand-dark: #62b6ff;
  --danger: #fb7185;
  --success: #34d399;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --bg-spot: rgba(49, 212, 232, 0.08);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-spot), transparent 28rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--brand-dark);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.primary-button,
.secondary-button,
.link-button,
.text-button,
.status,
.user-nav,
th {
  white-space: nowrap;
  word-break: keep-all;
}

.auth-shell {
  min-height: 100vh;
  background: var(--bg);
}

html[data-theme="dark"] .auth-shell {
  background: var(--bg);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 18px;
  background:
    linear-gradient(135deg, rgba(19, 199, 222, 0.12), rgba(135, 86, 255, 0.1)),
    #f8fbff;
}

html[data-theme="dark"] .auth-page {
  background:
    linear-gradient(135deg, rgba(49, 212, 232, 0.08), rgba(155, 124, 255, 0.08)),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  padding: 38px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .auth-card {
  background: rgba(21, 28, 38, 0.94);
  border-color: var(--line);
}

.auth-logo {
  width: 280px;
  max-width: 100%;
  height: auto;
  display: block;
  margin-bottom: 28px;
  filter: drop-shadow(0 6px 14px rgba(19, 199, 222, 0.12));
}

.auth-heading p,
.page-header p,
.article-kicker {
  margin: 0 0 8px;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 14px;
}

.auth-heading h1,
.page-header h1,
.article h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.2;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.form-stack label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

html[data-theme="dark"] .form-stack label,
html[data-theme="dark"] .editor-form label,
html[data-theme="dark"] .advanced-fields summary {
  color: #d7e0ea;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid #cad5e2;
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select {
  width: 100%;
  height: 44px;
  border: 1px solid #cad5e2;
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(18, 103, 216, 0.12);
}

input.invalid {
  border-color: #e11d48;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.1);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 68px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  height: 30px;
  padding: 0 10px;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.field-hint {
  min-height: 20px;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.field-hint.error {
  color: #be123c;
}

.field-hint.success {
  color: var(--success);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #0f1720;
  border-color: #334155;
  color: var(--text);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  padding: 0 18px;
  line-height: 1;
}

.link-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
}

.link-button {
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  line-height: 1;
}

html[data-theme="dark"] .secondary-button,
html[data-theme="dark"] .icon-button {
  background: #1d2a3a;
  border-color: #3a4b63;
  color: var(--text);
}

.auth-switch {
  margin: 22px 0 0;
  color: var(--muted);
}

.alert,
.notice {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.notice {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.topbar {
  height: 68px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 300px) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.public-topbar {
  grid-template-columns: minmax(210px, 300px) minmax(0, 1fr) auto;
}

.public-topbar-spacer {
  min-width: 0;
}

.public-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.public-nav > a:not(.primary-button) {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: #334155;
  font-weight: 800;
}

html[data-theme="dark"] .public-nav > a:not(.primary-button) {
  color: #d7e0ea;
}

.public-main {
  min-height: calc(100vh - 68px);
  padding: 44px min(7vw, 96px) 80px;
}

html[data-theme="dark"] .topbar {
  background: rgba(18, 27, 39, 0.96);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 900;
  min-width: 0;
}

.brand img {
  width: 188px;
  max-width: 100%;
  height: auto;
  display: block;
}

.brand-product {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid #dbe6f1;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

html[data-theme="dark"] .brand-product,
html[data-theme="dark"] .user-nav > a,
html[data-theme="dark"] .nav-menu summary,
html[data-theme="dark"] .account-menu summary {
  background: #1d2a3a;
  border-color: var(--line);
  color: var(--text);
}

.menu-toggle {
  display: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.top-search input {
  background: #f8fafc;
}

html[data-theme="dark"] .top-search input {
  background: #121d2a;
  border-color: #3a4b63;
  color: var(--text);
}

.top-search {
  min-width: 0;
}

.user-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}

.user-nav form {
  margin: 0;
}

.user-nav button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  cursor: pointer;
  padding: 0;
  font-weight: 800;
  line-height: 1.2;
}

.user-nav > a,
.user-nav button,
.nav-menu summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
}

.user-nav > a,
.nav-menu summary {
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-weight: 800;
}

.user-nav > a.top-nav-link {
  background: transparent;
  border-color: transparent;
  color: #475569;
}

.user-nav > a.top-nav-link:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: var(--brand-dark);
}

.user-nav > a.top-nav-link.active {
  background: #eef7fb;
  border-color: rgba(18, 103, 216, 0.16);
  color: #0f8ca2;
}

html[data-theme="dark"] .user-nav > a.top-nav-link {
  color: #cbd5e1;
}

html[data-theme="dark"] .user-nav > a.top-nav-link:hover,
html[data-theme="dark"] .user-nav > a.top-nav-link.active {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--brand);
}

.user-nav button {
  color: var(--brand-dark);
}

.user-name {
  max-width: 116px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu {
  position: relative;
}

.nav-menu summary {
  cursor: pointer;
  list-style: none;
}

.nav-menu summary::-webkit-details-marker {
  display: none;
}

.nav-menu[open] summary {
  border-color: rgba(18, 103, 216, 0.35);
  background: #eff6ff;
  color: var(--brand-dark);
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: grid;
  min-width: 150px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.14);
}

html[data-theme="dark"] .nav-menu-panel {
  background: #172231;
}

.nav-menu-panel a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  color: #334155;
  font-weight: 800;
}

html[data-theme="dark"] .nav-menu-panel a,
html[data-theme="dark"] .doc-tree summary,
html[data-theme="dark"] .doc-tree a {
  color: #d7e0ea;
}

.nav-menu-panel a:hover {
  background: #f1f5f9;
  color: var(--brand-dark);
}

html[data-theme="dark"] .nav-menu-panel a:hover {
  background: var(--panel-soft);
}

.account-menu {
  position: relative;
}

.account-menu summary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 4px 10px 4px 6px;
  border: 1px solid #dbe6f1;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  list-style: none;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-menu[open] summary {
  border-color: rgba(18, 103, 216, 0.32);
  background: #eef7fb;
}

html[data-theme="dark"] .account-menu[open] summary {
  border-color: rgba(98, 182, 255, 0.45);
  background: #223247;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.user-avatar.large {
  width: 46px;
  height: 46px;
  font-size: 17px;
}

.account-summary-name {
  max-width: 96px;
  overflow: hidden;
  color: var(--text);
  font-weight: 900;
  text-overflow: ellipsis;
}

.account-caret {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.account-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 45;
  min-width: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 48px rgba(17, 24, 39, 0.16);
}

html[data-theme="dark"] .account-menu-panel {
  background: #172231;
  border-color: #3a4b63;
}

.account-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.account-card div {
  min-width: 0;
}

.account-card strong,
.account-card span,
.account-card em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-card strong {
  color: var(--text);
  font-size: 15px;
}

.account-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.account-card em {
  width: fit-content;
  margin-top: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

html[data-theme="dark"] .account-card em {
  background: rgba(16, 185, 129, 0.14);
  color: #86efac;
}

.account-menu-section {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.account-menu-section a,
.disabled-menu-item,
.account-logout button {
  display: flex;
  align-items: center;
  min-height: 38px;
  width: 100%;
  padding: 0 10px;
  border-radius: 6px;
  color: #334155;
  font-weight: 800;
  text-align: left;
}

.account-menu-section a:hover,
.account-logout button:hover {
  background: #f1f5f9;
  color: var(--brand-dark);
}

html[data-theme="dark"] .account-menu-section a,
html[data-theme="dark"] .disabled-menu-item,
html[data-theme="dark"] .account-logout button {
  color: #d7e0ea;
}

html[data-theme="dark"] .account-menu-section a:hover,
html[data-theme="dark"] .account-logout button:hover {
  background: var(--panel-soft);
}

.disabled-menu-item {
  color: var(--muted);
  cursor: default;
}

.account-logout {
  margin: 0;
  padding: 8px;
}

.account-logout button {
  border: 0;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
}

html[data-theme="dark"] .account-logout button {
  color: #fb7185;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 224px;
  min-height: calc(100vh - 68px);
}

.sidebar,
.toc {
  position: sticky;
  top: 68px;
  align-self: start;
  height: calc(100vh - 68px);
  overflow: auto;
  background: var(--panel);
}

.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px 16px 18px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-title,
.toc-title {
  color: #475569;
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 14px;
}

html[data-theme="dark"] .sidebar-title,
html[data-theme="dark"] .toc-title {
  color: #cbd5e1;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .toc,
html[data-theme="dark"] .sidebar-footer {
  background: #141e2a;
}

.theme-switcher {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

html[data-theme="dark"] .theme-switcher {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.theme-switcher button {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.theme-switcher button:hover {
  color: var(--text);
}

.theme-switcher button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.12);
}

html[data-theme="dark"] .theme-switcher button.active {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.site-links a:hover,
.doc-tree a:hover {
  background: var(--panel-soft);
}

html[data-theme="dark"] .site-links a.active,
html[data-theme="dark"] .doc-tree a.active {
  color: #f8fbff;
  background: linear-gradient(135deg, rgba(49, 212, 232, 0.18), rgba(155, 124, 255, 0.16));
  border-color: rgba(98, 182, 255, 0.26);
}

.site-links,
.doc-tree,
.doc-tree nav {
  display: grid;
  gap: 4px;
}

.site-links {
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.doc-tree details {
  display: grid;
  gap: 4px;
}

.doc-tree details .doc-tree {
  padding-left: 12px;
}

.site-links a,
.doc-tree summary,
.doc-tree a {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #334155;
  line-height: 1.35;
  min-width: 0;
}

html[data-theme="dark"] .site-links a,
html[data-theme="dark"] .doc-tree summary,
html[data-theme="dark"] .doc-tree a {
  color: #d5dee9;
}

html[data-theme="dark"] .doc-tree summary::before {
  border-color: #8da2ba;
}

html[data-theme="dark"] .site-links a:hover,
html[data-theme="dark"] .doc-tree a:hover {
  background: #1d2a3a;
  color: #f8fbff;
}

.doc-tree summary {
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.doc-tree summary::-webkit-details-marker {
  display: none;
}

.doc-tree summary::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  transform: rotate(-45deg);
  transition: transform 0.16s ease;
}

.doc-tree details[open] > summary::before {
  transform: rotate(45deg);
}

.doc-tree a {
  font-size: 14px;
}

.site-links a {
  font-size: 14px;
  font-weight: 800;
}

.tree-emoji {
  flex: 0 0 auto;
}

.tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-links a.active,
.doc-tree a.active {
  background: linear-gradient(135deg, rgba(19, 199, 222, 0.12), rgba(135, 86, 255, 0.13));
  color: #0f172a;
  font-weight: 800;
}

.main-content {
  min-width: 0;
  padding: 44px min(5vw, 72px) 80px;
}

.article,
.search-page,
.admin-page,
.editor-page,
.empty-state {
  max-width: 1040px;
  margin: 0 auto;
}

.draft-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 28px;
  padding: 16px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
}

.draft-preview-bar strong {
  display: inline-block;
  margin-left: 8px;
  color: #713f12;
}

.draft-preview-bar p {
  margin: 8px 0 0;
  color: #854d0e;
}

.draft-preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.draft-preview-actions form {
  margin: 0;
}

html[data-theme="dark"] .draft-preview-bar {
  background: rgba(113, 63, 18, 0.22);
  border-color: rgba(245, 158, 11, 0.35);
}

html[data-theme="dark"] .draft-preview-bar strong,
html[data-theme="dark"] .draft-preview-bar p {
  color: #fde68a;
}

.article-summary {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
  margin: 16px 0 0;
}

.page-lead {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
  margin-top: 12px;
}

.video-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin: 22px 0 4px;
  padding: 0 16px;
  border-radius: 6px;
  background: #e8f7fb;
  color: #075985;
  font-weight: 800;
}

.article-body {
  margin-top: 36px;
  color: #273241;
  font-size: 17px;
  line-height: 1.9;
}

html[data-theme="dark"] .article-body {
  color: #d7e0ea;
}

.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5 {
  margin: 38px 0 14px;
  color: #111827;
  line-height: 1.35;
}

html[data-theme="dark"] .article-body h2,
html[data-theme="dark"] .article-body h3,
html[data-theme="dark"] .article-body h4,
html[data-theme="dark"] .article-body h5 {
  color: #f8fafc;
}

.article-body h2 {
  font-size: 28px;
}

.article-body h3 {
  font-size: 23px;
}

.article-body p {
  margin: 16px 0;
}

.article-body img {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  display: block;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

html[data-theme="dark"] .article-body img {
  background: #0f1720;
}

.article-body blockquote {
  margin: 20px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--brand);
  background: #f8fafc;
  color: #475569;
}

.article-callout {
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
  color: #334155;
}

.article-callout-title {
  margin-bottom: 8px;
  color: #0f172a;
  font-weight: 900;
}

.article-callout p {
  margin: 8px 0 0;
}

html[data-theme="dark"] .article-body blockquote,
html[data-theme="dark"] .article-callout,
html[data-theme="dark"] .advanced-fields,
html[data-theme="dark"] .upload-panel,
html[data-theme="dark"] .editor-help {
  background: var(--panel-soft);
}

html[data-theme="dark"] .article-callout {
  border-color: var(--line);
}

html[data-theme="dark"] .article-callout-title {
  color: #f8fafc;
}

.article-body pre {
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  line-height: 1.7;
}

.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.article-body p code,
.article-body li code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #eef2f7;
  color: #0f172a;
}

html[data-theme="dark"] .article-body p code,
html[data-theme="dark"] .article-body li code {
  background: #253244;
  color: #f8fafc;
}

.article-body ul,
.article-body ol {
  padding-left: 1.3em;
}

.article-table {
  margin: 22px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

html[data-theme="dark"] .article-table {
  background: var(--panel);
}

.article-table table {
  min-width: 520px;
}

.article-table th,
.article-table td {
  padding: 12px 14px;
}

.toc {
  border-left: 1px solid var(--line);
  padding: 22px 18px;
}

.toc a,
.toc span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc .toc-level-3 {
  padding-left: 10px;
}

.toc .toc-level-4,
.toc .toc-level-5 {
  padding-left: 20px;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 12px;
  margin-top: 28px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-list {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.result-count {
  color: var(--muted);
  margin: 0 0 4px;
}

.result-card {
  display: block;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.result-card:hover {
  border-color: rgba(18, 103, 216, 0.45);
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.07);
}

.result-card span {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.result-card h2 {
  margin: 8px 0;
  font-size: 20px;
}

.result-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.table-wrap {
  margin-top: 24px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.04);
}

.action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.create-actions {
  gap: 12px;
}

.create-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.04);
}

.create-action-button:hover {
  border-color: rgba(18, 103, 216, 0.45);
  color: var(--brand-dark);
}

.editor-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.dashboard-card {
  display: grid;
  gap: 8px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.dashboard-card span {
  color: var(--brand-dark);
  font-size: 30px;
  font-weight: 900;
}

.dashboard-card strong {
  font-size: 14px;
  white-space: nowrap;
}

.user-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.user-stat-card {
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.user-stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.user-stat-card strong {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.user-stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.inline-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 12px;
  margin-top: 24px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.inline-edit-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.editor-form label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.editor-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.editor-form textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid #cad5e2;
  border-radius: 6px;
  padding: 14px;
  color: var(--text);
  font: 15px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  outline: none;
}

.advanced-fields {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.upload-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.upload-panel p,
.upload-panel span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.upload-panel input[type="file"] {
  height: auto;
  padding: 10px;
}

.advanced-fields summary {
  cursor: pointer;
  padding: 13px 14px;
  color: #334155;
  font-weight: 900;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0 14px 14px;
}

.editor-form textarea:focus {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(18, 103, 216, 0.12);
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-actions .primary-button {
  min-width: 120px;
  padding: 0 16px;
}

.form-actions .secondary-button {
  min-width: 118px;
}

.editor-help {
  margin-top: 18px;
  padding: 18px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.7;
}

.editor-help p {
  margin: 8px 0 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  font-weight: 900;
}

td span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

td strong {
  display: block;
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td > span {
  display: block;
  max-width: 460px;
  line-height: 1.5;
}

.admin-page td:not(:first-child),
.admin-page th:not(:first-child) {
  white-space: nowrap;
}

.table-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
}

.table-actions form {
  margin: 0;
}

.sort-actions {
  gap: 6px;
}

.role-form {
  display: inline-grid;
  grid-template-columns: minmax(128px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.role-form select {
  height: 36px;
  padding: 0 10px;
}

.user-actions {
  align-items: center;
}

.password-reset-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.password-reset-form input {
  width: 136px;
  height: 34px;
  padding: 0 10px;
}

.danger-text {
  color: var(--danger);
}

.deleted-row {
  opacity: 0.72;
}

.status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-weight: 800;
}

.status.active {
  color: var(--success);
  background: #ecfdf3;
}

.status.disabled {
  color: var(--danger);
  background: #fff1f2;
}

.status.draft {
  color: #946200;
  background: #fffbeb;
}

.empty-state {
  padding: 72px 0;
}

.primary-link {
  display: inline-flex;
  margin-top: 18px;
  font-weight: 800;
}

.simple-page {
  max-width: 980px;
  margin: 0 auto;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.dot.green {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.dot.blue {
  background: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}

.about-hero p {
  margin: 0 0 12px;
  color: var(--brand-dark);
  font-weight: 800;
}

.about-hero h1 {
  margin: 0;
  max-width: 820px;
  font-size: clamp(34px, 4.2vw, 48px);
  line-height: 1.18;
}

.about-hero h1 span {
  margin-left: 0.28em;
  color: #0f9fbe;
}

.about-hero .page-lead {
  display: grid;
  gap: 14px;
  margin-top: 26px;
  max-width: 780px;
}

.about-hero .page-lead p {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.85;
}

.about-hero .page-lead p:first-child {
  color: #334155;
  font-size: 18px;
  font-weight: 800;
}

html[data-theme="dark"] .about-hero .page-lead p:first-child {
  color: #d7e0ea;
}

.join-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 56px 0 30px;
  color: var(--muted);
  font-size: 13px;
}

.join-divider::before,
.join-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.contact-card {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 28px 24px 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.contact-card-label {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.contact-card img {
  width: min(250px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.contact-card h2 {
  margin: 2px 0 0;
  font-size: 19px;
  text-align: center;
}

.contact-card p {
  margin: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.wechat-mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.wechat-mark.green {
  background: #12b76a;
}

.wechat-mark.blue {
  background: #2e90fa;
}

html[data-theme="dark"] .contact-card-label {
  color: #d7e0ea;
}

.feedback-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.feedback-form label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

html[data-theme="dark"] .feedback-form label {
  color: #d7e0ea;
}

.feedback-form label span {
  color: var(--muted);
  font-size: 12px;
}

.feedback-form .full-span,
.feedback-form button {
  grid-column: 1 / -1;
}

.feedback-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #cad5e2;
  border-radius: 6px;
  padding: 14px;
  color: var(--text);
  line-height: 1.7;
  outline: none;
}

.open-book-hero {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.open-book-hero p {
  margin: 0 0 10px;
  color: var(--brand-dark);
  font-weight: 800;
}

.open-book-hero h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1.18;
}

.open-book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.disabled-action {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  color: #64748b;
  cursor: not-allowed;
  filter: grayscale(0.28);
  opacity: 0.78;
  pointer-events: none;
}

html[data-theme="dark"] .disabled-action {
  background: linear-gradient(135deg, #253346, #1d2a3a);
  color: #93a4b8;
  opacity: 0.8;
}

.open-book-login-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
}

.open-book-note {
  margin: 24px 0 30px;
  padding: 16px 18px;
  border-left: 4px solid var(--brand-dark);
  background: var(--panel);
  border-radius: 0 8px 8px 0;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.03);
}

html[data-theme="dark"] .open-book-note {
  background: #172231;
  border-left-color: var(--brand-dark);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

.open-book-note strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.open-book-note p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.open-book-list {
  display: grid;
  gap: 18px;
}

.open-book-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.open-book-section-head h2 {
  margin: 0;
  font-size: 22px;
}

.open-book-section-head span {
  color: var(--muted);
  font-weight: 700;
}

.open-book-directory {
  display: grid;
  gap: 10px;
}

.open-book-directory h3 {
  margin: 0;
  color: #334155;
  font-size: 15px;
}

html[data-theme="dark"] .open-book-directory h3 {
  color: #d7e0ea;
}

.open-book-directory > div {
  display: grid;
  gap: 10px;
}

.open-book-item {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.04);
}

html[data-theme="dark"] .open-book-item {
  background: #172231;
  border-color: #35465d;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
}

.open-book-item:hover {
  border-color: rgba(18, 103, 216, 0.35);
  transform: translateY(-1px);
}

html[data-theme="dark"] .open-book-item:hover {
  border-color: rgba(98, 182, 255, 0.46);
  background: #1b2a3c;
}

.open-book-item span {
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.open-book-item h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1.35;
}

.open-book-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.open-book-item strong {
  width: fit-content;
  color: var(--brand-dark);
  font-size: 14px;
}

.feedback-list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.feedback-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.feedback-card-head,
.feedback-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.feedback-card-head time,
.feedback-meta {
  color: var(--muted);
  font-size: 13px;
}

.feedback-card p {
  margin: 14px 0;
  color: var(--text);
  line-height: 1.8;
  white-space: pre-wrap;
}

html[data-theme="dark"] th {
  background: var(--panel-soft);
  color: #cbd5e1;
}

html[data-theme="dark"] .result-card:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) auto;
  }

  .brand-product {
    display: none;
  }

  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0 14px;
  }

  .menu-toggle {
    display: inline-block;
  }

  .brand img {
    width: 148px;
  }

  .brand-product,
  .top-search,
  .user-name,
  .account-summary-name {
    display: none;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 68px;
    left: 0;
    z-index: 30;
    width: min(84vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 16px 0 36px rgba(17, 24, 39, 0.14);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    padding: 28px 18px 64px;
  }

  .article h1,
  .page-header h1 {
    font-size: 28px;
  }

  .search-panel {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .inline-create-form,
  .inline-edit-form {
    grid-template-columns: 1fr;
  }

  .action-header,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .draft-preview-bar,
  .draft-preview-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .create-action-button,
  .draft-preview-actions .primary-button,
  .draft-preview-actions .secondary-button {
    width: 100%;
  }

  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .feedback-form,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .about-hero h1 {
    font-size: 34px;
  }
}

@media (max-width: 520px) {
  .auth-card {
    padding: 24px;
  }

  .auth-logo {
    width: 220px;
  }

  .auth-heading h1 {
    font-size: 28px;
  }

  .user-nav {
    gap: 8px;
  }

  .nav-menu summary,
  .user-nav button {
    padding: 0 8px;
  }

  .account-menu-panel {
    right: -8px;
    min-width: min(86vw, 260px);
  }
}
