:root {
  --bg: #0f1419;
  --bg-elevated: #1a2332;
  --bg-card: #1e2a3a;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --text-muted: #9aa8bc;
  --accent: #5b9fd4;
  --accent-soft: rgba(91, 159, 212, 0.15);
  --accent-2: #7cb87c;
  --accent-3: #d4a05b;
  --accent-4: #b07cd4;
  --bg-code: #0b1016;
  --bg-media: #0a0e13;
  --code-text: #d5deea;
  --code-src: #b8c5d6;
  --glow-a: rgba(91, 159, 212, 0.18);
  --glow-b: rgba(176, 124, 212, 0.12);
  --radius: 12px;
  --font: "IBM Plex Sans", "Noto Sans SC", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Source Code Pro", monospace;
}

html[data-theme="light"] {
  --bg: #f3f5f8;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #d7dee6;
  --text: #1c2430;
  --text-muted: #5b6b7c;
  --accent: #2b6ea8;
  --accent-soft: rgba(43, 110, 168, 0.12);
  --accent-2: #3d8a4a;
  --accent-3: #b47a2c;
  --accent-4: #7a4ea3;
  --bg-code: #eef2f6;
  --bg-media: #e6ebf1;
  --code-text: #243040;
  --code-src: #5b6b7c;
  --glow-a: rgba(43, 110, 168, 0.1);
  --glow-b: rgba(180, 122, 44, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  color-scheme: dark;
}

html[data-theme="light"],
html[data-theme="light"] body {
  color-scheme: light;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, var(--glow-a), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, var(--glow-b), transparent);
  background-attachment: fixed;
}

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

a:hover {
  text-decoration: underline;
}

.wrap {
  width: min(1080px, calc(100% - 2.5rem));
  margin: 0 auto;
}

/* ---- header / nav ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  border-bottom: 1px solid transparent;
}

.brand {
  font-weight: 650;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

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

.nav {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
}

.theme-toggle {
  margin-left: 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- hero (homepage) ---- */
.hero {
  min-height: calc(100vh - 8rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 0 3rem;
}

.hero-intro {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 0 0 2.25rem;
}

.hero-avatar {
  width: 112px;
  height: 112px;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
  border: 2px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.hero-brand {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}

@media (max-width: 520px) {
  .hero-intro {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
  }

  .hero-avatar {
    width: 96px;
    height: 96px;
  }
}

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

@media (max-width: 720px) {
  .gate-grid {
    grid-template-columns: 1fr;
  }
}

.gate {
  display: block;
  padding: 1.4rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
  min-height: 8.5rem;
}

.gate:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-2px);
}

.gate-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.45rem;
}

.gate[data-tone="robot"] .gate-kicker {
  color: var(--accent-2);
}

.gate[data-tone="obs"] .gate-kicker {
  color: var(--accent-3);
}

.gate[data-tone="wiki"] .gate-kicker {
  color: var(--accent-4);
}

.gate[data-tone="native"] .gate-kicker {
  color: #c97b6a;
}

.gate-title {
  font-size: 1.25rem;
  font-weight: 650;
  margin: 0 0 0.45rem;
}

.gate-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.hero-foot {
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.hero-foot a {
  color: var(--text-muted);
  border-bottom: 1px dashed var(--border);
}

.hero-foot a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ---- topic list pages ---- */
.page-head {
  padding: 2rem 0 1.25rem;
}

.crumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.crumb a {
  color: var(--text-muted);
}

.page-title {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 0 0 0.4rem;
  font-weight: 700;
}

.page-sub {
  margin: 0;
  color: var(--text-muted);
  max-width: 40rem;
}

.search-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 1.5rem 0 0.5rem;
}

.search-bar input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 0.75rem 1rem;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.meta-row {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 3rem;
}

.article-card {
  display: block;
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.article-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

.article-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.article-card .summary {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.article-card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.date {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(30, 42, 58, 0.4);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

/* ---- robot pipeline (compact one-viewport) ---- */
.pipeline-viewport {
  min-height: 100vh;
}

.pipeline-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.pipeline-top {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.pipeline-page {
  padding-bottom: 1rem;
}

.pipeline-page--compact {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.5rem 0 1rem;
}

.pipeline-head {
  margin-bottom: 1.25rem;
}

.pipeline-head .crumb {
  margin-bottom: 0.35rem;
}

.pipeline-page-title {
  margin: 0 0 0.25rem;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 700;
}

.pipeline-one-liner {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.pipeline-flow {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.pipe-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0.7rem;
  color: var(--text);
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-top: 3px solid var(--step-accent, var(--accent));
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.pipe-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--step-accent, var(--accent));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.pipe-card[data-stage="collect"] {
  --step-accent: #5b9fd4;
}

.pipe-card[data-stage="train"] {
  --step-accent: #d4a05b;
}

.pipe-card[data-stage="deploy"] {
  --step-accent: #7cb87c;
}

.pipe-card[data-stage="online"] {
  --step-accent: #c97b6a;
}

.pipe-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 0.65rem;
  background: var(--bg-media);
}

.pipe-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--step-accent, var(--accent));
  margin-bottom: 0.2rem;
}

.pipe-card h2 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.pipe-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.pipe-arrow {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  padding: 0 0.15rem;
  min-width: 28px;
}

.pipe-arrow svg {
  display: block;
  width: 22px;
  height: 36px;
  overflow: visible;
}

.pipe-arrow-nudge {
  animation: pipe-arrow-flow 1.15s ease-in-out infinite;
  transform-origin: center;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 45%, transparent));
}

.pipe-arrow-nudge:nth-child(2) {
  animation-delay: 0.18s;
  opacity: 0.45;
  margin-left: -10px;
}

@keyframes pipe-arrow-flow {
  0% { transform: translateX(-5px); opacity: 0.25; }
  35% { transform: translateX(2px); opacity: 1; }
  70% { transform: translateX(7px); opacity: 0.55; }
  100% { transform: translateX(-5px); opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .pipe-arrow-nudge {
    animation: none;
    opacity: 0.9;
    filter: none;
    margin-left: 0;
  }
}

.pipeline-mini-foot {
  padding: 0.75rem 0 1.1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pipeline-mini-foot a {
  color: var(--text-muted);
}

.pipeline-mini-foot a:hover {
  color: var(--accent);
  text-decoration: none;
}

.pipeline-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.35rem;
}

.pipeline-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--step-accent, var(--accent));
}

.pipeline-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .pipeline-flow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .pipe-arrow {
    display: none;
  }

  .pipeline-page--compact {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .pipeline-flow {
    grid-template-columns: 1fr;
  }
}

/* stage detail pages */
.stage-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 1.5rem;
  align-items: center;
  margin: 0 0 2rem;
}

.stage-hero-copy .page-title {
  margin-bottom: 0.6rem;
}

.stage-hero-copy .page-sub {
  margin-bottom: 1rem;
}

.stage-hero-media {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-media);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

.stage-hero-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.stage-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 2rem;
}

.stage-point {
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(30, 42, 58, 0.55);
}

.stage-point h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.stage-point p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stage-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.stage-nav a {
  color: var(--text-muted);
}

.stage-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

@media (max-width: 800px) {
  .stage-hero {
    grid-template-columns: 1fr;
  }

  .stage-points {
    grid-template-columns: 1fr;
  }
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 2rem;
}

.doc-card {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 1.1rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.doc-card:hover {
  text-decoration: none;
  border-color: var(--accent-3);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.doc-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-media);
}

.doc-kicker {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--accent-3);
  margin-bottom: 0.3rem;
}

.doc-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 650;
}

.doc-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .doc-card {
    grid-template-columns: 1fr;
  }
}

/* ---- article / notes ---- */
.article {
  padding-bottom: 3rem;
}

.article h2 {
  margin: 2.4rem 0 0.85rem;
  font-size: 1.35rem;
  font-weight: 650;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.article h3 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.08rem;
}

.article p,
.article li {
  color: var(--text-muted);
}

.article p {
  margin: 0.7rem 0;
}

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

.article ul,
.article ol {
  margin: 0.4rem 0 0.9rem;
  padding-left: 1.25rem;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin: 0 0 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.toc a {
  color: var(--text-muted);
}

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

.diagram {
  margin: 1rem 0 1.4rem;
  padding: 1rem 0.75rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.diagram .mermaid {
  display: flex;
  justify-content: center;
}

.callout {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent-3);
  background: rgba(212, 160, 91, 0.08);
  border-radius: 0 10px 10px 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.note-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.8rem 0 1.2rem;
}

.note-table th,
.note-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.note-table th {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
}

.note-table td {
  color: var(--text-muted);
}

.note-table code {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--accent);
}

.pre-wrap {
  margin: 0.8rem 0 1.2rem;
  padding: 0.9rem 1rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.pre-wrap .src {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--code-src);
  display: block;
  margin-bottom: 0.55rem;
}

.pre-wrap pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--code-text);
  white-space: pre;
}

html[data-theme="light"] .diagram .mermaid {
  filter: none;
}

html[data-theme="light"] .search-bar input {
  background: var(--bg-elevated);
}

.eq {
  margin: 0.9rem 0;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  overflow-x: auto;
}

.tutor-strip { margin: 0 0 1.4rem; }
.tutor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin: 0 0 1.6rem;
}
@media (max-width: 720px) {
  .tutor-grid { grid-template-columns: 1fr; }
}
.tutor-card {
  display: block;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  border-left: 4px solid var(--accent, #2b6ea8);
}
.tutor-card:hover { text-decoration: none; border-color: var(--accent, #2b6ea8); }
.tutor-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent, #2b6ea8);
}
.tutor-card h2 { margin: 0.25rem 0 0.35rem; font-size: 1.15rem; }
.tutor-card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
