/* The studio (templates/labkit/studio.html): the Robot Lab's layout for every
   engineering lab – the mission and code on the left, the stage on the right. */
.st { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.25fr); gap: 14px; align-items: start; margin-top: 6px; }
.st-left, .st-right { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.st-right { position: sticky; top: 76px; }
@media (max-width: 1100px) {
  .st { grid-template-columns: minmax(0, 1fr); }
  .st-right { position: static; }
}

/* mission picker and brief */
.st-pick { display: flex; gap: 6px; align-items: center; }
.st-select { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px; }
.st-nav { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.st-nav:disabled { opacity: .35; cursor: default; }
.st-track { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
.st-title { margin: 2px 0 6px; font-size: clamp(1.35rem, 2.1vw, 1.75rem); line-height: 1.15; color: var(--ink); }
.st-task { position: relative; margin: 0; padding: 10px 12px 10px 40px; border-radius: 12px; line-height: 1.55; color: #422006; background: linear-gradient(135deg, #fffbeb, #fef3c7); border: 1px solid #fcd34d; }
.st-task::before { content: "🎯"; position: absolute; left: 12px; top: 9px; }
.st-task:empty { display: none; }
.st-left .lk-explain { font-size: 15px; line-height: 1.7; }
.st-left .lk-explain p { margin: 0 0 10px; }

/* parts and snippets: click one to put it into the code */
.st-snippets { display: flex; flex-wrap: wrap; gap: 6px; }
.st-snippets button { border: 0; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; color: #fff; background: var(--c, #0d9488); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.st-snippets button:hover { filter: brightness(1.1); }
.st-snippets .st-group { width: 100%; margin: 6px 0 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.st-snippets svg { width: 22px; height: 22px; }

/* the code */
.st-code .lk-editor { min-height: 340px; }
.st-input { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink); }
.st-input small { font-weight: 400; color: var(--muted); }
.st-input textarea { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 13px/1.5 "JetBrains Mono", ui-monospace, monospace; resize: vertical; }
.st-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.st-bar .lk-keys { margin-left: auto; }

/* the stage: a dark bench, so plots, boards and circuits stand out */
.st-stagehead { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink); }
.st-badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.st-badge:empty { display: none; }
.st-stage { position: relative; min-height: 380px; padding: 12px; border-radius: 16px; overflow: hidden; color: #e2e8f0; display: flex; flex-direction: column; gap: 10px;
  background: radial-gradient(circle at 1px 1px, rgba(148, 163, 184, .13) 1px, transparent 0) 0 0 / 22px 22px, #0b1220; border: 1px solid #1e293b; }
.st-empty { margin: auto; color: #94a3b8; font-size: 14px; text-align: center; }
.st-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.st-run { padding: 9px 18px; border: 0; border-radius: 10px; background: #16a34a; color: #fff; font-weight: 700; cursor: pointer; }
.st-run:hover { background: #15803d; }
.st-stop { width: 40px; height: 40px; border: 0; border-radius: 10px; background: #dc2626; color: #fff; cursor: pointer; }
.st-speed { display: inline-flex; gap: 3px; margin-left: auto; }
.st-speed button { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; }
.st-speed .is-on { background: var(--ink); color: var(--card); }
body.lk-running .st-run { opacity: .6; }

/* live readings, like a multimeter strip */
.st-readout { display: flex; flex-wrap: wrap; gap: 6px; }
.st-readout:empty { display: none; }
.st-readout span { display: flex; flex-direction: column; padding: 5px 11px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); line-height: 1.25; }
.st-readout small { font-size: 11px; color: var(--muted); }
.st-readout b { font: 600 14px "JetBrains Mono", ui-monospace, monospace; color: var(--ink); }

/* the console */
.st-console { border-radius: 12px; overflow: hidden; background: #1c1917; }
.st-console-head { margin: 0; padding: 5px 12px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #a8a29e; background: #292524; }
.st-log { margin: 0; min-height: 56px; max-height: 220px; overflow-y: auto; padding: 8px 12px; color: #e7e5e4; font: 13px/1.5 "JetBrains Mono", ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.st-log .is-err { color: #fca5a5; }
.st-log .is-info { color: #93c5fd; }
.st-log .is-ok { color: #86efac; }
.st-log .is-dim { color: #78716c; }

/* figures drawn on the stage (studio-draw.js) */
.st-figs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.st-fig { margin: 0; padding: 8px; border-radius: 12px; background: rgba(15, 23, 42, .85); border: 1px solid rgba(148, 163, 184, .18); min-width: 0; }
.st-fig.is-wide { grid-column: 1 / -1; }
.st-fig figcaption { margin: 0 0 4px 4px; font-size: 12.5px; font-weight: 600; color: #cbd5e1; }
.st-fig canvas, .st-fig svg { display: block; width: 100%; height: auto; }
.st-fig.is-image canvas { image-rendering: pixelated; border-radius: 6px; }
.st-tbl { overflow-x: auto; }
.st-tbl table { width: 100%; border-collapse: collapse; font: 12.5px/1.4 "JetBrains Mono", ui-monospace, monospace; color: #e2e8f0; }
.st-tbl th, .st-tbl td { padding: 4px 8px; border-bottom: 1px solid rgba(148, 163, 184, .18); text-align: right; white-space: nowrap; }
.st-tbl th { color: #93c5fd; font-weight: 600; text-align: right; }
.st-tbl th:first-child, .st-tbl td:first-child { text-align: left; }
.st-tbl tr.is-hl td { background: rgba(34, 197, 94, .15); }
/* the site's tables (#main thead th: sticky, light; striped rows) don't belong on the dark stage */
#main .st-tbl th { position: static; background: transparent; color: #93c5fd; font-size: 12.5px; letter-spacing: 0; text-transform: none; padding: 4px 8px; border-bottom: 1px solid rgba(148, 163, 184, .3); text-align: right; }
#main .st-tbl th:first-child { text-align: left; }
#main .st-tbl tbody tr:nth-child(even) { background: rgba(148, 163, 184, .06); }
.st-note { margin: 0; font-size: 13px; color: #cbd5e1; }
.st-term { margin: 0; padding: 10px 12px; border-radius: 10px; background: #020617; color: #d1fae5; font: 13.5px/1.55 "JetBrains Mono", ui-monospace, monospace; white-space: pre-wrap; min-height: 120px; overflow: auto; }
.st-tests { display: grid; gap: 6px; }
.st-test { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 10px; border-radius: 10px; background: rgba(15, 23, 42, .85); border: 1px solid rgba(148, 163, 184, .18); font-size: 13px; }
.st-test b { grid-row: span 2; font-size: 18px; }
.st-test code { font-family: "JetBrains Mono", ui-monospace, monospace; color: #e2e8f0; white-space: pre-wrap; }
.st-test.is-ok { border-color: rgba(34, 197, 94, .5); }
.st-test.is-bad { border-color: rgba(239, 68, 68, .55); }

/* ------------------------------------------------------------------ motion: lively, never in the way */
.st-figs > figure, .st-stage > .el-circuit, .st-stage > .pw-circuit, .st-stage > .ct-anim, .st-stage > .mc-anim, .st-stage > .mk-anim, .st-tests > .st-test {
  animation: st-in .45s cubic-bezier(.2, .8, .2, 1) both; }
.st-figs > figure:nth-child(2), .st-tests > .st-test:nth-child(3) { animation-delay: .08s; }
.st-figs > figure:nth-child(3), .st-tests > .st-test:nth-child(4) { animation-delay: .16s; }
.st-figs > figure:nth-child(n + 4), .st-tests > .st-test:nth-child(n + 5) { animation-delay: .24s; }
@keyframes st-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.st-readout span { animation: st-pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes st-pop { from { opacity: 0; transform: scale(.8); } }
.st-snippets button { transition: transform .15s, filter .15s; }
.st-snippets button:hover { transform: translateY(-2px) rotate(-1deg); }
.st-run { position: relative; transition: transform .1s, background .15s; }
.st-run:active { transform: scale(.96); }
body.lk-running .st-run::after { content: ""; position: absolute; right: -6px; top: -6px; width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid #bbf7d0; border-top-color: transparent; animation: st-spin .7s linear infinite; }
@keyframes st-spin { to { transform: rotate(360deg); } }

/* how far through the lab you are */
.st-progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.st-progress i { flex: 1; height: 7px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.st-progress i b { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #f59e0b, #22c55e); transition: width .8s cubic-bezier(.2, .8, .2, 1); }

/* the celebration when a mission is done */
.st-party { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 5; }
.st-party-card { padding: 18px 26px; border-radius: 18px; background: rgba(2, 6, 23, .88); border: 1px solid rgba(250, 204, 21, .5); text-align: center;
  box-shadow: 0 20px 50px -20px rgba(250, 204, 21, .5); animation: st-party 2.6s cubic-bezier(.2, 1.2, .3, 1) both; }
.st-party-card b { display: block; font: 700 22px Inter, system-ui, sans-serif; color: #fde68a; }
.st-party-card .stars { margin-top: 6px; font-size: 30px; letter-spacing: 6px; }
.st-party-card .stars span { display: inline-block; animation: st-star .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.st-party-card .stars span:nth-child(2) { animation-delay: .15s; } .st-party-card .stars span:nth-child(3) { animation-delay: .3s; }
.st-party i { position: absolute; width: 9px; height: 14px; border-radius: 3px; top: 40%; left: 50%; background: hsl(var(--h) 90% 60%);
  animation: st-confetti 1.6s ease-out both; transform: rotate(var(--r)); }
@keyframes st-party { 0% { opacity: 0; transform: scale(.6); } 12% { opacity: 1; transform: scale(1.05); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes st-star { from { opacity: 0; transform: scale(0) rotate(-90deg); } }
@keyframes st-confetti { to { opacity: 0; transform: translate(var(--x), var(--y)) rotate(calc(var(--r) + 540deg)); } }
@media (prefers-reduced-motion: reduce) {
  .st-figs > figure, .st-stage > *, .st-tests > .st-test, .st-readout span, .st-party-card, .st-party-card .stars span, .st-party i { animation: none !important; }
  body.lk-running .st-run::after { animation: none; }
}

/* =====================================================================
   Three-part studio (Nov 2026): missions on the far left, Instructions / Code tabs
   in the middle, Output / Expected tabs on the right. Text stays a comfortable
   size on big screens: lab pages do not use the site's large-screen scaling.
   ===================================================================== */
@media (min-width: 1920px) { html:has(.lk) { font-size: 100%; } html.ec-lg:has(.lk) { font-size: 112.5%; } html.ec-xl:has(.lk) { font-size: 125%; } }
.lk:has(.st3) .lk-top h1 { font-size: 1.35rem; line-height: 1.2; }
.lk:has(.st3) .lk-lead { display: none; }
.lk:has(.st3) { max-width: 1760px; font-size: 15px; }

.st3 { grid-template-columns: 236px minmax(0, 1fr) minmax(0, 1.1fr); gap: 14px; }
.st3.st-side-off { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.st3.st-side-off .st-side { display: none; }
.st3 .st-side-open { display: none; }
.st3.st-side-off .st-side-open { display: grid; }

/* far left: every mission, then all labs */
.st-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 8px; min-width: 0; max-height: calc(100vh - 92px); padding: 10px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--card); }
.st-side-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--ink); }
.st-side-toggle { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; font-size: 16px; }
.st-side-toggle:hover { color: var(--ink); background: var(--paper); }
.st-list { display: flex; flex-direction: column; gap: 2px; min-height: 80px; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.st-list-track { margin: 8px 4px 2px; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.st-list button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 5px 8px; border: 2px solid transparent; border-radius: 10px; background: none;
  text-align: left; font-size: 13.5px; font-weight: 600; line-height: 1.25; color: var(--ink); cursor: pointer; }
.st-list button i { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); font-style: normal; font-size: 11px; font-weight: 800; color: var(--muted); }
.st-list button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-list button:hover { background: var(--paper); }
.st-list button.is-done i { background: #4f7d32; border-color: #4f7d32; color: #fff; }
.st-list button.is-on { background: rgb(var(--c-accent-2-tint)); border-color: rgb(var(--c-accent-2-light)); }
.st-list button.is-on i { border-color: rgb(var(--c-accent-2)); color: rgb(var(--c-accent-2)); }
.st-list button.is-on.is-done i { color: #fff; }
.st-labs { flex: none; border-top: 2px solid var(--line); padding-top: 6px; font-size: 13.5px; }
.st-labs summary { min-height: 36px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; border-radius: 10px; cursor: pointer; font-weight: 800; color: var(--ink); list-style: none; }
.st-labs summary::-webkit-details-marker { display: none; }
.st-labs summary::after { content: "▾"; color: var(--muted); }
.st-labs[open] { max-height: 46vh; overflow-y: auto; }
.st-labs-cat { margin: 8px 6px 2px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.st-labs a { display: block; padding: 5px 8px; border-radius: 8px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-labs a:hover { background: var(--paper); }
.st-labs a.is-on { background: rgb(var(--c-accent-2-tint)); font-weight: 800; }
.st-labs-all { margin-top: 6px; font-weight: 800; color: rgb(var(--c-accent-2)) !important; }

/* tabs */
.st-tabs { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 14px; background: var(--paper); border: 2px solid var(--line); }
.st-tabs [role="tab"] { flex: 1; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: none; font-size: 14px; font-weight: 800; color: var(--muted); cursor: pointer; white-space: nowrap; }
.st-tabs [role="tab"]:hover { color: var(--ink); }
.st-tabs [role="tab"].is-on { background: var(--card); color: rgb(var(--c-accent-2)); box-shadow: 0 2px 0 var(--line); }
.st-tabs .st-badge { flex: none; }
.st-tabs .st-badge:empty { display: none; }
.st3 .st-pane { display: none; flex-direction: column; gap: 10px; min-width: 0; }
.st3[data-left="info"] .st-left > [data-pane="info"], .st3[data-left="code"] .st-left > [data-pane="code"],
.st3[data-right="out"] .st-right > [data-pane="out"], .st3[data-right="goal"] .st-right > [data-pane="goal"] { display: flex; }
.st-go-code { align-self: flex-start; }
.st3 .st-title { font-size: clamp(1.15rem, 1.5vw, 1.4rem); }
.st3 .st-code .lk-editor { min-height: 320px; }
.st3 .st-stage { min-height: 340px; }

/* expected */
.st-goal { padding: 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); }
.st-goal-h { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.st-goal-task { margin: 0; padding: 12px 14px; border-radius: 12px; background: rgb(var(--c-accent-2-tint)); color: var(--ink); font-size: 15px; line-height: 1.55; }
.st-goal-empty { margin: 0; padding: 12px 14px; border-radius: 12px; border: 2px dashed var(--line); color: var(--muted); font-size: 14px; }
.st-goal .lk-btn { align-self: flex-start; }

/* small laptops: the mission list folds away (the picker and ‹ › stay); tablets and phones: one column */
@media (max-width: 1279px) {
  .st3, .st3.st-side-off { grid-template-columns: minmax(360px, 1fr) minmax(0, 1.15fr); }
  .st3 .st-side { display: none; }
  .st3:not(.st-side-off) .st-side-open, .st3 .st-side-open { display: none; }
}
@media (min-width: 1280px) { .st3:not(.st-side-off) .st-pick .st-select { display: none; } .st3:not(.st-side-off) .st-pick { justify-content: flex-end; } }
@media (max-width: 1100px) {
  .st3, .st3.st-side-off { grid-template-columns: minmax(0, 1fr); }
  .st-tabs [role="tab"] { min-height: 46px; }
  .st3 .st-code .lk-editor { min-height: 260px; }
}
