:root{
  --ink:#17213b;
  --soft:#40506e;
  --muted:#66738a;
  --paper:#f2fbff;
  --line:#cbd9ea;
  --sky:#58b9e8;
  --leaf:#22a36f;
  --coral:#f26d5b;
  --sun:#ffd15c;
  --violet:#6f64d8;
  --shadow:0 18px 42px rgba(18,32,61,.13);
  --pixel:0 4px 0 rgba(23,33,59,.18);
}
*{box-sizing:border-box}
html{min-width:320px}
body{
  min-height:100vh;
  margin:0;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
  color:var(--ink);
  background:
    linear-gradient(180deg,#eef9ff 0,#f7fffb 56%,#fff8e2 100%);
  letter-spacing:0;
}
body:before{
  content:"";
  position:fixed;
  inset:0;
  z-index:-1;
  background-image:
    linear-gradient(rgba(23,33,59,.055) 1px,transparent 1px),
    linear-gradient(90deg,rgba(23,33,59,.055) 1px,transparent 1px);
  background-size:34px 34px;
  mask-image:linear-gradient(180deg,rgba(0,0,0,.62),transparent 74%);
}
a{color:inherit;text-decoration:none}
button,input,textarea{font:inherit}
button{cursor:pointer}
.lab-topbar{
  position:sticky;
  top:0;
  z-index:30;
  min-height:68px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:12px 34px;
  background:rgba(255,255,255,.94);
  border-bottom:1px solid rgba(23,33,59,.12);
  backdrop-filter:blur(14px);
}
.lab-brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:950;
}
.lab-brand span{
  width:40px;
  height:40px;
  display:grid;
  place-items:center;
  border:2px solid var(--ink);
  border-radius:8px;
  background:var(--ink);
  color:#fff;
  box-shadow:4px 4px 0 var(--sun);
}
.lab-topbar nav{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.lab-topbar a:not(.lab-brand),.lab-topbar button,.lab-mini-actions button,.lab-actions button{
  min-height:40px;
  border:2px solid var(--ink);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  padding:0 12px;
  font-weight:950;
  box-shadow:var(--pixel);
}
.lab-hero{
  width:min(1260px,calc(100% - 42px));
  margin:0 auto;
  padding:34px 0 18px;
  display:grid;
  grid-template-columns:minmax(0,1.3fr) minmax(280px,.7fr);
  gap:18px;
  align-items:end;
}
.lab-hero h1{
  margin:12px 0 10px;
  max-width:900px;
  font-size:clamp(2.2rem,4vw,3.55rem);
  line-height:1.05;
  text-wrap:balance;
}
.lab-hero p,.lab-note p,.mission-goal,.coach-card li{
  color:var(--soft);
  line-height:1.68;
  font-size:1.02rem;
}
.lab-badge{
  display:inline-flex;
  align-items:center;
  gap:7px;
  width:max-content;
  max-width:100%;
  border:2px solid rgba(23,33,59,.16);
  border-radius:999px;
  background:#fff;
  color:#236b63;
  padding:7px 11px;
  font-size:.78rem;
  font-weight:950;
}
.lab-badge:before{
  content:"";
  width:8px;
  height:8px;
  border:2px solid currentColor;
  border-radius:8px;
  background:var(--sun);
}
.lab-listen-card,.mission-panel,.builder-panel,.stage-panel,.lab-note{
  border:2px solid var(--ink);
  border-radius:8px;
  background:rgba(255,255,255,.96);
  box-shadow:var(--shadow);
}
.lab-listen-card{
  padding:18px;
}
.lab-listen-card strong{
  display:block;
  font-size:1.14rem;
}
.lab-listen-card p{
  margin:8px 0 14px;
  color:var(--soft);
  line-height:1.56;
}
.lab-mini-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.lab-shell{
  width:min(1340px,calc(100% - 42px));
  margin:0 auto 46px;
  display:grid;
  grid-template-columns:280px minmax(0,1fr) 360px;
  gap:16px;
  align-items:start;
}
.mission-panel,.builder-panel,.stage-panel{
  min-height:620px;
  padding:16px;
}
.mission-panel,.stage-panel{
  position:sticky;
  top:84px;
}
.panel-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}
.panel-head h2{
  margin:8px 0 0;
  font-size:clamp(1.55rem,2.4vw,2.15rem);
  line-height:1.14;
}
.mission-list{
  display:grid;
  gap:10px;
}
.mission-card{
  width:100%;
  min-height:118px;
  text-align:left;
  border:2px solid var(--line);
  border-radius:8px;
  background:#fff;
  color:var(--ink);
  padding:12px;
  box-shadow:none;
}
.mission-card.active{
  border-color:var(--ink);
  background:#fff8df;
  box-shadow:var(--pixel);
}
.mission-card span,.block-button small,.check-row span{
  display:block;
  color:var(--muted);
  font-size:.78rem;
  font-weight:900;
  line-height:1.35;
}
.mission-card strong{
  display:block;
  margin:6px 0;
  font-size:1.02rem;
  line-height:1.28;
}
.coach-card{
  margin-top:14px;
  border:2px solid var(--line);
  border-radius:8px;
  background:#f7fffb;
  padding:14px;
}
.coach-card strong{
  display:block;
  margin-bottom:8px;
}
.coach-card ol{
  margin:0;
  padding-left:22px;
}
.lab-columns{
  display:grid;
  grid-template-columns:270px minmax(0,1fr);
  gap:14px;
}
.block-palette,.workspace-panel,.check-panel,.evidence-panel{
  border:2px solid var(--line);
  border-radius:8px;
  background:#f8fbff;
  padding:14px;
}
.block-palette h3,.workspace-panel h3,.check-panel h3,.evidence-panel h3{
  margin:0 0 10px;
  font-size:1rem;
}
.block-grid{
  display:grid;
  gap:8px;
}
.block-button{
  width:100%;
  min-height:58px;
  text-align:left;
  border:2px solid rgba(23,33,59,.22);
  border-radius:8px;
  padding:9px 10px;
  color:#fff;
  font-weight:950;
  box-shadow:3px 3px 0 rgba(23,33,59,.16);
}
.block-button small{color:rgba(255,255,255,.88)}
.block-event{background:#cc8a00}
.block-motion{background:#247ad6}
.block-looks{background:#7656d8}
.block-control{background:#e07020}
.block-data{background:#d94c7a}
.block-sound{background:#158966}
.workspace-stack{
  display:grid;
  gap:8px;
  min-height:338px;
  border:2px dashed rgba(23,33,59,.18);
  border-radius:8px;
  background:#fff;
  padding:10px;
}
.empty-stack{
  display:grid;
  place-items:center;
  min-height:300px;
  color:var(--muted);
  text-align:center;
  line-height:1.5;
}
.program-block{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:8px;
  align-items:center;
  min-height:58px;
  border:2px solid rgba(23,33,59,.2);
  border-radius:8px;
  padding:8px;
  color:#fff;
  box-shadow:3px 3px 0 rgba(23,33,59,.16);
}
.program-block strong{
  display:block;
  line-height:1.28;
}
.program-block input{
  width:100%;
  margin-top:6px;
  border:2px solid rgba(255,255,255,.72);
  border-radius:8px;
  background:rgba(255,255,255,.94);
  color:var(--ink);
  padding:7px 8px;
}
.block-controls{
  display:flex;
  gap:5px;
}
.block-controls button{
  width:32px;
  height:32px;
  border:2px solid rgba(255,255,255,.7);
  border-radius:8px;
  background:rgba(255,255,255,.92);
  color:var(--ink);
  font-weight:950;
}
.reflection-box{
  width:100%;
  min-height:96px;
  margin-top:12px;
  border:2px solid var(--ink);
  border-radius:8px;
  background:#fff;
  padding:12px;
  resize:vertical;
  line-height:1.5;
}
.scratch-stage{
  position:relative;
  height:268px;
  border:2px solid var(--ink);
  border-radius:8px;
  overflow:hidden;
  background:
    linear-gradient(#aee8ff 0 52%,#fff0ba 52% 100%);
  box-shadow:inset 0 -24px 0 rgba(255,209,92,.22);
}
.grid-line{
  position:absolute;
  left:18px;
  right:18px;
  bottom:74px;
  border-top:6px dotted rgba(23,33,59,.24);
}
.stage-sprite{
  position:absolute;
  left:24px;
  bottom:84px;
  width:58px;
  height:58px;
  display:grid;
  place-items:center;
  border:2px solid var(--ink);
  border-radius:8px;
  background:var(--coral);
  color:#fff;
  font-weight:950;
  transition:transform .45s ease,background .25s ease;
  box-shadow:5px 5px 0 rgba(23,33,59,.2);
}
.stage-sprite.color-shift{
  background:var(--leaf);
}
.stage-sprite.pulse{
  animation:pulse .42s ease 2;
}
@keyframes pulse{
  50%{transform:scale(1.08) translateX(var(--sprite-x,0px)) rotate(var(--sprite-rot,0deg))}
}
.speech-bubble{
  position:absolute;
  left:88px;
  bottom:160px;
  max-width:220px;
  min-height:42px;
  border:2px solid var(--ink);
  border-radius:8px;
  background:#fff;
  padding:9px 11px;
  color:var(--ink);
  font-weight:900;
  line-height:1.3;
  box-shadow:3px 3px 0 rgba(23,33,59,.14);
}
.speech-bubble:after{
  content:"";
  position:absolute;
  left:22px;
  bottom:-10px;
  width:16px;
  height:16px;
  border-right:2px solid var(--ink);
  border-bottom:2px solid var(--ink);
  background:#fff;
  transform:rotate(45deg);
}
.lab-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:9px;
  margin:12px 0;
}
.lab-actions .run-button{
  background:var(--leaf);
  color:#fff;
}
.check-list{
  display:grid;
  gap:8px;
}
.check-row{
  display:grid;
  grid-template-columns:42px minmax(0,1fr);
  gap:9px;
  align-items:start;
  border:2px solid var(--line);
  border-radius:8px;
  background:#fff;
  padding:9px;
}
.check-status{
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border:2px solid var(--ink);
  border-radius:8px;
  background:#fff6ce;
  font-weight:950;
}
.check-row.pass .check-status{
  background:var(--leaf);
  color:#fff;
}
.check-row.fail .check-status{
  background:#fff1ed;
  color:#8a2b20;
}
.check-row strong{
  display:block;
  line-height:1.28;
}
.evidence-panel{
  margin-top:12px;
}
.evidence-panel pre{
  max-height:200px;
  overflow:auto;
  margin:0;
  border:2px solid rgba(23,33,59,.12);
  border-radius:8px;
  background:#12203d;
  color:#eaf2ff;
  padding:10px;
  white-space:pre-wrap;
  line-height:1.45;
}
.submit-status{
  min-height:22px;
  margin:8px 0 0;
  color:#164b3d;
  font-weight:900;
  line-height:1.4;
}
.lab-note{
  width:min(1180px,calc(100% - 42px));
  margin:0 auto 58px;
  padding:22px;
  display:grid;
  grid-template-columns:minmax(0,.72fr) minmax(0,1.1fr);
  gap:18px;
  align-items:start;
}
.lab-note h2{
  margin:10px 0 0;
  font-size:clamp(1.55rem,2.6vw,2.25rem);
  line-height:1.16;
}
button:hover,a:hover{
  transform:translateY(-1px);
}
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible{
  outline:none;
  box-shadow:0 0 0 4px rgba(255,209,92,.36),var(--pixel);
}
@media(max-width:1180px){
  .lab-shell{
    grid-template-columns:1fr;
  }
  .mission-panel,.stage-panel{
    position:static;
    min-height:0;
  }
  .lab-columns{
    grid-template-columns:1fr;
  }
}
@media(max-width:820px){
  .lab-topbar{
    align-items:flex-start;
    flex-direction:column;
    padding:12px 18px;
  }
  .lab-topbar nav{
    width:100%;
  }
  .lab-hero,.lab-note{
    grid-template-columns:1fr;
    width:min(100% - 24px,1180px);
  }
  .lab-shell{
    width:min(100% - 24px,1180px);
  }
  .panel-head,.lab-actions{
    display:grid;
    grid-template-columns:1fr;
  }
  .scratch-stage{
    height:238px;
  }
}

/* v0.1.66: Scratch Lab is a clean student workspace. */
.scratch-v066 .v066-lab-hero,
.scratch-v070 .v070-lab-hero{
  padding-top:26px;
  grid-template-columns:minmax(0,1fr) minmax(260px,360px);
}
.scratch-v066 .v066-lab-hero h1,
.scratch-v070 .v070-lab-hero h1{
  font-size:clamp(2.35rem,5vw,4rem);
  max-width:680px;
}
.scratch-v066 .v066-lab-hero p,
.scratch-v070 .v070-lab-hero p{
  max-width:720px;
}
.scratch-v066 .lab-note,
.scratch-v070 .lab-note{
  display:none;
}
.scratch-v066 .evidence-panel h3,
.scratch-v070 .evidence-panel h3{
  color:var(--ink);
}
.visual-workspace-panel{
  margin:8px 0 14px;
  border:2px solid var(--ink);
  border-radius:8px;
  background:#fffdf0;
  padding:14px;
  box-shadow:var(--pixel);
}
.tight-head{
  align-items:center;
  margin-bottom:10px;
}
.tight-head h3{
  margin:0 0 4px;
  font-size:1.06rem;
}
.tight-head p{
  margin:0;
  color:var(--muted);
  font-size:.88rem;
  line-height:1.45;
}
.visual-workspace-panel button{
  min-height:42px;
  border:2px solid var(--ink);
  border-radius:8px;
  background:var(--sun);
  color:var(--ink);
  padding:0 12px;
  font-weight:950;
  box-shadow:var(--pixel);
}
.engine-note{
  min-height:32px;
  display:flex;
  align-items:center;
  margin:0 0 10px;
  border:2px solid rgba(23,33,59,.12);
  border-radius:8px;
  background:#f8fbff;
  color:var(--soft);
  padding:7px 10px;
  font-size:.86rem;
  font-weight:850;
}
.blockly-workspace{
  width:100%;
  height:330px;
  border:2px solid var(--ink);
  border-radius:8px;
  overflow:hidden;
  background:#f7fbff;
}
.blockly-workspace.blockly-fallback{
  display:grid;
  place-items:center;
  min-height:120px;
}
@media(max-width:820px){
  .scratch-v066 .v066-lab-hero,
  .scratch-v070 .v070-lab-hero{
    grid-template-columns:1fr;
  }
  .tight-head{
    display:grid;
    grid-template-columns:1fr;
  }
  .blockly-workspace{
    height:300px;
  }
}

/* v0.2.0 Scratch Lab polish: calmer, wider, game-lab feeling. */
.scratch-v070{
  background:
    linear-gradient(180deg,#e9f8ff 0,#f8fffb 54%,#fff7df 100%);
}
.scratch-v070 .lab-topbar{
  border-bottom:2px solid rgba(23,33,59,.12);
  box-shadow:0 12px 28px rgba(18,32,61,.07);
}
.scratch-v070 .v070-lab-hero{
  width:min(1360px,calc(100% - 42px));
  padding:28px 0 18px;
  grid-template-columns:minmax(0,1fr) minmax(280px,380px);
}
.scratch-v070 .v070-lab-hero h1{
  letter-spacing:0;
}
.scratch-v070 .lab-listen-card{
  background:linear-gradient(180deg,#fff,#fff9df);
}
.scratch-v070 .lab-shell{
  width:min(1440px,calc(100% - 42px));
  grid-template-columns:270px minmax(0,1fr) 385px;
}
.scratch-v070 .mission-panel,
.scratch-v070 .builder-panel,
.scratch-v070 .stage-panel{
  border-width:2px;
  box-shadow:0 22px 54px rgba(18,32,61,.13);
}
.scratch-v070 .mission-panel{
  background:linear-gradient(180deg,#fff,#f7fffb);
}
.scratch-v070 .builder-panel{
  background:linear-gradient(180deg,#fff,#f8fbff);
}
.scratch-v070 .stage-panel{
  background:linear-gradient(180deg,#fff,#fff9df);
}
.scratch-v070 .mission-card{
  min-height:104px;
}
.scratch-v070 .mission-card.active{
  background:linear-gradient(180deg,#fff8df,#f0fff5);
}
.scratch-v070 .visual-workspace-panel{
  background:linear-gradient(180deg,#fffdf0,#fff);
}
.scratch-v070 .blockly-workspace{
  height:370px;
}
.scratch-v070 .lab-columns{
  grid-template-columns:240px minmax(0,1fr);
}
.scratch-v070 .workspace-stack{
  min-height:360px;
}
.scratch-v070 .scratch-stage{
  height:300px;
  background:
    linear-gradient(#acebff 0 50%,#fff0ba 50% 100%);
}
.scratch-v070 .scratch-stage:before{
  content:"";
  position:absolute;
  inset:16px;
  border:2px dashed rgba(23,33,59,.15);
  border-radius:8px;
}
.scratch-v070 .stage-sprite{
  width:64px;
  height:64px;
}
.scratch-v070 .lab-actions{
  grid-template-columns:1.2fr .8fr;
}
.scratch-v070 .lab-actions .run-button{
  min-height:54px;
  font-size:1.05rem;
}
@media(max-width:1180px){
  .scratch-v070 .lab-shell{
    grid-template-columns:1fr;
  }
  .scratch-v070 .lab-columns{
    grid-template-columns:1fr;
  }
}
@media(max-width:820px){
  .scratch-v070 .v070-lab-hero,
  .scratch-v070 .lab-shell{
    width:min(100% - 24px,1440px);
  }
  .scratch-v070 .blockly-workspace{
    height:300px;
  }
  .scratch-v070 .scratch-stage{
    height:250px;
  }
}
