.memlab-shell{
  position:fixed;inset:0;z-index:1600;display:none;color:#eaf0f7;font-family:inherit
}
.memlab-shell.open{display:block}
.memlab-backdrop{position:absolute;inset:0;background:rgba(2,5,9,.78);backdrop-filter:blur(10px)}
.memlab-panel{
  position:absolute;inset:12px;display:grid;grid-template-rows:auto 1fr;overflow:hidden;
  border:1px solid #253142;border-radius:22px;background:linear-gradient(180deg,#0b1119 0%,#080d14 100%);
  box-shadow:0 24px 70px rgba(0,0,0,.5)
}
.memlab-head{
  display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:14px;
  padding:16px 18px;border-bottom:1px solid #202a38;background:#0d141e
}
.memlab-title{display:flex;align-items:center;gap:12px;min-width:0}
.memlab-mark{
  display:grid;place-items:center;width:42px;height:42px;flex:0 0 42px;border-radius:14px;
  background:#172333;border:1px solid #2f4158;font-weight:800
}
.memlab-title>div:last-child{min-width:0}
.memlab-title strong{display:block;font-size:18px}
.memlab-title small{
  display:block;color:#8fa0b5;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis
}
.memlab-head-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:nowrap}
.memlab-btn,.memlab-icon-btn{
  border:1px solid #2c3a4d;background:#111a25;color:#dce6f2;border-radius:10px;
  padding:9px 12px;min-height:40px;cursor:pointer;font:inherit
}
.memlab-icon-btn{width:42px;padding:0;flex:0 0 42px}
.memlab-btn:hover,.memlab-icon-btn:hover{background:#172333}
.memlab-btn.primary{background:#173452;border-color:#2b5f91}
.memlab-btn.danger{border-color:#6a2f38;color:#ffb8c0}
.memlab-btn:disabled{opacity:.45;cursor:not-allowed}
.memlab-body{overflow:auto;padding:20px;overscroll-behavior:contain}
.memlab-hero{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(320px,.85fr);gap:16px;margin-bottom:16px}
.memlab-card{border:1px solid #202c3b;border-radius:16px;background:#0d151f;padding:16px;min-width:0}
.memlab-card h3{margin:0 0 6px;font-size:15px}
.memlab-card p{margin:0;color:#8fa0b5;line-height:1.5}
.memlab-engine-card .memlab-engine-state{margin-top:10px}
.memlab-engine-card p{margin-top:12px}
.memlab-engine-state{display:flex;align-items:center;justify-content:space-between;gap:14px}
.memlab-engine-copy{min-width:0}
.memlab-engine-copy strong{display:block;font-size:22px}
.memlab-engine-copy small{display:block;color:#89a0b7;margin-top:5px;line-height:1.4}
.memlab-toggle{display:flex;align-items:center;gap:9px;flex:0 0 auto}
.memlab-toggle input{width:46px;height:24px;accent-color:#4fa4ff}
.memlab-stats{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin-bottom:16px
}
.memlab-stat{padding:14px;border:1px solid #202c3b;border-radius:14px;background:#0b131c}
.memlab-stat span{display:block;color:#7f91a7;font-size:12px}
.memlab-stat strong{display:block;font-size:24px;margin-top:6px}
.memlab-stat small{display:block;color:#65798f;font-size:11px;margin-top:4px}
.memlab-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(320px,.8fr);gap:16px;align-items:start}
.memlab-stack{display:grid;gap:16px}
.memlab-pipeline{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px;margin-top:14px}
.memlab-stage{
  position:relative;padding:14px;border:1px solid #293648;border-radius:14px;background:#101923;min-height:142px
}
.memlab-stage:not(:last-child)::after{
  content:"→";position:absolute;right:-10px;top:50%;transform:translate(50%,-50%);width:24px;height:24px;
  display:grid;place-items:center;border-radius:50%;background:#0b1119;color:#5f7590;z-index:2
}
.memlab-stage .num{
  display:inline-grid;place-items:center;width:24px;height:24px;border-radius:8px;
  background:#1d2a39;color:#b9cbe0;font-size:12px;font-weight:700
}
.memlab-stage strong{display:block;margin-top:10px}
.memlab-stage small{display:block;color:#8092a8;line-height:1.45;margin-top:5px}
.memlab-stage.active{border-color:#31628c;background:#102033}
.memlab-stage.good{border-color:#2d684e;background:#0f1e19}
.memlab-section-head{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:12px}
.memlab-section-head h3{margin:0}
.memlab-section-head small{color:#7f91a7}
.memlab-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.memlab-field{display:grid;gap:6px}
.memlab-field label{font-size:12px;color:#9aabc0}
.memlab-field select,.memlab-field input{
  width:100%;min-height:42px;border-radius:10px;border:1px solid #2a394c;background:#09111a;
  color:#e7eef6;padding:9px 10px;font:inherit
}
.memlab-field small{color:#71849a;line-height:1.4}
.memlab-setting-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 0;border-bottom:1px solid #1b2532}
.memlab-setting-row:last-child{border-bottom:0}
.memlab-setting-row strong{display:block}
.memlab-setting-row small{display:block;color:#74879d;margin-top:4px}
.memlab-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}
.memlab-message{min-height:20px;margin-top:10px;color:#8db8dd;font-size:13px}
.memlab-filter{display:flex;gap:8px;flex-wrap:wrap}
.memlab-filter input{
  flex:1 1 220px;min-height:40px;border-radius:10px;border:1px solid #2a394c;background:#09111a;color:#e7eef6;padding:8px 10px
}
.memlab-run-list,.memlab-ledger{display:grid;gap:10px}
.memlab-run,.memlab-observation{border:1px solid #223043;border-radius:12px;background:#0a121b;padding:12px}
.memlab-run-top,.memlab-observation-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.memlab-run strong,.memlab-observation strong{overflow-wrap:anywhere}
.memlab-meta{color:#73869d;font-size:12px;margin-top:5px;line-height:1.4}
.memlab-badges{display:flex;gap:6px;flex-wrap:wrap;margin-top:9px}
.memlab-badge{
  display:inline-flex;align-items:center;min-height:24px;padding:3px 7px;border-radius:999px;
  border:1px solid #2a394c;background:#101923;color:#afc0d4;font-size:11px;max-width:100%;overflow-wrap:anywhere
}
.memlab-badge.good{border-color:#2d684e;color:#8fd8b4}
.memlab-badge.warn{border-color:#745c28;color:#e9cb82}
.memlab-badge.bad{border-color:#6a2f38;color:#f2a1ab}
.memlab-badge.semantic{border-color:#355d86;color:#9fcbf2;background:#0f1c2a}
.memlab-badge.live{border-color:#31628c;color:#a9d3fa;background:#102033}
.memlab-note{margin-top:8px;color:#9aacbf;line-height:1.45;font-size:13px}
.memlab-warn-note{color:#d9be7a}
.memlab-code{
  white-space:pre-wrap;overflow-wrap:anywhere;margin:10px 0 0;padding:12px;border-radius:10px;
  background:#071019;border:1px solid #1f2b3a;color:#aebed0;font-size:12px;max-height:260px;overflow:auto
}
.memlab-neighbours{
  margin-top:10px;border-top:1px solid #192636;padding-top:9px;color:#8298ae;font-size:12px
}
.memlab-neighbours summary{cursor:pointer;color:#9db4ca;user-select:none}
.memlab-neighbour-list{display:grid;gap:5px;margin-top:8px;padding:9px;border-radius:9px;background:#08111a;border:1px solid #1c2b3b}
.memlab-neighbour-list div{overflow-wrap:anywhere;line-height:1.4}
.memlab-health{display:grid;gap:8px}
.memlab-health-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 0;border-bottom:1px solid #1b2532}
.memlab-health-row:last-child{border-bottom:0}
.memlab-health-row span{color:#899bb0;min-width:0}
.memlab-health-row .memlab-badge{justify-content:flex-end;text-align:right}
.memlab-empty{padding:18px;text-align:center;color:#708399;border:1px dashed #2a3748;border-radius:12px}
.memlab-login{max-width:560px;margin:40px auto}
.memlab-login input{
  width:100%;min-height:44px;margin-top:10px;border-radius:10px;border:1px solid #2a394c;background:#09111a;color:#e7eef6;padding:9px 10px
}
.memlab-footnote{font-size:12px;color:#6f8298;margin-top:10px;line-height:1.5}
.memlab-kicker{display:inline-flex;align-items:center;gap:6px;color:#79a9d4;font-size:12px;text-transform:uppercase;letter-spacing:.08em}
.memlab-dot{width:8px;height:8px;border-radius:50%;background:#59697c}
.memlab-dot.on{background:#56c792;box-shadow:0 0 0 4px rgba(86,199,146,.1)}
.memlab-dot.off{background:#d86d79}
.memlab-divider{height:1px;background:#1c2735;margin:14px 0}
.memlab-architecture{border-color:#263a51;background:linear-gradient(180deg,#0d1722,#0c141d)}
.memlab-architecture strong{color:#b7d8f5}

@media(max-width:1200px){
  .memlab-grid{grid-template-columns:1fr}
  .memlab-hero{grid-template-columns:1fr}
  .memlab-pipeline{grid-template-columns:repeat(2,minmax(0,1fr))}
  .memlab-stage:not(:last-child)::after{display:none}
}
@media(max-width:820px){
  .memlab-panel{inset:6px;border-radius:16px}
  .memlab-head{padding:12px 14px;gap:8px}
  .memlab-title{gap:9px}
  .memlab-mark{width:38px;height:38px;flex-basis:38px;border-radius:12px}
  .memlab-title strong{font-size:16px}
  .memlab-title small{font-size:11px}
  .memlab-head-actions{gap:6px}
  .memlab-head-actions .memlab-btn{padding:8px 10px}
  .memlab-body{padding:12px}
}
@media(max-width:640px){
  .memlab-panel{inset:0;border-radius:0}
  .memlab-title small{display:none}
  .memlab-head-actions .memlab-btn span{display:none}
  .memlab-head-actions .memlab-btn{width:42px;padding:0}
  .memlab-stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .memlab-pipeline{grid-template-columns:1fr}
  .memlab-form-grid{grid-template-columns:1fr}
  .memlab-engine-state{align-items:flex-start}
  .memlab-engine-copy strong{font-size:19px}
  .memlab-filter{display:grid;grid-template-columns:1fr 1fr}
  .memlab-filter input{grid-column:1/-1}
  .memlab-run-top,.memlab-observation-top{align-items:flex-start}
}
