:root {
  --bg: #0e0e12;
  --bg-2: #16161d;
  --bg-3: #1e1e28;
  --panel: #1a1a22;
  --line: #2c2c38;
  --text: #ececf1;
  --muted: #9a9aab;
  --accent: #9b97c1;
  --accent-2: #b7b3d9;
  --danger: #e57373;
  --ok: #81c784;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html {
  height: 100%;
  scroll-behavior: smooth;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  flex-shrink: 0;
  padding: 0 16px 0 12px;
  background: var(--accent);
  color: #fff;
  z-index: 40;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  min-width: 0;
}
.topbar-brand:hover { color: #fff; }
.topbar-brand img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #16161d;
}
.topbar-search {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}
.topbar-search input {
  width: 100%;
  background: #1a1a22;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px 9px 36px;
  font: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23cfcfe0' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.topbar-search input::placeholder { color: #9a9aab; }
.topbar-account {
  color: #fff;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.topbar-account:hover { background: rgba(0,0,0,.18); color: #fff; }

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

.app {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}
.brand img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #111;
}
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 15px; }
.brand-text span { color: var(--accent); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.nav { padding: 12px 0 32px; }
.nav-group { margin: 4px 0 10px; }
.nav-section {
  color: #e8e4ff;
  font-size: 15px;
  letter-spacing: .03em;
  padding: 14px 18px 8px;
  font-weight: 800;
  line-height: 1.25;
}
.nav-group.is-active .nav-section {
  color: #fff;
  text-shadow:
    0 0 8px rgba(155, 151, 193, .95),
    0 0 18px rgba(155, 151, 193, .65),
    0 0 32px rgba(155, 151, 193, .35);
}

.nav a {
  display: block;
  color: var(--text);
  padding: 8px 18px 8px 22px;
  border-left: 3px solid transparent;
  font-size: 14px;
  font-weight: 700;
}
.nav a:hover { background: var(--bg-3); color: #fff; }
.nav a.active {
  background: rgba(155, 151, 193, .18);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 800;
  text-shadow:
    0 0 8px rgba(155, 151, 193, .95),
    0 0 18px rgba(155, 151, 193, .65),
    0 0 28px rgba(155, 151, 193, .4);
}

.page-layout {
  display: flex;
  align-items: stretch;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.toc {
  width: 280px;
  flex-shrink: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: #121218;
  padding: 18px 8px 48px 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.toc::-webkit-scrollbar { width: 0; height: 0; display: none; }
.toc-title {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 700;
  padding: 4px 10px 14px 12px;
}
.toc a.toc-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ececf1;
  font-size: 13.5px;
  padding: 6px 8px 6px 4px;
  line-height: 1.3;
  min-width: 0;
}
.toc a.toc-item::before {
  content: "›";
  flex-shrink: 0;
  width: 12px;
  color: #8e8e9c;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
}
.toc a.toc-item:hover {
  color: #fff;
  background: transparent;
}
.toc a.toc-item.is-current {
  color: #fff;
  background: transparent;
}
.toc a.toc-item.is-current::before { color: var(--accent-2); }
.toc-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.toc-depth-0 {
  font-weight: 700;
  color: #fff;
}
.toc-depth-1 {
  font-weight: 400;
  padding-left: 22px !important;
}
.toc-depth-2,
.toc-depth-3 {
  font-weight: 400;
  padding-left: 36px !important;
  font-size: 12.5px;
  color: #c8c8d2;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.main:not(:has(.page-layout)) { overflow-y: auto; overscroll-behavior: contain; }
.page-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.adminbar {
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  padding: 10px 22px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}
.adminbar .who { color: var(--muted); margin-right: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn-primary { background: var(--accent); color: #16161d; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); color: #111; }
.btn-danger { background: transparent; color: var(--danger); border-color: #5a3030; }
.btn-danger:hover { background: #3a2020; }

.page {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 28px 80px;
}
.page-kicker {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.page h1.page-title {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 750;
  text-shadow: none;
  filter: none;
}
.meta { color: var(--muted); font-size: 13px; margin-bottom: 28px; }

.contents { font-size: 16.5px; line-height: 1.7; color: #dddde6; }
.contents h1, .contents h2, .contents h3, .contents h4 {
  color: #fff;
  margin: 1.6em 0 .6em;
  line-height: 1.3;
  font-weight: 800;
  text-shadow: none;
  filter: none;
  scroll-margin-top: 24px;
}
.contents h1 { font-size: 1.85em; }
.contents h2 { font-size: 1.4em; }
.contents h3 { font-size: 1.15em; }
.contents .toc-anchor,
.contents h1 > a[href^="#"],
.contents h2 > a[href^="#"],
.contents h3 > a[href^="#"] {
  display: none !important;
}
.contents a { border-bottom: 1px dashed rgba(155,151,193,.4); }
.contents ul, .contents ol { padding-left: 1.3em; }
.contents li { margin: .28em 0; }
.contents hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.contents table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0 1.4em;
  font-size: 14.5px;
  overflow: hidden;
  border-radius: 8px;
}
.contents th, .contents td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.contents th { background: var(--bg-3); color: var(--accent-2); }
.contents img { max-width: 100%; border-radius: 8px; }
.contents blockquote {
  margin: 1em 0;
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  background: rgba(155, 151, 193, .08);
  border-radius: 0 8px 8px 0;
}
.contents blockquote.is-warning { border-left-color: #ffb74d; background: rgba(255, 183, 77, .08); }
.contents blockquote.is-danger { border-left-color: #ef9a9a; background: rgba(239, 154, 154, .08); }
.contents blockquote.is-info { border-left-color: var(--accent); }
.contents code {
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .92em;
}

.flash {
  max-width: 980px;
  margin: 16px auto 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(155, 151, 193, .15);
  border: 1px solid rgba(155, 151, 193, .35);
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 70% 20%, rgba(155,151,193,.18), transparent 55%),
    var(--bg);
  padding: 24px;
}
body:has(.login-wrap) {
  overflow: auto;
  display: block;
  height: auto;
  min-height: 100%;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(22, 22, 29, .92);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card .brand { border: 0; padding: 0 0 18px; }
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: #121218;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0;
  border-color: var(--accent);
}
.full { width: 100%; }
.error {
  background: rgba(229, 115, 115, .12);
  border: 1px solid #6d3030;
  color: #ef9a9a;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}

.editor-page { padding: 22px 28px 60px; }
.editor-page h1 { margin: 0 0 16px; }
.editor-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 1100px) {
  .toc {
    width: 220px;
  }
}
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; max-height: 36vh; }
  .page-layout { flex-direction: column; }
  .toc {
    width: 100%;
    height: auto;
    max-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .grid-2 { grid-template-columns: 1fr; }
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; }
.table th { color: var(--accent); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
