:root {
  --bg: #0a0a12;
  --panel: #12121f;
  --panel-2: #171728;
  --ink: #e7e7f0;
  --muted: #9a9ab5;
  --accent: #22d3ee;
  --accent-2: #a78bfa;
  --line: #26263a;
  --rise: #34d399;
  --fall: #f87171;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
a { color: var(--accent); }

/* HERO */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-media { position: absolute; inset: 0; z-index: 0; }
.hero-media img { width: 100%; height: 100%; object-fit: cover; opacity: 0.5; }
.hero-overlay {
  position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 30% 20%, rgba(167,139,250,0.25), transparent 60%),
              linear-gradient(180deg, rgba(10,10,18,0.55), rgba(10,10,18,0.92));
}
.hero-content { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 88px 24px 56px; }
.eyebrow { letter-spacing: 0.22em; font-size: 12px; color: var(--accent); margin: 0 0 12px; }
.hero h1 { font-size: clamp(28px, 5vw, 48px); line-height: 1.1; margin: 0 0 16px; }
.lede { font-size: 18px; color: var(--muted); max-width: 680px; }

.stat-row { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 32px; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 30px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }

/* PANELS */
main { max-width: 900px; margin: 0 auto; padding: 24px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  margin: 24px 0;
}
.panel h2 { margin-top: 0; font-size: 22px; }
.fine { color: var(--muted); font-size: 14px; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; color: var(--accent-2); }

/* LOOP DIAGRAM */
.diagram-wrap { display: flex; justify-content: center; margin: 8px 0 4px; }
.loop-diagram { width: 100%; max-width: 640px; height: auto; }
.d-core { fill: #fff; font-size: 20px; font-weight: 700; }
.d-core-sub { fill: #e9d5ff; font-size: 11px; letter-spacing: 0.1em; }
.d-node circle { fill: var(--panel-2); stroke: var(--accent); stroke-width: 1.5; }
.d-node text { fill: var(--ink); font-size: 15px; text-anchor: middle; }
.d-node .d-lbl { fill: var(--muted); font-size: 9px; letter-spacing: 0.06em; }
.d-arc { fill: none; stroke: #7dd3fc; stroke-width: 1.6; opacity: 0.55; stroke-dasharray: 4 4; }
.d-node { animation: pulse 6s infinite ease-in-out; }
.d-node[data-i="1"] { animation-delay: 1s; }
.d-node[data-i="2"] { animation-delay: 2s; }
.d-node[data-i="3"] { animation-delay: 3s; }
.d-node[data-i="4"] { animation-delay: 4s; }
.d-node[data-i="5"] { animation-delay: 5s; }
@keyframes pulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }

/* TABLES */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.08em; }
.num { text-align: right; }
.methods td:first-child { white-space: nowrap; color: var(--accent-2); }
.table-scroll { overflow-x: auto; }
.repos td:first-child { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.delta-up { color: var(--rise); }
.delta-flat { color: var(--muted); }
.loading { color: var(--muted); text-align: center; padding: 20px; }

/* CHART */
.chart-wrap svg { width: 100%; height: auto; }

/* GEN LOG */
.gen-log { padding-left: 20px; }
.gen-log li { margin-bottom: 12px; }
.gen-log .g-num { color: var(--accent); font-weight: 700; }
.gen-log .g-fit { color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* FOOTER */
footer { max-width: 900px; margin: 0 auto; padding: 32px 24px 64px; color: var(--muted); border-top: 1px solid var(--line); }


/* LEARNINGS DATASET */
.learnings { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.learnings li {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
}
.learn-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.learn-kind {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent-2); font-weight: 700;
}
.learn-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: rgba(34,211,238,0.12); color: var(--accent);
  border: 1px solid rgba(34,211,238,0.3);
}
.learnings .fine { color: var(--muted); font-size: 12px; }


/* ============================ bilingual + new UI ======================== */

/* Language toggle (fixed, top-right) */
.lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  gap: 2px;
  background: rgba(18, 18, 31, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(8px);
}
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lang-btn:hover { color: var(--ink); }
.lang-btn.active { background: var(--accent); color: #06121a; }

/* Slightly larger line-height + system CJK fonts for Chinese */
body.lang-zh {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.75;
}
body.lang-zh .eyebrow { letter-spacing: 0.08em; }

/* Manual trigger button */
.trigger-row {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.18), rgba(34, 211, 238, 0.06));
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  padding: 12px 22px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
}
.trigger-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(34, 211, 238, 0.25);
  border-color: var(--accent);
}
.trigger-btn:disabled { opacity: 0.7; cursor: progress; }
.trigger-icon { font-size: 18px; display: inline-block; }
.trigger-btn.running .trigger-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.trigger-status { margin: 0; font-size: 14px; color: var(--muted); }
.trigger-status.ok { color: var(--rise); }
.trigger-status.err { color: var(--fall); }
.trigger-status.running { color: var(--accent); }

/* three.js knowledge graph */
.graph-3d {
  position: relative;
  width: 100%;
  height: 460px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 30%, #12122a, #0a0a12 70%);
  cursor: grab;
}
.graph-3d canvas { display: block; }
.graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}
.graph-tip {
  position: absolute;
  max-width: 280px;
  pointer-events: none;
  background: rgba(10, 10, 18, 0.94);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  z-index: 5;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}
.graph-tip .tip-kind { color: var(--muted); font-size: 11px; }
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin: 0 2px;
}
.dot-learn { background: #22d3ee; }
.dot-repo { background: #34d399; }
.dot-topic { background: #a78bfa; }

/* Pagination */
.pager {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pager-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pager-btn:hover { border-color: var(--accent); background: rgba(34, 211, 238, 0.08); }

/* AI badge emphasis */
.learn-badge.ai { background: rgba(34, 211, 238, 0.16); color: var(--accent); border-color: rgba(34, 211, 238, 0.4); }

@media (max-width: 560px) {
  .graph-3d { height: 360px; }
  .lang-switch { top: 10px; right: 10px; }
}
