:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #202124;
  --muted: #646862;
  --border: #d8d8d0;
  --accent: #1d5f71;
  --accent-strong: #164b5a;
  --code-bg: #fbfbf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

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

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-title {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1rem;
}

.site-main {
  width: min(1060px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.search-panel,
.results-panel,
.thread__header,
.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  padding: clamp(1rem, 3vw, 2rem);
}

h1,
h2 {
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

p {
  margin: 0;
}

.search-form label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-weight: 650;
}

.archive-intro {
  display: grid;
  gap: 0.75rem;
  max-width: 78ch;
}

.archive-tagline {
  max-width: 72ch;
  font-weight: 650;
}

.search-row {
  display: flex;
  gap: 0.6rem;
}

input,
button {
  min-height: 2.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

input {
  width: 100%;
  padding: 0 0.8rem;
}

button {
  padding: 0 1rem;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.results-panel {
  margin-top: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.results-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1rem;
}

.results-heading p,
.result-meta,
.thread__meta,
.back-link {
  color: var(--muted);
}

.sort-links {
  font-size: 0.94rem;
}

.sort-links a[aria-current="true"] {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.results-list {
  display: grid;
  gap: 0.85rem;
  padding-left: 4rem;
  margin: 0;
}

.results-list a {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.results-list li {
  padding-right: 0.5rem;
}

.result-meta {
  margin-top: 0.15rem;
  font-size: 0.94rem;
}

.inline-filter {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.inline-filter label {
  color: var(--muted);
  font-weight: 650;
}

.inline-filter__count {
  min-height: 1.45rem;
}

.back-link {
  margin-bottom: 1rem;
  padding-inline: clamp(1rem, 3vw, 1.5rem);
}

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

.thread__header,
.post {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.post__header {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.post__body {
  margin: 1rem 0 0;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .site-header,
  .results-heading,
  .search-row {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header {
    padding: 0.75rem;
  }

  .site-main {
    width: 100%;
    padding: 0.75rem 0 2rem;
  }

  .thread {
    gap: 0.75rem;
    min-width: 0;
  }

  .thread__header {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding: 0.75rem;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .post {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding: 0.75rem;
    min-width: 0;
  }

  .post__header {
    padding-bottom: 0.6rem;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .post__body {
    margin-top: 0.75rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .post__body--flowed {
    display: grid;
    gap: 1rem;
    overflow-x: visible;
    white-space: normal;
    min-width: 0;
    overflow-wrap: anywhere;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .post__body--flowed p {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .post__body-preserved {
    margin: 0;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    white-space: pre;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.45;
  }
}
