/* the workshop: the robot's 3D view with the drive pad on it, and a panel to build with
   (beside the view on wide screens, under it on phones). same dark studio as the other labs. */
.ws {
  --g-ink: #eef2f7;
  --g-muted: rgba(226, 232, 240, .64);
  --g-line: rgba(255, 255, 255, .1);
  --g-fill: rgba(255, 255, 255, .06);
  --g-fill-2: rgba(255, 255, 255, .11);
  --g-teal: #5eead4;
  --g-amber: #fbbf5a;
  --ease: cubic-bezier(.2, .8, .2, 1);
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(300px, 340px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "intro stage" "panel stage"; column-gap: 8px;
  height: clamp(640px, 88vh, 900px); padding: 0 12px 12px 0;
  border-radius: 28px; color: var(--g-ink); overflow: clip;
  background: radial-gradient(120% 80% at 70% 0%, #1b2636 0%, transparent 60%), linear-gradient(180deg, #121820 0%, #0c1118 100%);
}
.ws button, .ws input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.ws :focus-visible { outline: 2px solid var(--g-teal); outline-offset: 2px; }
.ws-intro { grid-area: intro; padding: 28px 22px 0 28px; }
.ws-intro h1 { margin: 0; font-size: clamp(1.8rem, 2.4vw, 2.3rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.05; color: #fff; }
.ws-intro p { margin: 8px 0 0; color: var(--g-muted); font-size: .95rem; line-height: 1.5; }

/* the panel */
.ws-panel { grid-area: panel; min-height: 0; overflow-y: auto; -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 14px); mask-image: linear-gradient(180deg, transparent 0, #000 14px); padding: 16px 18px 18px 28px; display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; }
.ws-group h2 { margin: 0 0 8px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--g-muted); }
.ws-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-chip { min-height: 34px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--g-line); background: var(--g-fill); font-size: .84rem; cursor: pointer; transition: background .2s, color .2s; }
.ws-chip:hover { background: var(--g-fill-2); }
.ws-chip[aria-checked="true"] { background: #fff; color: #0f172a; border-color: #fff; font-weight: 600; }
.ws-about { margin: 8px 0 0; color: var(--g-muted); font-size: .82rem; line-height: 1.45; }
.ws-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.ws-part { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 7px; border-radius: 14px; border: 1px solid var(--g-line); background: var(--g-fill); cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; transition: background .2s, border-color .2s, transform .12s var(--ease); }
.ws-part:hover { background: var(--g-fill-2); }
.ws-part:active { cursor: grabbing; transform: scale(.97); }
.ws-part svg { width: 42px; height: 42px; pointer-events: none; }
.ws-part span { font-size: .74rem; font-weight: 600; text-align: center; line-height: 1.15; }
.ws-part.is-armed { border-color: var(--g-teal); background: color-mix(in srgb, var(--g-teal) 14%, transparent); }
.ws-part:disabled { opacity: .3; cursor: not-allowed; }
.ws-hint { margin: 8px 0 0; color: var(--g-muted); font-size: .8rem; line-height: 1.45; }
.ws-mounts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ws-mounts[hidden] { display: none; }
.ws-mounts > span { font-size: .8rem; color: var(--g-teal); margin-right: 2px; }
.ws-chip.ws-chip-all { border-color: rgba(94, 234, 212, .55); color: var(--g-teal); font-weight: 600; }
.ws-built { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ws-built li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--g-fill); font-size: .84rem; }
.ws-built li b { font-weight: 600; }
.ws-built li.ws-empty { background: none; padding: 2px 0; color: var(--g-muted); font-size: .8rem; }
.ws-x { width: 32px; height: 32px; border: 0; border-radius: 10px; background: transparent; color: var(--g-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.ws-x:hover { background: var(--g-fill-2); color: #fff; }

/* the 3D view and what floats on it */
.ws-stage { grid-area: stage; position: relative; min-height: 0; margin-top: 12px; border-radius: 22px; overflow: hidden; background: radial-gradient(60% 60% at 50% 40%, #223146 0%, #131a23 70%); }
.ws-view { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; cursor: grab; }
.ws-view:active { cursor: grabbing; }
.ws-stage > [role="status"]:not(.ws-toast) { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 4; padding: 10px 16px; border-radius: 999px; background: rgba(12, 17, 24, .78); color: var(--g-ink); font-size: .9rem; pointer-events: none; }
.ws-stage > [role="status"]:not(.ws-toast)[hidden], .ws-stage > [role="status"]:not(.ws-toast):empty { display: none; }
.ws-read { position: absolute; left: 14px; top: 14px; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 280px); pointer-events: none; }
.ws-read span { padding: 5px 10px; border-radius: 999px; background: rgba(12, 17, 24, .62); border: 1px solid var(--g-line); font-size: .78rem; color: var(--g-muted); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ws-read b { color: var(--g-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.ws-read.warn span:nth-child(2) { border-color: var(--g-amber); color: var(--g-amber); }
.ws-tools { position: absolute; right: 14px; top: 14px; z-index: 3; display: flex; gap: 6px; }
.ws-btn { min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--g-line); background: rgba(12, 17, 24, .62); font-size: .84rem; font-weight: 500; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ws-btn:hover { background: rgba(40, 50, 64, .8); }
.ws-drive { position: absolute; right: 16px; bottom: 16px; z-index: 3; display: flex; align-items: flex-end; gap: 12px; }
.ws-pad { position: relative; width: 132px; height: 132px; border-radius: 50%; background: rgba(12, 17, 24, .55); border: 1px solid var(--g-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); touch-action: none; cursor: pointer; }
.ws-pad::before { content: ''; position: absolute; inset: 22px; border-radius: 50%; border: 1px dashed rgba(255, 255, 255, .12); }
.ws-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: #fff; box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .6); pointer-events: none; }
.ws-pad.is-on .ws-knob { background: var(--g-teal); }
.ws-flip { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 10px 8px; border-radius: 16px; background: rgba(12, 17, 24, .55); border: 1px solid var(--g-line); font-size: .74rem; color: var(--g-muted); }
.ws-flip[hidden] { display: none; }
.ws-flip input { writing-mode: vertical-lr; direction: rtl; width: 32px; height: 96px; accent-color: var(--g-amber); }
.ws-toast { position: absolute; left: 50%; bottom: 18px; z-index: 5; transform: translate(-50%, 12px); max-width: calc(100% - 200px); padding: 9px 16px; border-radius: 999px; background: rgba(12, 17, 24, .9); border: 1px solid var(--g-line); font-size: .86rem; text-align: center; opacity: 0; pointer-events: none; transition: opacity .25s, transform .35s var(--ease); }
.ws-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ws-toast.good { border-color: rgba(94, 234, 212, .5); color: var(--g-teal); }
.ws-toast.has-act { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; pointer-events: none; }
.ws-toast.show.has-act { pointer-events: auto; }
.ws-toast .ws-toast-act { flex: none; white-space: nowrap; min-height: 32px; padding: 4px 14px; border-radius: 999px; border: 0; background: var(--g-teal); color: #0f172a; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.ws-toast .ws-toast-act:hover { filter: brightness(1.08); }
.ws.is-building .ws-view { opacity: .6; transition: opacity .2s; }
.ws-dragchip { position: fixed; left: 0; top: 0; z-index: 3000; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border-radius: 999px; background: #0f172a; color: #eef2f7; border: 1px solid var(--g-teal, #5eead4); font: 600 .8rem system-ui, sans-serif; pointer-events: none; box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .6); }
.ws-dragchip[hidden] { display: none; }
.ws-dragchip svg { width: 28px; height: 28px; }

/* tablets and phones: the view on top, the panel under it */
@media (max-width: 899px) {
  .ws-panel { -webkit-mask-image: none; mask-image: none; }
  .ws { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "intro" "stage" "panel"; padding: 0 10px 10px; }
  .ws-intro { padding: 22px 10px 0; }
  .ws-stage { height: clamp(340px, 58svh, 600px); }
  .ws-panel { padding: 16px 6px 6px; overflow: visible; }
}
@media (max-width: 560px) {
  .ws { border-radius: 22px; padding: 0 8px 8px; }
  .ws-intro { padding: 16px 8px 0; }
  .ws-intro h1 { font-size: 1.55rem; }
  .ws-intro p { display: none; }
  .ws-read { max-width: calc(100% - 130px) !important; }
  .ws-read span { font-size: .72rem; padding: 4px 8px; }
  .ws-tools { flex-direction: column; align-items: flex-end; }
  .ws-pad { width: 116px; height: 116px; }
  .ws-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  .ws-toast { max-width: calc(100% - 150px); left: 12px; transform: translate(0, 12px); text-align: left; border-radius: 14px; }
  .ws-toast.show { transform: none; }
  .ws-toast.has-act { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 10px 10px 14px; }
}
/* phones held sideways: the view on the left, the panel scrolls on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .ws { height: auto; grid-template-columns: minmax(0, 1fr) minmax(280px, 42%); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "stage intro" "stage panel"; padding: 8px; }
  .ws-stage { position: sticky; top: 6px; height: max(260px, calc(100svh - 84px)); margin: 0; }
  .ws-intro { padding: 6px 4px 0 8px; }
  .ws-intro h1 { font-size: 1.25rem; }
  .ws-intro p { display: none; }
  .ws-panel { padding: 12px 4px 4px 8px; overflow: visible; }
  .ws-pad { width: 108px; height: 108px; }
}
@media (prefers-reduced-motion: reduce) { .ws * { transition: none !important; } }

/* ---------- code it ---------- */
.ws-code h3 { margin: 12px 0 6px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--g-muted); }
.ws-code .ws-about { margin: 0 0 8px; }
.ws-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ws-act { min-height: 38px; padding: 7px 16px; border-radius: 12px; border: 1px solid var(--g-line); background: var(--g-fill); font-size: .86rem; font-weight: 600; cursor: pointer; transition: background .2s; }
.ws-act:hover { background: var(--g-fill-2); }
.ws-act.primary { background: #fff; color: #0f172a; border-color: #fff; }
.ws-act.primary:hover { background: #e7eef6; }
.ws-act.primary.is-on { background: var(--g-amber); border-color: var(--g-amber); color: #1f1300; }
.ws-hint.bad { color: #ffb4a8; }
.ws-serial { margin: 0; min-height: 64px; max-height: 150px; overflow-y: auto; padding: 8px 10px; border-radius: 12px; background: #070a0f; border: 1px solid var(--g-line); color: #b7f5d8; font: .76rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.ws-serial:empty::before { content: 'Nothing printed yet. Try Serial.println("hi");'; color: var(--g-muted); }
.ws-read .ws-run { border-color: rgba(251, 191, 90, .6); color: var(--g-amber); font-weight: 600; }

/* the editor: over the 3D view (full screen on phones) */
.ws-editor { position: absolute; inset: 10px; z-index: 20; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 18px; background: rgba(10, 14, 20, .97); border: 1px solid var(--g-line); color: #eef2f7; font-family: Inter, system-ui, sans-serif; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7); }
.ws-editor-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.ws-editor-bar strong { font-size: .95rem; }
.ws-editor-bar span { flex: 1 1 260px; color: rgba(226, 232, 240, .64); font-size: .76rem; line-height: 1.4; }
.ws-editor-tpl { min-height: 34px; padding: 4px 10px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06); color: inherit; font: inherit; font-size: .82rem; }
.ws-editor-tpl option { color: #0f172a; }
.ws-editor-wrap { flex: 1; min-height: 0; display: flex; border-radius: 12px; background: #070a0f; border: 1px solid rgba(255, 255, 255, .08); overflow: hidden; }
.ws-editor-gutter { margin: 0; padding: 10px 8px 10px 10px; min-width: 2.4em; text-align: right; color: rgba(226, 232, 240, .35); font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow: hidden; user-select: none; border-right: 1px solid rgba(255, 255, 255, .06); }
.ws-editor-text { flex: 1; min-width: 0; margin: 0; padding: 10px 12px; border: 0; outline: none; resize: none; background: transparent; color: #e6edf3; font: .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; white-space: pre; overflow: auto; }
.ws-editor-msg { min-height: 1.4em; font-size: .82rem; }
.ws-editor-msg.ok { color: #5eead4; }
.ws-editor-msg.bad { color: #ffb4a8; }
.ws-editor-foot { display: flex; flex-wrap: wrap; gap: 6px; }
body > .ws-editor { position: fixed; inset: 0; z-index: 2000; border-radius: 0; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
body > .ws-editor .ws-act { min-height: 42px; }

/* v3: real-looking parts. the exploded view's labels, and the parts list */
.ws-btn[aria-pressed="true"] { background: var(--g-teal); color: #0b1218; border-color: transparent; }
.ws-tags { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .3s; }
.ws-tags.show { opacity: 1; }
.ws-tags span { position: absolute; left: 0; top: 0; padding: 3px 8px; border-radius: 999px; background: rgba(12, 17, 24, .72); border: 1px solid var(--g-line); color: var(--g-ink); font-size: .72rem; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.ws.is-exploded .ws-drive { opacity: .35; }
.ws-bom { margin-top: 8px; border-radius: 12px; background: var(--g-fill); }
.ws-bom summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 9px 12px; cursor: pointer; font-size: .84rem; font-weight: 600; list-style: none; }
.ws-bom summary::-webkit-details-marker { display: none; }
.ws-bom summary::before { content: '▸'; color: var(--g-muted); margin-right: 2px; transition: transform .2s; }
.ws-bom[open] summary::before { transform: rotate(90deg); }
.ws-bom summary span { flex: 1; }
.ws-bom summary small { color: var(--g-muted); font-weight: 400; font-size: .76rem; }
.ws-bom table { width: 100%; border-collapse: collapse; font-size: .78rem; margin: 0 0 6px; }
.ws-bom th { text-align: left; font-weight: 600; color: var(--g-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: 4px 12px; }
.ws-bom td { padding: 6px 12px; border-top: 1px solid var(--g-line); vertical-align: top; }
.ws-bom td:first-child, .ws-bom th:first-child { width: 2.5em; padding-right: 0; font-variant-numeric: tabular-nums; }
.ws-bom td:last-child, .ws-bom th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ws-bom td small { display: block; color: var(--g-muted); font-size: .7rem; margin-top: 1px; }
@media (max-width: 560px) { .ws-tags span { font-size: .64rem; padding: 2px 6px; } }
