/* Taguru docs — shared design system.
   The tokens and the aesthetic come from mcp-rag-walkthrough.html
   (the first page of this site); keep the two in step. */

:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-alt: #ede7d9;
  --code-bg: #2a2f3a;
  --code-ink: #dfe3ea;
  --code-key: #9fc2e8;
  --code-str: #d9c98a;
  --code-num: #e0a172;
  --code-dim: #8f99a8;
  --ink: #22262e;
  --ink-soft: #5b6570;
  --ink-faint: #8b93a0;
  --accent: #2c4a73;
  --accent-strong: #1c3252;
  --accent-soft: #dce6f0;
  --thread: #a8402f;
  --thread-soft: #f3e1dc;
  --line: #d8d2c4;
  --shadow: 0 1px 2px rgba(34, 38, 46, 0.06), 0 6px 20px rgba(34, 38, 46, 0.05);
  --font-heading: "Hiragino Mincho ProN", "YuMincho", "Yu Mincho", "HGS明朝E", serif;
  --font-body: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "YuGothic", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  --font-mono: "SF Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
}
:root[data-theme="dark"] {
  --bg: #14171e;
  --surface: #1b2029;
  --surface-alt: #232a36;
  --code-bg: #10141c;
  --code-ink: #d7dce4;
  --code-key: #8fb8e4;
  --code-str: #d7c78a;
  --code-num: #dd9a6c;
  --code-dim: #78818f;
  --ink: #e7e4da;
  --ink-soft: #a8b0bc;
  --ink-faint: #6d7684;
  --accent: #8fb1d8;
  --accent-strong: #b7d0ec;
  --accent-soft: #232f43;
  --thread: #dd8064;
  --thread-soft: #34241f;
  --line: #2b3140;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-alt: #ede7d9;
  --code-bg: #2a2f3a;
  --code-ink: #dfe3ea;
  --code-key: #9fc2e8;
  --code-str: #d9c98a;
  --code-num: #e0a172;
  --code-dim: #8f99a8;
  --ink: #22262e;
  --ink-soft: #5b6570;
  --ink-faint: #8b93a0;
  --accent: #2c4a73;
  --accent-strong: #1c3252;
  --accent-soft: #dce6f0;
  --thread: #a8402f;
  --thread-soft: #f3e1dc;
  --line: #d8d2c4;
  --shadow: 0 1px 2px rgba(34, 38, 46, 0.06), 0 6px 20px rgba(34, 38, 46, 0.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171e;
    --surface: #1b2029;
    --surface-alt: #232a36;
    --code-bg: #10141c;
    --code-ink: #d7dce4;
    --code-key: #8fb8e4;
    --code-str: #d7c78a;
    --code-num: #dd9a6c;
    --code-dim: #78818f;
    --ink: #e7e4da;
    --ink-soft: #a8b0bc;
    --ink-faint: #6d7684;
    --accent: #8fb1d8;
    --accent-strong: #b7d0ec;
    --accent-soft: #232f43;
    --thread: #dd8064;
    --thread-soft: #34241f;
    --line: #2b3140;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* ---------- Layout: sidebar + content ---------- */
.layout { display: flex; align-items: stretch; }
.content { flex: 1 1 auto; min-width: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.55em;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
/* White tile behind the logo: keeps its indigo linework legible on the
   dark theme no matter what the PNG's own background is. */
.brand-mark {
  width: 1.6em;
  height: 1.6em;
  border-radius: 5px;
  background: #fff;
  padding: 0.1em;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar {
  width: 16rem;
  flex: 0 0 16rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 1.5rem 1.15rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}
.side-nav { display: flex; flex-direction: column; gap: 1.25rem; }
.side-group { display: flex; flex-direction: column; gap: 0.12rem; }
.side-group-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 0.35rem 0.6rem;
}
.side-group a {
  display: block;
  padding: 0.32em 0.6em;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.side-group a:hover { background: var(--surface-alt); color: var(--ink); text-decoration: none; }
.side-group a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}
.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}
.sidebar-footer a { color: var(--ink-soft); }

/* ---------- Mobile top bar ---------- */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
}
.topbar .brand { margin-right: auto; }
.scrim { display: none; }

.theme-toggle, .nav-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover, .nav-toggle:hover { color: var(--ink); }

@media (max-width: 960px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    z-index: 40;
    transform: translateX(-103%);
    transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(20, 23, 30, 0.4);
  }
}

/* ---------- Hero ---------- */
header.hero { margin: 3rem 0 3.5rem; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--thread);
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin-bottom: 1.1rem;
}
.eyebrow::before {
  content: "";
  display: inline-block;
  width: 2.2em;
  height: 1px;
  background: var(--thread);
}
h1 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  line-height: 1.4;
  margin: 0 0 0.9rem;
  text-wrap: balance;
  color: var(--ink);
}
.lede {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 0 1.6rem;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.hero-meta span { white-space: nowrap; }
.hero-meta b { color: var(--ink-soft); font-weight: 600; }

/* ---------- Sections ---------- */
section { margin-bottom: 3.6rem; }
h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.3rem;
  text-wrap: balance;
}
h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.8rem 0 0.4rem;
}
.section-sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 1.6rem;
  max-width: 62ch;
}
p { max-width: 66ch; }
ul, ol { max-width: 66ch; padding-left: 1.4em; }
li { margin-bottom: 0.35em; }
li::marker { color: var(--ink-faint); }

/* ---------- Cards ---------- */
.model-card, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.6rem 1.8rem;
  box-shadow: var(--shadow);
}
.model-card p { margin: 0 0 0.9rem; font-size: 0.96rem; color: var(--ink); max-width: none; }
.model-card p:last-child { margin-bottom: 0; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.9rem;
  margin-top: 1.4rem;
}
.card { padding: 1.15rem 1.3rem; }
.card h3 { margin: 0 0 0.35rem; font-size: 0.98rem; }
.card p { margin: 0; font-size: 0.88rem; color: var(--ink-soft); max-width: none; }

/* Link cards (index navigation) */
.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.9rem;
  margin-top: 1.4rem;
}
a.nav-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.15rem 1.3rem;
  box-shadow: var(--shadow);
  color: var(--ink);
}
a.nav-card:hover { text-decoration: none; border-color: var(--accent); }
a.nav-card .nc-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 0.35rem;
}
a.nav-card .nc-title::after { content: "→"; color: var(--thread); font-weight: 400; }
a.nav-card p { margin: 0; font-size: 0.88rem; color: var(--ink-soft); max-width: none; }

.tuple {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0.15em 0.5em;
  border-radius: 5px;
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface-alt);
  color: var(--ink);
  padding: 0.32em 0.62em;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.chip.used {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
  font-weight: 600;
}
.chip.used-text {
  background: var(--thread-soft);
  color: var(--thread);
  border-color: transparent;
  font-weight: 600;
}

/* ---------- Loop diagram ---------- */
.loop {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0;
  margin-top: 1.4rem;
}
.loop-step {
  position: relative;
  padding: 1rem 1.1rem 1rem 0;
  border-bottom: 2px solid var(--line);
}
.loop-step .n {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--thread);
  display: block;
  margin-bottom: 0.35rem;
}
.loop-step .t {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  display: block;
  margin-bottom: 0.2rem;
}
.loop-step .d { font-size: 0.8rem; color: var(--ink-soft); }

/* ---------- Code ---------- */
pre {
  margin: 1.1rem 0;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 0.85rem 1rem;
  border-radius: 7px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.65;
}
pre code { font-size: inherit; background: none; padding: 0; border-radius: 0; }
code { font-family: var(--font-mono); }
p code, li code, td code, .note code, h3 code, .section-sub code, .card p code {
  font-size: 0.85em;
  background: var(--surface-alt);
  padding: 0.1em 0.38em;
  border-radius: 4px;
}
.k { color: var(--code-key); }
.s { color: var(--code-str); }
.nu { color: var(--code-num); }
.c { color: var(--code-dim); }
.hl { background: rgba(255, 255, 255, 0.14); border-radius: 3px; padding: 0 0.15em; }

/* ---------- Tables ---------- */
.tbl { overflow-x: auto; margin: 1.1rem 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.86rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
th, td {
  text-align: left;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
  background: var(--surface-alt);
}
td:first-child { font-family: var(--font-mono); font-size: 0.8rem; white-space: nowrap; }

/* ---------- Callouts ---------- */
.note {
  font-size: 0.88rem;
  color: var(--ink-soft);
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 0.85rem 1.05rem;
  margin: 1.2rem 0;
  max-width: none;
}
.note b { color: var(--ink); }
.note.warn { border-left: 3px solid var(--thread); border-radius: 0 8px 8px 0; }

/* ---------- Principles ---------- */
.principles { display: grid; gap: 0.9rem; margin-top: 1.4rem; }
.principle {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.8rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}
.principle:last-child { border-bottom: none; }
.principle .mark {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--thread);
}
.principle h3 {
  margin: 0 0 0.25rem;
  font-size: 0.98rem;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
}
.principle p { margin: 0; font-size: 0.88rem; color: var(--ink-soft); max-width: none; }

/* ---------- Architecture diagram ---------- */
.arch { display: grid; gap: 0.55rem; margin: 1.4rem 0; }
.arch-layer {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.9rem;
  align-items: stretch;
}
.arch-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
}
.arch-row { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.arch-box {
  flex: 1 1 8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  box-shadow: var(--shadow);
}
.arch-box b {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-strong);
  margin-bottom: 0.1rem;
}
.arch-box span { font-size: 0.76rem; color: var(--ink-soft); line-height: 1.5; display: block; }
.arch-box.lane-text b { color: var(--thread); }
.arch-box.dim { background: var(--surface-alt); box-shadow: none; }
.arch-down {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.8rem;
  line-height: 1;
  grid-column: 2;
}
@media (max-width: 640px) {
  .arch-layer { grid-template-columns: 1fr; }
  .arch-label { justify-content: flex-start; text-align: left; }
  .arch-down { grid-column: 1; }
}

/* ---------- Footer ---------- */
footer.colophon {
  margin-top: 4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}
footer.colophon a { color: var(--ink-soft); }

/* ---------- Page-to-page footer nav ---------- */
.next-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 1.4rem;
}
