:root {
  --bg: #f6f3ee;
  --bg-deep: #eae5dc;
  --ink: #1a1714;
  --ink-soft: #4a453d;
  --ink-muted: #8a847a;
  --accent-n: #b44533;
  --accent-z: #7a8a6a;
  --accent-p: #2a5a8a;
  --accent-impl: #8a5a2a;
  --rule: #ccc5b8;
  --code-bg: #1a1714;
  --code-fg: #e8e2d8;
  --card-bg: #fff;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Libre Franklin', sans-serif;
  --font-code: 'Source Code Pro', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-p);
  color: #fff;
}

/* ── HEADER ── */
.hero {
  max-width: 860px;
  margin: 0 auto;
  padding: 5rem 2rem 3rem;
}

.hero-kicker {
  font-family: var(--font-code);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent-p);
}

.hero-sub {
  font-size: 1.15rem;
  font-weight: 300;
  color: var(--ink-soft);
  max-width: 600px;
  line-height: 1.65;
}

.hero-meta {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-family: var(--font-code);
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

/* ── ARTICLE ── */
article {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 2rem 6rem;
}

article p {
  margin-bottom: 1.4rem;
}

article h2 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  margin: 3.5rem 0 1rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

article h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2.5rem 0 0.8rem;
  line-height: 1.3;
}

article strong {
  font-weight: 600;
  color: var(--ink);
}

article a {
  color: var(--accent-p);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(42, 90, 138, 0.3);
  transition: text-decoration-color 0.2s;
}
article a:hover {
  text-decoration-color: var(--accent-p);
}
/* ── TABLES ── */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 1.5rem 0;
}
.spec-table th {
  text-align: left;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--ink);
  font-size: 0.82rem;
}
.spec-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.spec-table .num {
  font-family: var(--font-code);
  font-weight: 600;
  color: var(--accent-p);
}

/* ── TRIT VIZ ── */
.trit-scale {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 2rem auto;
  max-width: 400px;
}
.trit-scale .pole {
  flex: 1;
  text-align: center;
  padding: 1rem 0.5rem;
  font-family: var(--font-code);
  font-size: 0.85rem;
  font-weight: 600;
}
.trit-scale .pole-n {
  background: linear-gradient(135deg, #f3ddd8, #f6ece8);
  color: var(--accent-n);
  border-radius: 8px 0 0 8px;
}
.trit-scale .pole-z {
  background: linear-gradient(135deg, #e4ead8, #eef2e4);
  color: var(--accent-z);
}
.trit-scale .pole-p {
  background: linear-gradient(135deg, #d0dfe8, #e0ecf4);
  color: var(--accent-p);
  border-radius: 0 8px 8px 0;
}
.trit-scale .pole small {
  display: block;
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 0.3rem;
}
  

/* ── DROP CAP ── */
.drop-cap::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 3.8rem;
  line-height: 0.8;
  padding-right: 0.12em;
  margin-top: 0.08em;
  color: var(--accent-p);
  font-weight: 700;
}

/* ── PULLQUOTE ── */
.pullquote {
  margin: 2.5rem -2rem;
  padding: 2rem 2.5rem;
  border-left: 4px solid var(--accent-p);
  background: linear-gradient(135deg, rgba(42,90,138,0.04), transparent);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ── TRUTH TABLES ── */
.truth-table-wrap {
  margin: 2rem 0;
  overflow-x: auto;
}
.truth-table {
  border-collapse: collapse;
  font-family: var(--font-code);
  font-size: 0.82rem;
  width: 100%;
}
.truth-table caption {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  text-align: left;
  margin-bottom: 0.5rem;
  color: var(--ink-soft);
}
.truth-table th {
  background: var(--ink);
  color: var(--code-fg);
  padding: 0.5rem 1rem;
  text-align: center;
  font-weight: 600;
}
.truth-table td {
  padding: 0.45rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}
.truth-table tr:nth-child(even) td {
  background: rgba(0,0,0,0.02);
}
.trit-n { color: var(--accent-n); font-weight: 600; }
.trit-z { color: var(--accent-z); font-weight: 600; }
.trit-p { color: var(--accent-p); font-weight: 600; }

/* ── CODE ── */
code {
  font-family: var(--font-code);
  font-size: 0.85em;
  background: rgba(0,0,0,0.06);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: var(--font-code);
  font-size: 0.82rem;
  line-height: 1.65;
}
pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
.code-comment { color: #7a8a6a; }
.code-keyword { color: #d4a06a; }
.code-value { color: #8ab4d4; }

/* ── DIAGRAM CARDS ── */
.diagram-card {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.diagram-card h4 {
  font-family: var(--font-code);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1rem;
}

/* ── TRIT VISUALIZATION ── */
.trit-viz {
  display: flex;
  gap: 3px;
  margin: 0.5rem 0;
  font-family: var(--font-code);
  font-size: 0.85rem;
}
.trit-viz .t {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-weight: 600;
}
.trit-viz .t-n { background: #f3ddd8; color: var(--accent-n); }
.trit-viz .t-z { background: #e4ead8; color: var(--accent-z); }
.trit-viz .t-p { background: #d0dfe8; color: var(--accent-p); }

.trit-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.6rem 0;
  font-size: 0.88rem;
}
.trit-label {
  font-family: var(--font-code);
  font-size: 0.78rem;
  color: var(--ink-muted);
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}
.trit-op {
  font-family: var(--font-code);
  font-size: 0.78rem;
  color: var(--ink-muted);
  width: 100%;
  text-align: right;
  font-style: italic;
}

/* ── APPLICATION BLOCKS ── */
.app-block {
  margin: 2.5rem 0;
  padding: 1.8rem 2rem;
  border-radius: 8px;
  border-left: 4px solid;
}
.app-block.app-tmr { border-color: var(--accent-p); background: rgba(42,90,138,0.04); }
.app-block.app-diff { border-color: var(--accent-n); background: rgba(180,69,51,0.04); }
.app-block.app-acl { border-color: var(--accent-impl); background: rgba(138,90,42,0.04); }
.app-block.app-sql { border-color: var(--accent-z); background: rgba(122,138,106,0.04); }

.app-block h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}
.app-block p {
  margin-bottom: 0.8rem;
}

/* ── COMPARISON TABLE ── */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 1.5rem 0;
}
.cmp-table th {
  text-align: left;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid var(--ink);
  font-size: 0.82rem;
}
.cmp-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.cmp-table .num {
  font-family: var(--font-code);
  font-weight: 600;
  color: var(--accent-p);
  text-align: center;
}

/* ── SEPARATOR ── */
.sep {
  text-align: center;
  margin: 3rem 0;
  color: var(--rule);
  font-size: 1.2rem;
  letter-spacing: 0.5em;
}

/* ── FOOTER ── */
.article-footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--ink-muted);
  line-height: 1.7;
}
.article-footer a {
  color: var(--accent-p);
}

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .hero h1 { font-size: 2.2rem; }
  article h2 { font-size: 1.5rem; }
  .pullquote { margin: 2rem 0; padding: 1.5rem; }
  .diagram-card { padding: 1.2rem; }
}

/* ── DIAGRAM CARDS ── */
.diagram-card {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.diagram-card h4 {
  font-family: var(--font-code);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1rem;
}

/* ── INSTRUCTION FORMAT ── */
.fmt-row {
  display: flex;
  gap: 2px;
  margin: 0.5rem 0;
  font-family: var(--font-code);
  font-size: 0.78rem;
}
.fmt-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.4rem;
  border-radius: 4px;
  text-align: center;
  line-height: 1.3;
}
.fmt-field .fname { font-weight: 600; }
.fmt-field .fbits { font-size: 0.68rem; color: var(--ink-muted); }
.fmt-op { background: #d0dfe8; color: var(--accent-p); flex: 4; }
.fmt-rd { background: #e0ecf4; color: #1a4a6a; flex: 3; }
.fmt-rs1 { background: #e4ead8; color: #4a6a3a; flex: 3; }
.fmt-rs2 { background: #f3ece0; color: #6a5a3a; flex: 3; }
.fmt-funct { background: #f0ebe4; color: var(--ink-muted); flex: 14; }
.fmt-imm { background: #f3ece0; color: #6a5a3a; flex: 17; }
.fmt-off20 { background: #f3ece0; color: #6a5a3a; flex: 20; }
.fmt-off23 { background: #f3ece0; color: #6a5a3a; flex: 23; }

.fmt-label {
  font-family: var(--font-code);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.05em;
}

/* ── ROADMAP ── */
.roadmap {
  position: relative;
  padding-left: 2rem;
  margin: 2rem 0;
}
.roadmap::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0.3rem;
  bottom: 0.3rem;
  width: 2px;
  background: var(--rule);
}
.roadmap-item {
  position: relative;
  margin-bottom: 1.8rem;
}
.roadmap-item::before {
  content: '';
  position: absolute;
  left: -1.65rem;
  top: 0.55rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent-p);
  background: var(--bg);
}
.roadmap-item.done::before {
  background: var(--accent-p);
}
.roadmap-item h4 {
  font-family: var(--font-code);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.roadmap-item h4 span {
  font-weight: 400;
  color: var(--ink-muted);
}
.roadmap-item p {
  font-size: 0.88rem;
  margin: 0;
  color: var(--ink-soft);
}

.layer-stack {
  display: flex; flex-direction: column; gap: 2px; margin: 1rem 0;
}
.layer {
  display: flex; align-items: center; border-radius: 6px;
  padding: 0.8rem 1.2rem; font-size: 0.88rem; gap: 1rem;
}
.layer-name {
  font-family: var(--font-code); font-weight: 600;
  min-width: 100px;
}
.layer-desc { color: var(--ink-soft); font-size: 0.85rem; }
.layer-trit { background: #d0dfe8; color: #1a4a6a; }
.layer-trits { background: #c8ddd0; color: #2a5a3a; }
.layer-tryte { background: #e0d8c8; color: #5a4a2a; }
.layer-logic { background: #ddd0e0; color: #5a2a6a; }
