/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --text: #24292f;
  --text-muted: #57606a;
  --link: #0969da;
  --link-hover: #0550ae;
  --border: #d0d7de;
  --code-bg: #f6f8fa;
  --nav-bg: #24292f;
  --nav-text: #ffffff;
  --accent: #0969da;
  --shadow: rgba(31, 35, 40, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --link: #58a6ff;
    --link-hover: #79c0ff;
    --border: #30363d;
    --code-bg: #161b22;
    --nav-bg: #161b22;
    --nav-text: #e6edf3;
    --accent: #58a6ff;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Navigation ===== */
nav.site-nav {
  background: var(--nav-bg);
  color: var(--nav-text);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px var(--shadow);
}

.nav-inner {
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nav-brand {
  font-size: 1rem;
  font-weight: 600;
  color: var(--nav-text);
  text-decoration: none;
  white-space: nowrap;
}

.nav-brand:hover {
  opacity: 0.85;
}

.nav-links {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.nav-links a {
  color: var(--nav-text);
  text-decoration: none;
  font-size: 0.875rem;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.nav-links a:hover {
  opacity: 1;
}

/* ===== Main Layout ===== */
main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ===== Typography ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.35;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  color: var(--text);
}

h1 {
  font-size: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.4rem;
  margin-top: 1rem;
}

h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.1rem;
}

h5,
h6 {
  font-size: 1rem;
}

p {
  margin-bottom: 1rem;
}

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

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

ul,
ol {
  padding-left: 1.75rem;
  margin-bottom: 1rem;
}

li {
  margin-bottom: 0.3rem;
}

li>ul,
li>ol {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}

/* ===== Images ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 6px;
  box-shadow: 0 2px 12px var(--shadow);
}

/* ===== Code ===== */
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* ===== Tables ===== */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

th {
  background: var(--bg-secondary);
  font-weight: 600;
  text-align: left;
}

th,
td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
}

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

/* ===== Blockquotes ===== */
blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.25rem 0;
  background: var(--bg-secondary);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
}

blockquote p {
  margin-bottom: 0;
}

/* ===== Horizontal Rule ===== */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ===== Back Link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s;
}

.back-link:hover {
  color: var(--link);
  border-color: var(--link);
  text-decoration: none;
  background: var(--bg-secondary);
}

/* ===== Hero (index page) ===== */
.hero {
  background: linear-gradient(135deg, #0969da 0%, #0550ae 100%);
  color: #fff;
  padding: 3rem 1.25rem;
  text-align: center;
  margin-bottom: 0;
}

.hero h1 {
  font-size: 2.2rem;
  color: #fff;
  border: none;
  margin-top: 0;
}

.hero p {
  font-size: 1.05rem;
  opacity: 0.9;
  max-width: 640px;
  margin: 0.75rem auto 0;
}

@media (prefers-color-scheme: dark) {
  .hero {
    background: linear-gradient(135deg, #1f6feb 0%, #0d419d 100%);
  }
}

/* ===== Footer ===== */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--link);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  main {
    padding: 1.5rem 1rem 3rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .hero h1 {
    font-size: 1.7rem;
  }

  .hero {
    padding: 2rem 1rem;
  }

  pre {
    font-size: 0.8rem;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  nav.site-nav {
    padding: 0 0.75rem;
  }

  .nav-inner {
    height: auto;
    padding: 0.5rem 0;
  }

  h1 {
    font-size: 1.4rem;
  }
}