:root {
  color-scheme: dark;
  --bg: #111111;
  --text: #ececec;
  --muted: #9a9a9a;
  --faint: #6e6e6e;
  --line: #2a2a2a;
  --fill: #1a1a1a;
  --accent: #6ea8ff;
  --ok: #4caf7a;
  --warn: #d4a017;
  --danger: #d35a5a;
  --overlay: rgba(0, 0, 0, 0.62);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f2;
  --text: #171717;
  --muted: #5a5a5a;
  --faint: #8b8b8b;
  --line: #d8d8d2;
  --fill: #ffffff;
  --accent: #2c6fd4;
  --ok: #2e8a58;
  --warn: #b57a00;
  --danger: #c43c3c;
  --overlay: rgba(20, 20, 20, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, sans-serif;
}

html {
  scroll-padding-top: 6.5rem;
}

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

a:hover {
  text-decoration: underline;
}

.chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0;
  max-width: 880px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.top .sep {
  margin: 0 0.4rem;
  color: var(--faint);
}

.top .home {
  color: var(--muted);
}

.top strong {
  color: var(--text);
  font-weight: 600;
}

.theme-toggle {
  appearance: none;
  width: 1.55rem;
  height: 1.55rem;
  margin-left: 0.35rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}

html[data-theme="dark"] .theme-toggle .icon-moon,
html:not([data-theme]) .theme-toggle .icon-moon {
  display: none;
}

html[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: 880px;
  margin: 0.85rem auto 0;
  padding: 0 1.25rem;
}

.nav a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav a.is-active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--fill);
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3.5rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

h1 {
  margin: 0 0 0.55rem;
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h2 {
  margin: 1.75rem 0 0.65rem;
  font-size: 1.15rem;
  font-weight: 650;
}

h3 {
  margin: 1.2rem 0 0.45rem;
  font-size: 0.98rem;
  font-weight: 650;
}

p {
  margin: 0 0 0.85rem;
}

.lead {
  color: var(--muted);
  font-size: 0.98rem;
}

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

li {
  margin: 0.22rem 0;
}

li + li {
  margin-top: 0.28rem;
}

pre {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

code {
  font: 0.9em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

p code,
li code,
td code {
  padding: 0.05rem 0.28rem;
  border-radius: 4px;
  background: var(--fill);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.1rem;
  font-size: 0.9rem;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.callout {
  margin: 0 0 1.1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--fill);
}

.callout.warn {
  border-left-color: var(--warn);
}

.callout strong {
  display: block;
  margin-bottom: 0.25rem;
}

.toc {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0 0;
}

.toc a {
  display: block;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
  color: var(--text);
  text-decoration: none;
}

.toc a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.toc a span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.pager a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  padding: 1rem;
}

.modal {
  width: min(22rem, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem 1.15rem 1.15rem;
}

.modal h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.modal p {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

.modal input[type="password"] {
  width: 100%;
  background: var(--fill);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  margin-bottom: 0.75rem;
}

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: -0.35rem 0 0.7rem;
}

.auth-error[hidden] {
  display: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

button.ghost,
button.sec {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

button.sec {
  background: var(--fill);
}

.page.doc h1 {
  font-size: 1.45rem;
  margin-top: 0.35rem;
}

.page.doc h2 {
  scroll-margin-top: 1rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.page.doc h2:first-of-type {
  border-top: 0;
}

.page.doc hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.4rem 0;
}

.page.doc table th:empty,
.page.doc table td:empty {
  display: none;
}

@media (max-width: 640px) {
  table {
    display: block;
    overflow-x: auto;
  }
}
