:root {
  color-scheme: dark;
  --bg: #0d1014;
  --surface: #151a20;
  --surface-soft: #1c222a;
  --text: #f3f0e8;
  --muted: #a9a498;
  --faint: #79756c;
  --line: rgba(230, 222, 204, 0.14);
  --line-strong: rgba(230, 222, 204, 0.24);
  --accent: #d7a84f;
  --accent-strong: #f0d38a;
  --accent-cold: #7db7b1;
  --link: #e7bf72;
  --code: #23272e;
  --shadow: rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(180deg, #11161c 0%, var(--bg) 520px);
  background-size: 40px 40px, 40px 40px, auto;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

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

a:hover {
  color: var(--accent-strong);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 16, 20, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background:
    linear-gradient(135deg, transparent 43%, rgba(240, 211, 138, 0.9) 46%, rgba(240, 211, 138, 0.9) 54%, transparent 57%),
    linear-gradient(135deg, rgba(215, 168, 79, 0.28), rgba(125, 183, 177, 0.18));
  transform: rotate(45deg);
}

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

.top-tool-link,
.locale-tab,
.nav-link,
.toc-link {
  cursor: pointer;
}

.top-tool-link {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
}

.top-tool-link:hover,
.top-tool-link.active {
  border-color: var(--accent);
  background: rgba(215, 168, 79, 0.13);
}

.locale-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 14px;
}

.locale-tab {
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.locale-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.locale-tab:disabled {
  cursor: default;
}

.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 230px;
  gap: 38px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 38px 30px 88px;
}

.layout.sheet-mode {
  max-width: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

.layout.sheet-mode .sidebar,
.layout.sheet-mode .toc {
  display: none;
}

.sidebar,
.toc {
  position: sticky;
  top: 92px;
  align-self: start;
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.sidebar {
  padding: 14px 14px 18px 0;
  border-right: 1px solid var(--line);
}

.sidebar-title {
  margin: 0 0 16px 10px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.nav-link,
.toc-link {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-link {
  position: relative;
  min-height: 38px;
  padding: 8px 10px 8px 20px;
  border-left: 2px solid transparent;
  border-radius: 0 7px 7px 0;
  font-size: 14px;
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.42;
  transform: translateY(-50%);
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(215, 168, 79, 0.14), rgba(255, 255, 255, 0.035));
  color: var(--text);
}

.nav-link.active::before {
  background: var(--accent);
  opacity: 1;
}

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

.toc-link {
  padding: 5px 0;
  font-size: 13px;
}

.toc-link:hover {
  color: var(--text);
}

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

.toc-link.level-4 {
  padding-left: 24px;
  font-size: 12px;
}

.content {
  min-width: 0;
  outline: none;
}

.content-enter {
  animation: content-in 160ms ease-out;
}

@keyframes content-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.doc {
  max-width: 850px;
  padding: 42px 48px 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 32, 0.78);
  box-shadow: 0 24px 70px var(--shadow);
}

.doc h1,
.doc h2,
.doc h3,
.doc h4 {
  line-height: 1.22;
  letter-spacing: 0;
}

.doc h1 {
  margin: 0 0 32px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-weight: 700;
}

.doc h2 {
  margin: 44px 0 14px;
  color: var(--accent-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 700;
}

.doc h3 {
  margin: 30px 0 10px;
  font-size: 21px;
}

.doc h4 {
  margin: 24px 0 8px;
  color: #ddd2be;
  font-size: 17px;
}

.doc p,
.doc li {
  color: #e4ded1;
}

.doc p {
  margin: 0 0 16px;
}

.doc ul,
.doc ol {
  margin: 10px 0 20px;
  padding-left: 25px;
}

.doc li {
  margin: 7px 0;
}

.list-quote {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.doc blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 2px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, 0.045);
}

.doc blockquote p:last-child {
  margin-bottom: 0;
}

.doc hr {
  height: 1px;
  margin: 34px 0;
  border: 0;
  background: var(--line-strong);
}

.doc code {
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--code);
  color: #f2d49a;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.doc pre {
  overflow-x: auto;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--code);
}

.doc pre code {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre;
}

.tool-section {
  margin-top: 44px;
}

.tool-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: center;
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.tool-card:hover {
  border-color: var(--accent);
  background: rgba(215, 168, 79, 0.1);
}

.tool-card strong,
.tool-card small {
  display: block;
}

.tool-card small {
  margin-top: 3px;
  color: var(--muted);
}

.tool-card-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 43%, rgba(240, 211, 138, 0.9) 46%, rgba(240, 211, 138, 0.9) 54%, transparent 57%),
    rgba(215, 168, 79, 0.18);
  transform: rotate(45deg);
}

.table-wrap {
  max-width: 100%;
  margin: 18px 0 24px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.025);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--accent-strong);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
    min-height: 0;
    padding: 14px 16px;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .layout {
    display: block;
    padding: 20px 16px 56px;
  }

  .layout.sheet-mode {
    padding: 0;
  }

  .sidebar {
    position: static;
    max-height: none;
    margin-bottom: 24px;
    padding: 0 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .doc {
    padding: 30px 22px 42px;
  }

  .doc h1 {
    font-size: 34px;
  }

  .doc h2 {
    font-size: 24px;
  }
}
