:root{
  --bg0:#060a12;
  --bg1:#0b1220;
  --bg2:#0e1730;
  --panel:#0b1326;
  --panel2:#0b1530;
  --border:rgba(255,255,255,.08);
  --border2:rgba(255,255,255,.12);
  --text:#d7e2ff;
  --muted:#97a7d8;
  --muted2:#7f8cc0;
  --accent:#77a7ff;
  --accent2:#9f7bff;
  --danger:#ff5d7a;
  --ok:#55e6a5;
  --warn:#ffd27a;

  /* token family hues (base); per-token variation is done via CSS variables */
  --h-keyword: 212;
  --h-intrinsic: 190;
  --h-type: 262;
  --h-number: 42;
  --h-string: 18;
  --h-comment: 120;
  --h-operator: 320;
  --h-ident: 220;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background: radial-gradient(1200px 800px at 40% -10%, rgba(119,167,255,.14), transparent 70%),
              radial-gradient(1000px 900px at 110% 10%, rgba(159,123,255,.12), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1) 45%, var(--bg0));
}

.app{
  display:flex;
  flex-direction:column;
  height:100%;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border-bottom:1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand{display:flex; align-items:center; gap:12px; min-width:260px;}
.logo{
  width:34px;height:34px;border-radius:10px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), transparent 48%),
    linear-gradient(135deg, rgba(119,167,255,.95), rgba(159,123,255,.92));
  box-shadow: 0 10px 30px rgba(119,167,255,.18), 0 10px 30px rgba(159,123,255,.16);
  border:1px solid rgba(255,255,255,.18);
}
.brandText .title{font-weight:700; letter-spacing:.2px;}
.brandText .subtitle{color:var(--muted2); font-size:12px; margin-top:1px;}

.topActions{display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end;}
.sep{width:1px; height:22px; background:var(--border); margin:0 2px;}

.btn{
  appearance:none;
  border:1px solid var(--border2);
  background: rgba(255,255,255,.04);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  font-size:13px;
  cursor:pointer;
  transition: transform .05s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.18);}
.btn:active{transform: translateY(1px);}
.btnPrimary{
  background: linear-gradient(135deg, rgba(119,167,255,.92), rgba(159,123,255,.86));
  border-color: rgba(255,255,255,.22);
  box-shadow: 0 10px 30px rgba(119,167,255,.16), 0 10px 30px rgba(159,123,255,.10);
}
.btnPrimary:hover{filter: brightness(1.03);}
.btnDanger{border-color: rgba(255,93,122,.38); background: rgba(255,93,122,.08);}
.btnDanger:hover{background: rgba(255,93,122,.12); border-color: rgba(255,93,122,.5);}

.main{
  display:grid;
  grid-template-columns: 340px 1fr;
  gap:12px;
  padding:12px;
  min-height:0;
  flex:1;
}

.sidebar{
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:0;
}

.panel{
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
  min-height:0;
}
.panelHeader{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px;
  background: rgba(0,0,0,.12);
  border-bottom:1px solid var(--border);
}
.panelTitle{font-weight:700; font-size:13px;}
.panelMeta{color:var(--muted2); font-size:12px;}
.panelBody{padding:10px 12px; min-height:0;}

.input{
  width:100%;
  padding:9px 10px;
  border-radius:11px;
  background: rgba(0,0,0,.18);
  border:1px solid var(--border);
  color:var(--text);
  outline:none;
}
.input:focus{border-color: rgba(119,167,255,.45); box-shadow: 0 0 0 3px rgba(119,167,255,.12);}

.docList{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:7px;
  max-height: 220px;
  overflow:auto;
  padding-right:2px;
}
.docItem{
  border:1px solid var(--border);
  background: rgba(0,0,0,.14);
  border-radius:12px;
  padding:9px 10px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.docItem:hover{border-color: rgba(255,255,255,.16); background: rgba(0,0,0,.18);}
.docItem[aria-selected="true"]{
  border-color: rgba(119,167,255,.45);
  background: rgba(119,167,255,.10);
}
.docName{font-weight:650; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.docBadge{color:var(--muted2); font-size:11px;}

.encyResults{
  margin-top:10px;
  max-height: 220px;
  overflow:auto;
  padding-right:2px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.encyCard{
  border:1px solid var(--border);
  background: rgba(0,0,0,.14);
  border-radius:12px;
  padding:9px 10px;
}
.encyTop{display:flex; align-items:center; justify-content:space-between; gap:8px;}
.encyTerm{font-weight:750; font-size:13px;}
.encyKind{font-size:11px; color:var(--muted2);}
.encyDesc{margin-top:6px; color:var(--muted); font-size:12px; line-height:1.35;}
.encyCardClick{cursor:pointer;}
.encyCardClick:hover{border-color: rgba(119,167,255,.35); background: rgba(119,167,255,.06);}
.issueJump{cursor:pointer;}
.issueJump:hover{border-color: rgba(255,255,255,.16);}
.issuePosLink{text-decoration:underline dotted; text-underline-offset:2px;}

.legend{display:flex; gap:8px; margin-bottom:10px;}
.pill{
  border:1px solid var(--border);
  border-radius:999px;
  padding:4px 8px;
  font-size:11px;
  background: rgba(0,0,0,.14);
}
.pillErr{border-color: rgba(255,93,122,.45); background: rgba(255,93,122,.08);}
.pillWarn{border-color: rgba(255,210,122,.45); background: rgba(255,210,122,.08);}
.pillInfo{border-color: rgba(119,167,255,.45); background: rgba(119,167,255,.08);}

.issues{
  max-height: 200px;
  overflow:auto;
  padding-right:2px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.issue{
  border:1px solid var(--border);
  border-radius:12px;
  background: rgba(0,0,0,.14);
  padding:9px 10px;
}
.issueLine{display:flex; align-items:center; justify-content:space-between; gap:10px;}
.issueTitle{font-weight:700; font-size:12.5px;}
.issuePos{color:var(--muted2); font-size:11px; white-space:nowrap;}
.issueBody{margin-top:6px; color:var(--muted); font-size:12px; line-height:1.35;}
.issueFixes{margin-top:8px; display:flex; flex-wrap:wrap; gap:7px;}
.fixBtn{
  border:1px solid var(--border2);
  background: rgba(255,255,255,.04);
  color:var(--text);
  font-size:11.5px;
  padding:6px 8px;
  border-radius:999px;
  cursor:pointer;
}
.fixBtn:hover{background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.18);}

.workspace{min-height:0;}
.quad{
  display:grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap:12px;
  height:100%;
  min-height:0;
}
.pane{
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:0;
}
.paneHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  background: rgba(0,0,0,.12);
  border-bottom:1px solid var(--border);
}
.paneTitle{font-weight:800; font-size:13px;}
.paneRight{display:flex; align-items:center; gap:8px; color:var(--muted2); font-size:12px;}
.miniLabel{color:var(--muted2); font-size:11px;}
.miniSep{width:1px; height:18px; background:var(--border);}
.select{
  appearance:none;
  border:1px solid var(--border);
  background: rgba(0,0,0,.16);
  color:var(--text);
  border-radius:10px;
  padding:6px 8px;
  font-size:12px;
  outline:none;
}
.select:focus{border-color: rgba(119,167,255,.45); box-shadow: 0 0 0 3px rgba(119,167,255,.12);}

.editorShell{
  position:relative;
  display:grid;
  grid-template-columns: 52px 1fr;
  gap:0;
  min-height:0;
  flex:1;
}
.editorGutter{
  background: rgba(0,0,0,.18);
  border-right:1px solid var(--border);
}
.editorStack{
  position:relative;
  min-height:0;
  overflow:auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size:13px;
  line-height:1.45;
}
.editorHighlight, .editorInput{
  margin:0;
  padding:10px 12px;
  white-space:pre;
  tab-size:2;
}
.editorHighlight{
  min-height:100%;
  color:transparent;
}
.editorInput{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  resize:none;
  border:0;
  outline:none;
  background: transparent;
  color: rgba(255,255,255,.92);
}
.editorInput::selection{background: rgba(119,167,255,.25);}

.tok{color: rgba(215,226,255,.92)}
.tok.kwd{color: hsl(var(--h-keyword) 90% calc(70% + var(--v, 0%))); font-weight:650;}
.tok.type{color: hsl(var(--h-type) 80% calc(72% + var(--v, 0%))); font-weight:650;}
.tok.intr{color: hsl(var(--h-intrinsic) 85% calc(70% + var(--v, 0%)));}
.tok.num{color: hsl(var(--h-number) 90% calc(70% + var(--v, 0%)));}
.tok.str{color: hsl(var(--h-string) 85% calc(70% + var(--v, 0%)));}
.tok.cmt{color: hsl(var(--h-comment) 45% calc(55% + var(--v, 0%))); font-style:italic;}
.tok.op{color: hsl(var(--h-operator) 70% calc(74% + var(--v, 0%)));}
.tok.id{color: hsl(var(--h-ident) 60% calc(74% + var(--v, 0%)));}
.tok.err{
  background: rgba(255,93,122,.12);
  border-bottom: 1px dashed rgba(255,93,122,.55);
  border-radius:4px;
}

.autocomplete{
  position:absolute;
  z-index:10;
  min-width: 260px;
  max-width: 480px;
  max-height: 220px;
  overflow:auto;
  background: rgba(8,12,22,.92);
  border:1px solid rgba(255,255,255,.14);
  border-radius:14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  padding:6px;
}
.acItem{
  padding:8px 9px;
  border-radius:10px;
  cursor:pointer;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.acItem:hover{background: rgba(255,255,255,.06);}
.acItem[aria-selected="true"]{background: rgba(119,167,255,.14);}
.acLeft{min-width:0;}
.acTerm{font-weight:750; font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.acDesc{color:var(--muted2); font-size:11px; margin-top:2px; line-height:1.25; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;}
.acKind{color:var(--muted2); font-size:11px; white-space:nowrap;}

.statusbar{
  padding:10px 14px;
  border-top:1px solid var(--border);
  background: rgba(0,0,0,.10);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:var(--muted2);
  font-size:12px;
}
.statusSep{display:inline-block; width:1px; height:12px; background:var(--border); margin:0 10px;}

@media (max-width: 1100px){
  .main{grid-template-columns: 1fr; }
  .sidebar{flex-direction:row; flex-wrap:wrap;}
  .panel{flex: 1 1 320px;}
}
