:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --ink: #111827;
  --muted: #667085;
  --line: #dde3ec;
  --accent: #0f172a;
  --accent-2: #156a72;
  --gold: #b7791f;
  --danger: #bd2b2b;
  --shadow: 0 18px 50px rgba(18, 28, 45, .10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --surface: #1e222b;
  --surface-2: #262c37;
  --ink: #eef2f8;
  --muted: #aab3c2;
  --line: #343c49;
  --accent: #f8fafc;
  --accent-2: #69c5c8;
  --gold: #f0ba57;
  --danger: #ff7b72;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  height: 72px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand,
.nav,
.top-actions,
.inline,
.row-actions,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--surface);
}

.nav {
  gap: 12px;
}

.nav-link,
.black-button,
.secondary-button,
.danger-button,
.icon-button {
  border-radius: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.nav-link {
  padding: 8px 15px;
  color: var(--muted);
  font-weight: 700;
}

.nav-link.active,
.black-button {
  background: #050505;
  border-color: #050505;
  color: #fff;
}

.black-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-weight: 700;
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger);
}

.icon-button {
  min-width: 42px;
  background: var(--surface);
  color: var(--ink);
}

.top-actions {
  gap: 10px;
}

.docs-shell {
  display: grid;
  grid-template-columns: 76px minmax(280px, 360px) minmax(0, 1fr) 240px;
  min-height: calc(100vh - 72px);
}

.rail {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 88px;
  border-right: 1px solid var(--line);
}

.rail-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: 0 10px 25px rgba(16, 24, 40, .06);
}

.rail-button.active {
  color: var(--ink);
  border-color: var(--ink);
}

.doc-list-panel {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 28px 20px 42px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.panel-head h1,
.reader h1,
.admin-heading h1,
.editor-head h1,
.message-page h1 {
  margin: 4px 0 8px;
  line-height: 1.15;
  letter-spacing: 0;
}

.panel-head h1 {
  font-size: 34px;
}

.panel-head p,
.summary,
.empty,
.message-page p,
.editor-form small {
  color: var(--muted);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
}

.search-box {
  display: grid;
  gap: 8px;
  margin: 24px 0 18px;
  color: var(--muted);
  font-weight: 700;
}

.search-box input,
.editor-form input,
.editor-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

.search-box input:focus,
.editor-form input:focus,
.editor-form textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-2) 18%, transparent);
}

.visual-strip {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 22px;
  background: var(--surface-2);
}

.visual-strip img {
  display: block;
  width: 100%;
  height: auto;
}

.doc-group {
  margin: 22px 0;
}

.doc-group h2 {
  font-size: 17px;
  margin: 0 0 10px;
}

.doc-card {
  display: grid;
  gap: 5px;
  padding: 14px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.doc-card:hover,
.doc-card.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.doc-card strong {
  line-height: 1.35;
}

.doc-card small {
  color: var(--muted);
}

.reader {
  max-width: 880px;
  width: 100%;
  padding: 58px 48px 90px;
  background: var(--surface);
}

.reader-meta,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reader-meta span,
.tag-row span,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reader h1 {
  margin-top: 18px;
  font-size: clamp(34px, 5vw, 56px);
}

.article-body {
  margin-top: 34px;
  font-size: 17px;
}

.article-body h1,
.article-body h2,
.article-body h3 {
  margin-top: 42px;
  line-height: 1.25;
}

.article-body h2 {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.article-body p,
.article-body li {
  color: color-mix(in srgb, var(--ink) 84%, var(--muted));
}

.article-body code,
.article-body pre {
  border-radius: 8px;
  background: var(--surface-2);
}

.article-body code {
  padding: 2px 6px;
}

.article-body pre {
  overflow: auto;
  padding: 18px;
}

.article-body a {
  color: var(--accent-2);
  font-weight: 700;
}

.outline {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  padding: 28px 24px;
  border-left: 1px solid var(--line);
  overflow: auto;
  background: var(--bg);
}

.outline strong {
  display: block;
  margin-bottom: 18px;
}

.outline a,
.outline span {
  display: block;
  padding: 7px 0;
  color: var(--muted);
}

.outline a.active {
  color: var(--ink);
  font-weight: 800;
}

.admin-shell,
.editor-shell,
.message-page {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 46px 0 72px;
}

.admin-heading,
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 24px;
}

.admin-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) 140px 100px 120px 230px;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
}

.table-head {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.table-row + .table-row {
  border-top: 1px solid var(--line);
}

.table-row small {
  display: block;
  color: var(--muted);
}

.row-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions form {
  margin: 0;
}

.status.published {
  color: var(--accent-2);
}

.status.draft {
  color: var(--gold);
}

.editor-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-form label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.editor-form .wide,
.form-actions {
  grid-column: 1 / -1;
}

.editor-form textarea {
  min-height: 440px;
  resize: vertical;
  line-height: 1.7;
}

.check {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.check input {
  width: auto;
}

.form-actions {
  gap: 10px;
}

.message-page {
  min-height: calc(100vh - 72px);
  display: grid;
  align-content: center;
  justify-items: start;
}

.empty-reader {
  padding-top: 20vh;
}

@media (max-width: 1120px) {
  .docs-shell {
    grid-template-columns: 64px minmax(260px, 340px) minmax(0, 1fr);
  }

  .outline {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: 68px;
    padding: 12px 14px;
  }

  .nav {
    display: none;
  }

  .docs-shell {
    display: block;
  }

  .rail {
    display: none;
  }

  .doc-list-panel {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .reader {
    padding: 34px 20px 72px;
  }

  .top-actions .icon-button {
    display: none;
  }

  .table-head {
    display: none;
  }

  .table-row {
    grid-template-columns: 1fr;
  }

  .admin-heading,
  .editor-head,
  .editor-form {
    display: grid;
    grid-template-columns: 1fr;
  }
}
