:root {
  --fg: #1c1c1a;
  --fg-muted: #6b6b66;
  --bg: #f4f4f1;
  --bg-alt: #ffffff;
  --border: #dededa;
  --link: #3f7a1a;
  --link-hover: #4c8623;
  --accent: #65b32e;
  --quote: #6b6b66;
  --quote-bar: #dededa;
  --bar: #111111;
  --bar-text: #e8e8e4;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e6e1;
    --fg-muted: #9a9a93;
    --bg: #161614;
    --bg-alt: #1f1f1c;
    --border: #33332f;
    --link: #8fd25a;
    --link-hover: #76bf3d;
    --accent: #76bf3d;
    --quote: #9a9a93;
    --quote-bar: #33332f;
    --bar: #0a0a0a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

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

header.site {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 3px solid var(--accent);
  background: var(--bar);
  color: var(--bar-text);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-title a {
  color: var(--bar-text);
  font-weight: 600;
  font-size: 1.1rem;
}
.site-title a:hover { color: var(--accent); text-decoration: none; }

.search input {
  background: rgba(255, 255, 255, 0.08);
  color: var(--bar-text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  min-width: 220px;
  font-family: inherit;
}
.search input::placeholder { color: rgba(232, 232, 228, 0.55); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

footer.site {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  text-align: center;
}

h1 { font-size: 1.6rem; margin: 0 0 0.75rem; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.75rem; font-weight: 600; }

.meta { color: var(--fg-muted); font-size: 0.9rem; margin-top: 0; }

nav.crumbs {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
nav.crumbs > span { color: var(--fg); font-weight: 500; }

.view-toggle {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}
.view-toggle strong { color: var(--fg); }

.years .year-row {
  display: flex;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.years .year {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
}
.years .months {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.35rem;
  flex: 1;
}
.years .months a,
.years .months .month-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  background: var(--bg-alt);
}
.years .months a:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.years .months .month-empty {
  color: var(--fg-muted);
  opacity: 0.35;
  border-style: dashed;
  background: transparent;
}
.years .months .count {
  font-size: 0.7rem;
  color: var(--fg-muted);
}

@media (max-width: 700px) {
  .years .months {
    grid-template-columns: repeat(6, 1fr);
  }
}

.month-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}
.month-grid a {
  display: block;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  text-align: center;
}
.month-grid a:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.month-grid .name { display: block; font-weight: 500; }
.month-grid .count { display: block; color: var(--fg-muted); font-size: 0.8rem; margin-top: 0.2rem; }

ul.thread-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.thread-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, max-content) 8rem;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
ul.thread-list li:hover { background: var(--bg-alt); }
ul.thread-list .subject {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
ul.thread-list .by {
  color: var(--fg-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
ul.thread-list time {
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

ul.thread-list.threaded .depth-1 .subject { padding-left: 1.25rem; }
ul.thread-list.threaded .depth-2 .subject { padding-left: 2.5rem; }
ul.thread-list.threaded .depth-3 .subject { padding-left: 3.75rem; }
ul.thread-list.threaded .depth-4 .subject { padding-left: 5rem; }
ul.thread-list.threaded .depth-5 .subject { padding-left: 6.25rem; }
ul.thread-list.threaded .depth-6 .subject { padding-left: 7.5rem; }

article.message header {
  margin-bottom: 1rem;
}
article.message dl.headers {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.75rem;
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}
article.message dl.headers dt { font-weight: 500; }
article.message dl.headers dd { margin: 0; color: var(--fg); }

pre.body {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--fg);
}

.attachments ul { list-style: none; padding: 0; margin: 0; }
.attachments li {
  padding: 0.25rem 0;
  font-size: 0.9rem;
}
.attachments .mime, .attachments .size {
  color: var(--fg-muted);
  margin-left: 0.5rem;
  font-size: 0.8rem;
}

.thread-context {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.thread-context h2 { margin-top: 0; }
.thread-context ul { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.thread-context li { padding: 0.15rem 0; }
.thread-context .by { color: var(--fg-muted); font-size: 0.85rem; margin-left: 0.5rem; }

nav.message-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
nav.message-nav .group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
nav.message-nav .label { color: var(--fg-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
nav.message-nav .disabled { color: var(--fg-muted); opacity: 0.4; }

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.search-form input[type=search] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}
.search-form input[type=search]:focus {
  outline: none;
  border-color: var(--accent);
}
.search-form button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}
.search-form button:hover { background: var(--link-hover); border-color: var(--link-hover); }

ul.list-catalog {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.list-catalog li {
  padding: 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 0.75rem;
  align-items: baseline;
}
ul.list-catalog li:hover { background: var(--bg-alt); }
ul.list-catalog .subject { font-weight: 500; font-size: 1.05rem; }
ul.list-catalog .by { color: var(--fg-muted); font-size: 0.9rem; }

.search-results li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
}
.search-results .subject { font-weight: 500; }
.search-results .snippet { color: var(--fg-muted); font-size: 0.9rem; margin: 0.25rem 0 0; }
.search-results mark { background: rgba(255, 220, 0, 0.35); color: inherit; }

@media (max-width: 700px) {
  ul.thread-list li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  ul.thread-list time { text-align: left; }
  .search input { min-width: 140px; }
}
