@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --bg-outer: #e9e6df;
  --bg-paper: #f9f8f4;
  --bg-card: #ffffff;
  --bg-code: #efede6;
  --bg-header: #181817;
  --bg-notice: #f7f0d4;
  --ink: #161615;
  --ink-muted: #52504a;
  --border: #181817;
  --border-muted: #9c988e;
  --accent-red: #991b1b;
  --accent-blue: #0d367a;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 17px;
}

body {
  margin: 0;
  padding: 1.25rem 0.75rem 3rem;
  background-color: var(--bg-outer);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.62;
  text-align: start;
  overflow-wrap: break-word;
}

p {
  margin: 0.65rem 0;
  text-wrap: pretty;
}

h1, h2, h3, h4, th {
  text-wrap: balance;
}

a {
  color: var(--accent-blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

a:visited {
  color: #3d2163;
}

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

/* --- CONTAINER --- */
.page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem 2rem;
}

/* --- HEADER --- */
.site-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.title {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
}

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

.tagline {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

.lang-switch {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
}

.lang-switch a {
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  padding: 0 0.2rem;
}

.lang-switch a.active,
.lang-switch a:hover {
  color: var(--accent-red);
  text-decoration: underline;
}

/* --- NAVIGATION BAR --- */
.nav {
  background: var(--bg-header);
  color: #f9f8f4;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  margin-bottom: 1.15rem;
}

.nav a {
  color: #f9f8f4;
  text-decoration: none;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
}

.nav a:visited {
  color: #f9f8f4;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: #f9f8f4;
  color: var(--ink);
}

.nav-sep {
  color: #76736a;
  user-select: none;
}

/* --- SECTIONS, BOXES & CARDS --- */
.hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.box,
.wide-section {
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 1rem 1.2rem;
  min-width: 0;
}

.section-title {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
  margin-bottom: 0.85rem;
}

.section-title h2 {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  font-weight: 700;
  margin: 0;
}

.notice {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  background: var(--bg-notice);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.notice b {
  font-family: var(--font-mono);
}

/* --- QA / LOG BLOCKS --- */
.qa-item {
  border-left: 2px solid var(--border);
  padding-left: 0.85rem;
  margin: 0.85rem 0;
}

.qa-q {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

/* --- GRIDS --- */
.grid {
  display: grid;
  gap: 0.85rem;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.card {
  border: 1px solid var(--border);
  background: var(--bg-paper);
  padding: 0.85rem 1rem;
  min-width: 0;
}

.feature-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px dotted var(--border-muted);
  padding-bottom: 0.2rem;
}

/* --- CODE, ASCII & TABLES --- */
code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

code {
  background: var(--bg-code);
  padding: 0.1rem 0.32rem;
  border: 1px solid #d4d0c5;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 0.75rem 0.95rem;
  overflow-x: auto;
  margin: 0.65rem 0;
  line-height: 1.48;
}

pre code {
  background: none;
  padding: 0;
  border: 0;
}

.ascii {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.25;
  white-space: pre;
  overflow-x: auto;
  background: var(--bg-code);
  border: 1px solid var(--border-muted);
  padding: 0.75rem;
  margin: 0.75rem 0 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.94rem;
  margin: 0.75rem 0;
  background: var(--bg-card);
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--bg-code);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
}

/* --- DOCUMENTATION SIDEBAR LAYOUT --- */
.doc-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.doc-toc {
  position: sticky;
  top: 0.85rem;
  max-height: calc(100vh - 1.7rem);
  overflow-y: auto;
}

.doc-toc ul {
  list-style: none;
  margin: 0.35rem 0;
  padding-left: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.65;
}

.doc-toc > .box > ul {
  padding-left: 0;
}

.doc-toc li {
  margin: 0.15rem 0;
}

.doc-toc a {
  text-decoration: none;
  color: var(--ink);
}

.doc-toc a:hover {
  color: var(--accent-red);
  text-decoration: underline;
}

.doc-section {
  margin-bottom: 1.1rem;
  scroll-margin-top: 1rem;
}

.doc-section h3 {
  font-family: var(--font-mono);
  font-size: 1.02rem;
  margin: 1.15rem 0 0.4rem 0;
  padding-bottom: 0.2rem;
  border-bottom: 1px dotted var(--border-muted);
}

/* --- BUTTONS & DOWNLOADS --- */
.btn {
  display: inline-block;
  background: var(--bg-header);
  color: #f9f8f4 !important;
  padding: 0.35rem 0.85rem;
  text-decoration: none !important;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer;
}

.btn:hover {
  background: var(--accent-blue);
  color: #ffffff !important;
}

.btn-secondary {
  background: var(--bg-code);
  color: var(--ink) !important;
}

.btn-secondary:hover {
  background: var(--border);
  color: #f9f8f4 !important;
}

.download-card {
  border: 1px solid var(--border);
  background: var(--bg-paper);
  padding: 0.9rem 1rem;
}

.download-card h3 {
  margin: 0 0 0.35rem 0;
  font-size: 1rem;
  font-family: var(--font-mono);
}

.download-card .file-info {
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.download-card .checksum {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin: 0.35rem 0 0.5rem;
}

/* --- UTILITIES --- */
.small {
  font-size: 0.92rem;
}

.tiny {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.center {
  text-align: center;
}

footer {
  margin-top: 1.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

@media (max-width: 960px) {
  .hero,
  .doc-layout {
    grid-template-columns: 1fr;
  }

  .doc-toc {
    position: static;
    max-height: none;
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  body {
    padding: 0.5rem 0.35rem 2rem;
  }

  .page {
    padding: 0.85rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}
