:root{
  --bg:#0b0f17;
  --panel:rgba(255,255,255,.04);
  --panel2:rgba(255,255,255,.02);
  --text:#e8eefc;
  --muted:#a9b6d3;
  --line:#1f2a44;
  --accent:#7aa2ff;
  --accent2:#ff7ad9;
  --radius:18px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(1200px 600px at 15% 0%, rgba(122,162,255,.18), transparent 55%),
    radial-gradient(1000px 500px at 85% 10%, rgba(255,122,217,.14), transparent 55%),
    var(--bg);
  color:var(--text);
}

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

.app{
  display:grid;
  grid-template-columns: 1fr 360px;
  gap:18px;
  padding:18px;
  min-height:100vh;
}

.left{
  display:flex;
  flex-direction:column;
  gap:18px;
  min-width:0;
}

.right{
  position:sticky;
  top:18px;
  height: calc(100vh - 36px);
  display:flex;
  flex-direction:column;
  gap:12px;
}

.card{
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
}

.hero h1{
  margin:0;
  font-size:20px;
  letter-spacing:.2px;
  line-height:1.35;
}
.hero .sub{
  margin:8px 0 0;
  color:var(--muted);
  font-size:13px;
  line-height:1.65;
}

.term{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:1px 6px;
  border-radius:10px;
  border:1px solid rgba(122,162,255,.25);
  background:rgba(122,162,255,.08);
  cursor:pointer;
  transition:.15s ease;
  white-space:nowrap;
}
.term:hover{
  border-color:rgba(122,162,255,.7);
  background:rgba(122,162,255,.14);
  transform:translateY(-1px);
}
.term::after{
  content:"↗";
  opacity:.65;
  font-size:12px;
}

.stage-nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:10px;
}
.stage-btn{
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  color:var(--text);
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
  transition:.15s ease;
  font-size:12px;
}
.stage-btn:hover{border-color:rgba(255,122,217,.5);transform:translateY(-1px)}
.stage-btn.active{
  background:rgba(122,162,255,.12);
  border-color:rgba(122,162,255,.55);
  box-shadow:0 10px 22px rgba(122,162,255,.12);
}

.kvs{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:12px;
}
.kv{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  border-radius:14px;
  padding:10px 12px;
  min-width:220px;
  flex:1 1 240px;
}
.kv b{display:block;font-size:12px}
.kv span{display:block;margin-top:4px;font-size:12px;color:var(--muted);line-height:1.5}

.mermaid-wrap{
  margin-top:12px;
  background:rgba(0,0,0,.22);
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  overflow:auto;
}
.mermaid-wrap svg{max-width:100%;height:auto}

/* Mermaid 节点产品化：手型 + hover 高亮 */
.mermaid-wrap svg .stepbtn{cursor:pointer;}
.mermaid-wrap svg .stepbtn:hover rect,
.mermaid-wrap svg .stepbtn:hover polygon{
  filter: drop-shadow(0 10px 18px rgba(122,162,255,.25));
  stroke: rgba(122,162,255,.85) !important;
  stroke-width: 2px;
}

.hint{
  margin-top:10px;
  color:var(--muted);
  font-size:12px;
  line-height:1.65;
}

.article h2{
  margin:14px 0 10px;
  font-size:14px;
  letter-spacing:.2px;
}
.article h2:first-child{margin-top:0}
.article .row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.index{
  flex: 1 1 auto;
  min-height: 220px;
  overflow:auto;
}
.index-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.index-header h3{margin:0;font-size:14px}
#indexSearch{
  width: 55%;
  min-width: 160px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.18);
  color:var(--text);
  outline:none;
}
#indexSearch::placeholder{color:rgba(169,182,211,.7)}
.term-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.term-item{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  border-radius:14px;
  padding:10px 12px;
  cursor:pointer;
  transition:.15s ease;
}
.term-item:hover{
  transform:translateY(-1px);
  border-color:rgba(122,162,255,.55);
  background:rgba(122,162,255,.08);
}
.term-item .label{
  font-size:13px;
  font-weight:650;
}
.term-item .mini{
  margin-top:4px;
  font-size:12px;
  color:var(--muted);
  line-height:1.45;
}

.qa{
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(0,0,0,.22);
  overflow:hidden;
  box-shadow: var(--shadow);
  display:none;
}
.qa.show{display:flex;flex-direction:column}
.qa-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.02);
}
.qa-title{font-size:13px;font-weight:700}
.qa-mini{font-size:11px;color:var(--muted);margin-top:2px}
.qa-close{
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  color:var(--text);
  border-radius:10px;
  padding:6px 8px;
  cursor:pointer;
}
.qa-body{
  padding:12px;
  overflow:auto;
  max-height: 38vh;
}
.msg{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:12px;
}
.bubble{
  max-width: 100%;
  border-radius:14px;
  padding:10px 12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  font-size:12px;
  line-height:1.65;
  white-space:pre-wrap;
}
.bubble.user{
  background:rgba(122,162,255,.08);
  border-color:rgba(122,162,255,.25);
}
.bubble.assistant{
  background:rgba(0,0,0,.18);
}
.cursor{
  display:inline-block;
  margin-left:2px;
  opacity:.85;
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.followups{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:8px;
}
.fup{
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  color:var(--text);
  padding:7px 9px;
  border-radius:12px;
  cursor:pointer;
  font-size:12px;
  transition:.15s ease;
}
.fup:hover{border-color:rgba(255,122,217,.5);transform:translateY(-1px)}

.qa-input{
  display:flex;
  gap:10px;
  padding:10px 12px;
  border-top:1px solid var(--line);
  background:rgba(255,255,255,.02);
}
#qaPrompt{
  flex:1 1 auto;
  padding:9px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.18);
  color:var(--text);
  outline:none;
}
#qaPrompt::placeholder{color:rgba(169,182,211,.7)}
#qaSend{
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  color:var(--text);
  padding:9px 12px;
  border-radius:12px;
  cursor:pointer;
  transition:.15s ease;
}
#qaSend:hover{border-color:rgba(122,162,255,.55);transform:translateY(-1px)}

.footer{
  color:var(--muted);
  font-size:12px;
  text-align:center;
  padding:10px 4px;
}

@media (max-width: 980px){
  .app{grid-template-columns: 1fr}
  .right{position:relative;top:auto;height:auto}
  #indexSearch{width:100%}
  .qa-body{max-height: 42vh;}
}
