:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-alt: #eef2f6;
  --border: #d8dee6;
  --text: #161b22;
  --text-muted: #57606a;
  --accent: #0f3d6e;
  --accent-hover: #1a5ca3;
  --badge-bg: #fff3cd;
  --badge-border: #e6c665;
  --badge-text: #5c4300;
  --code-bg: #f3f5f8;
  --max-width: 1040px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.65;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

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

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Status Banner */
.status-banner {
  background: var(--badge-bg);
  border-bottom: 1px solid var(--badge-border);
  color: var(--badge-text);
  font-size: 0.875rem;
  padding: 0.45rem 0;
  text-align: center;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.site-brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.site-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.site-title:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-version {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  color: var(--text-muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.site-nav a {
  color: var(--text-muted);
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* Main Content */
.site-main {
  padding: 2.25rem 0 3.5rem;
}

h1, h2, h3, h4 {
  color: var(--text);
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: 2rem;
  margin-top: 0;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

h2 {
  font-size: 1.45rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.15rem;
}

blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1.1rem;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  color: var(--text);
}

blockquote p:first-child {
  margin-top: 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
}

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

th {
  background: var(--surface);
  font-weight: 600;
}

tbody tr:nth-child(even) {
  background: #fafbfc;
}

/* Code */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.12rem 0.35rem;
  border-radius: 3px;
}

li code,
td code {
  overflow-wrap: anywhere;
}

mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 0.25rem 0;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.45;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.84rem;
}

/* Cards and Grids */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.hero h1 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #ffffff;
  text-decoration: none;
}

.btn-secondary {
  background: #ffffff;
  color: var(--accent);
}

.btn-secondary:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.2rem;
}

.card h3 {
  margin-top: 0;
  font-size: 1.05rem;
}

.spec-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.85rem;
}

.spec-toc strong {
  color: var(--text);
  margin-right: 0.15rem;
}

.spec-toc a {
  color: var(--accent);
  white-space: nowrap;
}

.diagram-wrap {
  margin: 1.5rem 0;
  overflow-x: auto;
}

.diagram-wrap svg {
  display: block;
  width: 100%;
  max-width: 780px;
  height: auto;
  margin: 0 auto;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

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