:root {
  color-scheme: light dark;
  --font-sans: "Lucida Grande", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --bg: #f2f8fc;
  --bg-top: #cce3f3;
  --surface: #ffffff;
  --surface-alt: #e9f5fd;
  --surface-soft: #eef7fc;
  --fg: #12232e;
  --muted: #5d7280;
  --line: #c4d6e2;
  --panel: #f7fbfd;
  --accent: #005893;
  --accent-hover: #007bce;
  --accent-strong: #002a46;
  --accent-soft: #d9eefb;
  --navy: #002a46;
  --shadow-sm: 0 1px 2px rgba(0, 42, 70, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 42, 70, 0.09);
  --max: 72rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1a24;
    --bg-top: #08131b;
    --surface: #122530;
    --surface-alt: #16303d;
    --surface-soft: #10232e;
    --fg: #e6f1f7;
    --muted: #9ab0be;
    --line: #26404e;
    --panel: #10232e;
    --accent: #7cc4ef;
    --accent-hover: #a8dcff;
    --accent-strong: #cfeaff;
    --accent-soft: #163849;
    --navy: #cfeaff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 17px;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-top) 0, #e8f4fb 280px, var(--bg) 540px);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(180deg, var(--bg-top) 0, #0a1d28 280px, var(--bg) 540px);
  }
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--accent-strong);
  color: #fff;
  padding: 0.5rem 1rem;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Header / nav */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(207, 231, 246, 0.92));
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

@media (prefers-color-scheme: dark) {
  .site-header {
    background: linear-gradient(180deg, rgba(9, 24, 34, 0.96), rgba(12, 36, 50, 0.92));
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 4.4rem;
  flex-wrap: wrap;
  padding-block: 0.5rem;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand-tagline {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.site-nav a {
  padding: 0.35rem 0.55rem;
  border-radius: 0.4rem;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.search {
  position: relative;
  flex: 1 1 18rem;
  min-width: 14rem;
  max-width: 24rem;
  margin-left: auto;
}

.search pagefind-searchbox {
  display: block;
  width: 100%;
}

main {
  min-height: 62vh;
  padding-block: 1.25rem 4rem;
}

h1,
h2,
h3 {
  line-height: 1.25;
}

h1,
h2,
h3,
strong {
  color: var(--navy);
}

/* Home */

.hero {
  position: relative;
  overflow: hidden;
  margin: 0.5rem 0 2rem;
  padding: clamp(1.6rem, 4vw, 3rem);
  border-radius: 1rem;
  background: radial-gradient(circle at 12% 0, #007bce 0, #005893 38%, #002a46 100%);
  box-shadow: var(--shadow-md);
  color: #fff;
}

.hero::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 48%);
  content: "";
  pointer-events: none;
}

.hero h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #9bd6f7;
}

.hero-sub {
  margin: 0.7rem 0 0;
  color: #e3f4ff;
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.hero-note {
  margin: 0.35rem 0 0;
  color: #a9d8f5;
  font-size: 0.85rem;
}

.index-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 0 1rem;
}

.index-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.index-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.archive-stats {
  margin: 0.2rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.archive-stats strong {
  color: var(--navy);
}

/* Forum index */

.forum-category {
  margin: 0 0 1.5rem;
}

.category-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border: 1px solid #002a46;
  border-bottom: 0;
  border-radius: 0.7rem 0.7rem 0 0;
  background: linear-gradient(180deg, #003a61, #002a46);
  color: #fff;
}

.category-head h2 {
  margin: 0;
  color: #fff;
  font-size: 1.02rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.category-desc {
  margin: 0;
  color: #cfe7f6;
  font-size: 0.82rem;
}

.subcategory-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 0.35rem;
  padding: 0 0.2rem;
}

.subcategory-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.forum-table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem 5rem 14rem;
  gap: 1rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem 0.7rem 0 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.forum-table-head span:nth-child(n + 2) {
  text-align: center;
}

.forum-table-head span:last-child {
  text-align: left;
}

.forum-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem 5rem 14rem;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
  transition: background-color 0.15s ease;
}

.forum-row:nth-of-type(even) {
  background: var(--surface-alt);
}

.forum-row:hover {
  background: var(--accent-soft);
}

.forum-category > .forum-row:last-child {
  border-radius: 0 0 0.7rem 0.7rem;
}

.forum-main {
  min-width: 0;
}

.forum-title {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.3;
}

.forum-title a {
  color: var(--navy);
  text-decoration: none;
}

.forum-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.forum-desc {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.subforums {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.subforums > span {
  font-weight: 700;
}

.subforum-chip {
  display: inline-block;
  margin: 0.12rem 0.15rem 0 0;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  text-decoration: none;
}

.subforum-chip:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.forum-stat {
  display: flex;
  flex-direction: column;
  text-align: center;
  line-height: 1.1;
}

.forum-stat strong {
  font-size: 1.05rem;
}

.forum-stat span {
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.forum-latest {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.forum-latest a {
  display: block;
  overflow: hidden;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forum-latest a:hover {
  text-decoration: underline;
}

.forum-latest span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

/* Section pages */

.breadcrumbs {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.breadcrumbs a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.section-hero {
  margin: 0 0 1.5rem;
  padding: clamp(1.1rem, 3vw, 1.8rem);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: linear-gradient(135deg, var(--surface), var(--surface-alt));
  box-shadow: var(--shadow-sm);
}

.section-hero h1 {
  margin: 0.15rem 0 0.4rem;
  color: var(--navy);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
}

.section-description {
  max-width: 60rem;
  margin: 0 0 0.6rem;
  color: var(--muted);
}

.section-stats {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.section-latest {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.section-latest a {
  color: var(--accent);
  font-weight: 600;
}

.list-title {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.subforum-section {
  margin: 0 0 1.75rem;
}

.subforum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  align-items: start;
  gap: 0.7rem;
}

.forum-single > .forum-row:only-child {
  border-top: 1px solid var(--line);
  border-radius: 0.7rem;
}

.subcategory-head {
  margin: 1rem 0 0;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 0.6rem 0.6rem 0 0;
  background: var(--surface-soft);
}

.subcategory-head h3 {
  margin: 0;
  color: var(--navy);
}

.subforum-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.subforum-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.subforum-name {
  color: var(--navy);
  font-size: 0.96rem;
  font-weight: 700;
}

.subforum-desc {
  color: var(--muted);
  font-size: 0.82rem;
}

.subforum-stats {
  margin-top: 0.15rem;
  color: var(--accent);
  font-size: 0.72rem;
}

/* Topic lists */

.topic-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.topic-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6rem 5rem 11rem;
  gap: 1rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.topic-head span:nth-child(2),
.topic-head span:nth-child(3) {
  text-align: center;
}

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

.topic-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6rem 5rem 11rem;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--line);
}

.topic-list li:first-child {
  border-top: 0;
}

.topic-list li:nth-child(even) {
  background: var(--surface-alt);
}

.topic-list li:hover {
  background: var(--accent-soft);
}

.topic-main {
  min-width: 0;
}

.topic-title {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
}

.topic-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.8rem;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.topic-author {
  color: var(--fg);
  font-weight: 600;
}

.topic-count {
  color: var(--navy);
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.topic-last {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.topic-last span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-muted {
  background: var(--surface-soft);
  color: var(--muted);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.page-link {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.page-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

/* Topic page */

.topic-hero {
  margin: 0 0 1.25rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: linear-gradient(135deg, var(--surface), var(--surface-alt));
}

.topic-hero h1 {
  margin: 0.1rem 0 0.4rem;
  color: var(--navy);
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.topic-meta-top {
  margin: 0;
}

.topic .post {
  overflow: hidden;
  scroll-margin-top: 6rem;
  overflow-wrap: anywhere;
  margin: 0 0 1rem;
  padding: 0 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.topic .post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.8rem;
  margin: 0 -1rem 0.9rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
}

.post-author {
  color: var(--navy);
  font-weight: 700;
}

.post-number {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.post blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 0.9rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 0.4rem 0.4rem 0;
  background: var(--accent-soft);
  color: var(--fg);
}

.post blockquote blockquote {
  margin: 0.5rem 0;
  background: transparent;
}

.post pre {
  overflow-x: auto;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--surface-soft);
}

.post code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.post img {
  max-width: 100%;
  height: auto;
  border-radius: 0.35rem;
}

.math-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 1rem 0;
}

.spoiler {
  margin: 0.75rem 0;
  padding: 0.4rem 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 0.45rem;
  background: var(--surface-soft);
}

.spoiler summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.signature {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.signature summary {
  cursor: pointer;
}

.attachments {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  font-size: 0.82rem;
}

.attachments ul {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.2rem;
}

.edited {
  margin: 0.75rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.poll {
  margin: 0 0 1.2rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--accent-soft);
}

.poll ul {
  margin: 0.5rem 0 0;
}

.prev-next {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 0;
}

/* Footer */

.site-footer {
  margin-top: 3rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: 0.8rem;
}

@media (prefers-color-scheme: dark) {
  .site-footer {
    background: rgba(10, 26, 37, 0.6);
  }
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

.footer-brand strong {
  color: var(--navy);
}

.footer-brand span {
  display: block;
  font-size: 0.75rem;
}

.site-footer p {
  margin: 0.1rem 0;
}

/* Pagefind Component UI */

:root {
  --pf-text: var(--fg);
  --pf-text-secondary: var(--muted);
  --pf-text-muted: var(--muted);
  --pf-background: var(--surface);
  --pf-border: var(--line);
  --pf-border-focus: var(--accent);
  --pf-skeleton: var(--surface-soft);
  --pf-skeleton-shine: var(--surface);
  --pf-hover: var(--accent-soft);
  --pf-mark: var(--accent-strong);
  --pf-scroll-shadow: rgba(0, 42, 70, 0.08);
  --pf-shadow-sm: var(--shadow-sm);
  --pf-shadow-md: var(--shadow-md);
  --pf-shadow-lg: 0 16px 48px rgba(0, 42, 70, 0.2);
  --pf-outline-focus: var(--accent);
  --pf-font: var(--font-sans);
  --pf-border-radius: 0.5rem;
  --pf-input-height: 38px;
  --pf-input-font-size: 16px;
  --pf-searchbox-max-width: 100%;
  --pf-searchbox-dropdown-max-height: 60vh;
  --pf-dropdown-z-index: 60;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pf-text: #e6f1f7;
    --pf-text-secondary: #9ab0be;
    --pf-text-muted: #9ab0be;
    --pf-background: #122530;
    --pf-border: #26404e;
    --pf-border-focus: #7cc4ef;
    --pf-skeleton: #10232e;
    --pf-skeleton-shine: #16303d;
    --pf-hover: #163849;
    --pf-mark: #cfeaff;
    --pf-scroll-shadow: rgba(255, 255, 255, 0.1);
    --pf-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  }
}

/* Responsive */

@media (max-width: 900px) {
  .header-inner {
    gap: 0.75rem;
  }

  .site-nav {
    order: 3;
    width: 100%;
  }

  .search {
    order: 2;
    flex-basis: 100%;
    max-width: none;
  }

  .forum-table-head {
    display: none;
  }

  .forum-row {
    grid-template-columns: minmax(0, 1fr) 4.5rem 4.5rem;
  }

  .forum-latest {
    grid-column: 1 / -1;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--line);
  }

  .topic-head {
    display: none;
  }

  .topic-list li {
    grid-template-columns: minmax(0, 1fr) 4.5rem 4.5rem;
  }

  .topic-last {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 0.6rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--line);
  }
}

@media (max-width: 620px) {
  html {
    font-size: 16px;
  }

  .wrap {
    width: min(100% - 1.2rem, var(--max));
  }

  .header-inner {
    align-items: flex-start;
  }

  .brand {
    width: 100%;
  }

  .site-nav {
    order: 2;
  }

  .search {
    order: 3;
  }

  .forum-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }

  .forum-stat {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.35rem;
    margin-right: 1rem;
    text-align: left;
  }

  .topic-list li {
    grid-template-columns: minmax(0, 1fr);
  }

  .topic-count {
    display: none;
  }

  .topic-last {
    border-top: 1px dashed var(--line);
  }

  .prev-next {
    flex-direction: column;
  }
}
