:root{
  --bg0:#0b1020;
  --panel:rgba(255,255,255,0.06);
  --panel2:rgba(255,255,255,0.10);
  --border:rgba(255,255,255,0.10);
  --text:#e6eaf2;
  --muted:#a8b0c4;
  --accent:#7dd3fc;
  --danger:#f87171;
  --ok:#34d399;
  --shadow:0 18px 60px rgba(0,0,0,0.45);
  --radius:16px;
  --mono:"Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans:"Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background:
    radial-gradient(1200px 800px at 25% 20%, rgba(125,211,252,0.18), transparent 60%),
    radial-gradient(900px 600px at 80% 40%, rgba(52,211,153,0.12), transparent 60%),
    radial-gradient(800px 700px at 50% 90%, rgba(248,113,113,0.10), transparent 60%),
    linear-gradient(180deg, #070a12, #0b1020 60%, #070a12);
  overflow:hidden;
}

a{color:inherit; text-decoration:none}

.topbar{
  position:sticky;
  top:0;
  z-index:30;
  height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 14px;
  border-bottom:1px solid var(--border);
  background:rgba(0,0,0,0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand{
  display:flex;
  gap:10px;
  align-items:center;
  font-weight:700;
  letter-spacing:0.2px;
}
.badge{
  font-size:11px;
  padding:3px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  color:var(--muted);
  background:rgba(255,255,255,0.04);
}
.actions{
  display:flex;
  gap:10px;
  align-items:center;
}
.btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
  font-weight:600;
  font-size:12px;
}
.btn:hover{background:rgba(255,255,255,0.10)}
.btn.primary{
  border-color:rgba(125,211,252,0.35);
  background:rgba(125,211,252,0.18);
}
.btn.danger{
  border-color:rgba(248,113,113,0.35);
  background:rgba(248,113,113,0.14);
}
.btn:disabled{opacity:0.45; cursor:not-allowed}

.shell{
  min-height:calc(100vh - 56px);
  height:calc(100vh - 56px);
  display:flex;
  padding:14px;
  gap:14px;
  overflow:hidden;
}

.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.left{
  width:340px;
  min-width:300px;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  height:100%;
}

.right{
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  height:100%;
}

.tabs{
  display:flex;
  gap:8px;
  padding:10px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,0.03);
}
.tab{
  flex:1;
  text-align:center;
  padding:10px 10px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
  font-size:12px;
  color:var(--muted);
  border:1px solid transparent;
}
.tab.active{
  color:var(--text);
  background:rgba(255,255,255,0.08);
  border-color:var(--border);
}

.section{
  padding:12px;
  overflow:visible;
}

.panelScroll{
  flex:1;
  overflow:auto;
  scrollbar-gutter: stable both-edges;
}

.h1{
  margin:0 0 8px 0;
  font-size:14px;
  font-weight:800;
}
.p{
  margin:0 0 10px 0;
  font-size:12px;
  line-height:1.35;
  color:var(--muted);
}

.card{
  border:1px solid var(--border);
  background:rgba(255,255,255,0.05);
  border-radius:14px;
  padding:10px;
  margin-bottom:10px;
}

.list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(0,0,0,0.12);
  cursor:pointer;
}
.item:hover{background:rgba(255,255,255,0.06)}
.item.active{
  border-color:rgba(125,211,252,0.40);
  background:rgba(125,211,252,0.10);
}
.item .name{
  font-weight:800;
  font-size:12px;
}
.item .hint{
  font-size:11px;
  color:var(--muted);
  font-family:var(--mono);
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.kv{
  display:flex;
  gap:8px;
  align-items:center;
  font-size:12px;
  color:var(--muted);
}
.kv strong{color:var(--text)}
.slider{
  width:260px;
}

.canvasWrap{
  height:280px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.canvasBox{
  flex:1;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(0,0,0,0.20);
  position:relative;
  overflow:hidden;
}
canvas{width:100%; height:100%}
.canvasLegend{
  display:flex;
  gap:10px;
  font-size:11px;
  color:var(--muted);
  justify-content:space-between;
}

.opsGrid{
  display:grid;
  grid-template-columns: repeat(50, 1fr);
  gap:2px;
  width:100%;
  max-width:100%;
}
.dot{
  width:100%;
  padding-top:100%;
  border-radius:2px;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.03);
  transform:scale(0.92);
  opacity:0.85;
  transition-property: background, border-color, transform, opacity;
  transition-duration: var(--dur, 220ms);
  transition-timing-function: cubic-bezier(0.2,0.8,0.2,1);
  transition-delay: var(--delay, 0ms);
}
.dot.on{
  background:rgba(125,211,252,0.65);
  border-color:rgba(125,211,252,0.15);
  transform:scale(1);
  opacity:1;
}

.divider{height:1px; background:var(--border); margin:10px 0}

.editor{
  width:100%;
  min-height:220px;
  resize:vertical;
  background:rgba(0,0,0,0.25);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  color:var(--text);
  font-family:var(--mono);
  font-size:12px;
  outline:none;
}

.select, .input{
  background:rgba(0,0,0,0.25);
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px 10px;
  color:var(--text);
  font-size:12px;
  outline:none;
}

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

.outputArea{
  height:100%;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.traceTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,0.03);
}

.traceBody{
  display:grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap:12px;
  padding:12px;
  overflow:hidden;
  height:min(720px, calc(100vh - 190px));
}

.codeView{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(0,0,0,0.22);
  overflow:auto;
  font-family:var(--mono);
  font-size:12px;
}

.codeLine{
  display:flex;
  gap:10px;
  padding:6px 10px;
  border-bottom:1px solid rgba(255,255,255,0.03);
}
.codeLine:last-child{border-bottom:none}
.ln{
  width:40px;
  text-align:right;
  color:rgba(168,176,196,0.85);
  user-select:none;
}
.code{
  white-space:pre;
  overflow:hidden;
  text-overflow:ellipsis;
  flex:1;
}
.codeLine.active{
  background:rgba(125,211,252,0.14);
}
.codeLine.active .ln{color:rgba(230,234,242,0.95)}
.sideBox{
  display:flex;
  flex-direction:column;
  gap:10px;
  overflow:hidden;
}
.box{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(0,0,0,0.18);
  overflow:auto;
}
.boxHeader{
  padding:10px 10px;
  border-bottom:1px solid rgba(255,255,255,0.05);
  font-weight:800;
  font-size:12px;
}
.boxBody{
  padding:10px;
  font-size:12px;
  color:var(--muted);
  line-height:1.35;
}

.table{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}
.table th, .table td{
  padding:8px 8px;
  border-bottom:1px solid rgba(255,255,255,0.06);
  text-align:left;
}
.table th{color:var(--text)}
.table td{color:var(--muted); font-family:var(--mono)}
.small{font-size:11px; color:var(--muted)}
.hidden{display:none}


/* Algorithm Lab additions */
.row .select{flex:1; min-width:160px}
.row .btn{white-space:nowrap}
@media (max-width: 980px){
  body{overflow:auto}
  .shell{height:auto; overflow:visible}
  .left,.right{height:auto}
  .panelScroll{overflow:visible}

  .shell{flex-direction:column; height:auto}
  .left{width:100%}
  .traceBody{grid-template-columns: 1fr}
}

.h2{
  margin:0 0 8px 0;
  font-size:12px;
  font-weight:800;
  color:var(--text);
}

.opsStats{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  font-size:12px;
  color:var(--muted);
}
.opsStats strong{color:var(--text)}
.opsStats .full{grid-column: 1 / -1}
.opsPill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  background:rgba(0,0,0,0.18);
  font-family:var(--mono);
  font-size:11px;
  color:var(--text);
}

/* Scrollbars (padronizado) */
.panelScroll, .codeView, .box, .editor{
  scrollbar-gutter: stable both-edges;
}
*{
  scrollbar-width: thin;
  scrollbar-color: rgba(125,211,252,0.55) rgba(255,255,255,0.08);
}
*::-webkit-scrollbar{width:10px; height:10px}
*::-webkit-scrollbar-track{background:rgba(255,255,255,0.06); border-radius:999px}
*::-webkit-scrollbar-thumb{background:rgba(125,211,252,0.35); border-radius:999px; border:2px solid rgba(255,255,255,0.06)}
*::-webkit-scrollbar-thumb:hover{background:rgba(125,211,252,0.55)}


/* MicroLabs Loader Modal */
.mlLoader{
  position:fixed;
  inset:0;
  z-index:100;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:auto;
}
.mlLoader.hidden{display:none}
.mlLoaderBackdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mlLoaderCard{
  position:relative;
  width:min(520px, calc(100vw - 28px));
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.12);
  background:
    radial-gradient(700px 260px at 20% 10%, rgba(125,211,252,0.18), transparent 55%),
    radial-gradient(520px 240px at 85% 35%, rgba(52,211,153,0.12), transparent 60%),
    rgba(11,16,32,0.92);
  box-shadow:0 22px 70px rgba(0,0,0,0.55);
  padding:14px 14px 12px 14px;
  animation: mlPop 180ms cubic-bezier(0.2,0.8,0.2,1);
}
@keyframes mlPop{
  from{transform:translateY(6px) scale(0.985); opacity:0.0}
  to{transform:translateY(0) scale(1); opacity:1}
}
.mlLoaderTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.mlLoaderBrand{
  display:flex;
  align-items:center;
  gap:10px;
}
.mlLoaderMark{
  width:38px;
  height:38px;
  border-radius:14px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  color:rgba(230,234,242,0.96);
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(255,255,255,0.06);
  box-shadow: inset 0 0 0 1px rgba(125,211,252,0.10);
}
.mlLoaderTitle{
  font-weight:900;
  letter-spacing:0.2px;
  font-size:13px;
  line-height:1.1;
  color:rgba(230,234,242,0.95);
}
.mlLoaderSubtitle{
  font-size:11px;
  color:rgba(168,176,196,0.95);
  margin-top:2px;
}
.mlLoaderMsg{
  margin-top:12px;
  font-size:12px;
  color:rgba(230,234,242,0.92);
  font-weight:700;
}
.mlLoaderHint{
  margin-top:6px;
  font-size:11px;
  color:rgba(168,176,196,0.92);
}
.mlLoaderSpinner{
  width:30px;
  height:30px;
  border-radius:999px;
  border:3px solid rgba(255,255,255,0.12);
  border-top-color: rgba(125,211,252,0.75);
  animation: mlSpin 800ms linear infinite;
}
@keyframes mlSpin{
  from{transform:rotate(0deg)}
  to{transform:rotate(360deg)}
}