:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe4ee;
  --ruby: #c92a3a;
  --teal: #0f9f8c;
  --code-bg: #111827;
  --code-ink: #e5e7eb;
}

* {
  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", sans-serif;
  line-height: 1.6;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.brand img {
  width: 108px;
  max-width: 32vw;
  height: auto;
  object-fit: contain;
}

.toplinks {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toplinks a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.92rem;
  font-weight: 700;
}

.shell {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 72px);
  overflow: auto;
  padding: 22px 18px 32px clamp(18px, 3vw, 32px);
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.searchbar {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.searchbar input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--bg);
  font: inherit;
}

.searchbar input:focus {
  outline: 3px solid rgba(15, 159, 140, 0.18);
  border-color: var(--teal);
}

#count {
  color: var(--muted);
  font-size: 0.84rem;
}

.nav-section {
  margin: 18px 0 8px;
  color: var(--ruby);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.navlist a {
  display: block;
  padding: 7px 9px;
  border-radius: 8px;
  color: #334155;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.navlist a:hover,
.navlist a.active {
  background: #eefaf8;
  color: #0b7569;
  text-decoration: none;
}

.reader {
  min-width: 0;
  padding: 26px clamp(18px, 5vw, 64px) 72px;
}

.docbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 980px;
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

#source-link {
  font-weight: 700;
}

.markdown {
  max-width: 980px;
  margin: 0 auto;
  padding-bottom: 64px;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  line-height: 1.18;
  margin: 1.55em 0 0.55em;
  scroll-margin-top: 96px;
}

.markdown h1 {
  margin-top: 0;
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0;
}

.markdown h2 {
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.markdown h3 {
  color: #1e293b;
  font-size: 1.25rem;
}

.markdown p,
.markdown li {
  font-size: 1rem;
}

.markdown ul,
.markdown ol {
  padding-left: 1.4rem;
}

.markdown li + li {
  margin-top: 0.25rem;
}

.markdown blockquote {
  margin: 1.2rem 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--ruby);
  background: #fff7f8;
  color: #3f1d24;
}

.markdown pre {
  overflow: auto;
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-ink);
}

.markdown code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown :not(pre) > code {
  padding: 0.15rem 0.32rem;
  border-radius: 6px;
  background: #e8eef6;
  color: #9f1239;
}

.markdown table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1rem 0;
}

.markdown th,
.markdown td {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown th {
  background: #eef2f7;
}

.markdown img {
  max-width: min(100%, 520px);
  height: auto;
}

.empty {
  padding: 16px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .toplinks {
    justify-content: flex-start;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .reader {
    padding-top: 20px;
  }

  .docbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
