:root {
  color-scheme: light;
  --bg: #f8f7f2;
  --surface: #ffffff;
  --surface-2: #efeee7;
  --text: #1d2527;
  --muted: #687174;
  --line: #dedbd0;
  --accent: #d74f35;
  --accent-2: #0a7b83;
  --code-bg: #182126;
  --code-text: #eaf4f3;
  --shadow: 0 18px 45px rgba(36, 43, 44, 0.1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171b1f;
  --surface: #20262b;
  --surface-2: #2a3238;
  --text: #eef1eb;
  --muted: #a9b0ad;
  --line: #394047;
  --accent: #ff7a4d;
  --accent-2: #4db6bd;
  --code-bg: #0f1518;
  --code-text: #edf7f6;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
}

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

a {
  color: var(--accent-2);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--text);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  line-height: 1;
  box-shadow: 4px 4px 0 var(--text);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: min(620px, 100%);
}

.search {
  position: relative;
  display: block;
  width: min(420px, 100%);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.search input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
}

.menu-button {
  display: none;
}

.progress {
  position: fixed;
  top: 72px;
  left: 0;
  z-index: 21;
  width: 100%;
  height: 3px;
  background: transparent;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 34px;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 30px 24px 64px;
}

.sidebar {
  position: sticky;
  top: 104px;
  align-self: start;
  max-height: calc(100vh - 126px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nav-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list li {
  min-width: 0;
}

.nav-group,
.toc-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.nav-group[open],
.toc-group[open] {
  background: color-mix(in srgb, var(--surface-2) 68%, var(--surface));
}

.nav-group summary,
.toc-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 780;
  line-height: 1.3;
  list-style: none;
}

.nav-group summary::-webkit-details-marker,
.toc-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after,
.toc-group summary::after {
  content: "⌄";
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  transform: rotate(-90deg);
  transition: transform 0.18s ease;
}

.nav-group[open] summary::after,
.toc-group[open] summary::after {
  transform: rotate(0deg);
}

.nav-group summary span,
.toc-group summary span {
  min-width: 0;
}

.nav-group summary small,
.toc-group summary small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-list a,
.toc-panel a {
  display: block;
  padding: 8px 10px;
  border-left: 3px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
}

.nav-major-link,
.toc-major-link {
  margin: 0 10px 8px;
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  color: var(--accent-2) !important;
  font-size: 0.78rem !important;
  font-weight: 760;
}

.nav-sublist,
.toc-sublist {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0 8px 10px;
  list-style: none;
}

.nav-sublist a {
  font-size: 0.84rem;
}

.nav-list a:hover,
.nav-list a.active,
.toc-panel a:hover {
  border-left-color: var(--accent);
  background: var(--surface-2);
  color: var(--text);
}

.content-shell {
  min-width: 0;
}

.guide {
  max-width: 960px;
  padding: 44px clamp(22px, 5vw, 64px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.guide > :first-child {
  margin-top: 0;
}

.guide h1,
.guide h2,
.guide h3,
.guide h4 {
  line-height: 1.16;
}

.guide h1 {
  margin: 0 0 12px;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  letter-spacing: 0;
}

.guide h2 {
  margin-top: 54px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: clamp(1.65rem, 3vw, 2.35rem);
}

.guide h3 {
  margin-top: 34px;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.guide h4 {
  margin-top: 26px;
  font-size: 1.06rem;
}

.guide p,
.guide li {
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

.guide strong {
  color: var(--text);
}

.guide blockquote {
  margin: 26px 0;
  padding: 16px 20px;
  border-left: 5px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
  color: var(--text);
}

.guide hr {
  height: 1px;
  margin: 32px 0;
  border: 0;
  background: var(--line);
}

.toc-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 36px;
}

.toc-group {
  overflow: hidden;
}

.toc-group summary {
  min-height: 58px;
  padding: 14px 16px;
}

.toc-group summary span {
  font-size: 0.96rem;
}

.toc-sublist {
  padding: 0 12px 14px;
}

.toc-sublist a {
  font-size: 0.9rem;
}

.guide pre {
  overflow: auto;
  margin: 22px 0;
  padding: 18px;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  line-height: 1.55;
}

.guide code {
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent-2) 13%, transparent);
  color: var(--text);
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.92em;
}

.guide pre code {
  background: transparent;
  color: inherit;
}

.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: var(--surface-2);
  color: var(--text);
}

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

.empty-state {
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.match {
  padding: 0 2px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

body.nav-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .topbar {
    padding: 10px 16px;
  }

  .brand {
    min-width: auto;
  }

  .brand small {
    display: none;
  }

  .menu-button {
    display: grid;
  }

  .app-shell {
    display: block;
    padding: 20px 14px 48px;
  }

  .sidebar {
    position: fixed;
    inset: 76px 12px auto;
    z-index: 30;
    display: none;
    max-height: calc(100vh - 96px);
  }

  body.nav-open .sidebar {
    display: block;
  }

  .guide {
    padding: 32px clamp(18px, 4vw, 34px);
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar-actions {
    width: 100%;
  }

  .brand strong {
    font-size: 0.96rem;
  }

  .progress {
    top: 126px;
  }

  .guide h1 {
    font-size: 2.15rem;
  }
}
