* {
  box-sizing: border-box;
}

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #181a1f;
  --muted: #5f6673;
  --border: #d8dde6;
  --accent: #2b66f6;
  --accent-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1f27;
    --text: #f5f7fa;
    --muted: #b5bdc9;
    --border: #323846;
    --accent: #8bb1ff;
    --accent-text: #111318;
  }
}

html[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #181a1f;
  --muted: #5f6673;
  --border: #d8dde6;
  --accent: #2b66f6;
  --accent-text: #ffffff;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #111318;
  --surface: #1a1f27;
  --text: #f5f7fa;
  --muted: #b5bdc9;
  --border: #323846;
  --accent: #8bb1ff;
  --accent-text: #111318;
  color-scheme: dark;
}

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

header,
footer {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.shell {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem;
}

.site-header,
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.brand small,
.muted {
  color: var(--muted);
}

.brand small {
  display: block;
  font-weight: 400;
}

.nav-list,
.footer-list,
.inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hero-actions,
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.masonry {
  display: block;
  column-gap: 1rem;
}

.masonry-2 {
  column-count: 2;
}

.masonry-3 {
  column-count: 3;
}

.masonry-gallery {
  column-width: 16rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.page-stack > * + *,
.section > * + * {
  margin-top: 1rem;
}

.gallery-item > * + *,
details + details {
  margin-top: 0.75rem;
}

.masonry > .card,
.masonry > .gallery-item,
.masonry > .notice {
  display: inline-block;
  width: 100%;
  margin: 0 0 1rem;
  break-inside: avoid;
}

.card,
details,
fieldset,
.gallery-item,
.notice {
  padding: 1rem;
}

.card,
details,
fieldset,
.gallery-item,
.notice,
.copy-button,
.theme-toggle,
input,
textarea,
select,
th,
td {
  border: 1px solid var(--border);
  background: var(--surface);
}

.copy-button,
.button,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  text-decoration: none;
}

.button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.theme-toggle {
  margin-left: auto;
}

.stat-list {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: max-content 1fr;
  margin: 0;
}

.stat-list dt {
  font-weight: 700;
}

.stat-list dd,
figure,
blockquote,
.gallery-item h3,
.gallery-item p {
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.center {
  text-align: center;
}

.full-width {
  width: 100%;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field-row {
  display: grid;
  gap: 1rem;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-radius: 0.5rem;
}

textarea {
  min-height: 10rem;
  resize: vertical;
}

.bare-list {
  margin: 0;
  padding-left: 1.25rem;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.nav-list a,
.footer-list a,
.card-link,
.thread-title {
  color: inherit;
  text-decoration: none;
}

.nav-list a:hover,
.footer-list a:hover,
.card-link:hover,
.thread-title:hover {
  text-decoration: underline;
}

.page-eyebrow,
.meta-row,
.muted-link,
.empty-state,
.comment-time,
.edited {
  color: var(--muted);
}

.page-eyebrow,
.meta-row,
.comment-time,
.edited,
.thread-stats,
.pager {
  font-size: 0.9rem;
}

.page-title,
.blog-featured__title,
.post-title {
  margin: 0;
}

.page-lede,
.post-lede,
.card-description,
.gallery-summary,
.faq-copy {
  color: var(--muted);
}

.meta-row,
.chip-list,
.reaction-list,
.thread-stats,
.pager,
.utility-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chip,
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.reaction-chip img {
  width: 1rem;
  height: 1rem;
}

.blog-featured,
.post-hero,
.post-content,
.page-sidebar,
.thread-item,
.comment {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}

.blog-featured,
.thread-item {
  display: grid;
  gap: 1rem;
}

.blog-featured__media,
.card-media,
.thread-thumb {
  display: block;
}

.blog-featured__media img,
.card-media img,
.post-cover,
.gallery-post__image,
.thread-thumb img {
  width: 100%;
  height: auto;
}

.card-media {
  margin-bottom: 1rem;
}

.blog-featured__description,
.card-description,
.post-lede,
.gallery-summary,
.faq-copy {
  margin: 0;
}

.faq-list,
.comment-list,
.thread-list,
.adjacent-nav {
  display: grid;
  gap: 1rem;
}

.faq-item h3,
.thread-item h2,
.thread-item p {
  margin: 0;
}

.post-layout {
  display: grid;
  gap: 1rem;
}

.post-content > * + *,
.prose > * + *,
.comment-list > * + * {
  margin-top: 1rem;
}

.prose h2,
.prose h3 {
  margin: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose pre,
.prose blockquote,
.prose table {
  margin: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose pre,
.prose blockquote {
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
}

.prose :not(pre) > code {
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-title {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.toc-list {
  display: grid;
  gap: 0.5rem;
}

.toc-link {
  display: block;
}

.toc-link--nested {
  padding-left: 1rem;
}

.adjacent-nav a {
  display: block;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}

.adjacent-nav a:hover {
  text-decoration: underline;
}

.adjacent-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.notice-accent {
  border-top: 2px solid var(--accent);
}

.gallery-post__image-wrap {
  margin-bottom: 1rem;
}

.comment {
  padding: 1rem;
}

.comment-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

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

.comment-author {
  font-weight: 700;
}

.avatar,
.avatar-fallback {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.avatar {
  object-fit: cover;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
}

.comment-body {
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.replies {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.comment--depth-1 {
  margin-left: 1rem;
}

.comment--depth-2 {
  margin-left: 2rem;
}

.comment--depth-3 {
  margin-left: 3rem;
}

.comment--depth-4 {
  margin-left: 4rem;
}

.thread-item {
  grid-template-columns: 10rem minmax(0, 1fr);
}

.thread-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.thread-copy > * + * {
  margin-top: 0.75rem;
}

@media (max-width: 700px) {
  .masonry-2,
  .masonry-3,
  .masonry-gallery {
    column-count: 1;
    column-width: auto;
  }

  .site-header,
  .site-footer {
    align-items: flex-start;
  }

  .nav-list,
  .footer-list {
    flex-direction: column;
    gap: 0.5rem;
  }

  .thread-item {
    grid-template-columns: 1fr;
  }

  .comment--depth-1,
  .comment--depth-2,
  .comment--depth-3,
  .comment--depth-4 {
    margin-left: 0.75rem;
  }
}

@media (min-width: 701px) and (max-width: 980px) {
  .masonry-3 {
    column-count: 2;
  }
}

@media (min-width: 980px) {
  .blog-featured {
    grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  }

  .post-layout {
    grid-template-columns: minmax(0, 1fr) 18rem;
    align-items: start;
  }
}
