:root {
  --bg: #121212;
  --fg: #d0d0d0;
  --muted: #555;
  --accent: #e5e5e5;
  --border: #1a1a2e;
}
[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #777;
  --accent: #0066cc;
  --border: #ddd;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font:
    16px/1.7 "Inter",
    sans-serif;
  background: var(--bg);
  color: var(--fg);
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  overflow-x: hidden;
}
@media (min-width: 900px) {
  .wrap {
    grid-template-columns: 1fr 200px;
  }
}
a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 2rem 0 1rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
h2 {
  font-size: 1.5rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
h3 {
  font-size: 1.25rem;
  color: var(--fg);
}
h4 {
  font-size: 1rem;
  color: var(--muted);
}
p,
ul,
ol,
table,
pre,
blockquote {
  margin: 0 0 1.2rem;
  max-width: 100%;
}
p {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
ul,
ol {
  padding-left: 1.5rem;
}
li {
  margin: 0.3rem 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
li > ul,
li > ol {
  margin: 0;
}
code {
  background: var(--border);
  padding: 0.15em 0.4em;
  font-size: 0.9em;
  font-family: "JetBrains Mono", monospace;
  border-radius: 3px;
  word-break: break-word;
}
pre {
  background: var(--border);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.9em;
  font-family: "JetBrains Mono", monospace;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  max-width: 100%;
  white-space: pre;
  word-wrap: normal;
}
pre code {
  background: none;
  padding: 0;
  word-break: normal;
}
table {
  border-collapse: collapse;
  font-size: 0.9em;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
  -webkit-overflow-scrolling: touch;
}
th,
td {
  text-align: left;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
th {
  color: var(--accent);
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
}
blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
  font-style: italic;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
nav {
  grid-column: 1/-1;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
}
nav a {
  color: var(--muted);
  margin-right: 1.5rem;
}
nav a:hover,
nav a.active {
  color: var(--accent);
  text-decoration: none;
}
#theme,
#repo {
  cursor: pointer;
  background: 0;
  border: 1px solid var(--border);
  color: var(--muted);
  font: inherit;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
}
#theme {
  margin-left: 0.5rem;
}
#theme:hover,
#repo:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
#content {
  min-height: 60vh;
  max-width: min(90ch, 100%);
}
#toc {
  display: none;
}
@media (min-width: 900px) {
  #toc {
    display: block;
    position: sticky;
    top: 2rem;
    align-self: start;
    font-size: 0.9rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
  }
}
#toc h4 {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  border: 0;
}
#toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
#toc li {
  margin: 0.4rem 0;
  line-height: 1.4;
}
#toc a {
  color: var(--muted);
  text-decoration: none;
  display: block;
  transition: color 0.2s;
}
#toc a:hover,
#toc a.active {
  color: var(--accent);
}
#toc .h3 {
  padding-left: 0.75rem;
}
#toc .h4 {
  padding-left: 1.5rem;
}
.patterns {
  list-style: none;
  padding: 0;
}
.patterns li {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}
.patterns a {
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  font-weight: 600;
}
.patterns small {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}
footer {
  grid-column: 1/-1;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

#content img {
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 4px;
}

img.light-only {
  display: none;
}
img.dark-only {
  display: block;
}
[data-theme="light"] img.light-only {
  display: block;
}
[data-theme="light"] img.dark-only {
  display: none;
}

@media (max-width: 600px) {
  .wrap {
    padding: 1rem 0.75rem;
    gap: 1.5rem;
  }
  h1 {
    font-size: 1.5rem;
  }
  h2 {
    font-size: 1.25rem;
  }
  h3 {
    font-size: 1.1rem;
  }
  h1,
  h2,
  h3,
  h4 {
    margin: 1.5rem 0 0.75rem;
  }
  nav {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  nav > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  nav a {
    margin-right: 0.75rem;
  }
  #theme,
  #repo {
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    min-width: 44px;
  }
  pre {
    padding: 0.75rem;
    font-size: 0.8em;
  }
  code {
    font-size: 0.85em;
  }
  th,
  td {
    padding: 0.5rem;
    font-size: 0.85em;
    white-space: normal;
    word-break: break-word;
  }
  ul,
  ol {
    padding-left: 1.25rem;
  }
  #content {
    max-width: 100%;
  }
}

.hero {
  padding: 3rem 0 4rem;
  max-width: 800px;
}

.hero h1 {
  font-size: 2.5rem;
  margin: 0 0 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-weight: 500;
}

.hero-description {
  font-size: 1rem;
  color: var(--fg);
  line-height: 1.6;
  margin: 0;
}

.pattern-category {
  margin: 3rem 0;
}

.pattern-category h2 {
  font-size: 1.5rem;
  margin: 0 0 1.5rem;
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.75rem;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .pattern-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .pattern-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pattern-card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--fg);
}

.pattern-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  border-color: var(--accent);
  text-decoration: none;
}

[data-theme="light"] .pattern-card:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.pattern-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pattern-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
}

.pattern-card-content {
  padding: 1.25rem;
}

.pattern-card-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--accent);
}

.pattern-card-content p {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .hero {
    padding: 2rem 0 3rem;
  }

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

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .hero-description {
    font-size: 0.95rem;
  }

  .pattern-category h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .pattern-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .pattern-card-content {
    padding: 1rem;
  }

  .pattern-card-content h3 {
    font-size: 1rem;
  }

  .pattern-card-content p {
    font-size: 0.85rem;
  }
}